1
\$\begingroup\$

How do you make a shader that will draw ontop of everything else? Im using an approach where I draw square faces in 3d space to simulate a 2d box, but when I make a 3d object, it will clip over the 2d boxes as I move around.

How do you go about making 2d boxes that are drawn directly onto screen, but without clipping thru stuff in 3d space.

Im using openGL and glsl, swapping between shaders as I call objects draw call.

\$\endgroup\$
2
\$\begingroup\$

To do that you simply call glDisable(GL_DEPTH_TEST); before drawing your GUI and after drawing your scene/screen.

That way, you draw your GUI on top of the scene and is unaffected by depth test.

For the shader, i think a basic shader will do.


I hope i remember it correctly.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Well, that was easy. Took 1 second, altho I feel maybe I shouldve figured this out myself thanks anyway :D \$\endgroup\$ – Charlie Apr 21 '16 at 15:03
  • \$\begingroup\$ no problemo ;D i'm studying opengl myself \$\endgroup\$ – Greffin28 Apr 21 '16 at 15:07
  • \$\begingroup\$ I love it compared to direct3d. Do you know freeglut as well? Or do you use the glfw approach? \$\endgroup\$ – Charlie Apr 21 '16 at 15:13
  • \$\begingroup\$ I've never tried direct3d before so i can't say anything. For c++ i use sfml and glfw for java. \$\endgroup\$ – Greffin28 Apr 21 '16 at 15:17
  • \$\begingroup\$ oh yeah, I use sfml for sound and networking, altho I really should look at those from more of a standards perspective. Especially networking. cool =) I didnt like glfw, for c++ anyway. \$\endgroup\$ – Charlie Apr 21 '16 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.