global gOpenGL -- RavOpenGL xtra instance global GL -- OpenGL constants on startMovie -- Load the OpenGL script xtra gOpenGL = xtra("RavOpenGL").new() -- Load GL DLL gOpenGL.RavLoadGL("", "") -- Function omitted in demo code: loads OpenGL constants into namespace GL loadGLConstants() -- Window settings w = 640 h = 480 _movie.stage.title = "Triangle" _movie.stage.rect = rect(0, 0, w, h) _movie.centerStage = TRUE -- Create OpenGL display sprite m = new(#RavOpenGLDisplay) _movie.puppetSprite(1, TRUE) sprite(1).rect = rect(0, 0, w, h) sprite(1).member = m _movie.updateStage() -- Create the OpenGL buffer mainBufferID = gOpenGL.RavCreateBuffer(w, h, 32, 32) -- Set the sharing mode between script and sprite xtras dcID = gOpenGL.RavGetBufferProp(mainBufferID, #ravGC) sprite(1).RavShareBuffer(dcID, #true) gOpenGL.glViewport(0, 0, w, h) gOpenGL.glMatrixMode(GL.PROJECTION) gOpenGL.glLoadIdentity() gOpenGL.glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0) gOpenGL.glMatrixMode(GL.MODELVIEW) gOpenGL.glClearColor(0.3, 0.3, 0.3, 0.0) gOpenGL.glClear(GL.COLOR_BUFFER_BIT + GL.DEPTH_BUFFER_BIT) gOpenGL.glShadeModel(GL.SMOOTH) gOpenGL.glLoadIdentity() gOpenGL.glTranslatef(-15.0, -15.0, 0.0) gOpenGL.glBegin(GL.TRIANGLES) gOpenGL.glColor3f(1.0, 0.0, 0.0) gOpenGL.glVertex2f(0.0, 0.0) gOpenGL.glColor3f(0.0, 1.0, 0.0) gOpenGL.glVertex2f(30.0, 0.0) gOpenGL.glColor3f(0.0, 0.0, 1.0) gOpenGL.glVertex2f(0.0, 30.0) gOpenGL.glEnd() gOpenGL.glFlush() -- Show the window _movie.stage.visible = TRUE end