In this version I fixed some problems, when loading the library into the image. There were initialization problems of the library wrappers and some invalid method calls:
If you want to look at the small set of examples you should open the organizer and simply start the “MSKOpenGLExamplesView” application. The drop-down list should give you the list of selectable examples – just play with them.
If you want to write you own example you have to write several methods for each example:
First you write a method beginning with “ex”:
exIGP22 "Interactive Graphics Programming - page 76" ^'Sierpinski Drawing - Interactive Graphics Programming - page 76'
and then you write single methods for “setup”, “resize” and “render” – but pay attention to the method names needed for these methods. Some examples
primIGP22Setup "Interactive Graphics Programming -Listening 2.2" ^[ :if :dc :rc :env | if glClearColor: 1.0 green: 1.0 blue: 1.0 alpha: 1.0 ] primIGP22Resize "Interactive Graphics Programming -Listening 2.2" ^[ :if :dc :rc :env :w :h | | height aspectRatio | height := h = 0 ifTrue:[ 1 ] ifFalse:[ h ]. if glViewport: 0 y: 0 width: w height: height ; glMatrixMode: GlProjection ; glLoadIdentity ; gluOrtho2D: 0.0 right: 50.0 bottom: 0.0 top: 50.0; glMatrixMode: GlModelview ; glLoadIdentity. ] primIGP22RenderScene "Interactive Graphics Programming -Listening 2.2" ^[ :if :dc :rc :env | | j k aRandom vertices points | aRandom := EsRandom new. if glClear: OpenGLConstants::GlColorBufferBit ; glColor3f: 1.0 green: 0.0 blue: 0.0. vertices := OGL2DPointD new: 3. vertices at: 0 put: ((vertices at: 0) x: 0.0 ; y: 0.0) ; at: 1 put: ((vertices at: 1) x: 25.0 ; y: 50.0) ; at: 2 put: ((vertices at: 2) x: 50.0 ; y: 0.0). points := GLfloat new: 2. points at: 0 put: 7.5 ; at: 1 put: 5.0. if glBegin: OpenGLConstants::GlPoints. 20000 timesRepeat: [ j := (aRandom next * 3.0) truncated. points at: 0 put: (((points at: 0) + (vertices at: j) x) / 2.0). points at: 1 put: (((points at: 1) + (vertices at: j) y) / 2.0). if glColor3f: (aRandom next * 1.0) green: (aRandom next * 1.0) blue: (aRandom next * 1.0); glVertex2fv: points. "Transcript cr ; show: (j printString,' -> ',points printString). " ]. if glEnd ; glFlush; swapBuffers: dc. ]
Where “:if :dc :rc :env” means the dll-interface, the device context, the rendering context and the environment (which has no function yet).
In this example I used the structures like GLfloat, but in later examples I returned back to use the standard Smalltalk Float and Integer classes again – only for vectors I use structures …