glTranslatef does not work
lwjgl, opengl
Solution
glTranslatef won't work because it's between glBegin/glEnd.
You can use glGetError() (eg) to make finding bugs like this easier.
Problem
In my project I want to render rain, so I use particles. My render method: ``` public void draw(Camera camera) { glBegin(GL_POINTS); glPushMatrix(); glTranslatef(camera.getX(), camera.getEyeLevel(), camera.getY()); glColor4f(0, 0, 0.8f, 0.1f); for(int i = 0; i < _currentParticlesCount; i++) { _particles[i].draw(); } glPopMatrix(); glEnd(); } ``` Rain particle init method: ``` particle.setX(Utils.RANDOM.nextFloat() * RAIN_RADIUS * (Utils.RANDOM.nextBoolean() ? 1 : -1)); particle.setY(Utils.RANDOM.nextFloat() * RAIN_RADIUS); particle.setZ(Utils.RANDOM.nextFloat() * RAIN_RADIUS * (Utils.RANDOM.nextBoolean() ? 1 : -1)); ``` You see that I want to translate all the particles to the camera's place - relative to player. But there is one problem, glTranslatef simply does n't work. So I see all the particles in the beginning of the world's coordinate system. In fact, when I draw stars (particles) using the same principle, glTranslatef works properly. Stars render method: ``` glDisable(GL_DEPTH_TEST); glPushMatrix(); glTranslatef(camera.getX(), camera.getEyeLevel(), camera.getY()); glBegin(GL_POINTS); glColor3f(1, 1, 1); for(int i = 0; i < STARS_COUNT; i++) { _starsArray[i].draw(); } glEnd(); glPopMatrix(); glEnable(GL_DEPTH_TEST); ``` What am I doing wrong? P. S. I use OpenGL 1.1 LWJGL, Java OpenGL wrapper (lwjgl.org)