glMax2d

BlitzMax Forums/BlitzMax Beginners Area/glMax2d

Jayjay(Posted 2012) [#1]
Hi All

Thanks for any help in advance...

I am wanting to draw some simple polygons using DrawLine(x1,y1,x2,y2) under OpenGL but my program keeps crashing in Max2D?

I have set the viewport size, GLGraphics 640,480,0

Could this be a clipping error, ie crashes as x,y is off screen??

Its been a while since I used Max but I assumed that once the GLGraphics was set you could just use the standard Max2D commands?

Or am I wrong?


matibee(Posted 2012) [#2]
I'm really not sure about this.

First, do you want to use opengl directly or just use the opengl graphics driver? (Silly question but you admitted you've been away a while :)

I made a test, and as you say it crashes because there's no graphics driver set. But I added DrawRect and DrawLine calls to my opengl GUI app and they work.

There are also specific opengl commands: glDrawText, glDrawRect etc.

Here's some simple opengl line drawing code tho if helps..

GLGraphics 640, 480

While Not AppTerminate()
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
	glLoadIdentity()

	glLineWidth( 2.0 )
	glBegin( GL_LINES )
		glColor3f( 1,0,0 )
		glVertex3f( 0, 0, 0 )
		glVertex3f( 20, 0, 0 )
		glColor3f( 0,1,0 )
		glvertex3f( 0, 0, 0 )
		glVertex3f( 0, 0, -20 )
		glColor3f( 0,0,1 )
		glVertex3f( 0, 0, 0 )
		glVertex3f( 0, 20, 0 )
	glEnd 
	
	Flip 1	
Wend 



kfprimm(Posted 2012) [#3]
DrawLine is a Max2D function.

You have to have a Max2D driver (like GLMax2D) set in order to use it. For example,
SetGraphicsDriver GLMax2DDriver()
Graphics 640,480


By calling GLGraphics, you basically doing this,
SetGraphicsDriver GLGraphicsDriver()
Graphics 800,600