Blending Problem

BlitzMax Forums/OpenGL Module/Blending Problem

Haramanai(Posted 2005) [#1]
As i was reading about openGL i came across Blending. here is the program.

Strict

Import BRL.System
Import PUB.Glew

Global ScreenWidth% = 640
Global ScreenHeight% = 480
Global ScreanDepth% = 32

bglCreateContext ScreenWidth , ScreenHeight , ScreanDepth , BGL_BACKBUFFER

Function InitGL()

glClearColor(1.0 , 1.0 , 0.0 , 0.0) 'Yellow BackGround
glClearDepth 1.0
glViewPort (0 , 0 , ScreenWidth , ScreenHeight)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(60.0 , ScreenWidth / ScreenHeight , 1.0 , 20.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
gluLookAt(0.0 , 0.0 , 5.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0)

glBlendFunc GL_ONE , GL_ONE
glEnable GL_BLEND

End Function

InitGL()

While Not KeyDown(Key_Escape)
Display()
Keys()
FlushMem()
bglSwapBuffers()
Wend

Function Display()
glClear GL_COLOR_BUFFER_BIT
glColor3f 0.0 , 0.0 , 1.0
glRectf -0.5 , -0.5 , 0.5 , 0.5

End Function


Function keys()

If KeyHit(Key_A)
glBlendEquation GL_FUNC_ADD
EndIf


when i run the program and push the A Button BlitzMax Creates an error and crash the program

My quastion is : is this a bug of BlitzMax or rubish code of mine


Bot Builder(Posted 2005) [#2]
This kind of problem is most likely not a bug with BMAX, but a bug with either bmax's glew/gl implementation, or your program. I'm not really sure which.


teamonkey(Posted 2005) [#3]
You need to call glewinit() somewhere.


Haramanai(Posted 2005) [#4]
I tryed to call glewInit() after the BGLCreateContext command. I tryed even in the main loop but stills the same error. I tryed the same program in win98 (previusly in winxp) and i take from blitxMax the error unhandled memory ecxeption error for the command glBlendEquation GL_FUNC_ADD


ImaginaryHuman(Posted 2005) [#5]
I haven't heard of glBlendEquasion, is that a glew call?


Sveinung(Posted 2005) [#6]
Check your GLDriver. Mine does not support glBlendColor or glBlendEquation. Maybe you need to update the driver?

Sveinung


Sarge(Posted 2005) [#7]
im not 100% sure but maby you need to use the GLglBlendEquationProc to use the glBlendEquation.

dont really know.


teamonkey(Posted 2005) [#8]
I haven't heard of glBlendEquasion, is that a glew call?

Yeah, you need to check if the GL_ARB_imaging extension is present using glGetString.

http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/glBlendEquation.3.html


Haramanai(Posted 2005) [#9]
glGetString always returns 0. try this...
Print glGetString(GL_VERSION)

Here is a link about glGetString
http://www.mevis.de/~uwe/opengl/glGetString.html


teamonkey(Posted 2005) [#10]
glGetString(GL_EXTENSIONS) will return a C string (const char *) of all the extensions currently loaded, each separated by a single space. You can search the string for GL_ARB_imaging.


Angus(Posted 2005) [#11]
Sorry to drag this back from the grave, but I've just been playing with the OpenGL parts of BMax, and have run up against this problem.

When I try to use glBlendEquation the error message I get is "Caused error <unknown>"

I displayed the output of glGetString(GL_EXTENSIONS) and couldn't seem to find GL_ARB_Imaging. I'm using a fairly old ATI card, is that the limiting factor in terms of my version of OpenGL? Or the Extensions? I looked at the OpenGL site, and it said that I should refer to my card manufacturer for the most recent version of OGL for my card. I'm using the most up-to-date drivers for this card.

Also, I assume that blend effects such as add and subtract are available to me in some way, as they're used in Max2D. Are these types of blending implemented through certain configurations of the glBlendFunc parameters?

Any advice appreciated.


Dreamora(Posted 2005) [#12]
You could answer this question yourself checking out brl.glmax2d module sources searching for ALPHABLEND or any other blend constant :)


Angus(Posted 2005) [#13]
Have done so, all is clear now. Cheers.