Page 5 of 6

Re: Easy GL2D

Posted: Sat Apr 02, 2011 3:49 am
by relminator
Update 04/02/2011
  • Added gl[Get/Set]ActiveTexture() for Stencil FX (See Sprites example)
    Added uoff and voff to glSpriteOnQuad for more FX
    Changed Sprite Examples

Re: Easy GL2D

Posted: Sat Jul 16, 2011 11:06 pm
by suprsmashkng
Hey relminator,

I really love your Easy GL2D library. I'd been floundering around with the 2D engine for a few weeks and then found your library and haven't looked back.

I'm at an impasse with collision checking in a game I'm trying to make. Can you recommend a way to do it? After looking around the Internet for ideas, my initial plan was to do rough collision checking by looking at sprites' bounding boxes and then following up, if necessary, with precise, per-pixel checking within the bounding boxes' rectangle of intersection. The problem is I have no idea how to check if a pixel is "on" in Easy GL2D! Can you think of a way to do it, or a workaround? Any help would be appreciated. Thanks a lot.

Re: Easy GL2D

Posted: Thu Sep 01, 2011 1:43 am
by relminator
Hi. sorry for the late reply. Been kinda busy these days. ;*(

Yeah AABB is very fast and I would stick to it if it can do what you want.

I've used only AABBs on this game and I did fine:

http://rel.phatcode.net/index.php?actio ... Impakto-DS


For a more geometrically friendly collision detection you can use SAT.

http://rel.phatcode.net/junk.php?id=109

I would not use pixel by pixel collisions on the DS as it's very slow even after clipping and cropping collision bounds via AABB.

Re: Easy GL2D

Posted: Thu Sep 01, 2011 2:24 am
by suprsmashkng
I looked into SAT a little bit. I tried to do myself with someone else's fixed-point arithmetic library but ran into problems, so I'm excited to see how your implementation works. I settled on treating an object's bounding box as a convex hull and doing an inclusion test on each of the vertices of the other object's bounding box, and it works perfectly. However, I can imaging it slowing down for a busy game with lots of bounding boxes, so perhaps I'll try your SAT method.

Thanks for the help!

Re: Easy GL2D

Posted: Sat Dec 10, 2011 4:09 am
by defer
Hi,
I've used gl2d for the sdl 1.3 port, which has saved me alot of time. I'd like to integrate it into sdl as well as fix an issue I'm facing. However your code doesn't have a licence. SDL is using the zlib licence (http://hg.libsdl.org/SDL/file/tip/COPYING). Could you consider allowing me to use your code there, or licence gl2d with a zlib compatible licence ?

Re: Easy GL2D

Posted: Fri Jan 27, 2012 8:53 am
by relminator
defer wrote:Hi,
I've used gl2d for the sdl 1.3 port, which has saved me alot of time. I'd like to integrate it into sdl as well as fix an issue I'm facing. However your code doesn't have a licence. SDL is using the zlib licence (http://hg.libsdl.org/SDL/file/tip/COPYING). Could you consider allowing me to use your code there, or licence gl2d with a zlib compatible licence ?
Sure, just use it in anyway you like.
;*)

Re: Easy GL2D

Posted: Wed Sep 12, 2012 2:52 pm
by slenkar
do all sprites have to be power of 2?
what about sprites that are NOT power of 2 on a texture that IS power of 2?

also I would like to alter the gl2d source so I can parent one sprite to another, so I would have to remove some calls to glLoadidentity

as gl2d is included as a .a file how would I do this

Re: Easy GL2D

Posted: Wed Sep 12, 2012 4:27 pm
by elhobbs
sprites do not need to be a power of 2, but the textures used to hold the sprite frames do need to be power of 2. look at the spritres example, this is how it is setup. The lib source is in the download - the distributable_source directory. instead of referencing the lib in your makefile just copy the files in the gl2d source and include directories to your project's source and include directories. then you can change whatever you like.

Re: Easy GL2D

Posted: Wed Sep 12, 2012 6:46 pm
by slenkar
thanks for the help on sprites,

I realized the texturedquad function is all you need to do do funky stuff like parenting etc. as long as xtranslatef32 is copied from gl2d.c as its inline

Re: Easy GL2D

Posted: Thu Sep 13, 2012 10:36 am
by relminator
Yep, what elhobbs said. By parenting you mean...

Code: Select all

Parent
    transform
        Child
           transform
              Grandchild
Or something like that?

Just do something like this:

Code: Select all


void DrawTentacle( s32 angle, int Segments, glImage *spr )
{

	int i;
	glPushMatrix();
	
		for( i = 0; i < Segments; i++ )
		{
			glTranslate3f32( 7, 0, 0 );
			glRotateZi( angle );
			glSpriteRotate( 0, 0, 0, GL_FLIP_NONE, spr );
		}

	glPopMatrix( 1 );
	
	
}
Then call it like:

Code: Select all

// Start 2D mode
		glBegin2D();

			
			// Draw our enemies
			glSpriteRotate(    x, y, Frame*30 * 3, GL_FLIP_NONE, &Enemies[81]);
			
			
			glPushMatrix();
				glLoadIdentity();
				glTranslate3f32( 128, 96, 0 );   // center of the tentakill
				glRotateZi( Frame * 280);		  // rotation of the tentakill
			
				s32 angle = (sinLerp(-Frame*40));	// angle of the first tentacle
				glPushMatrix();						// relative draw tentacle
					DrawTentacle( angle, 8, &Bullets[Frame/4 & 3] );
				glPopMatrix( 1 );
				
				
				angle = (sinLerp(-Frame*60));
				glRotateZi(BRAD_PI/2);				// quarter turn for next tentacle
				glPushMatrix();
					DrawTentacle( angle, 8, &Bullets[Frame/4 & 3] );
				glPopMatrix( 1 );
				
				angle = (sinLerp(-Frame*40));
				glRotateZi(BRAD_PI/2);
				glPushMatrix();
					DrawTentacle( angle, 8, &Bullets[Frame/4 & 3] );
				glPopMatrix( 1 );
				
				angle = (sinLerp(-Frame*60));
				glRotateZi(BRAD_PI/2);
				glPushMatrix();
					DrawTentacle( angle, 8, &Bullets[Frame/4 & 3] );
				glPopMatrix( 1 );
				
			glPopMatrix( 1 );
			
			// draw the center of tentacle
			glSpriteRotate(    128, 96, Frame*180 * 3, GL_FLIP_NONE, &Enemies[1]);

				
		glEnd2D();