INLINE calls

Previous topic - Next topic

Kitty Hello

http://www.glbasic.com/files/gl.gbas

BINGO! The complete OpenGL Command set inline in GLBasic!!! Muhahaha!

bigsofty

Yay! Great stuff, your some guy Gernot! :D

There goes my weekend..! time to play... ;)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

bigsofty

Code (glbasic) Select
init_GL()

WHILE TRUE

X_MAKE3D 1,1000,45 // Viewport 3D

glClear(GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef(-1.5,0.0,-6.0); // Move Left 1.5 Units And Into The Screen 6.0
glBegin(GL_TRIANGLES); // Drawing Using Triangles
glColor3f(1.0,0.0,0.0); // Set The Color To Red
glVertex3f( 0.0, 1.0, 0.0); // Top
glColor3f(0.0,1.0,0.0); // Set The Color To Green
glVertex3f(-1.0,-1.0, 0.0); // Bottom Left
glColor3f(0.0,0.0,1.0); // Set The Color To Blue
glVertex3f( 1.0,-1.0, 0.0); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0,0.0,0.0); // Move Right 3 Units
glColor3f(0.5,0.5,1.0); // Set The Color To Blue One Time Only
glBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0, 1.0, 0.0); // Top Left
glVertex3f( 1.0, 1.0, 0.0); // Top Right
glVertex3f( 1.0,-1.0, 0.0); // Bottom Right
glVertex3f(-1.0,-1.0, 0.0); // Bottom Left
glEnd(); // Done Drawing The Quad

 SHOWSCREEN
WEND
:D


I had to put all the GL Globals in a FUNCTION...
Code (glbasic) Select
FUNCTION init_GL:
GLOBAL GL_VERSION_1_1                                     = 1
GLOBAL GL_VERSION_1_2                                     = 1
GLOBAL GL_VERSION_1_3    ...
...
ENDFUNCTION
...which allowed me to load in the GLB GL code as a seperate library.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

bigsofty

Now if this was built into the command set... I wouldn't have the overhead of a function call and return for each GL command... hint, hint ;)

This is so potentially powerful that the extension of the graphics engine could be handled by the community! New 3d formats, landscape support etc...!
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

If it's built-in, there would be the overhead as well for wrapping the data types.
You should not need a initGL function. GLBasic should assign the values to the globals.
uhm... oh dear. It might not.
Could be a "missing feature".

bigsofty

Ah, I see... I could allays pre-process it externally and in-line every GLCommand I suppose... sounds terrible but I'm sure I could automate it. Now if we had pre-process Macro support... :P hehe

Yep, if its loading in as a seperate file it complains the globals are outside a function, its no bother though to wrap them in a function and call it once...

...BUT thanks again Gernot, this is great and lots of fun for anyone trying to learn OpenGL in basic and it works! :D
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Fixed the GLOBAL bug, update might take some time, though. Have to test a lot before.

bigsofty

Ah, cool, this will make libs that little bit easier to be portable! ;)

Although, I kinda like to have an initialisation section for globals... feels more structured? Maybe just me...
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

bigsofty

On a related note, is it possible for you to release the little bit of C++ code that initialises the rendering context for 3D and 2D as its kinda guesswork on my part to how the various OpenGL options have been configured and my code should follow... I can see why you may not want to do this Gernot though, so its not important if you don't want to. ;)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Hb!

Talking about inline, seems to be that the demo version of this program, still doesn't accepts it, It would be good to have it... although, I'm not complaining but simply asking for it, Please forgive me, if  I said something that isn't proper ...

Kitty Hello

It was a bug. I changed it in the new version.

Hb!

ok thanks, maybe i should download it, since I want to start using Newton Sdk... to  create gravity.. (anyway I still need to find a way to make this possible by using basic language only.)

Kitty Hello

gravity?

Code (glbasic) Select
g = 9.81
timefactor = 0.01 // adjust here
acc_y = g

WHILE TRUE
   speed_y = (speed_y * g ) timefactor
   pos_y = pos_y + speed_d*timefactor
  PRINT "Falling", 0,pos_y
SHOWSCREEN
WEND