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.terasology.rendering.cameras.PerspectiveCamera.java
License:Apache License
public void loadNormalizedModelViewMatrix() { glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadMatrix(MatrixUtils.matrixToFloatBuffer(getNormViewMatrix())); }
From source file:org.terasology.rendering.gui.animation.AnimationOpacity.java
License:Apache License
@Override public void renderEnd() { DefaultRenderingProcess.getInstance().getFBO(id).unbind(); Material program = Assets.getMaterial("engine:animateOpacity"); program.setFloat("alpha", currentOpacity, true); program.enable();/*from w w w . j a v a 2 s . c om*/ DefaultRenderingProcess.getInstance().getFBO(id).bindTexture(); glMatrixMode(GL_TEXTURE); glPushMatrix(); glLoadIdentity(); glTranslatef(0, 0.5f, 0); glScalef(1f, -1f, 1f); glTranslatef(target.getAbsolutePosition().x / Display.getWidth(), target.getAbsolutePosition().y / Display.getHeight() - 0.5f, 0f); glScalef(target.getSize().x / Display.getWidth(), target.getSize().y / Display.getHeight(), 1f); glMatrixMode(GL11.GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(target.getAbsolutePosition().x, target.getAbsolutePosition().y, 0f); glScalef(target.getSize().x, target.getSize().y, 1.0f); mesh.render(); glPopMatrix(); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); }
From source file:org.terasology.rendering.gui.animation.AnimationRotate.java
License:Apache License
@Override public void renderEnd() { DefaultRenderingProcess.getInstance().getFBO(id).unbind(); DefaultRenderingProcess.getInstance().getFBO(id).bindTexture(); glMatrixMode(GL_TEXTURE);/*from w ww .ja v a 2 s . co m*/ glPushMatrix(); glLoadIdentity(); glTranslatef(0, 0.5f, 0); glScalef(1f, -1f, 1f); glTranslatef(target.getPosition().x / Display.getWidth(), target.getPosition().y / Display.getHeight() - 0.5f, 0f); glScalef(target.getSize().x / Display.getWidth(), target.getSize().y / Display.getHeight(), 1f); glMatrixMode(GL11.GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(target.getPosition().x + target.getSize().x / 2, target.getPosition().y + target.getSize().y / 2, 0f); glRotatef(currentAngle, 0f, 0f, 1f); glTranslatef(-target.getSize().x / 2, -target.getSize().y / 2, 0f); glScalef(target.getSize().x, target.getSize().y, 1.0f); mesh.render(); glPopMatrix(); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); }
From source file:org.terasology.rendering.gui.framework.style.StyleShadow.java
License:Apache License
private void renderOutside() { //======================================= // render strips //======================================= glMatrixMode(GL_TEXTURE);/* w ww . j a v a 2 s . c o m*/ glPushMatrix(); glTranslatef(stripPosition.x / shadow.getWidth(), stripPosition.y / shadow.getHeight(), 0.0f); glScalef(sectorSize.x / shadow.getWidth(), sectorSize.y / shadow.getHeight(), 1.0f); glMatrixMode(GL11.GL_MODELVIEW); //top if (width.x > 0) { glPushMatrix(); glRotatef(90f, 0f, 0f, 1f); glTranslatef(-width.x, -getSize().x + offset[1], 0f); glScalef(width.x, getSize().x - offset[0] - offset[1], 1.0f); mesh.render(); glPopMatrix(); } //right if (width.y > 0) { glPushMatrix(); glRotatef(180f, 0f, 0f, 1f); glTranslatef(-getSize().x - width.y, -getSize().y + offset[3], 0f); glScalef(width.y, getSize().y - offset[2] - offset[3], 1.0f); mesh.render(); glPopMatrix(); } //bottom if (width.z > 0) { glPushMatrix(); glRotatef(-90f, 0f, 0f, 1f); glTranslatef(-getSize().y - width.z, offset[4], 0f); glScalef(width.z, getSize().x - offset[4] - offset[5], 1.0f); mesh.render(); glPopMatrix(); } //left if (width.w > 0) { glPushMatrix(); glRotatef(0f, 0f, 0f, 1f); glTranslatef(-width.w, offset[6], 0f); glScalef(width.w, getSize().y - offset[6] - offset[7], 1.0f); mesh.render(); glPopMatrix(); } glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); //======================================= // render corners //======================================= glMatrixMode(GL_TEXTURE); glPushMatrix(); glTranslatef(outerCornerPosition.x, outerCornerPosition.y, 0.0f); glScalef(sectorSize.x / shadow.getWidth(), sectorSize.y / shadow.getHeight(), 1.0f); glMatrixMode(GL11.GL_MODELVIEW); //top left if (width.x > 0 && width.w > 0) { glPushMatrix(); glRotatef(0f, 0f, 0f, 1f); glTranslatef(-width.w, -width.x, 0f); glScalef(width.w, width.x, 1.0f); mesh.render(); glPopMatrix(); } //top right if (width.x > 0 && width.y > 0) { glPushMatrix(); glRotatef(90f, 0f, 0f, 1f); glTranslatef(-width.x, -getSize().x - width.y, 0f); glScalef(width.x, width.y, 1.0f); mesh.render(); glPopMatrix(); } //bottom left if (width.z > 0 && width.w > 0) { glPushMatrix(); glRotatef(-90f, 0f, 0f, 1f); glTranslatef(-getSize().y - width.z, -width.w, 0f); glScalef(width.z, width.w, 1.0f); mesh.render(); glPopMatrix(); } //bottom right if (width.y > 0 && width.z > 0) { glPushMatrix(); glRotatef(-180f, 0f, 0f, 1f); glTranslatef(-getSize().x - width.y, -getSize().y - width.z, 0f); glScalef(width.y, width.z, 1.0f); mesh.render(); glPopMatrix(); } glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); }
From source file:org.terasology.rendering.gui.framework.style.StyleShadow.java
License:Apache License
private void renderInside() { //======================================= // render strips //======================================= glMatrixMode(GL_TEXTURE);/* w w w . j a va 2 s.c o m*/ glPushMatrix(); glTranslatef(stripPosition.x / shadow.getWidth(), stripPosition.y / shadow.getHeight(), 0.0f); glScalef(sectorSize.x / shadow.getWidth(), sectorSize.y / shadow.getHeight(), 1.0f); glMatrixMode(GL11.GL_MODELVIEW); //top if (width.x > 0) { glPushMatrix(); glRotatef(-90f, 0f, 0f, 1f); glTranslatef(-width.x, width.w, 0f); glScalef(width.x, getSize().x - width.y - width.w, 1.0f); mesh.render(); glPopMatrix(); } //right if (width.y > 0) { glPushMatrix(); glRotatef(0f, 0f, 0f, 1f); glTranslatef(getSize().x - width.y, width.x, 0f); glScalef(width.y, getSize().y - width.x - width.z, 1.0f); mesh.render(); glPopMatrix(); } //bottom if (width.z > 0) { glPushMatrix(); glRotatef(90f, 0f, 0f, 1f); glTranslatef(getSize().y - width.z, -getSize().x + width.y, 0f); glScalef(width.z, getSize().x - width.y - width.w, 1.0f); mesh.render(); glPopMatrix(); } //left if (width.w > 0) { glPushMatrix(); glRotatef(180f, 0f, 0f, 1f); glTranslatef(-width.w, -getSize().y + width.z, 0f); glScalef(width.w, getSize().y - width.x - width.z, 1.0f); mesh.render(); glPopMatrix(); } glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); //======================================= // render corners //======================================= glMatrixMode(GL_TEXTURE); glPushMatrix(); glTranslatef(innerCornerPosition.x / shadow.getWidth(), innerCornerPosition.y / shadow.getHeight(), 0.0f); glScalef(sectorSize.x / shadow.getWidth(), sectorSize.y / shadow.getHeight(), 1.0f); glMatrixMode(GL11.GL_MODELVIEW); //top left if (width.x > 0 && width.w > 0) { glPushMatrix(); glRotatef(180f, 0f, 0f, 1f); glTranslatef(-width.w, -width.x, 0f); glScalef(width.w, width.x, 1.0f); mesh.render(); glPopMatrix(); } //top right if (width.x > 0 && width.y > 0) { glPushMatrix(); glRotatef(-90f, 0f, 0f, 1f); glTranslatef(-width.x, getSize().x - width.y, 0f); glScalef(width.x, width.y, 1.0f); mesh.render(); glPopMatrix(); } //bottom left if (width.z > 0 && width.w > 0) { glPushMatrix(); glRotatef(90f, 0f, 0f, 1f); glTranslatef(getSize().y - width.z, -width.w, 0f); glScalef(width.z, width.w, 1.0f); mesh.render(); glPopMatrix(); } //bottom right if (width.y > 0 && width.z > 0) { glPushMatrix(); glRotatef(0f, 0f, 0f, 1f); glTranslatef(getSize().x - width.y, getSize().y - width.z, 0f); glScalef(width.y, width.z, 1.0f); mesh.render(); glPopMatrix(); } glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); }
From source file:org.terasology.rendering.gui.framework.UIGraphicsElement.java
License:Apache License
@Override public void render() { if (_mesh == null) return;//from w w w . ja v a 2 s. c o m TextureManager.getInstance().bindTexture(_textureName); glEnable(GL11.GL_TEXTURE_2D); glMatrixMode(GL_TEXTURE); glPushMatrix(); glTranslatef(_textureOrigin.x, _textureOrigin.y, 0.0f); glScalef(_textureSize.x, _textureSize.y, 1.0f); glMatrixMode(GL11.GL_MODELVIEW); glPushMatrix(); glScalef(getSize().x, getSize().y, 1.0f); _mesh.render(); glPopMatrix(); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); glDisable(GL11.GL_TEXTURE_2D); }
From source file:org.terasology.rendering.gui.widgets.UIImage.java
License:Apache License
@Override public void render() { if (mesh == null) { return;/* w ww .ja v a 2 s. co m*/ } if (mesh.isDisposed()) { logger.error("Disposed mesh encountered!"); return; } if (texture != null) { CoreRegistry.get(ShaderManager.class).enableDefaultTextured(); glBindTexture(GL11.GL_TEXTURE_2D, texture != null ? texture.getId() : 0); glMatrixMode(GL_TEXTURE); glPushMatrix(); glTranslatef(textureOrigin.x, textureOrigin.y, 0.0f); glScalef(textureSize.x, textureSize.y, 1.0f); glMatrixMode(GL11.GL_MODELVIEW); glPushMatrix(); if (rotate > 0f) { glRotatef(rotate, 0f, 0f, 1f); } glScalef(getSize().x, getSize().y, 1.0f); mesh.render(); glPopMatrix(); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL11.GL_MODELVIEW); } else { glPushMatrix(); if (rotate > 0f) { glRotatef(rotate, 0f, 0f, 1f); } glScalef(getSize().x, getSize().y, 0.0f); mesh.render(); glPopMatrix(); } super.render(); }
From source file:org.terasology.rendering.nui.internal.LwjglCanvas.java
License:Apache License
@Override public void drawMesh(Mesh mesh, Material material, Rect2i region, Quat4f rotation, Vector3f offset, float scale) { if (material == null) { logger.warn("Attempted to draw with nonexistent material"); return;/*w w w . ja v a 2 s . com*/ } if (mesh == null) { logger.warn("Attempted to draw nonexistent mesh"); return; } if (!state.cropRegion.overlaps(relativeToAbsolute(region))) { return; } AABB meshAABB = mesh.getAABB(); Vector3f meshExtents = meshAABB.getExtents(); float fitScale = 0.35f * Math.min(region.width(), region.height()) / Math.max(meshExtents.x, Math.max(meshExtents.y, meshExtents.z)); Vector3f centerOffset = meshAABB.getCenter(); centerOffset.scale(-1.0f); Matrix4f centerTransform = new Matrix4f(Quat4fUtil.IDENTITY, centerOffset, 1.0f); Matrix4f userTransform = new Matrix4f(rotation, offset, -fitScale * scale); Matrix4f translateTransform = new Matrix4f(Quat4fUtil.IDENTITY, new Vector3f(state.drawRegion.minX() + region.minX() + region.width() / 2, state.drawRegion.minY() + region.minY() + region.height() / 2, 0), 1); userTransform.mul(centerTransform); translateTransform.mul(userTransform); Matrix4f finalMat = new Matrix4f(modelView); finalMat.mul(translateTransform); MatrixUtils.matrixToFloatBuffer(finalMat, matrixBuffer); Rect2i cropRegion = relativeToAbsolute(region).intersect(state.cropRegion); material.setFloat4("croppingBoundaries", cropRegion.minX(), cropRegion.maxX() + 1, cropRegion.minY(), cropRegion.maxY() + 1); material.setMatrix4("posMatrix", translateTransform); glEnable(GL11.GL_DEPTH_TEST); glClear(GL11.GL_DEPTH_BUFFER_BIT); glMatrixMode(GL11.GL_MODELVIEW); glPushMatrix(); glLoadMatrix(matrixBuffer); matrixBuffer.rewind(); boolean matrixStackSupported = material.supportsFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK); if (matrixStackSupported) { material.activateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK); } material.setFloat("alpha", state.getAlpha()); material.bindTextures(); mesh.render(); if (matrixStackSupported) { material.deactivateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK); } glPopMatrix(); glDisable(GL11.GL_DEPTH_TEST); }
From source file:org.terasology.rendering.nui.internal.LwjglCanvasRenderer.java
License:Apache License
@Override public void drawMesh(Mesh mesh, Material material, Rect2i drawRegion, Rect2i cropRegion, Quat4f rotation, Vector3f offset, float scale, float alpha) { AABB meshAABB = mesh.getAABB();// w w w . j av a 2 s .co m Vector3f meshExtents = meshAABB.getExtents(); float fitScale = 0.35f * Math.min(drawRegion.width(), drawRegion.height()) / Math.max(meshExtents.x, Math.max(meshExtents.y, meshExtents.z)); Vector3f centerOffset = meshAABB.getCenter(); centerOffset.scale(-1.0f); Matrix4f centerTransform = new Matrix4f(Quat4fUtil.IDENTITY, centerOffset, 1.0f); Matrix4f userTransform = new Matrix4f(rotation, offset, -fitScale * scale); Matrix4f translateTransform = new Matrix4f(Quat4fUtil.IDENTITY, new Vector3f( drawRegion.minX() + drawRegion.width() / 2, drawRegion.minY() + drawRegion.height() / 2, 0), 1); userTransform.mul(centerTransform); translateTransform.mul(userTransform); Matrix4f finalMat = new Matrix4f(modelView); finalMat.mul(translateTransform); MatrixUtils.matrixToFloatBuffer(finalMat, matrixBuffer); material.setFloat4(CROPPING_BOUNDARIES_PARAM, cropRegion.minX(), cropRegion.maxX() + 1, cropRegion.minY(), cropRegion.maxY() + 1); material.setMatrix4("posMatrix", translateTransform); glEnable(GL11.GL_DEPTH_TEST); glClear(GL11.GL_DEPTH_BUFFER_BIT); glMatrixMode(GL11.GL_MODELVIEW); glPushMatrix(); glLoadMatrix(matrixBuffer); matrixBuffer.rewind(); boolean matrixStackSupported = material.supportsFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK); if (matrixStackSupported) { material.activateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK); } material.setFloat("alpha", alpha); material.bindTextures(); mesh.render(); if (matrixStackSupported) { material.deactivateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK); } glPopMatrix(); glDisable(GL11.GL_DEPTH_TEST); }
From source file:org.terasology.rendering.opengl.OpenGLFont.java
License:Apache License
public void drawString(int x, int y, String text, org.newdawn.slick.Color color) { if (isDisposed()) { return;//from w ww .j ava 2 s . c o m } CoreRegistry.get(ShaderManager.class).enableDefaultTextured(); Texture bound = null; int posX = x; int posY = y; for (char c : text.toCharArray()) { if (c == '\n') { posX = x; posY += data.getLineHeight(); } else { FontCharacter character = data.getCharacter(c); if (character != null && character.getPage() != null) { Texture page = character.getPage(); if (!character.getPage().equals(bound)) { glBindTexture(GL11.GL_TEXTURE_2D, page.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(); } } } }