Hello, I’ve created a sprite engine with OpenGL ( http://www.tinrocket.com/content/superspritesurface/index.html ) but I’m having problems tiling images. I’m using quads with texture maps, and the problem I’m having is getting the images to draw 1:1 with the pixels on the screen.
This is how I’ve set up my camera:
below is an image tile:
I’m incrementing the X & Y translation in a double loop, stepping by the height and width of the image. This is how I think I should be drawing the image tiles:
glBegin(GL_QUADS) glTexCoord2d(0.0,0.0) glVertex2d(0.0,0.0) glTexCoord2d(0.0,1.0) glVertex2d(0.0,Image.Height-1.0) glTexCoord2d(1.0,1.0) glVertex2d(Image.Width-1.0,Image.Height-1.0) glTexCoord2d(1.0,0.0) glVertex2d(Image.Width-1.0,0.0) glEnd
but this is the output I’m getting:
it seems that each tile is drawing 1 pixel short on the top and bottom. I think now I might be messing up where I’m assigning the texture coordinates. I’ve tried a bunch of things in various permutations:
offsetting the UV coordinates by half a pixel
offsetting the translated coordinate by half a pixel
offsetting the quad coordinates
but nothing is allowing me to get a 1:1 mapping to the screen. Can anyone help?