opengl - glTranslatef does not work -
in project want render rain, 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 = 0; < _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 want translate particles camera's place - relative player. there 1 problem, gltranslatef n't work. see particles in beginning of world's coordinate system.
in fact, when draw stars (particles) using 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 = 0; < stars_count; i++) { _starsarray[i].draw(); } glend(); glpopmatrix(); glenable(gl_depth_test); what doing wrong?
p. s. use opengl 1.1 lwjgl, java opengl wrapper (lwjgl.org)
gltranslatef won't work because it's between glbegin/glend.
you can use glgeterror() (eg) make finding bugs easier.
Comments
Post a Comment