Qbasicnews.com
no gl clutter - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+---- Forum: FB Projects (http://qbasicnews.com/newforum/forum-16.html)
+---- Thread: no gl clutter (/thread-8550.html)



no gl clutter - xteraco - 12-13-2005

i've been gettin tired of opengl cluttering my code, so i made a little thing, it lets you have all your gl formalitys in one file, and all your "functional" code in the other files

i know this isnt a new idea or anything... its ment to be sortof an example, or something for n00bs

openGL.bas
Code:
'openGL initializer function

'$include: 'GL/gl.bi'
'$include: 'GL/glu.bi'
#include once "fbgfx.bi"




'try GFX_FULLSCREEN for fullscreen display ;)
screenres 800,600,16, ,GFX_WINDOWED or GFX_OPENGL

glViewport 0, 0, 800, 600
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 45.0, 800.0/600.0, 0.1, 100.0
glMatrixMode GL_MODELVIEW
glLoadIdentity

glShadeModel GL_SMOOTH
glClearColor 0.0, 0.0, 0.0, 1.0
glClearDepth 1.0
glEnable GL_DEPTH_TEST
glDepthFunc GL_LEQUAL
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST


test_program.bas
Code:
'$include: 'openGL.bas'

dim as integer Tri_rot

do
    glclear GL_color_buffer_bit or Gl_depth_buffer_bit
    glLoadidentity
    gltranslated 0,0,-6 'translated is like translatef, d = decimal instead of float
    glrotated Tri_rot, 0,1,0

glbegin gl_triangle_fan
        glColor3d 1,3,1
        glVertex3d 0,1,0
        glColor3d 1,3,1
        glVertex3d -1,-1,0
        glColor3d 1,3,1
        glVertex3d 2,-1,0
glend
flip

Tri_rot = Tri_rot + 1
loop


if both .bas files are in the same dir, it should work


cheers
~xteraco