Page 13 of 19

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Fri Aug 06, 2010 11:01 pm
by XianForce
Haha, no problem man =D. Glad to see you making progress. So you got all your problems situated?

Yeah, I can't wait to finish up my OpenGL rendering stuff =D, and this just gives me tons of inspiration to continue haha.

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 5:00 am
by LeonBlade
Looks about that way man yeah :)
Happy to hear this is inspired you, lots of stuff on here inspires me too!

Work just ended not too long ago, so now I'm gonna start work on the editor perhaps!
I'll keep this updated with my advancements as always.

Thanks again man.

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 6:17 am
by Milch
Uhm Leon, one thing I might add.

Code: Select all

bool Sprite::OnDraw(SpriteTexture texture, Vector2 position, SDL_Rect tile)
{   
   glBindTexture(GL_TEXTURE_2D, texture.texture);
   
   glBegin(GL_QUADS);
   {      
      float min_x = (float)(tile.x)/texture.width;
      float min_y = (float)(tile.y)/texture.height;
      float max_x = (float)(tile.x + tile.w)/texture.width;
      float max_y = (float)(tile.y + tile.h)/texture.height;
      
      glTexCoord2f(min_x, max_y); glVertex2i(position.x, position.y);
      glTexCoord2f(max_x, max_y); glVertex2i(position.x + tile.w, position.y);
      glTexCoord2f(max_x, min_y); glVertex2i(position.x + tile.w, position.y + tile.h);
      glTexCoord2f(min_x, min_y); glVertex2i(position.x, position.y + tile.h);
   }
   glEnd();
   
   return true;   
}
glBindTexture is one of the most expensive calls to OpenGL.
It loads the whole texture inside the memory of your graphics card, everytime you call it.
So you should try to only load your texture one time, then display all the sprites using this texture, and so on.
You dont have to do this for each object, but do it atleast for the tiles.
It should increase your speed a bit.

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 8:56 am
by LeonBlade
Thanks a lot Milch, I didn't know that haha :)
I'll make sure to optimize my engine so I don't keep loading the texture each time.
How should I go about when I render my map?
Because I render the map once, and then I render NPCs, and then the map again for above tiles.

How do I do Z buffering in OpenGL so that I can change positions of the tiles on the fly while still saving on memory.

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 10:37 am
by dandymcgee
LeonBlade wrote:How do I do Z buffering in OpenGL so that I can change positions of the tiles on the fly while still saving on memory.
You can either add a z coord to the position:

Code: Select all

glTexCoord2f(min_x, max_y); glVertex3i(position.x, position.y, position.z);
Or define some constants:

Code: Select all

//In order bottom to top
enum { Z_TILE_GROUND, Z_TILE_WALL, Z_NPC, Z_TILE_ROOF };
glTexCoord2f(min_x, max_y); glVertex3i(position.x, position.y, Z_NPC);
Don't forget to set up depth testing if you haven't already.
glEnable(GL_DEPTH_TEST);

In game loop:
glClear(GL_DEPTH_BUFFER_BIT);

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 10:43 am
by LeonBlade
I've run into some issues :(
About to go to bed now, but I'll post this for you guys and just tell me if you know what is the issue:
Image

Code: Select all

Unable to read symbols for "@executable_path/../Frameworks/libpng.framework/Versions/1.4.1/libpng" (file not found).
Unable to read symbols from "libpng" (not yet mapped into memory).
Unable to read symbols for "@executable_path/../Frameworks/SDL.framework/Versions/A/SDL" (file not found).
Unable to read symbols from "SDL" (not yet mapped into memory).
Unable to read symbols for "QtOpenGL.framework/Versions/4/QtOpenGL" (file not found).
Unable to read symbols from "QtOpenGL" (not yet mapped into memory).
Unable to read symbols for "QtGui.framework/Versions/4/QtGui" (file not found).
Unable to read symbols from "QtGui" (not yet mapped into memory).
Unable to read symbols for "QtCore.framework/Versions/4/QtCore" (file not found).
Unable to read symbols from "QtCore" (not yet mapped into memory).
Could not find object file "/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/libgcc.a(_eprintf.o)" - no debug information available for "/var/tmp/gcc_40/gcc_40-5493~93/src/gcc/libgcc2.c".

