Java Code Examples for org.lwjgl.opengl.GL11#glDepthFunc()
The following examples show how to use
org.lwjgl.opengl.GL11#glDepthFunc() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenGLRendererPrimitives20.java From ldparteditor with MIT License | 7 votes |
/** * Initializes the Scene and gives OpenGL-Hints */ @Override public void init() { // MARK OpenGL Hints and Initialization GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_STENCIL_TEST); GL11.glClearDepth(1.0f); GL11.glClearColor(View.primitive_background_Colour_r[0], View.primitive_background_Colour_g[0], View.primitive_background_Colour_b[0], 1.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glPointSize(4); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); }
Example 2
Source File: Render.java From mapwriter with MIT License | 5 votes |
public static void setCircularStencil(double x, double y, double r) { GL11.glEnable(GL11.GL_DEPTH_TEST); // disable drawing to the color buffer. // circle will only be drawn to depth buffer. GL11.glColorMask(false, false, false, false); // enable writing to depth buffer GL11.glDepthMask(true); // Clearing the depth buffer causes problems with shader mods. // I guess we just have to hope that the rest of the depth buffer // contains z values greater than 2000 at this stage in the frame // render. // It would be much easier to use the stencil buffer instead, but it is // not specifically requested in the Minecraft LWJGL display setup code. // So the stencil buffer is only available on GL implementations that // set it up by default. // clear depth buffer to z = 3000.0 //GL11.glClearDepth(3000.0); //GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); // always write to depth buffer GL11.glDepthFunc(GL11.GL_ALWAYS); // draw stencil pattern (filled circle at z = 1000.0) Render.setColour(0xffffffff); Render.zDepth = 1000.0; Render.drawCircle(x, y, r); Render.zDepth = 0.0; // re-enable drawing to colour buffer GL11.glColorMask(true, true, true, true); // disable drawing to depth buffer GL11.glDepthMask(false); // only draw pixels with z values that are greater // than the value in the depth buffer. // The overlay is drawn at 2000 so this will pass inside // the circle (2000 > 1000) but not outside (2000 <= 3000). GL11.glDepthFunc(GL11.GL_GREATER); }
Example 3
Source File: Renderer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public final static void initGL() { VBO.releaseAll(); GL11.glFrontFace(GL11.GL_CCW); GL11.glCullFace(GL11.GL_BACK); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPixelStorei(GL11.GL_PACK_ROW_LENGTH, 0); GL11.glPixelStorei(GL11.GL_PACK_SKIP_PIXELS, 0); GL11.glPixelStorei(GL11.GL_PACK_SKIP_ROWS, 0); GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_PACK_SWAP_BYTES, 0); GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0); GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0); GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_SWAP_BYTES, 0); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glShadeModel(GL11.GL_SMOOTH); // GL11.glAlphaFunc(GL11.GL_GREATER, Globals.ALPHA_CUTOFF); // Setup landscape texture coordinate gen GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); GLState.activeTexture(GL13.GL_TEXTURE1); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL); GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GLState.activeTexture(GL13.GL_TEXTURE0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPointSize(7.0f); clearScreen(); GL11.glClearDepth(1.0); }
Example 4
Source File: ShadowRenderer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
protected static void setupShadows() { VBO.releaseIndexVBO(); GL11.glEnable(GL11.GL_BLEND); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glDepthFunc(GL11.GL_EQUAL); GLStateStack.switchState(GLState.VERTEX_ARRAY); GL11.glEnable(GL11.GL_TEXTURE_GEN_S); GL11.glEnable(GL11.GL_TEXTURE_GEN_T); // Workaround, See comment in renderShadow GL11.glMatrixMode(GL11.GL_TEXTURE); }
Example 5
Source File: ShadowRenderer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
protected static void resetShadows() { // Workaround, See comment in renderShadow GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); }
Example 6
Source File: CurveRenderState.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Do the actual drawing of the curve into the currently bound framebuffer. * @param color the color of the curve * @param borderColor the curve border color */ private void renderCurve(Color color, Color borderColor, int to) { staticState.initGradient(); RenderState state = saveRenderState(); staticState.initShaderProgram(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID); GL20.glUseProgram(staticState.program); GL20.glEnableVertexAttribArray(staticState.attribLoc); GL20.glEnableVertexAttribArray(staticState.texCoordLoc); GL20.glUniform1i(staticState.texLoc, 0); GL20.glUniform4f(staticState.colLoc, color.r, color.g, color.b, color.a); GL20.glUniform4f(staticState.colBorderLoc, borderColor.r, borderColor.g, borderColor.b, borderColor.a); float lastSegmentX = to == 0 ? curve[1].x - curve[0].x : curve[to].x - curve[to-1].x; float lastSegmentY = to == 0 ? curve[1].y - curve[0].y : curve[to].y - curve[to-1].y; float lastSegmentInvLen = 1.f/(float)Math.hypot(lastSegmentX, lastSegmentY); GL20.glUniform4f(staticState.endPointLoc, curve[to].x, curve[to].y, lastSegmentX * lastSegmentInvLen, lastSegmentY * lastSegmentInvLen); //stride is 6*4 for the floats (4 bytes) (u,v)(x,y,z,w) //2*4 is for skipping the first 2 floats (u,v) GL20.glVertexAttribPointer(staticState.attribLoc, 4, GL11.GL_FLOAT, false, 6 * 4, 2 * 4); GL20.glVertexAttribPointer(staticState.texCoordLoc, 2, GL11.GL_FLOAT, false, 6 * 4, 0); GL11.glColorMask(false,false,false,false); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, pointIndices[to]); GL11.glColorMask(true,true,true,true); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, pointIndices[to]); GL11.glDepthFunc(GL11.GL_LESS); GL11.glFlush(); GL20.glDisableVertexAttribArray(staticState.texCoordLoc); GL20.glDisableVertexAttribArray(staticState.attribLoc); restoreRenderState(state); }
Example 7
Source File: LwjglRasteriser.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void resetState() { GL11.glColorMask(true, true, true, true); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glFrontFace(GL11.GL_CW); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); }
Example 8
Source File: AntibuilderParticle.java From Artifacts with MIT License | 4 votes |
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { par1Tessellator.draw(); GL11.glPushMatrix(); ParticleUtils.bindTexture("textures/items/radarparticle.png"); //GL11.glDepthMask(false); GL11.glDepthFunc(GL11.GL_ALWAYS); //GL11.glEnable(3042); //GL11.glBlendFunc(770, 1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F); //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); par1Tessellator.startDrawingQuads(); /*int bright = -1; try { bright = ReflectionHelper.getPrivateValue(Tessellator.class, par1Tessellator, new String[] { "brightness", "b", "field_78401_l" }); } catch (Exception e) { System.out.println("Bad reflection"); }*/ par1Tessellator.setBrightness(255); float var8 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; if (var8 < 0.0F) { var8 = 0.0F; } if (var8 > 1.0F) { var8 = 1.0F; } this.particleScale = this.reddustParticleScale;// * var8; //replace this //super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); //Minecraft.getMinecraft().renderEngine.bindTexture(rl); float f6 = (float)this.particleTextureIndexX / 32.0F; float f7 = f6 + 0.029375F; // 0.0624375 // 0.0625 float f8 = (float)this.particleTextureIndexY / 32.0F; float f9 = f8 + 0.029375F; float f10 = 0.15F;// * this.particleScale; float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); float f14 = 1.0F; //par1Tessellator.draw(); //GL11.glDepthFunc(GL11.GL_ALWAYS); //par1Tessellator.startDrawingQuads(); //par1Tessellator.setBrightness(255); //GL11.glDisable(GL11.GL_DEPTH_TEST); float al = 0.0F; EntityPlayer player = (EntityPlayer) this.worldObj.findNearestEntityWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(this.posX - 16, this.posY-16, this.posZ-16, this.posX+16, this.posY+16, this.posZ+16), this); if(player != null) { double d = player.getDistanceToEntity(this); if(d < 6 && d > 1) { al = (float)(d / 8D); } else if(d > 1) al = 6F / 8F; }/**/ par1Tessellator.setColorRGBA_F(this.particleRed * f14 - al/2, this.particleGreen * f14, this.particleBlue * f14 + al, 0.05F); par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9); par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f7, (double)f8); par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f6, (double)f8); par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f6, (double)f9); par1Tessellator.draw(); //GL11.glDepthFunc(GL11.GL_LEQUAL); //par1Tessellator.startDrawingQuads(); //rl = new ResourceLocation("textures/particle/particles.png"); //Minecraft.getMinecraft().renderEngine.bindTexture(rl2); //GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(ParticleUtils.getParticleTexture()); par1Tessellator.startDrawingQuads(); par1Tessellator.setBrightness(0); }
Example 9
Source File: Renderer.java From AnyaBasic with MIT License | 4 votes |
Renderer( int screenWidth, int screenHeight ) { try { Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight)); Display.create(); Display.setTitle( "AnyaBasic 0.4.0 beta" ); } catch( LWJGLException e ) { e.printStackTrace(); } this.screenWidth = screenWidth; this.screenHeight = screenHeight; GL11.glViewport( 0, 0, screenWidth, screenHeight ); GL11.glMatrixMode( GL11.GL_PROJECTION ); GL11.glLoadIdentity(); GL11.glOrtho( 0, screenWidth, screenHeight, 0, 1, -1 ); GL11.glMatrixMode( GL11.GL_MODELVIEW ); GL11.glLoadIdentity(); GL11.glShadeModel(GL11.GL_SMOOTH); //set shading to smooth(try GL_FLAT) GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //set Clear color to BLACK GL11.glClearDepth(1.0f); //Set Depth buffer to 1(z-Buffer) GL11.glDisable(GL11.GL_DEPTH_TEST); //Disable Depth Testing so that our z-buffer works GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable( GL11.GL_ALPHA_TEST ); GL11.glAlphaFunc(GL11.GL_GREATER, 0); GL11.glEnable( GL11.GL_BLEND ); GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA ); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glMatrixMode( GL11.GL_MODELVIEW ); GL11.glLoadIdentity(); GL11.glTranslatef( 0.375f, 0.375f, 0 ); // magic trick }
Example 10
Source File: RadarParticle.java From Artifacts with MIT License | 4 votes |
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { par1Tessellator.draw(); GL11.glPushMatrix(); ParticleUtils.bindTexture("textures/items/radarparticle.png"); //GL11.glDepthMask(false); GL11.glDepthFunc(GL11.GL_ALWAYS); //GL11.glEnable(3042); //GL11.glBlendFunc(770, 1); GL11.glColor4f(1.0F, 1.0F, 1.0F, this.particleAlpha); par1Tessellator.startDrawingQuads(); /*int bright = -1; try { bright = ReflectionHelper.getPrivateValue(Tessellator.class, par1Tessellator, new String[] { "brightness", "b", "field_78401_l" }); } catch (Exception e) { System.out.println("Bad reflection"); }*/ par1Tessellator.setBrightness(255); float var8 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; if (var8 < 0.0F) { var8 = 0.0F; } if (var8 > 1.0F) { var8 = 1.0F; } this.particleScale = this.reddustParticleScale;// * var8; //replace this //super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); //Minecraft.getMinecraft().renderEngine.bindTexture(rl); float f6 = (float)this.particleTextureIndexX / 16.0F; float f7 = f6 + 0.0624375F; float f8 = (float)this.particleTextureIndexY / 16.0F; float f9 = f8 + 0.0624375F; float f10 = 0.3F;// * this.particleScale; float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); float f14 = 1.0F; //par1Tessellator.draw(); //GL11.glDepthFunc(GL11.GL_ALWAYS); //par1Tessellator.startDrawingQuads(); //par1Tessellator.setBrightness(255); //GL11.glDisable(GL11.GL_DEPTH_TEST); par1Tessellator.setColorRGBA_F(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha); par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9); par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f7, (double)f8); par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f6, (double)f8); par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f6, (double)f9); par1Tessellator.draw(); //GL11.glDepthFunc(GL11.GL_LEQUAL); //par1Tessellator.startDrawingQuads(); //rl = new ResourceLocation("textures/particle/particles.png"); //Minecraft.getMinecraft().renderEngine.bindTexture(rl2); //GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glPopMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(ParticleUtils.getParticleTexture()); par1Tessellator.startDrawingQuads(); par1Tessellator.setBrightness(0); }
Example 11
Source File: Render.java From mapwriter with MIT License | 4 votes |
public static void disableStencil() { GL11.glDepthMask(true); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_DEPTH_TEST); }
Example 12
Source File: ImmediateModeOGLRenderer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @see org.newdawn.slick.opengl.renderer.SGL#glDepthFunc(int) */ public void glDepthFunc(int func) { GL11.glDepthFunc(func); }
Example 13
Source File: OpenGLHelper.java From Et-Futurum with The Unlicense | 4 votes |
public static void depthFunc(int func) { GL11.glDepthFunc(func); }
Example 14
Source File: OpenGLRenderer20.java From ldparteditor with MIT License | 4 votes |
/** * Initializes the Scene and gives OpenGL-Hints */ @Override public void init() { // MARK OpenGL Hints and Initialization GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthFunc(GL11.GL_LESS); GL11.glClearDepth(1.0f); GL11.glClearColor(View.background_Colour_r[0], View.background_Colour_g[0], View.background_Colour_b[0], 1.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glPointSize(5); // GL11.glLineWidth(2); GL11.glEnable(GL11.GL_LIGHTING); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnable(GL11.GL_LIGHT1); GL11.glEnable(GL11.GL_LIGHT2); GL11.glEnable(GL11.GL_LIGHT3); GL11.glLightModelfv(GL11.GL_LIGHT_MODEL_AMBIENT, BufferFactory.floatBuffer(new float[] { 0.1f, 0.1f, 0.1f, 1f })); GL11.glLightfv(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, BufferFactory.floatBuffer(new float[] { View.light1_Colour_r[0], View.light1_Colour_g[0], View.light1_Colour_b[0], 1f })); GL11.glLightfv(GL11.GL_LIGHT0, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { View.light1_specular_Colour_r[0], View.light1_specular_Colour_g[0], View.light1_specular_Colour_b[0], 1f })); GL11.glLightf(GL11.GL_LIGHT0, GL11.GL_LINEAR_ATTENUATION, .001f); GL11.glLightfv(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, BufferFactory.floatBuffer(new float[] { View.light2_Colour_r[0], View.light2_Colour_g[0], View.light2_Colour_b[0], 1f })); GL11.glLightfv(GL11.GL_LIGHT1, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { View.light2_specular_Colour_r[0], View.light2_specular_Colour_g[0], View.light2_specular_Colour_b[0], 1f })); GL11.glLightf(GL11.GL_LIGHT1, GL11.GL_LINEAR_ATTENUATION, .001f); GL11.glLightfv(GL11.GL_LIGHT2, GL11.GL_DIFFUSE, BufferFactory.floatBuffer(new float[] { View.light3_Colour_r[0], View.light3_Colour_g[0], View.light3_Colour_b[0], 1f })); GL11.glLightfv(GL11.GL_LIGHT2, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { View.light3_specular_Colour_r[0], View.light3_specular_Colour_g[0], View.light3_specular_Colour_b[0], 1f })); GL11.glLightf(GL11.GL_LIGHT2, GL11.GL_LINEAR_ATTENUATION, .001f); GL11.glLightfv(GL11.GL_LIGHT3, GL11.GL_DIFFUSE, BufferFactory.floatBuffer(new float[] { View.light4_Colour_r[0], View.light4_Colour_g[0], View.light4_Colour_b[0], 1f })); GL11.glLightfv(GL11.GL_LIGHT3, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { View.light4_specular_Colour_r[0], View.light4_specular_Colour_g[0], View.light4_specular_Colour_b[0], 1f })); GL11.glLightf(GL11.GL_LIGHT3, GL11.GL_LINEAR_ATTENUATION, .001f); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE); GL11.glMaterialfv(GL11.GL_FRONT, GL11.GL_SPECULAR, BufferFactory.floatBuffer(new float[] { 1.0f, 1.0f, 1.0f, 1.0f })); GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 128f); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); if (fsGlossId == -1) { vsGlossId = loadGlossVertexShader(); fsGlossId = loadGlossFragmentShader(); if (pGlossId == -1 && vsGlossId != -1 && fsGlossId != -1) { pGlossId = GL20.glCreateProgram(); GL20.glAttachShader(pGlossId, vsGlossId); GL20.glAttachShader(pGlossId, fsGlossId); GL20.glLinkProgram(pGlossId); GL20.glValidateProgram(pGlossId); baseImageLoc = GL20.glGetUniformLocation(pGlossId, "colorMap"); //$NON-NLS-1$ glossMapLoc = GL20.glGetUniformLocation(pGlossId, "glossMap"); //$NON-NLS-1$ cubeMapLoc = GL20.glGetUniformLocation(pGlossId, "cubeMap"); //$NON-NLS-1$ cubeMapMatteLoc = GL20.glGetUniformLocation(pGlossId, "cubeMapMatte"); //$NON-NLS-1$ cubeMapMetalLoc = GL20.glGetUniformLocation(pGlossId, "cubeMapMetal"); //$NON-NLS-1$ alphaSwitchLoc = GL20.glGetUniformLocation(pGlossId, "alphaSwitch"); //$NON-NLS-1$ normalSwitchLoc = GL20.glGetUniformLocation(pGlossId, "normalSwitch"); //$NON-NLS-1$ noTextureSwitch = GL20.glGetUniformLocation(pGlossId, "noTextureSwitch"); //$NON-NLS-1$ noGlossMapSwitch = GL20.glGetUniformLocation(pGlossId, "noGlossMapSwitch"); //$NON-NLS-1$ cubeMapSwitch = GL20.glGetUniformLocation(pGlossId, "cubeMapSwitch"); //$NON-NLS-1$ noLightSwitch = GL20.glGetUniformLocation(pGlossId, "noLightSwitch"); //$NON-NLS-1$ } } }
Example 15
Source File: OpenGLRenderer33.java From ldparteditor with MIT License | 4 votes |
@Override public void init() { if (shaderProgram.isDefault()) shaderProgram = new GLShader("renderer.vert", "renderer.frag"); //$NON-NLS-1$ //$NON-NLS-2$ if (shaderProgram2.isDefault()) shaderProgram2 = new GLShader("primitive.vert", "primitive.frag"); //$NON-NLS-1$ //$NON-NLS-2$ if (shaderProgram2D.isDefault()) shaderProgram2D = new GLShader("2D.vert", "2D.frag"); //$NON-NLS-1$ //$NON-NLS-2$ if (shaderProgramCondline.isDefault()) shaderProgramCondline = new GLShader("condline.vert", "condline.frag"); //$NON-NLS-1$ //$NON-NLS-2$ shaderProgramCondline.use(); GL20.glUniform1f(shaderProgramCondline.getUniformLocation("showAll"), c3d.getLineMode() == 1 ? 1f : 0f); //$NON-NLS-1$ GL20.glUniform1f(shaderProgramCondline.getUniformLocation("condlineMode"), c3d.getRenderMode() == 6 ? 1f : 0f); //$NON-NLS-1$ stack.setShader(shaderProgram); shaderProgram.use(); shaderProgram.texmapOff(); { GL20.glUniform1f(shaderProgram.getUniformLocation("l0_r"), View.light1_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0_g"), View.light1_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0_b"), View.light1_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0s_r"), View.light1_specular_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0s_g"), View.light1_specular_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l0s_b"), View.light1_specular_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1_r"), View.light2_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1_g"), View.light2_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1_b"), View.light2_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1s_r"), View.light2_specular_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1s_g"), View.light2_specular_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l1s_b"), View.light2_specular_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2_r"), View.light3_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2_g"), View.light3_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2_b"), View.light3_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2s_r"), View.light3_specular_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2s_g"), View.light3_specular_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l2s_b"), View.light3_specular_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3_r"), View.light4_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3_g"), View.light4_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3_b"), View.light4_Colour_b[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3s_r"), View.light4_specular_Colour_r[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3s_g"), View.light4_specular_Colour_g[0]); //$NON-NLS-1$ GL20.glUniform1f(shaderProgram.getUniformLocation("l3s_b"), View.light4_specular_Colour_b[0]); //$NON-NLS-1$ shaderProgram.setFactor(1f); } GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthFunc(GL11.GL_LESS); GL11.glClearDepth(1.0f); GL11.glClearColor(View.background_Colour_r[0], View.background_Colour_g[0], View.background_Colour_b[0], 1.0f); GL11.glPointSize(5); modelRenderer.init(); modelRendererLDrawStandard.init(); }
Example 16
Source File: Model.java From pycode-minecraft with MIT License | 4 votes |
public void genList() { this.glList = GL11.glGenLists(1); GL11.glNewList(this.glList, GL11.GL_COMPILE); // if use_texture: glEnable(GL_TEXTURE_2D) GL11.glFrontFace(GL11.GL_CCW); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glDepthFunc(GL11.GL_LESS); GL11.glCullFace(GL11.GL_BACK); String currentMaterial = ""; Material mtl; for (Face face : this.faces) { if (!face.material.equals(currentMaterial)) { currentMaterial = face.material; mtl = this.materials.get(face.material); if (mtl == null) { GL11.glColor3f(1, 1, 1); } else { // if 'texture_Kd' in mtl: // # use diffuse texmap // glBindTexture(GL_TEXTURE_2D, mtl['texture_Kd']) GL11.glColor3f(mtl.diffuse.x, mtl.diffuse.y, mtl.diffuse.z); } } GL11.glBegin(GL11.GL_POLYGON); for (int i = 0; i < face.vertexes.size(); i++) { if (face.normals.get(i) != 0) { Vector3f n = this.normals.get(face.normals.get(i)); GL11.glNormal3f(n.x, n.y, n.z); } // if texture_coords[i]: // glTexCoord2fv(self.texcoords[texture_coords[i] - 1]) Vector3f v = this.vertices.get(face.vertexes.get(i)); GL11.glVertex3f(v.x, v.y, v.z); } GL11.glEnd(); } GL11.glCullFace(GL11.GL_BACK); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glDisable(GL11.GL_CULL_FACE); // if use_texture: glDisable(GL11.GL_TEXTURE_2D); GL11.glEndList(); }
Example 17
Source File: LWJGL15DrawContext.java From settlers-remake with MIT License | 3 votes |
public LWJGL15DrawContext(GLCapabilities glcaps, boolean debug) { this.glcaps = glcaps; if(debug) debugOutput = new LWJGLDebugOutput(this); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); init(); }