Hi, I’m very new to openGL. I’m trying to draw a basic map made of tiles.
I’ve been trying to look at tutorials but I’m not really understanding it that well yet and a lot of tutorials are not very good.
I’m hoping to get some help from this post. Anything that would help would be good. Links to good tutorials that thoroughly explain everything, code examples, whatever. Thanks.
I used the code below before but I learned this is a depreciated method and I should be using vertex buffers which I am only starting to comprehend.
//mapblocks[block] gets the correct block.
//mapblocks is very large and only a portion of it can be rendered at a time.
//Width and Height are the width and height of the tile I want to draw (somewhat redundant,pretty much just TILE_SIZE).
//X and Y are where the block should be on the screen. Top left of the screen is 0,0. y increases going down. x increases going right.
//TILE_SIZE is the height/width of a tile.
//This is inside a nested loop that calculated x/y and mapblocks[block] relation for each block to be drawn.
glTexCoord2f(0, 0); glVertex3f(X, Y, 0);
glTexCoord2f(TILE_SIZE, 0); glVertex3f(X + Width, Y, 0);
glTexCoord2f(TILE_SIZE, TILE_SIZE); glVertex3f(X + Width, Y + Height, 0);
glTexCoord2f(0, TILE_SIZE); glVertex3f(X, Y + Height, 0);