Starting /Users/leonblade/Programming/Mac/Blade Brothers Engine/OpenGLTest/OpenGLTest.app/Contents/MacOS/OpenGLTest...
/Users/leonblade/Programming/Mac/Blade Brothers Engine/OpenGLTest/OpenGLTest.app/Contents/MacOS/OpenGLTest exited with code 0
This is the "Application Output" in Qt, I'm kinda brain dead at the moment... haha, so I'll work on it later.
But I'm pretty sure libpng isn't working right...

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 10:57 am
by LeonBlade
Thanks Danny :)
Also, I think I see the problem but I'm too tired to figure it out now...

Code: Select all

Unable to read symbols for "@executable_path/../Frameworks/libpng.framework/Versions/1.4.1/libpng" (file not found).
>@executable_path/../Frameworks

You think that's the problem? I don't know... anyways, be back later after sleep!

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 3:06 pm
by XianForce
Continuing off of what Milch said...

Well I knew that Binding an OpenGL texture was an expensive state change, but I never thought to render it like that... But it made me think to do something like this:

You create a multimap with a key of GLuints, and the element being a sprite. Then when you want to 'render' something, you store it in this map, and when your done storing things for that frame, flush it and render everything. That way you easily know which render calls are going to use which textures.

Then again, this is just a thought, but I think it's an interesting concept haha.

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 4:09 pm
by Milch
As far as I know a process like this is used in most modern games - but I never thought about an actual implementation - and it doesnt even sound that complicate :D
Gonna have to test this...

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sat Aug 07, 2010 11:28 pm
by LeonBlade
I still gotta figure out my stupid problem with Qt and libpng and shit like that.
I'll figure it out after work.

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sun Aug 08, 2010 5:51 am
by LeonBlade
...the fuck is this shit?
Okay, so I change the paths because I forgot that my working directory. But it still fucks up, the fopen fucks up and I get errors and shit.
BUT I run the binary on it's own and this happens...
Image
...uhh... okay? >_<
So it works NOW but not before? What the fuck did I do wrong?

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sun Aug 08, 2010 8:36 am
by LeonBlade
I fucking dicked around with trying to set the current working directory in Qt for fucking an hour or two using all this stupid shit... (mind you I'm tired right now)
And out of god damn know where I check the project settings and it's in a fucking dialog...

I felt like such a fucking idiot :nono:
Anyways, I'm going to start getting the game to run in the window (just to test), then the editor!
Also, I got SDL to run in Qt finally too :) but I'm glad I'm using them both together though.

Also, today is my birthday... so I expect everyone to get me something when I wake up ;)
Thanks everyone for your help thus far, it's very much appreciated. <3

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sun Aug 08, 2010 9:46 am
by K-Bal
Happy Birthday Leon :)

AND NOW GET BACK TO WORK ON THE GAMEZ!!!

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sun Aug 08, 2010 9:51 am
by GroundUpEngine
Gratz!!! I haz cake for you!
Image

Re: Blade Brothers Engine: Creating my first 2D Game Engine

Posted: Sun Aug 08, 2010 12:32 pm
by MrDeathNote
LeonBlade wrote:I fucking dicked around with trying to set the current working directory in Qt for fucking an hour or two using all this stupid shit... (mind you I'm tired right now)
And out of god damn know where I check the project settings and it's in a fucking dialog...

I felt like such a fucking idiot :nono:
Anyways, I'm going to start getting the game to run in the window (just to test), then the editor!
Also, I got SDL to run in Qt finally too :) but I'm glad I'm using them both together though.

Also, today is my birthday... so I expect everyone to get me something when I wake up ;)
Thanks everyone for your help thus far, it's very much appreciated. <3
Just wondering, but why do you need to use SDL with Qt?