Here is a guidance list for developing code using low level OpenGL calls with the Cobalt code base. Using low level calls like this in an image-based system like Cobalt can be risky so appropriate precautions should be taken, especially backups.

  • The OpenGL driver functions are called from Cobalt using the Foreign Function Interface (FFI). The ease of coding OpenGL calls has improved with the FFI alternate calling convention introduced in Cobalt. On the Squeak Swiki, check out the FFI pages and especially Andreas Raab's FFI caveats.
  • Read about a typical Croquet development session.
  • Read and try the basic example OpenGL code in the Croquet Developer's Guide. Also look through the descriptions and browse the code for the fundamental rendering classes, especially the TPrimitive-based classes.
  • If you need to add OpenGL extensions that are not yet in Cobalt, browse the OGLExtManager class comments to read Bert Freudenberg's explanation of how to add platform-independent OpenGL extensions to Cobalt.
  • Because of the variety of video cards supported by OpenGL, it is generally good practice to implement fall-backs for OpenGL functions that may not be supported on all cards.
  • In the code for the Croquet Procedural Texturing project are some Tweak-based simple examples of OpenGL code, including a translation of the NeHe Tutorial #5.
  • There are some OpenGL functions where a pointer to a return value is passed as an argument. Here is an example of how to do that for an integer and a string return value:
length := IntegerArray new: 1.
ogl glGetObjectParameterivARB(object, GLObjectInfoLogLengthARB, length).
data := ByteArray new: length first.
ogl glGetInfoLogARB(object, data size, nil, data).
string := data asString.
  • An array of strings, for example shader program source code, can be passed to OpenGL by using Joshua Gargus' NullTerminatedStringArray class, which is included in the Procedural Texturing project code.