Click to See Complete Forum and Search --> : Rendering Isometric Game


Sea++
March 16th, 2009, 12:59 PM
I am attempting to create a game which renders the perceived 3d objects as 2d sprites on the screen in an isometric arrangement. Although I mention that it is arranged isometrically this is somewhat irrelevant to the topic.

I have spent the past few days learning c++ (enough to write what I want to write apart from displaying graphics); I program mostly in php so I'm used to simple functions which work without configuring which you can arrange to your heart's content to do exactly what you want in a few minutes. C++ is a lot different.

Back to the point. I "simply" want to display images on the screen. I understand that due to C++ being platform independent that sort of function isn't built in so I went looking for libraries which do it. I know there are loads so don't just suggest them without reading on. The problem I came across is that I'm using OS X with X Code so the windows libraries don't work and the others with examples didn't work or presumed I had libraries I didn't (don't ask what, this topic is aimed to assist future readers and not just myself).

I know that there have been loads of requests like this from beginners which have ended fruitless so please try and make your response as useful as possible to both me and others like me who will find this topic.

In case the request isn't obvious:
I would like a working C++ code (the whole cpp file with includes and download locations for these includes if they are not built in) so myself and others can build up from a working example.

The reason I mentioned the isometric part is that when images are being overlaid there is a need for transparency on the top images to ensure the bottom images show through. If the rendering is being done pixel by pixel this isn't a problem (although pixel by pixel processing for a realtime 2d game will be extremely cpu intensive), but if the rendering is being done by a library it requires either GIF or PNG support (correct me if there are other formats).

I don't mean to sound as though I'm requesting this from you by right, but I know it would be appreciated by anyone trying to break into the world of graphics in C++.

Thanks to anyone who replies :)

Sea++
March 16th, 2009, 06:53 PM
Mega breakthrough for me! I finally managed to make a really simple graphic application in X code. I used this tutorial:

http://blog.onesadcookie.com/2007/12/xcodeglut-tutorial.html

Although its a massive step from having nothing I'm still without images. I've tried lots of texturing and mapping tutorials, but most seem to be orientated around texturing 3d objects and the ones that did do what I wanted were aimed specifically towards Windows.

Surely there must be a simple way to texture a quad. If someone has a piece of code that achieves this I would be extremely grateful if they were to share it :)

The tutorial referenced above uses GLUT which I would really like to use because it is cross platform and I know it works for me. The only niggle I have with it is that you can only run the graphic code loop. I need to be able to initiate the new frame being rendered.

At the moment (from the tutorial) I have:


int main(int argc, char** argv)
{
glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);

glutCreateWindow("GLUT Program");

glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);

glutMainLoop();
return EXIT_SUCCESS;
}

The only place I can put code that will be looped over and over is in the idle function glutIdleFunc(idle). Any help on this would also be really appreciated.

:)

Freeman0119
March 23rd, 2009, 12:21 PM
I only program for Windows but I know OpenGL codes should look the same in X code. Texturing a 2d quad is exactly the same as texturing 3d quad. Actually all what you do for your 2d program should be done in a 3d way, you just align all your quads parallel to the xz plane and use an orthographical projection. Just grab one of those texturing tutorials you found and follow it to see how texturing works in 3d. Then you'll understand everything in 2d.

Simply put, texturing a quad requires 3 steps:
1. create the texture, from file or from memory
2. set the texture to current and enable texturing in your rendering
3. specify texture coordinates for each vertex when calling glVertex3f()

The first step is the only dfficulty. Either you write your own image file loading routine (which I can't help you with because I can't myself), or you use a third party library to load images (which I can't give you because I don't know those for mac os).

Hope this helps.