List of usage examples for org.lwjgl.opengl GL11 glMatrixMode
public static native void glMatrixMode(@NativeType("GLenum") int mode);
From source file:io.github.SolidStudiosTeam.Flicker.engine.GameLoop.java
License:Open Source License
@Override public void initGL() { /* Enable 2D textures. */ GL11.glEnable(GL11.GL_TEXTURE_2D);/*www . ja va 2 s . co m*/ /* Make all models smoothly textured. */ GL11.glShadeModel(GL11.GL_SMOOTH); /* Set the background color to that signature blue. */ GL11.glClearColor(0.9f, 1.0f, 1.0f, 0.0f); /* Set the clear depth to all-the-way */ GL11.glClearDepth(1.0); /* Enable the depth system. */ GL11.glEnable(GL11.GL_DEPTH_TEST); /* Set the function for depth to GL_LEQUAL. */ GL11.glDepthFunc(GL11.GL_LEQUAL); // GL11.glEnable(GL11.GL_BLEND); //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); /* Enable face culling, basically don't render this face relative to the camera's position. */ // GL11.glEnable(GL11.GL_CULL_FACE); /* Set OpenGL to cull the back face of our spatials. */ // GL11.glCullFace(GL11.GL_BACK); /* Set the matrix mode to projection. */ GL11.glMatrixMode(GL11.GL_PROJECTION); /* Reset the OpenGL configuration, loading our above prefrences. */ GL11.glLoadIdentity(); /* Set the perspective. */ GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 100.0f); /* Set the matrix mode to be model view. */ GL11.glMatrixMode(GL11.GL_MODELVIEW); /* Set the perspective correction hint to finest quality. */ GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); }
From source file:ion2d.INDirector.java
License:Open Source License
public static void setProjection(ProjectionFormat format) { if (Display.isCreated() == false) return;/*ww w. j a v a 2 s.c om*/ Dimension screen = getScreenSize(); switch (format) { case DirectorProjection2D: GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, screen.width, 0, screen.height, -1000, 1000); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); break; case DirectorProjection3D: GL11.glViewport(0, 0, screen.width, screen.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); float aspect = (screen.width * 1.0f) / (screen.height * 1.0f); GLU.gluPerspective(55, aspect, 0, screen.height + screen.width); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GLU.gluLookAt(screen.width / 2, screen.height / 2, getZEye(), screen.width / 2, screen.height / 2, 0.0f, 0.0f, 1.0f, 0.0f); break; } instance.currentProjection = format; }
From source file:itdelatrisu.opsu.render.CurveRenderState.java
License:Open Source License
/** * Backup the current state of the relevant OpenGL state and change it to * what's needed to draw the curve.// w w w. ja v a 2 s . c o m */ private RenderState startRender() { RenderState state = new RenderState(); state.smoothedPoly = GL11.glGetBoolean(GL11.GL_POLYGON_SMOOTH); state.blendEnabled = GL11.glGetBoolean(GL11.GL_BLEND); state.depthEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_TEST); state.depthWriteEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_WRITEMASK); state.texEnabled = GL11.glGetBoolean(GL11.GL_TEXTURE_2D); state.texUnit = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE); state.oldProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM); state.oldArrayBuffer = GL11.glGetInteger(GL15.GL_ARRAY_BUFFER_BINDING); GL11.glDisable(GL11.GL_POLYGON_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL14.glBlendEquation(GL14.GL_FUNC_ADD); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_1D); GL11.glBindTexture(GL11.GL_TEXTURE_1D, staticState.gradientTexture); GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL20.glUseProgram(0); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); return state; }
From source file:itdelatrisu.opsu.render.CurveRenderState.java
License:Open Source License
/** * Restore the old OpenGL state that's backed up in {@code state}. * @param state the old state to restore *///w w w . j a v a 2 s .c o m private void endRender(RenderState state) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_BLEND); GL20.glUseProgram(state.oldProgram); GL13.glActiveTexture(state.texUnit); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, state.oldArrayBuffer); if (!state.depthWriteEnabled) GL11.glDepthMask(false); if (!state.depthEnabled) GL11.glDisable(GL11.GL_DEPTH_TEST); if (state.texEnabled) GL11.glEnable(GL11.GL_TEXTURE_2D); if (state.smoothedPoly) GL11.glEnable(GL11.GL_POLYGON_SMOOTH); if (!state.blendEnabled) GL11.glDisable(GL11.GL_BLEND); }
From source file:jake2.desktop.LWJGLAdapter.java
License:Open Source License
@Override public void glMatrixMode(int mode) { GL11.glMatrixMode(mode); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setMatrixMode(int type) { GL11.glMatrixMode(matrixModeToGL[type]); }
From source file:junkdisplay.JunkDisplayLWJGL.java
protected void initGLLWJGL() { if (!LEVEL_EDITOR) { GL11.glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } else {//from w ww. j av a 2 s . co m GL11.glViewport(0, 0, 1500, 800); } GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); if (!LEVEL_EDITOR) { GL11.glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1); } else { GL11.glOrtho(0, 1500, 800, 0, 1, -1); } GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); initTextures(); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); createModel(); }
From source file:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_SetupGL// w ww . j a va2 s . co m */ void R_SetupGL() { // // set up viewport // //int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width); int x = r_newrefdef.x; //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width); int x2 = r_newrefdef.x + r_newrefdef.width; //int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height); int y = vid.height - r_newrefdef.y; //int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height); int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height); int w = x2 - x; int h = y - y2; GL11.glViewport(x, y2, w, h); // // set up projection matrix // float screenaspect = (float) r_newrefdef.width / r_newrefdef.height; GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096); GL11.glCullFace(GL11.GL_FRONT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glRotatef(-90, 1, 0, 0); // put Z going up GL11.glRotatef(90, 0, 0, 1); // put Z going up GL11.glRotatef(-r_newrefdef.viewangles[2], 1, 0, 0); GL11.glRotatef(-r_newrefdef.viewangles[0], 0, 1, 0); GL11.glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1); GL11.glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]); GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, r_world_matrix); r_world_matrix.clear(); // // set drawing parms // if (gl_cull.value != 0.0f) GL11.glEnable(GL11.GL_CULL_FACE); else GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_SetGL2D//from ww w .j ava2s. co m */ void R_SetGL2D() { // set 2D virtual screen size GL11.glViewport(0, 0, vid.width, vid.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glColor4f(1, 1, 1, 1); }
From source file:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_BeginFrame// w ww . j av a 2 s . co m */ protected void R_BeginFrame(float camera_separation) { gl_state.camera_separation = camera_separation; /* ** change modes if necessary */ if (gl_mode.modified || vid_fullscreen.modified) { // FIXME: only restart if CDS is required cvar_t ref; ref = Cvar.Get("vid_ref", "lwjgl", 0); ref.modified = true; } if (gl_log.modified) { GLimp_EnableLogging((gl_log.value != 0.0f)); gl_log.modified = false; } if (gl_log.value != 0.0f) { GLimp_LogNewFrame(); } /* ** update 3Dfx gamma -- it is expected that a user will do a vid_restart ** after tweaking this value */ if (vid_gamma.modified) { vid_gamma.modified = false; if ((gl_config.renderer & GL_RENDERER_VOODOO) != 0) { // wird erstmal nicht gebraucht /* char envbuffer[1024]; float g; g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F; Com_sprintf( envbuffer, sizeof(envbuffer), "SSTV2_GAMMA=%f", g ); putenv( envbuffer ); Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g ); putenv( envbuffer ); */ VID.Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt"); } } GLimp_BeginFrame(camera_separation); /* ** go into 2D mode */ GL11.glViewport(0, 0, vid.width, vid.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glColor4f(1, 1, 1, 1); /* ** draw buffer stuff */ if (gl_drawbuffer.modified) { gl_drawbuffer.modified = false; if (gl_state.camera_separation == 0 || !gl_state.stereo_enabled) { if (gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT")) GL11.glDrawBuffer(GL11.GL_FRONT); else GL11.glDrawBuffer(GL11.GL_BACK); } } /* ** texturemode stuff */ if (gl_texturemode.modified) { GL_TextureMode(gl_texturemode.string); gl_texturemode.modified = false; } if (gl_texturealphamode.modified) { GL_TextureAlphaMode(gl_texturealphamode.string); gl_texturealphamode.modified = false; } if (gl_texturesolidmode.modified) { GL_TextureSolidMode(gl_texturesolidmode.string); gl_texturesolidmode.modified = false; } /* ** swapinterval stuff */ GL_UpdateSwapInterval(); // // clear screen if desired // R_Clear(); }