OpenGL with Blitzmax commands

BlitzMax Forums/OpenGL Module/OpenGL with Blitzmax commands

cgrossi(Posted 2014) [#1]
Hello, guys.

Does anyone know how to join blitzmax commands with opengl commands??? I want to study opengl and couldn't find a way to use both set of commands together...

Thanks!!


markcw(Posted 2014) [#2]
Do you mean like with the Nehe tutorials? The source is quite out of date now but it's fairly simple to get the demos running. The changes are mentioned in versions.txt.

Here are those changes and some more:
Framework brl.blitzgl -> Framework brl.GLGraphics
BGL_BACKBUFFER -> GRAPHICS_BACKBUFFER
BGL_DEPTHBUFFER -> GRAPHICS_DEPTHBUFFER
BGL_FULLSCREEN -> (removed, use depth 0 or 32)
FlushMem -> (removed)
bglCreateContext -> GLGraphics
bglTexFromPixmap -> GLTexFromPixmap
bglAdjustTexSize -> GLAdjustTexSize
bglDrawText -> GLDrawText
bglSwapBuffers -> Flip
bglSetMouseVisible 0 -> HideMouse
bglSetSwapInterval 0 -> (removed, use Flip 0)



cgrossi(Posted 2014) [#3]
No, I mean use blitzmax code mixed with opengl code...

Graphics 640,480

HideMouse

While Not KeyHit(KEY_ESCAPE)
Cls
x=MouseX()
y=MouseY()
DrawLine 320,240,x,y
DrawLine x-2,y,x-10,y
DrawLine x+2,y,x+10,y
DrawLine x,y-2,x,y-10
DrawLine x,y+2,x,y+10

'************ OPENGL CODE
GLDrawText "TEST",10,10

Flip
Wend


markcw(Posted 2014) [#4]
Well you use SetGraphicsDriver GLMax2DDriver() to have GL commands and Max2d together or SetGraphicsDriver GLGraphicsDriver() if you want pure GL.


markcw(Posted 2014) [#5]
Do you mean 2d, or 2d in 3d?

I have made a 2d in 3d demo which uses code from minib3d. It combines the Max2d demo with the first 8 Nehe tutorials. I've been wondering how to do this myself for a while but never got round to it so am quite pleased with it. Btw, I couldn't get blending working in demo 8 yet.

You need to save it to the Nehe_Tutorial folder and copy over spark.png from minib3d/examples/media.




cgrossi(Posted 2014) [#6]
Hi, munch.

I did what you said. To use glmax2ddriver. The opengl commands are executed ok, but when I uncomment the max2d command, the screen goes blank. No errors are displayed, nothing happnes, just the screen goes blank.... I don't want to use 3D, only 2D.




xlsior(Posted 2014) [#7]
I don't know if it also applies when mixing OpenGL & Max2D, but try:

GLShareContexts()


cgrossi(Posted 2014) [#8]
Hi, xlsior..

I got an error: Identifier GLShareContexts() not found.... I think my module is outdated... Do you know how I update it?


cgrossi(Posted 2014) [#9]
Hi..

I tried GLShareContexts and didn't work....

Cristiano


markcw(Posted 2014) [#10]
Okay, I adapted my previous example for your code. It still uses the same rendering "engine" from minib3d but now draws in 2d perspective. Needs spark.png.



cgrossi(Posted 2014) [#11]
Thank you a lot, munch. It worked very fine!!! Now I can begin my opengl studies!!

Cristiano


markcw(Posted 2014) [#12]
You're welcome, good luck!

Note that you can probably remove things like gl(En/Dis)ableClientState(GL_VERTEX_ARRAY) and gl(En/Dis)able(GL_FOG) as these shouldn't be relevant to 2d.


markcw(Posted 2014) [#13]
Re: Identifier GLShareContexts() not found. I recommend using the latest version of Bmx (1.50). This error is probably because you didn't imported the right module. I reproduced it by using "Framework brl.max2d" instead of "Framework brl.glmax2d". In this case, GLShareContexts is found in BRL.GLGraphics which is imported by BRL.GLMax2D.

If you don't specify what modules to use Bmx will use most of the brl and pub modules which increases your exe size. To find where a function is, the easiest way is to hit F1 twice but to find where it is imported by other modules you can use the MaxIDE Edit>Find in Files tool. Type the module name (eg. brl.max2d) and browse to the mod "scope" folder in this case "Blitzmax/mod/brl.mod".