List of usage examples for org.lwjgl.opengl GL11 glBegin
public static native void glBegin(@NativeType("GLenum") int mode);
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 *///from w w w.ja v a 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 ww . j a va 2s.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 w w w. j a va 2 s .com*/ }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
private void renderSolidTriangle(E3DTriangle triangle) { disableAllTextureUnits();/*from w ww . ja va 2s. 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 www . j av a2 s . c o m*/ }
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 a 2 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 w w . j av a 2 s .co m */ 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// ww w .j ava 2s . 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(); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/** * Render a quad's wireframe/*w w w. ja va 2 s .co m*/ * @param quad */ private void renderWireframeQuad(E3DQuad quad) { //Setup textures // int glTextureID = -1; // int detail0TextureID = -1; // int detail1TextureID = -1; // // if(quad.getTexture() != null) // glTextureID = quad.getTexture().getGlTextureID(); // if(quad.isTextureDetail0Available()) // detail0TextureID = quad.getTextureDetail0().getGlTextureID(); // if(quad.isTextureDetail1Available()) // detail1TextureID = quad.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)quad.getTextureCoordA().getX(), (float)quad.getTextureCoordA().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()); 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()); 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()); 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.particle.E3DParticleRendererARBPointSprite.java
License:Open Source License
public void renderParticle(E3DParticle particle) { //Setup textures int glTextureID = -1; int detail0TextureID = -1; int detail1TextureID = -1; if (particle.getQuad().isTextureAvailable()) glTextureID = particle.getQuad().getTexture().getGlTextureID(); if (particle.getQuad().isTextureDetail0Available()) detail0TextureID = particle.getQuad().getTextureDetail0().getGlTextureID(); if (particle.getQuad().isTextureDetail1Available()) detail1TextureID = particle.getQuad().getTextureDetail1().getGlTextureID(); setupPointSpriteParameters(particle.getSize()); getEngine().getGeometryRenderer().disableAllTextureUnits(); // if(textured) getEngine().getGeometryRenderer().setupTextureUnits(glTextureID, detail0TextureID, detail1TextureID); E3DVector3F position = null;//w w w .j a v a 2 s . co m GL11.glBegin(GL11.GL_POINTS); { position = particle.getOrientation().getPosition(); GL14.glPointParameterf(GL14.GL_BLEND_SRC_ALPHA, (float) particle.getAlpha());//(float)particle.getSize());//1f ); GL11.glColor4f(1f, 1f, 1f, (float) particle.getAlpha()); GL11.glVertex3f((float) position.getX(), (float) position.getY(), (float) position.getZ()); } GL11.glEnd(); GL11.glDisable(ARBPointSprite.GL_POINT_SPRITE_ARB); }