Blade Brothers Engine: Creating my first 2D Game Engine
Moderator: PC Supremacists
Re: Blade Brothers Engine: Creating my first 2D Game Engine
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.
Yeah, I can't wait to finish up my OpenGL rendering stuff =D, and this just gives me tons of inspiration to continue haha.
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Blade Brothers Engine: Creating my first 2D Game Engine
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.
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.
There's no place like ~/
- Milch
- Chaos Rift Junior
- Posts: 241
- Joined: Sat Jul 11, 2009 5:55 am
- Programming Language of Choice: C++
- Location: Austria, Vienna
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Uhm Leon, one thing I might add.
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.
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;
}
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.
Follow me on twitter!
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Blade Brothers Engine: Creating my first 2D Game Engine
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.
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.
There's no place like ~/
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Blade Brothers Engine: Creating my first 2D Game Engine
You can either add a z coord to the position: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.
Code: Select all
glTexCoord2f(min_x, max_y); glVertex3i(position.x, position.y, position.z);
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);
glEnable(GL_DEPTH_TEST);
In game loop:
glClear(GL_DEPTH_BUFFER_BIT);
Last edited by dandymcgee on Sat Aug 07, 2010 10:43 am, edited 1 time in total.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Blade Brothers Engine: Creating my first 2D Game Engine
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:
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...
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:
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
But I'm pretty sure libpng isn't working right...
There's no place like ~/
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Thanks Danny
Also, I think I see the problem but I'm too tired to figure it out now...
>@executable_path/../Frameworks
You think that's the problem? I don't know... anyways, be back later after sleep!
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).
You think that's the problem? I don't know... anyways, be back later after sleep!
There's no place like ~/
Re: Blade Brothers Engine: Creating my first 2D Game Engine
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.
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.
- Milch
- Chaos Rift Junior
- Posts: 241
- Joined: Sat Jul 11, 2009 5:55 am
- Programming Language of Choice: C++
- Location: Austria, Vienna
Re: Blade Brothers Engine: Creating my first 2D Game Engine
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...
Gonna have to test this...
Follow me on twitter!
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Blade Brothers Engine: Creating my first 2D Game Engine
I still gotta figure out my stupid problem with Qt and libpng and shit like that.
I'll figure it out after work.
I'll figure it out after work.
There's no place like ~/
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Blade Brothers Engine: Creating my first 2D Game Engine
...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...
...uhh... okay? >_<
So it works NOW but not before? What the fuck did I do wrong?
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...
...uhh... okay? >_<
So it works NOW but not before? What the fuck did I do wrong?
There's no place like ~/
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Blade Brothers Engine: Creating my first 2D Game Engine
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
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
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
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
There's no place like ~/
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Happy Birthday Leon
AND NOW GET BACK TO WORK ON THE GAMEZ!!!
AND NOW GET BACK TO WORK ON THE GAMEZ!!!
- GroundUpEngine
- Chaos Rift Devotee
- Posts: 835
- Joined: Sun Nov 08, 2009 2:01 pm
- Current Project: mixture
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Location: UK
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Gratz!!! I haz cake for you!
- MrDeathNote
- ES Beta Backer
- Posts: 594
- Joined: Sun Oct 11, 2009 9:57 am
- Current Project: cocos2d-x project
- Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
- Programming Language of Choice: C/++
- Location: Belfast, Ireland
- Contact:
Re: Blade Brothers Engine: Creating my first 2D Game Engine
Just wondering, but why do you need to use SDL with Qt?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
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
http://www.youtube.com/user/MrDeathNote1988
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup