List of usage examples for org.lwjgl.opengl GL11 glEnd
public static native void glEnd();
From source file:edu.csun.ecs.cs.multitouchj.ui.control.TexturedControl.java
License:Apache License
public void render() { if (!isVisible()) { return;// w w w . jav a 2s . c o m } Size controlSize = getSize(); Size imageSize = null; if (texture != null) { imageSize = texture.getImage().getSize(); } Color color = getColor(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(((float) color.getRed() / 255.0f), ((float) color.getGreen() / 255.0f), ((float) color.getBlue() / 255.0f), getOpacity()); Point position = getOpenGlPosition(); float halfWidth = (controlSize.getWidth() / 2.0f); float halfHeight = (controlSize.getHeight() / 2.0f); GL11.glTranslatef(position.getX(), position.getY(), 0.0f); float rotation = OpenGlUtility.getOpenGlRotation(getRotation()); GL11.glRotatef(rotation, 0.0f, 0.0f, 1.0f); if (texture != null) { GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT); GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, texture.getId().intValue()); } else { GL11.glDisable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT); } // bl -> br -> tr -> tl GL11.glBegin(GL11.GL_QUADS); if (texture != null) { GL11.glTexCoord2f(0.0f, 0.0f); } GL11.glVertex3f((-1 * halfWidth), (-1 * halfHeight), 0.0f); if (texture != null) { GL11.glTexCoord2f(imageSize.getWidth(), 0.0f); } GL11.glVertex3f(halfWidth, (-1 * halfHeight), 0.0f); if (texture != null) { GL11.glTexCoord2f(imageSize.getWidth(), imageSize.getHeight()); } GL11.glVertex3f(halfWidth, halfHeight, 0.0f); if (texture != null) { GL11.glTexCoord2f(0.0f, imageSize.getHeight()); } GL11.glVertex3f((-1 * halfWidth), halfHeight, 0.0f); GL11.glEnd(); }
From source file:effects.Projectile.java
License:Open Source License
public void draw() { GL11.glDisable(GL11.GL_LIGHTING);//from www. ja v a 2 s . c om material.bind(); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3f(pos.x, pos.y, pos.z); GL11.glVertex3f(pos.x + vel.x / 10, pos.y + vel.y / 10, pos.z + vel.z / 10); GL11.glEnd(); GL11.glEnable(GL11.GL_LIGHTING); }
From source file:engine.obj.OBJLoader.java
License:Open Source License
/** * Renders a given <code>Obj</code> file. * * @param model the <code>Obj</code> file to be rendered */// w w w.ja va 2 s .c o m public void render(Obj model) { GL11.glMaterialf(GL_FRONT, GL_SHININESS, 120); GL11.glBegin(GL_TRIANGLES); { for (Obj.Face face : model.getFaces()) { Vector3f[] normals = { model.getNormals().get(face.getNormals()[0] - 1), model.getNormals().get(face.getNormals()[1] - 1), model.getNormals().get(face.getNormals()[2] - 1) }; Vector2f[] texCoords = { model.getTextureCoordinates().get(face.getTextureCoords()[0] - 1), model.getTextureCoordinates().get(face.getTextureCoords()[1] - 1), model.getTextureCoordinates().get(face.getTextureCoords()[2] - 1) }; Vector3f[] vertices = { model.getVertices().get(face.getVertices()[0] - 1), model.getVertices().get(face.getVertices()[1] - 1), model.getVertices().get(face.getVertices()[2] - 1) }; { GL11.glNormal3f(normals[0].getX(), normals[0].getY(), normals[0].getZ()); GL11.glTexCoord2f(texCoords[0].getX(), texCoords[0].getY()); GL11.glVertex3f(vertices[0].getX(), vertices[0].getY(), vertices[0].getZ()); GL11.glNormal3f(normals[1].getX(), normals[1].getY(), normals[1].getZ()); GL11.glTexCoord2f(texCoords[1].getX(), texCoords[1].getY()); GL11.glVertex3f(vertices[1].getX(), vertices[1].getY(), vertices[1].getZ()); GL11.glNormal3f(normals[2].getX(), normals[2].getY(), normals[2].getZ()); GL11.glTexCoord2f(texCoords[2].getX(), texCoords[2].getY()); GL11.glVertex3f(vertices[2].getX(), vertices[2].getY(), vertices[2].getZ()); } } } GL11.glEnd(); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
public void renderPoint(E3DPoint point) { E3DVector4F color = point.getColor(); E3DVector3F pos = point.getPos();/*from w w w. j av a 2 s . com*/ GL11.glPointSize(100f);//(float)point.getSize()); GL11.glBegin(GL11.GL_POINTS);// Begin Drawing The Line GL11.glColor4f((float) color.getA(), (float) color.getB(), (float) color.getC(), (float) color.getD()); //default all white color for the base polygon //Draw vertices GL11.glVertex3f((float) (pos.getX()), (float) (pos.getY()), (float) (pos.getZ())); GL11.glEnd(); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
public void renderLine(E3DLine line) { E3DVector3F startColor = line.getStartColor(); E3DVector3F endColor = line.getEndColor(); E3DVector3F startPos = line.getStartPos(); E3DVector3F endPos = line.getEndPos(); GL11.glBegin(GL11.GL_LINES); // Begin Drawing The Line GL11.glColor4f((float) startColor.getX(), (float) startColor.getY(), (float) startColor.getZ(), 1.0F); //default all white color for the base polygon //Draw vertices GL11.glVertex3f((float) (startPos.getX()), (float) (startPos.getY()), (float) (startPos.getZ())); GL11.glColor4f((float) endColor.getX(), (float) endColor.getY(), (float) endColor.getZ(), 1.0F); //default all white color for the base polygon GL11.glVertex3f((float) (endPos.getX()), (float) (endPos.getY()), (float) (endPos.getZ())); GL11.glEnd(); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
private void renderSolidTriangle(E3DTriangle triangle) { disableAllTextureUnits();/*w w w . ja va 2 s.c om*/ GL11.glBegin(GL11.GL_TRIANGLES); // Begin Drawing Triangles GL11.glColor4f((float) triangle.getVertexColorA().getA(), (float) triangle.getVertexColorA().getB(), (float) triangle.getVertexColorA().getC(), (float) triangle.getVertexColorA().getD()); GL11.glVertex3f((float) (triangle.getVertexPosA().getX()), (float) (triangle.getVertexPosA().getY()), (float) (triangle.getVertexPosA().getZ())); GL11.glColor4f((float) triangle.getVertexColorB().getA(), (float) triangle.getVertexColorB().getB(), (float) triangle.getVertexColorB().getC(), (float) triangle.getVertexColorB().getD()); GL11.glVertex3f((float) (triangle.getVertexPosB().getX()), (float) (triangle.getVertexPosB().getY()), (float) (triangle.getVertexPosB().getZ())); GL11.glColor4f((float) triangle.getVertexColorC().getA(), (float) triangle.getVertexColorC().getB(), (float) triangle.getVertexColorC().getC(), (float) triangle.getVertexColorC().getD()); GL11.glVertex3f((float) (triangle.getVertexPosC().getX()), (float) (triangle.getVertexPosC().getY()), (float) (triangle.getVertexPosC().getZ())); GL11.glEnd(); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
private void renderTexturedTriangle(E3DTriangle triangle) { int detail0TextureID = -1; int detail1TextureID = -1; if (triangle.isTextureDetail0Available()) detail0TextureID = triangle.getTextureDetail0().getGlTextureID(); if (triangle.isTextureDetail1Available()) detail1TextureID = triangle.getTextureDetail1().getGlTextureID(); //Draw vertices ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB); boolean twoSupported = getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() >= 2; boolean threeSupported = getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() >= 3; GL11.glBegin(GL11.GL_TRIANGLES); // Begin Drawing Triangles ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float) triangle.getTextureCoordA().getX(), (float) triangle.getTextureCoordA().getY()); if (twoSupported && detail0TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE1_ARB, (float) triangle.getTextureCoordDetail0A().getX(), (float) triangle.getTextureCoordDetail0A().getY()); if (threeSupported && detail1TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE2_ARB, (float) triangle.getTextureCoordDetail1A().getX(), (float) triangle.getTextureCoordDetail1A().getY()); GL11.glColor4f((float) triangle.getVertexColorA().getA(), (float) triangle.getVertexColorA().getB(), (float) triangle.getVertexColorA().getC(), (float) triangle.getVertexColorA().getD()); GL11.glVertex3f((float) (triangle.getVertexPosA().getX()), (float) (triangle.getVertexPosA().getY()), (float) (triangle.getVertexPosA().getZ())); ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float) triangle.getTextureCoordB().getX(), (float) triangle.getTextureCoordB().getY()); if (twoSupported && detail0TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE1_ARB, (float) triangle.getTextureCoordDetail0B().getX(), (float) triangle.getTextureCoordDetail0B().getY()); if (threeSupported && detail1TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE2_ARB, (float) triangle.getTextureCoordDetail1B().getX(), (float) triangle.getTextureCoordDetail1B().getY()); GL11.glColor4f((float) triangle.getVertexColorB().getA(), (float) triangle.getVertexColorB().getB(), (float) triangle.getVertexColorB().getC(), (float) triangle.getVertexColorB().getD()); GL11.glVertex3f((float) (triangle.getVertexPosB().getX()), (float) (triangle.getVertexPosB().getY()), (float) (triangle.getVertexPosB().getZ())); ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float) triangle.getTextureCoordC().getX(), (float) triangle.getTextureCoordC().getY()); if (twoSupported && detail0TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE1_ARB, (float) triangle.getTextureCoordDetail0C().getX(), (float) triangle.getTextureCoordDetail0C().getY()); if (threeSupported && detail1TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE2_ARB, (float) triangle.getTextureCoordDetail1C().getX(), (float) triangle.getTextureCoordDetail1C().getY()); GL11.glColor4f((float) triangle.getVertexColorC().getA(), (float) triangle.getVertexColorC().getB(), (float) triangle.getVertexColorC().getC(), (float) triangle.getVertexColorC().getD()); GL11.glVertex3f((float) (triangle.getVertexPosC().getX()), (float) (triangle.getVertexPosC().getY()), (float) (triangle.getVertexPosC().getZ())); GL11.glEnd(); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
private void renderWireframeTriangle(E3DTriangle triangle) { // int glTextureID = -1; // int detail0TextureID = -1; // int detail1TextureID = -1; ///*w w w . j av a2 s.c o m*/ // if(triangle.isTextureAvailable()) // glTextureID = triangle.getTexture().getGlTextureID(); // if(triangle.isTextureDetail0Available()) // detail0TextureID = triangle.getTextureDetail0().getGlTextureID(); // if(triangle.isTextureDetail1Available()) // detail1TextureID = triangle.getTextureDetail1().getGlTextureID(); // // setupTextureUnits(glTextureID, detail0TextureID, detail1TextureID); //Draw vertices // ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB); // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); //default all white color for the base polygon GL11.glBegin(GL11.GL_LINE_LOOP); // Begin Drawing Triangles // ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float)triangle.getTextureCoordA().getX(), (float)triangle.getTextureCoordA().getY()); GL11.glColor4f((float) triangle.getVertexColorA().getA(), (float) triangle.getVertexColorA().getB(), (float) triangle.getVertexColorA().getC(), (float) triangle.getVertexColorA().getD()); GL11.glVertex3f((float) (triangle.getVertexPosA().getX()), (float) (triangle.getVertexPosA().getY()), (float) (triangle.getVertexPosA().getZ())); // ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float)triangle.getTextureCoordB().getX(), (float)triangle.getTextureCoordB().getY()); GL11.glColor4f((float) triangle.getVertexColorA().getA(), (float) triangle.getVertexColorA().getB(), (float) triangle.getVertexColorA().getC(), (float) triangle.getVertexColorA().getD()); GL11.glVertex3f((float) (triangle.getVertexPosB().getX()), (float) (triangle.getVertexPosB().getY()), (float) (triangle.getVertexPosB().getZ())); // ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float)triangle.getTextureCoordC().getX(), (float)triangle.getTextureCoordC().getY()); GL11.glColor4f((float) triangle.getVertexColorA().getA(), (float) triangle.getVertexColorA().getB(), (float) triangle.getVertexColorA().getC(), (float) triangle.getVertexColorA().getD()); GL11.glVertex3f((float) (triangle.getVertexPosC().getX()), (float) (triangle.getVertexPosC().getY()), (float) (triangle.getVertexPosC().getZ())); GL11.glEnd(); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * Render a quad normally (solid or textured) * @param quad/*w ww . j ava 2 s. com*/ */ private void renderSolidQuad(E3DQuad quad) { //Draw vertices GL11.glBegin(GL11.GL_QUADS); // Begin Drawing Triangles GL11.glColor4f((float) quad.getVertexColorA().getA(), (float) quad.getVertexColorA().getB(), (float) quad.getVertexColorA().getC(), (float) quad.getVertexColorA().getD()); GL11.glVertex3f((float) (quad.getVertexPosA().getX()), (float) (quad.getVertexPosA().getY()), (float) (quad.getVertexPosA().getZ())); GL11.glColor4f((float) quad.getVertexColorB().getA(), (float) quad.getVertexColorB().getB(), (float) quad.getVertexColorB().getC(), (float) quad.getVertexColorB().getD()); GL11.glVertex3f((float) (quad.getVertexPosB().getX()), (float) (quad.getVertexPosB().getY()), (float) (quad.getVertexPosB().getZ())); GL11.glColor4f((float) quad.getVertexColorC().getA(), (float) quad.getVertexColorC().getB(), (float) quad.getVertexColorC().getC(), (float) quad.getVertexColorC().getD()); GL11.glVertex3f((float) (quad.getVertexPosC().getX()), (float) (quad.getVertexPosC().getY()), (float) (quad.getVertexPosC().getZ())); GL11.glColor4f((float) quad.getVertexColorD().getA(), (float) quad.getVertexColorD().getB(), (float) quad.getVertexColorD().getC(), (float) quad.getVertexColorD().getD()); GL11.glVertex3f((float) (quad.getVertexPosD().getX()), (float) (quad.getVertexPosD().getY()), (float) (quad.getVertexPosD().getZ())); GL11.glEnd(); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * Render a quad normally (solid or textured) * @param quad/* w w w .j a va 2 s . co m*/ */ private void renderTexturedQuad(E3DQuad quad) { int detail0TextureID = -1; int detail1TextureID = -1; if (quad.isTextureDetail0Available()) detail0TextureID = quad.getTextureDetail0().getGlTextureID(); if (quad.isTextureDetail1Available()) detail1TextureID = quad.getTextureDetail1().getGlTextureID(); //Draw vertices ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB); boolean twoSupported = getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() >= 2; boolean threeSupported = getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() >= 3; GL11.glBegin(GL11.GL_QUADS); // Begin Drawing Triangles ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float) quad.getTextureCoordA().getX(), (float) quad.getTextureCoordA().getY()); if (twoSupported && detail0TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE1_ARB, (float) quad.getTextureCoordDetail0A().getX(), (float) quad.getTextureCoordDetail0A().getY()); if (threeSupported && detail1TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE2_ARB, (float) quad.getTextureCoordDetail1A().getX(), (float) quad.getTextureCoordDetail1A().getY()); GL11.glColor4f((float) quad.getVertexColorA().getA(), (float) quad.getVertexColorA().getB(), (float) quad.getVertexColorA().getC(), (float) quad.getVertexColorA().getD()); GL11.glVertex3f((float) (quad.getVertexPosA().getX()), (float) (quad.getVertexPosA().getY()), (float) (quad.getVertexPosA().getZ())); ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float) quad.getTextureCoordB().getX(), (float) quad.getTextureCoordB().getY()); if (twoSupported && detail0TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE1_ARB, (float) quad.getTextureCoordDetail0B().getX(), (float) quad.getTextureCoordDetail0B().getY()); if (threeSupported && detail1TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE2_ARB, (float) quad.getTextureCoordDetail1B().getX(), (float) quad.getTextureCoordDetail1B().getY()); GL11.glColor4f((float) quad.getVertexColorB().getA(), (float) quad.getVertexColorB().getB(), (float) quad.getVertexColorB().getC(), (float) quad.getVertexColorB().getD()); GL11.glVertex3f((float) (quad.getVertexPosB().getX()), (float) (quad.getVertexPosB().getY()), (float) (quad.getVertexPosB().getZ())); ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float) quad.getTextureCoordC().getX(), (float) quad.getTextureCoordC().getY()); if (twoSupported && detail0TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE1_ARB, (float) quad.getTextureCoordDetail0C().getX(), (float) quad.getTextureCoordDetail0C().getY()); if (threeSupported && detail1TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE2_ARB, (float) quad.getTextureCoordDetail1C().getX(), (float) quad.getTextureCoordDetail1C().getY()); GL11.glColor4f((float) quad.getVertexColorC().getA(), (float) quad.getVertexColorC().getB(), (float) quad.getVertexColorC().getC(), (float) quad.getVertexColorC().getD()); GL11.glVertex3f((float) (quad.getVertexPosC().getX()), (float) (quad.getVertexPosC().getY()), (float) (quad.getVertexPosC().getZ())); ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE0_ARB, (float) quad.getTextureCoordD().getX(), (float) quad.getTextureCoordD().getY()); if (twoSupported && detail0TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE1_ARB, (float) quad.getTextureCoordDetail0D().getX(), (float) quad.getTextureCoordDetail0D().getY()); if (threeSupported && detail1TextureID != -1) ARBMultitexture.glMultiTexCoord2fARB(ARBMultitexture.GL_TEXTURE2_ARB, (float) quad.getTextureCoordDetail1D().getX(), (float) quad.getTextureCoordDetail1D().getY()); GL11.glColor4f((float) quad.getVertexColorD().getA(), (float) quad.getVertexColorD().getB(), (float) quad.getVertexColorD().getC(), (float) quad.getVertexColorD().getD()); GL11.glVertex3f((float) (quad.getVertexPosD().getX()), (float) (quad.getVertexPosD().getY()), (float) (quad.getVertexPosD().getZ())); GL11.glEnd(); }