Max2D integration

BlitzMax Modules Forums/MiniB3D/Max2D integration

I'm wondering if it is any safe way to mix max2D commands with miniB3D. I'm using Klepto module, but I have some issues with some drawing commands. Are there any plans to integrate miniB3D with Max2D properly?

I may take another look at it at some point, but it's not really a priority. It should be easy enough for other people to iron out the issues though if they really want to.

This would be a good thing to do, it would make MiniB3d THE best max engine IMHO the only thing letting it down is its lack of Max2d stuff.

I would recommend using sprites instead to be honest. With a simple bit of code from the code archives you can emulate 2D coords behaviour.

Combining MiniB3D with Max2D at this stage would just open up another layer of possible issues which I don't wish to deal with.

Another thing to bare in mind is if in the future I decide to add a DX8 rendering mode, then your projects aren't going to work with it if they're full of Max2D code. OpenGL might be easy to mix and match, DX isn't.

The only thing I would like is text over 3d without the black background :), as you said everything else can be done with sprites as fast as Max2d but the text thing still eludes me.

Add this to before GLDrawText in TDebug.Text:

glEnable(GL_BLEND)

Easy!

Ah thanks, I havent dabbled that much in OpenGL yet. Will add the bit you have put there :).

Si: would it be possible to add a 'ResetForMax2D' command that resets the states so that Max2d can be used as you say in the FAQ

No :) That was added to an earlier version and issues kept appearing. Check out klepto's version, it's as good as I can do.

ok will do, TBH will probably use sprites anyways as they would be scaled with the screen resolutions. The reason why I ask as it would stop the hoard of 'when will we get Max2d' requests :)


You just have to insert the following things for the original
minib3d:
Global ortho_mv![16],ortho_pj![16]

Function RenderWorld()
		glMatrixMode GL_PROJECTION
		glLoadMatrixd TGLobal.ortho_pj
		glMatrixMode GL_MODELVIEW
		glLoadMatrixd TGLobal.ortho_mv
			
		TGLobal.EnableStates()	
			
		glPopAttrib
		
		SetBlend SolidBlend
		
		
		For Local cam:TCamera=EachIn TCamera.cam_list

			If cam.EntityHidden()=True Then Continue

			RenderCamera(cam)
			
		Next
		
		Local x,y,w,h
		GetViewport(x,y,w,h)
		
		glDisable(GL_LIGHTING)
		glDisable(GL_DEPTH_TEST)
		glDisable(GL_SCISSOR_TEST)
		glDisable(GL_FOG)
		glDisable(GL_CULL_FACE)

		glMatrixMode GL_TEXTURE
		glLoadIdentity
		
		glMatrixMode GL_PROJECTION
		glLoadIdentity
		glOrtho 0,GraphicsWidth(),GraphicsHeight(),0,-1,1
		
		glMatrixMode GL_MODELVIEW
		glLoadIdentity
		
		SetViewport x,y,w,h
		
		Local MaxTex:Int 
		glGetIntegerv(GL_MAX_TEXTURE_UNITS, Varptr(MaxTex))

		
		For Local Layer = 0 Until MaxTex
			glActiveTexture(GL_TEXTURE0+Layer)
				
			glDisable(GL_TEXTURE_CUBE_MAP)
			glDisable(GL_TEXTURE_GEN_S)
			glDisable(GL_TEXTURE_GEN_T)
			glDisable(GL_TEXTURE_GEN_R)

			glDisable(GL_TEXTURE_2D)
		Next
		
		glActiveTexture(GL_TEXTURE0)
		
		DrawRect -10,-10,5,5
		
	End Function

simply add the globals to TGlobal and replace renderworld()

for my modified version you have to add the globals and replace renderworld by the code of the first post.



This is from the thread minib3d meets max2d. this works like charm and seems to have no direct speed issues.

does it have any other issues

no ;)

Are those changes included in your last mod version? I'm getting problems with max2D integration, and I was wondering if those changes have to be added to your last module version

yes, the changes are build into my latest module version. You have to keep in mind that max2d commands only works after the RenderWorld command. And you may set the Blendmode to AlphaBlend because otherwise the commands could overwrite the backbuffer with black areas.