How to "use" OpenGL

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
Master-F-
Posts: 2
Joined: Jan 20, 2007 12:18

How to "use" OpenGL

Post by Master-F- »

Hi

I have a question:

how can i use OpenGL?
should i download something ... or include something?

i have this code:

Code: Select all

#include once "GL/gl.bi"
#include once "GL/glu.bi"

screenres width,height,depth,,&h2 OR fullscreen
glMatrixMode(GL_PROJECTION)
glLoadIdentity
glViewport(0,0,width,height)
glOrtho(0,width,height,0,-128,128)
glMatrixMode(GL_MODELVIEW)
glEnable(GL_CULL_FACE)
glCullFace(GL_BACK)
glEnable GL_TEXTURE_2D
glLoadIdentity
glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LESS)
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, 0.1)
do
  glClear  GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT

    glBegin GL_QUADS
        glVertex2i  0, 50    '' LINKS UNTEN  (1. Koordinate)
        glVertex2i 50, 50    '' RECHTS UNTEN (2. Koordinate)
        glVertex2i 50,  0    '' RECHTS OBEN  (3. Koordinate)
        glVertex2i  0,  0    '' LINKS OBEN   (4. Koordinate)
    glEnd
    
  glFlush ' Verarbeitung der Befehle
  flip
  screensync
loop until multikey(&h01) ' Verlasse die Schleife sobald Escape gedrückt wird
but this is not working?

pls, can someone help me :(

Thx a lot :)

Master-F-
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Post by 1000101 »

There are almost 50 examples of how to use OpenGL in the /examples/gl directory.
Stormy
Posts: 198
Joined: May 28, 2005 17:57
Location: Germany
Contact:

Post by Stormy »

Try this one:

Code: Select all

' Einbindung von OpenGL
#include once "GL/gl.bi"
#include once "GL/glu.bi"

' Festlegung der Konstanten, die für den Bildschirm wichtig sind
const scrnX = 640
const scrnY = 480
const depth = 32
const fullscreen = &h0           ' Vollbildmodus ( &h0 = aus, &h1 = an )

screenres scrnX,scrnY,depth,,&h2 OR fullscreen

' Konfiguration von OpenGL
glMatrixMode(GL_PROJECTION)      ' Matrix definieren
glLoadIdentity
glViewport(0,0,scrnX,scrnY)      ' Achse festlegen
glOrtho(0,scrnX,scrnY,0,-128,128)
glMatrixMode(GL_MODELVIEW)       ' Deaktivierung des Rendern der Rückseiten
glEnable(GL_CULL_FACE)
glCullFace(GL_BACK)
glEnable GL_TEXTURE_2D           ' Texturen aktivieren
glLoadIdentity
glEnable(GL_DEPTH_TEST)          ' Tiefentest
glDepthFunc(GL_LESS)
glEnable(GL_ALPHA_TEST)          ' Alphatest
glAlphaFunc(GL_GREATER, 0.1)


do
  glClear  GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT

glBegin GL_QUADS
	glVertex2i  0, 50    '' LINKS UNTEN  (1. Koordinate)
	glVertex2i 50, 50    '' RECHTS UNTEN (2. Koordinate)
	glVertex2i 50,  0    '' RECHTS OBEN  (3. Koordinate)
	glVertex2i  0,  0    '' LINKS OBEN   (4. Koordinate)
glEnd

  glFlush ' Verarbeitung der Befehle
  flip
  screensync
loop until multikey(&h01) ' Verlasse die Schleife sobald Escape gedrückt wird
I know that your snippet is from my tutorial. ;) I already began to translate it to English. It's gonna to be finished in few weeks (right after having finished my exams).
Master-F-
Posts: 2
Joined: Jan 20, 2007 12:18

Post by Master-F- »

thx a lot :D

i don't know, whether we can write german, or not :S

[german]
Lag es denn einfach daran, dass ich oben nur die CONSTanten weggelassen hatte?

hmm... eine kleine frage hätte ich noch:

wie bekomm ich denn das "hässliche" DOS-Fenster im Hintergrund weg?
[/german]

([google-translation]
- > it was simply because of the fact that I had omitted only the CONSTanten above? hmm… a small asks would have I still: how get I the “ugly” DOS window in the background away?
[/google-translation]
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

fbc -s gui yourprog.bas

will remove the console window
Post Reply