Search code examples
javaopengllwjgl

Billboards in OpenGL 1.1


I want to have a billboard sprite in OpenGL 1.1, but whenever I rotate the camera, it becomes offset. It looks fine up until the camera is rotated. Here is my code:

glPushMatrix();

glRotatef(player.rot%360, 0, 1, 0);
glTranslatef(player.x, 0, player.z);
level.render();
glRotatef(player.rot%360, 0, -1, 0);
// Render billboard here

glPopMatrix();

The billboard when the camera is rotated


Solution

  • Nevermind, I figured it out myself. After rendering the level, translate to the location where your billboard is supposed to be, then reverse the rotation on the matrix. Draw the billboard at origin.