List of usage examples for org.lwjgl.opengl GL11 GL_MODELVIEW
int GL_MODELVIEW
To view the source code for org.lwjgl.opengl GL11 GL_MODELVIEW.
Click Source Link
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
@Override // void dsDrawFrame (int width, int height, dsFunctions *fn, int pause) void dsDrawFrame(int width, int height, dsFunctions fn, boolean pause) { if (current_state < 1) dsDebug("internal error"); current_state = 2;/*from www . j ava2 s. c o m*/ // setup stuff GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glFrontFace(GL11.GL_CCW); // setup viewport GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); final float vnear = 0.1f; final float vfar = 100.0f; final float k = 0.8f; // view scale, 1 = +/- 45 degrees if (width >= height) { float k2 = (float) height / (float) width; GL11.glFrustum(-vnear * k, vnear * k, -vnear * k * k2, vnear * k * k2, vnear, vfar); } else { float k2 = (float) width / (float) height; GL11.glFrustum(-vnear * k * k2, vnear * k * k2, -vnear * k, vnear * k, vnear, vfar); } // setup lights. it makes a difference whether this is done in the // GL_PROJECTION matrix mode (lights are scene relative) or the // GL_MODELVIEW matrix mode (lights are camera relative, bad!). // static GLfloat light_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; // static GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; // static GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light_ambient); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light_diffuse); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, light_specular); GL11.glColor3f(1.0f, 1.0f, 1.0f); // clear the window GL11.glClearColor(0.5f, 0.5f, 0.5f, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // snapshot camera position (in MS Windows it is changed by the GUI thread) float[] view2_xyz = view_xyz.clone(); float[] view2_rxyz = view_rxyz.clone(); // memcpy (view2_xyz,view_xyz);//,sizeof(float)*3); // memcpy (view2_hpr,view_hpr);//,sizeof(float)*3); // go to GL_MODELVIEW matrix mode and set the camera GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); setCamera(view2_xyz[0], view2_xyz[1], view2_xyz[2], view2_rxyz[0], view2_rxyz[1], view2_rxyz[2]); // set the light position (for some reason we have to do this in model view. // static GLfloat light_position[] = { LIGHTX, LIGHTY, 1.0, 0.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light_position); // draw the background (ground, sky etc) drawSky(view2_xyz); drawGround(); // draw the little markers on the ground drawPyramidGrid(); // leave openGL in a known state - flat shaded white, no textures GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glColor3f(1, 1, 1); setColor(1, 1, 1, 1); // draw the rest of the objects. set drawing state first. color[0] = 1; color[1] = 1; color[2] = 1; color[3] = 1; tnum = DS_TEXTURE_NUMBER.DS_NONE; //if (fn.step) fn.step(pause); }
From source file:org.spout.engine.renderer.shader.BasicShader.java
License:Open Source License
public void assign(boolean compatabilityMode) { if (!variables.containsKey("Projection")) { throw new IllegalStateException("Basic Shader must have a projection matrix assigned"); }/*from w w w .j a va 2s . com*/ if (!variables.containsKey("View")) { throw new IllegalStateException("Basic Shader must have a view matrix assigned"); } if (compatabilityMode) { GL11.glMatrixMode(GL11.GL_PROJECTION); matrixBuffer.clear(); matrixBuffer.put(getProjectionMatrix().toArray()); matrixBuffer.flip(); GL11.glLoadMatrix(matrixBuffer); GL11.glMatrixMode(GL11.GL_MODELVIEW); /*matrixBuffer.clear(); matrixBuffer.put(getViewMatrix().toArray()); matrixBuffer.flip(); GL11.glLoadMatrix(matrixBuffer);*/ SpoutClient client = ((SpoutClient) Spout.getEngine()); Quaternion r = client.getActivePlayer().getTransform().getRotation(); Point p = client.getActivePlayer().getTransform().getPosition(); GL11.glLoadIdentity(); GL11.glRotatef(r.getPitch(), 1, 0, 0); GL11.glRotatef(r.getYaw(), 0, 1, 0); GL11.glRotatef(r.getRoll(), 0, 0, 1); GL11.glTranslatef(-p.getX(), -p.getY(), -p.getZ()); } else { super.assign(); } }
From source file:org.terasology.rendering.assets.Font.java
License:Apache License
public void drawString(int x, int y, String text, Color color) { ShaderManager.getInstance().enableDefaultTextured(); Texture bound = null;/*from www. ja va2 s. co m*/ int posX = x; int posY = y; for (char c : text.toCharArray()) { if (c == '\n') { posX = x; posY += lineHeight; } else { FontCharacter character = charMap.get(c); if (character != null) { if (!character.getPage().equals(bound)) { glBindTexture(GL11.GL_TEXTURE_2D, character.getPage().getId()); bound = character.getPage(); } glMatrixMode(GL11.GL_MODELVIEW); glPushMatrix(); glTranslatef(posX + character.getxOffset(), posY + character.getyOffset(), 0); glBegin(GL_TRIANGLE_FAN); glColor4f(color.r, color.g, color.b, color.a); glTexCoord2f(character.getX(), character.getY()); glVertex3f(0, 0, 0); glTexCoord2f(character.getX() + character.getTexWidth(), character.getY()); glVertex3f(character.getWidth(), 0, 0); glTexCoord2f(character.getX() + character.getTexWidth(), character.getY() + character.getTexHeight()); glVertex3f(character.getWidth(), character.getHeight(), 0); glTexCoord2f(character.getX(), character.getY() + character.getTexHeight()); glVertex3f(0, character.getHeight(), 0); glEnd(); glPopMatrix(); posX += character.getxAdvance(); } } } }
From source file:org.terasology.rendering.cameras.DefaultCamera.java
License:Apache License
public void loadProjectionMatrix() { glMatrixMode(GL_PROJECTION); GL11.glLoadMatrix(TeraMath.matrixToBuffer(_projectionMatrix)); glMatrixMode(GL11.GL_MODELVIEW); }
From source file:org.terasology.rendering.cameras.DefaultCamera.java
License:Apache License
public void loadModelViewMatrix() { glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadMatrix(TeraMath.matrixToBuffer(_viewMatrix)); _viewFrustum.updateFrustum(); }
From source file:org.terasology.rendering.cameras.DefaultCamera.java
License:Apache License
public void loadNormalizedModelViewMatrix() { glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadMatrix(TeraMath.matrixToBuffer(_normViewMatrix)); _viewFrustum.updateFrustum(); }
From source file:org.terasology.rendering.cameras.FirstPersonCamera.java
License:Apache License
public void loadProjectionMatrix() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(_activeFov, ASPECT_RATIO, 0.1f, 1024f); glMatrixMode(GL11.GL_MODELVIEW); }
From source file:org.terasology.rendering.cameras.FirstPersonCamera.java
License:Apache License
public void loadModelViewMatrix() { glMatrixMode(GL11.GL_MODELVIEW); glLoadIdentity();//from w w w.j a va2 s .c o m Vector3d right = new Vector3d(); right.cross(_viewingDirection, _up); right.scale(_bobbingRotationOffsetFactor); GLU.gluLookAt((float) _position.x, (float) _position.y + (float) _bobbingVerticalOffsetFactor * 2.0f, (float) _position.z, (float) _position.x + (float) _viewingDirection.x, (float) _position.y + (float) _viewingDirection.y + (float) _bobbingVerticalOffsetFactor * 2.0f, (float) _position.z + (float) _viewingDirection.z, (float) _up.x + (float) right.x, (float) _up.y + (float) right.y, (float) _up.z + (float) right.z); _viewFrustum.updateFrustum(); }
From source file:org.terasology.rendering.cameras.FirstPersonCamera.java
License:Apache License
public void loadNormalizedModelViewMatrix() { glMatrixMode(GL11.GL_MODELVIEW); glLoadIdentity();//from ww w .ja v a 2 s . com Vector3d right = new Vector3d(); right.cross(_viewingDirection, _up); right.scale(_bobbingRotationOffsetFactor); GLU.gluLookAt(0f, 0f, 0f, (float) _viewingDirection.x, (float) _viewingDirection.y, (float) _viewingDirection.z, (float) _up.x + (float) right.x, (float) _up.y + (float) right.y, (float) _up.z + (float) right.z); }
From source file:org.terasology.rendering.cameras.OculusStereoCamera.java
License:Apache License
@Deprecated public void loadProjectionMatrix() { glMatrixMode(GL_PROJECTION); GL11.glLoadMatrix(MatrixUtils.matrixToFloatBuffer(getProjectionMatrix())); glMatrixMode(GL11.GL_MODELVIEW); }