- Added gl[Get/Set]ActiveTexture() for Stencil FX (See Sprites example)
Added uoff and voff to glSpriteOnQuad for more FX
Changed Sprite Examples
Easy GL2D
-
- Posts: 84
- Joined: Sun Apr 11, 2010 10:43 am
Re: Easy GL2D
Update 04/02/2011
-
- Posts: 3
- Joined: Sat Jul 16, 2011 8:27 pm
Re: Easy GL2D
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.
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.
-
- Posts: 84
- Joined: Sun Apr 11, 2010 10:43 am
Re: Easy GL2D
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.
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.
-
- Posts: 3
- Joined: Sat Jul 16, 2011 8:27 pm
Re: Easy GL2D
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!
Thanks for the help!
Re: Easy GL2D
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 ?
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 ?
-
- Posts: 84
- Joined: Sun Apr 11, 2010 10:43 am
Re: Easy GL2D
Sure, just use it in anyway you like.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 ?
;*)
Re: Easy GL2D
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
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
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
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
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
-
- Posts: 84
- Joined: Sun Apr 11, 2010 10:43 am
Re: Easy GL2D
Yep, what elhobbs said. By parenting you mean...
Or something like that?
Just do something like this:
Then call it like:
Code: Select all
Parent
transform
Child
transform
Grandchild
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 );
}
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();
Who is online
Users browsing this forum: No registered users and 1 guest