Archived

This topic is now archived and is closed to further replies.

Tszafran

OpenGL Isometric Tile Engine

Recommended Posts

Hi, I am making a isometric game engine using OpenGL, it uses textured quads. I got it to load a map and render it but it scrolls tile per tile, not pixel per pixel. How would I do this? In SDL i would draw to a surface larger then the screen and move that while updating that surface, but what about in OpenGL? Should I draw more then the screen and move the screen viewport? That doesnt seem to be correct? Any ideas would be helpful. Thanks.

Share this post


Link to post
Share on other sites
Luckily for you, I've done something similar to this, only in a 2d drawing system. The process should be similar though. Basically, you only draw the quads that would possibly be on-screen. This is really easy since you're moving 1 tile at a time. The way it works in 2d is something like this:

//xOff and yOff are the offsets of the screen (how many tiles it has scrolled by)
for(i=0;i < sWidth;i++) {
for(j=0;j < sHeight;j++) {
//Assume blt has the following syntax:
//dest.blt(destx,desty,sourcePic)
buffer.blt(i*tWidth,j*tHeight,tilePic[map[xOff+i][yOff+j]]);
}
}

Now, if I understand what you're doing properly, you can do almost the exact same thing in 3d. All you really need to do is create 1 textured quad which you can move around to draw all the visible spaces (basically, it takes the place of the blt() function). Before each drawing, you would attach to it the appropriate texture (which from the example above would be tilePic[map[xOff+i][yOff+j]]).
Does this help?

[edited by - Cloral on August 30, 2002 12:12:27 AM]

Share this post


Link to post
Share on other sites