List of usage examples for org.lwjgl.opengl GL11 glVertexPointer
public static void glVertexPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer)
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void fillQuad(float x1, float y1, float x2, float y2) { ByteBuffer quadPoints = ByteBuffer.allocateDirect(4 * 2 * 4); quadPoints.order(ByteOrder.nativeOrder()); FloatBuffer floatBuff = quadPoints.asFloatBuffer(); floatBuff.put(x1);/*w w w . j a v a2 s . c o m*/ floatBuff.put(y1); floatBuff.put(x1); floatBuff.put(y2); floatBuff.put(x2); floatBuff.put(y2); floatBuff.put(x2); floatBuff.put(y1); floatBuff.position(0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, floatBuff); GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawLine(float[] points, boolean loop) { if (points.length % 3 != 0) { throw new IllegalArgumentException("Point array length needs to be multiple of 3."); }/*from ww w. j av a 2s . c o m*/ ByteBuffer floatBuff = generateTemporaryFloatBuffer(points); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, floatBuff); GL11.glDrawArrays(loop ? GL11.GL_LINE_LOOP : GL11.GL_LINE_STRIP, 0, points.length / 3); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
private void drawQuadWithTexture(TextureHandle texture, ByteBuffer buffer, int len) throws IllegalBufferException { bindTexture(texture);/*from www . j av a 2s. c om*/ GL11.glVertexPointer(3, GL11.GL_FLOAT, 5 * 4, buffer); buffer.position(3 * 4); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 5 * 4, buffer); GL11.glDrawArrays(GL11.GL_QUADS, 0, len); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
private void drawTrianglesWithTexture(TextureHandle texture, ByteBuffer buffer, int triangles) throws IllegalBufferException { bindTexture(texture);/*from www. j a va 2 s . c o m*/ GL11.glVertexPointer(3, GL11.GL_FLOAT, 5 * 4, buffer); buffer.position(3 * 4); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 5 * 4, buffer); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, triangles * 3); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawTrianglesWithTextureColored(TextureHandle texture, ByteBuffer buffer, int triangles) throws IllegalBufferException { bindTexture(texture);/*from w ww. j a va2s . c o m*/ GL11.glVertexPointer(3, GL11.GL_FLOAT, 6 * 4, buffer); buffer.position(3 * 4); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 6 * 4, buffer); buffer.position(5 * 4); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 6 * 4, buffer); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, triangles * 3); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawQuadWithTexture(TextureHandle texture, GeometryHandle geometry) throws IllegalBufferException { if (geometry == null) { throw new NullPointerException("Cannot draw a null geometry"); }//w w w. j ava2s.c om if (canUseVBOs) { bindTexture(texture); bindArrayBuffer(geometry); GL11.glVertexPointer(3, GL11.GL_FLOAT, 5 * 4, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 5 * 4, 3 * 4); GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); bindArrayBuffer(null); } else { drawQuadWithTexture(texture, getGeometryBuffer(geometry), 4); } }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawTrianglesWithTexture(TextureHandle texture, GeometryHandle geometry, int triangleCount) throws IllegalBufferException { if (canUseVBOs) { bindTexture(texture);//from w w w .j a v a 2 s .c o m bindArrayBuffer(geometry); GL11.glVertexPointer(3, GL11.GL_FLOAT, 5 * 4, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 5 * 4, 3 * 4); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, triangleCount * 3); bindArrayBuffer(null); } else { ByteBuffer buffer = getGeometryBuffer(geometry); buffer.rewind(); drawTrianglesWithTexture(texture, buffer, buffer.remaining() / 5 / 4); } }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawTrianglesWithTextureColored(TextureHandle texture, GeometryHandle geometry, int triangleCount) throws IllegalBufferException { if (canUseVBOs) { bindTexture(texture);//from w w w .j av a 2 s. c o m bindArrayBuffer(geometry); GL11.glVertexPointer(3, GL11.GL_FLOAT, 6 * 4, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 6 * 4, 3 * 4); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 6 * 4, 5 * 4); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, triangleCount * 3); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); bindArrayBuffer(null); } else { ByteBuffer buffer = getGeometryBuffer(geometry); drawTrianglesWithTextureColored(texture, buffer, buffer.remaining() / 4 / 5); } }
From source file:hellfirepvp.astralsorcery.client.sky.RenderDefaultSkybox.java
License:Open Source License
private static void renderDefaultSkybox(float partialTicks) { GlStateManager.disableTexture2D();/* www. j ava 2 s . co m*/ Vec3d vec3 = Minecraft.getMinecraft().world.getSkyColor(Minecraft.getMinecraft().getRenderViewEntity(), partialTicks); float f = (float) vec3.xCoord; float f1 = (float) vec3.yCoord; float f2 = (float) vec3.zCoord; if (Minecraft.getMinecraft().gameSettings.anaglyph) { float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; f = f3; f1 = f4; f2 = f5; } GlStateManager.color(f, f1, f2); Tessellator tessellator = Tessellator.getInstance(); net.minecraft.client.renderer.VertexBuffer vb = tessellator.getBuffer(); GlStateManager.depthMask(false); GlStateManager.enableFog(); GlStateManager.color(f, f1, f2); if (OpenGlHelper.useVbo()) { skyVBO.bindBuffer(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L); skyVBO.drawArrays(7); skyVBO.unbindBuffer(); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else { GlStateManager.callList(glSkyList); } GlStateManager.disableFog(); GlStateManager.disableAlpha(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); RenderHelper.disableStandardItemLighting(); float[] afloat = Minecraft.getMinecraft().world.provider.calcSunriseSunsetColors( Minecraft.getMinecraft().world.getCelestialAngle(partialTicks), partialTicks); if (afloat != null) { GlStateManager.disableTexture2D(); GlStateManager.shadeModel(7425); GlStateManager.pushMatrix(); GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate( MathHelper.sin(Minecraft.getMinecraft().world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); float f6 = afloat[0]; float f7 = afloat[1]; float f8 = afloat[2]; if (Minecraft.getMinecraft().gameSettings.anaglyph) { float f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F; float f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F; float f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F; f6 = f9; f7 = f10; f8 = f11; } vb.begin(6, DefaultVertexFormats.POSITION_COLOR); vb.pos(0.0D, 100.0D, 0.0D).color(f6, f7, f8, afloat[3]).endVertex(); //int j = 16; for (int l = 0; l <= 16; ++l) { float f21 = (float) l * (float) Math.PI * 2.0F / 16.0F; float f12 = MathHelper.sin(f21); float f13 = MathHelper.cos(f21); vb.pos((double) (f12 * 120.0F), (double) (f13 * 120.0F), (double) (-f13 * 40.0F * afloat[3])) .color(afloat[0], afloat[1], afloat[2], 0.0F).endVertex(); } tessellator.draw(); GlStateManager.popMatrix(); GlStateManager.shadeModel(7424); } GlStateManager.enableTexture2D(); GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); GlStateManager.pushMatrix(); float f16 = 1.0F - Minecraft.getMinecraft().world.getRainStrength(partialTicks); GlStateManager.color(1.0F, 1.0F, 1.0F, f16); GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(Minecraft.getMinecraft().world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); float f17 = 30.0F; Minecraft.getMinecraft().renderEngine.bindTexture(MC_DEF_SUN_PNG); vb.begin(7, DefaultVertexFormats.POSITION_TEX); vb.pos((double) (-f17), 100.0D, (double) (-f17)).tex(0.0D, 0.0D).endVertex(); vb.pos((double) f17, 100.0D, (double) (-f17)).tex(1.0D, 0.0D).endVertex(); vb.pos((double) f17, 100.0D, (double) f17).tex(1.0D, 1.0D).endVertex(); vb.pos((double) (-f17), 100.0D, (double) f17).tex(0.0D, 1.0D).endVertex(); tessellator.draw(); f17 = 20.0F; Minecraft.getMinecraft().renderEngine.bindTexture(MC_DEF_MOON_PHASES_PNG); int i = Minecraft.getMinecraft().world.getMoonPhase(); int k = i % 4; int i1 = i / 4 % 2; float f22 = (float) (k) / 4.0F; float f23 = (float) (i1) / 2.0F; float f24 = (float) (k + 1) / 4.0F; float f14 = (float) (i1 + 1) / 2.0F; vb.begin(7, DefaultVertexFormats.POSITION_TEX); vb.pos((double) (-f17), -100.0D, (double) f17).tex((double) f24, (double) f14).endVertex(); vb.pos((double) f17, -100.0D, (double) f17).tex((double) f22, (double) f14).endVertex(); vb.pos((double) f17, -100.0D, (double) (-f17)).tex((double) f22, (double) f23).endVertex(); vb.pos((double) (-f17), -100.0D, (double) (-f17)).tex((double) f24, (double) f23).endVertex(); tessellator.draw(); GlStateManager.disableTexture2D(); float f15 = Minecraft.getMinecraft().world.getStarBrightness(partialTicks) * f16; if (f15 > 0.0F) { GlStateManager.color(f15, f15, f15, f15); if (OpenGlHelper.useVbo()) { starVBO.bindBuffer(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L); starVBO.drawArrays(7); starVBO.unbindBuffer(); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else { GlStateManager.callList(starGLCallList); } } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableFog(); GlStateManager.popMatrix(); GlStateManager.disableTexture2D(); GlStateManager.color(0.0F, 0.0F, 0.0F); double d0 = Minecraft.getMinecraft().player.getPositionEyes(partialTicks).yCoord - Minecraft.getMinecraft().world.getHorizon(); if (d0 < 0.0D) { GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, 12.0F, 0.0F); if (OpenGlHelper.useVbo()) { sky2VBO.bindBuffer(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L); sky2VBO.drawArrays(7); sky2VBO.unbindBuffer(); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); } else { GlStateManager.callList(glSkyList2); } GlStateManager.popMatrix(); //float f18 = 1.0F; float f19 = -((float) (d0 + 65.0D)); //float f20 = -1.0F; vb.begin(7, DefaultVertexFormats.POSITION_COLOR); vb.pos(-1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex(); vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex(); tessellator.draw(); } if (Minecraft.getMinecraft().world.provider.isSkyColored()) { GlStateManager.color(f * 0.2F + 0.04F, f1 * 0.2F + 0.04F, f2 * 0.6F + 0.1F); } else { GlStateManager.color(f, f1, f2); } GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, -((float) (d0 - 16.0D)), 0.0F); GlStateManager.callList(glSkyList2); GlStateManager.popMatrix(); GlStateManager.enableTexture2D(); GlStateManager.depthMask(true); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setVertexPointer(int size, int type, int stride, long offset) { GL11.glVertexPointer(size, pointerTypeToGL[type], stride, offset); }