c++ - OpenGL fixed spot map glitch -


i developed game using opengl , c++, works fine glitch need fix: when move camera around (using mouse) map not remain in fixed spot. square (gl_quad) draw in front of me.

this example of glitch:

video

this drawing code of square if needed

texture = scene->gettexture("map_papyrus.png");     glblendfunc(gl_src_alpha, gl_one_minus_src_alpha);     glenable(gl_blend);     gluseprogram(this->shader->getres());     glactivetexture(gl_texture0);     glint texture_location = glgetuniformlocation(this->shader-              >getfragment(), "color_texture");     gluniform1i(texture_location, texture_location);     glbindtexture(gl_texture_2d, this->texture->getres());   glbegin(gl_quads); float size = .5f; float offsetx = 0.0f; float offsety = 0.0f; if (set->easymode) { size = .2f; offsetx = 0.8f; offsety = 0.35f; } gltexcoord2f(0,0); glvertex2f(-size + offsetx, -size + offsety); gltexcoord2f(1, 0); glvertex2f(size + offsetx, -size +offsety); gltexcoord2f(1,1);  glvertex2f(size + offsetx, size + offsety); gltexcoord2f(0, 1);  glvertex2f(-size + offsetx, size + offsety); glend(); gltranslated(0, 0, 0.00001); 

instead of rendering gui elements part of 3d world, i'd rather finish drawing world , overlay on top of gui (without clearing buffer).

that way hud doesn't need move based on camera's position , rotation. also, hud elements wont clip world.

glclear(...) // scene: glpushmatrix() glperspective(...) gltranslatef(...) glrotatef(...) glbegin(...) // ... glend(...) glpopmatrix() // ui: glpushmatrix() glortho(...) glbegin(...) // ... glend(...) glpopmatrix() // swap buffers 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -