ok so I’m trying to make a spritesheet and I’m at the point where I’m trying to only get part of the spritesheet drawn
public SpriteSheetSprite(Texture texture, int x, int y, int maxCol, int maxRows){
this.texture = texture;
this.x = x;
this.y = y;
this.maxCol = maxCol;
this.maxRows = maxRows;
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture.getTextureID());
//texture.bind();
}
@Override
public void Render() {
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2i(x,y);//top left
glTexCoord2f(32,0);
glVertex2i(x + getWidth(),y);//top right
glTexCoord2f(32,32);
glVertex2i(x+ getWidth(),y + getHeight());//bottem right
glTexCoord2f(0,32);
glVertex2i(x,y + getHeight());//bottem left
glEnd();
}
Using the above code my quad gets an image which is the spritesheet stretched over and over, that is to be expected as we’re no longer wrapping the texture around the quad from 0,0 to 1,1
The problem I’m having is that when I switch OpenGl from GL_TEXTURE_2D to GL_TEXTURE_RECTANGLE_ARB the texture no longer wants to be applied to the quad (I just get a white rectangle). Here is my code for initalizing open gl
private void startOpenGl(){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,Settings.WIDTH, Settings.HEIGHT,0,1,-1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
}
any help on the matter would be awesome