OpenGL To PixMap And Then to Max2d

BlitzMax Forums/BlitzMax Programming/OpenGL To PixMap And Then to Max2d

Sorry for the big title. But it explains the idia.
I don't know how to create a box Code so here it is




bglCreateContext 640,480,16,0,BGL_BACKBUFFER



glMatrixMode GL_PROJECTION							
glLoadIdentity										

glFrustum -0.1, 0.1,-0.1, 0.1, 0.1, 100.0			

glMatrixMode GL_MODELVIEW							
glLoadIdentity										



	glClear GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_FRAME_BUFFER_BIT	

	glLoadIdentity									
								
	glTranslatef 0.0 , 2.0 , -6.0
         glBegin GL_QUADS							
		glColor3f 0.0 , 0.5 , 0.5
		glVertex3f 5.0, 1.0, 0.0
		glColor3f 1.0 , 0.0 , 0.5				
		glVertex3f  1.0, 1.0, 0.0
		glColor3f 0.0 , 0.5 , 1.0				
		glVertex3f  10.0,-10.0, 0.0
		glColor3f 1.0 , 0.0 , 0.0				
		glVertex3f-10.0,-10.0,0.0				
		
	glEnd										

Global pixMap:TPixMap = CreatePixmap(640 , 480 , PF_RGB888)
Global i_ptr:Byte Ptr=PixmapPixelPtr(pixMap)

bglDrawText "This Will Take No Time..." , 10 , 10
bglDrawText "When It will Finish press Space To go to Max2d" , 10 , 50
bglSwapBuffers
glReadBuffer(GL_FRONT)

glReadPixels(0 , 0 , 640 , 480 , GL_RGB , GL_UNSIGNED_BYTE , i_ptr)
pixmap = YFlipPixmap(pixMap)	


While Not KeyDown(Key_Space)
Wend
bglDeleteContext




Graphics 640 , 480 ,  32

While Not KeyDown(Key_EScape)
	Cls
	DrawPixmap pixmap , 0 , 0
	DrawText "Press Escape To Exit" , 10 , 100
	Flip
	FlushMem
Wend



I edited your post so your now in a code box.

Thanks For the tip.

EDIT : That's better! =]

To use glReadPixels there other related OpenGl parameters that need to be set up to determine that the transfer works correctly.

I tryed to use it so to grab all the window at once and take the RGB but it was just crashing.

There are other commands you have to call first to set up the date transfer properly.