June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,34 @@
PRAGMA INCLUDE <GL/gl.h> <GL/freeglut.h>
PRAGMA LDFLAGS GL glut
OPTION PARSE FALSE
SUB Triangle
glViewport(0, 0, 640, 480)
glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
glClearColor(0.0, 0.0, 0.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT)
glTranslatef(-15.0, -15.0, 0.0)
glBegin(GL_TRIANGLES)
glColor3f(1.0, 0.0, 0.0)
glVertex2f(0.0, 0.0)
glColor3f(0.0, 1.0, 0.0)
glVertex2f(30.0, 0.0)
glColor3f(0.0, 0.0, 1.0)
glVertex2f(0.0, 30.0)
glEnd()
glutSwapBuffers()
END SUB
glutInit(&argc, argv)
glutInitWindowSize(640, 480)
glutCreateWindow("Triangle")
glutDisplayFunc(Triangle)
glutMainLoop()

View file

@ -0,0 +1,58 @@
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

View file

@ -32,7 +32,7 @@
(define/override (on-paint)
(with-gl-context (λ() (draw-opengl) (swap-gl-buffers))))
(define/override (on-size width height)
(with-gl-context (λ() (resize width height))))
(with-gl-context (λ() (resize width height) (on-paint))))
(super-instantiate () (style '(gl)))))
(define win (new frame% [label "Racket Rosetta Code OpenGL example"]

View file

@ -0,0 +1,25 @@
# Project: OpenGL
# Date : 2018/06/09
# Author: Gal Zsolt [~ CalmoSoft ~]
# Email : <calmosoft@gmail.com>
load "freeglut.ring"
load "opengl21lib.ring"
func main
glutInit()
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA)
glutInitWindowSize(320,320)
glutInitWindowPosition(100, 10)
glutCreateWindow("OpenGL")
glutDisplayFunc(:renderScene)
glutMainLoop()
func renderScene
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glBegin(GL_TRIANGLES)
glVertex3f(-0.5,-0.5,0.0)
glVertex3f(0.5,0.0,0.0)
glVertex3f(0.0,0.5,0.0)
glEnd()
glutSwapBuffers()