Created
December 28, 2016 12:43
-
-
Save colesnicov/1046a4f281a103ea8f52a45df6cc3a87 to your computer and use it in GitHub Desktop.
Mozny zpusob prepinani se mezi 2D a 3D zobrazenim. Vyuziti pro GUI?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void switchTo2D() { | |
if (currentRenderDimension != Dimension.DIM_2) { | |
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
glEnable(GL_BLEND); | |
glDisable(GL_CULL_FACE); | |
glDisable(GL_DEPTH_TEST); | |
glMatrixMode(GL_MODELVIEW); | |
glMatrixMode(GL_PROJECTION); | |
glLoadIdentity(); | |
gluOrtho2D(0, Display.getWidth(), Display.getHeight(), 0); | |
glViewport(0, 0, Display.getWidth(), Display.getHeight()); | |
glMatrixMode(GL_MODELVIEW); | |
glPushMatrix(); | |
glLoadIdentity(); | |
currentRenderDimension = Dimension.DIM_2; | |
} | |
} | |
public static void switchTo3D() { | |
if (currentRenderDimension != Dimension.DIM_3) { | |
glCullFace(GL_BACK); | |
glEnable(GL_CULL_FACE); | |
glEnable(GL_DEPTH_TEST); | |
glDisable(GL_BLEND); | |
glPopMatrix(); //From 2D | |
glMatrixMode(GL_PROJECTION); | |
glLoadIdentity(); | |
gluPerspective(PreferenceHelper.getInteger("fieldOfView"), (float) Display.getWidth() / Display.getHeight(), 0.1f, 1000); | |
glViewport(0, 0, Display.getWidth(), Display.getHeight()); | |
glMatrixMode(GL_MODELVIEW); | |
currentRenderDimension = Dimension.DIM_3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment