Java Code Examples for org.lwjgl.opengl.GL11#glEnableClientState()
The following examples show how to use
org.lwjgl.opengl.GL11#glEnableClientState() .
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: LWJGL15DrawContext.java From settlers-remake with MIT License | 5 votes |
void init() { GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f); GL11.glEnable(GL11.GL_TEXTURE_2D); }
Example 3
Source File: LWJGL15DrawContext.java From settlers-remake with MIT License | 5 votes |
public void draw2D(GeometryHandle geometry, TextureHandle texture, int primitive, int offset, int vertices, float x, float y, float z, float sx, float sy, float sz, AbstractColor color, float intensity) { if(lx != x || ly != y || lz != z || lsx != sx || lsy != sy || lsz != sz) { if(lsz != -1) GL11.glPopMatrix(); GL11.glPushMatrix(); if(x != 0 || y != 0 || z != 0) GL11.glTranslatef(x, y, z); if(sx != 1 || sy != 1 || sz != 1) GL11.glScalef(sx, sy, sz); lx = x; lsx = sx; ly = y; lsy = sy; lz = z; lsz = sz; } if(color != null) { float r = color.red*intensity; float g = color.green*intensity; float b = color.blue*intensity; float a = color.alpha; if(lr != r || lg != g || lb != b || la != a) GL11.glColor4f(lr=r, lg=g, lb=b, la=a); } else { if(lr != lg || lr != lb || lr != intensity || la != 1) GL11.glColor4f(intensity, intensity, intensity, 1); lr = lg = lb = intensity; la = 1; } bindTexture(texture); bindGeometry(geometry); EGeometryFormatType format = geometry.getFormat(); if(format.getTexCoordPos() == -1) GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); specifyFormat(format); GL11.glDrawArrays(primitive, offset * vertices, vertices); if(format.getTexCoordPos() == -1) GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
Example 4
Source File: LWJGL15DrawContext.java From settlers-remake with MIT License | 5 votes |
protected void specifyFormat(EGeometryFormatType format) { if (format.getTexCoordPos() == -1) { if(tex_coord_on) GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0); } else { if(!tex_coord_on) GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); int stride = format.getBytesPerVertexSize(); GL11.glVertexPointer(2, GL11.GL_FLOAT, stride, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, stride, format.getTexCoordPos()); } tex_coord_on = format.getTexCoordPos() != -1; }
Example 5
Source File: LWJGL15DrawContext.java From settlers-remake with MIT License | 5 votes |
public void drawTrianglesWithTextureColored(TextureHandle textureid, GeometryHandle shapeHandle, GeometryHandle colorHandle, int offset, int lines, int width, int stride, float x, float y) { bindTexture(textureid); int starti = offset < 0 ? (int)Math.ceil(-offset/(float)stride) : 0; if(lsz != -1) GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslatef(x, y, -.1f); GL11.glScalef(1, 1, 0); GL11.glMultMatrixf(heightMatrix); if(!tex_coord_on) { GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); tex_coord_on = true; } bindGeometry(shapeHandle); GL11.glVertexPointer(3, GL11.GL_FLOAT, 5 * 4, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 5 * 4, 3 * 4); bindGeometry(colorHandle); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, 0); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); for (int i = starti; i != lines; i++) { GL11.glDrawArrays(GL11.GL_TRIANGLES, (offset + stride * i) * 3, width * 3); } GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glPopMatrix(); lsz = -1; }
Example 6
Source File: LwjglMesh.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void bind() { if (vertices == null) return; assert (isFinalised); assert (numVertices > 0); org.lwjgl.opengl.Util.checkGLError(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, 0, vertices); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glColorPointer(4, true, 0, colours); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, 0, texCoords); if (texture != null) { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId()); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); } org.lwjgl.opengl.Util.checkGLError(); }
Example 7
Source File: VAOGLRenderer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.opengl.renderer.ImmediateModeOGLRenderer#initDisplay(int, int) */ public void initDisplay(int width, int height) { super.initDisplay(width, height); startBuffer(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); }
Example 8
Source File: FastBlockModelRenderer.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
public static void renderVertexBuffer(VertexBuffer vertexBuffer) { // Check if optifine shaders are currently loaded. final boolean areOptifineShadersEnabled = GibsModelRegistry.isOptifineShadersEnabled(); GlStateManager.pushMatrix(); GlStateManager.resetColor(); GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); GlStateManager.glEnableClientState(GL11.GL_COLOR_ARRAY); // Extra OpenGL states that must be enabled when shaders are enabled. if (areOptifineShadersEnabled) { GL11.glEnableClientState(32885); GL20.glEnableVertexAttribArray(11); GL20.glEnableVertexAttribArray(12); GL20.glEnableVertexAttribArray(10); } GlStateManager.pushMatrix(); vertexBuffer.bindBuffer(); // Even more OpenGL states that must be enabled when shaders are enabled. if (areOptifineShadersEnabled) { int vertexSizeI = 14; GL11.glVertexPointer(3, 5126, 56, 0L); GL11.glColorPointer(4, 5121, 56, 12L); GL11.glTexCoordPointer(2, 5126, 56, 16L); OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glTexCoordPointer(2, 5122, 56, 24L); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); GL11.glNormalPointer(5120, 56, 28L); GL20.glVertexAttribPointer(11, 2, 5126, false, 56, 32L); GL20.glVertexAttribPointer(12, 4, 5122, false, 56, 40L); GL20.glVertexAttribPointer(10, 3, 5122, false, 56, 48L); } else { GlStateManager.glVertexPointer(3, 5126, 28, 0); GlStateManager.glColorPointer(4, 5121, 28, 12); GlStateManager.glTexCoordPointer(2, 5126, 28, 16); OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.glTexCoordPointer(2, 5122, 28, 24); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); } vertexBuffer.drawArrays(7); GlStateManager.popMatrix(); vertexBuffer.unbindBuffer(); GlStateManager.resetColor(); for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements()) { VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement .getUsage(); int i = vertexformatelement.getIndex(); switch (vertexformatelement$enumusage) { case POSITION: GlStateManager.glDisableClientState(32884); break; case UV: OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + i); GlStateManager.glDisableClientState(32888); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); break; case COLOR: GlStateManager.glDisableClientState(32886); GlStateManager.resetColor(); } } OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0); // Finally disable some of those extra OpenGL states that were be enabled due to shaders. if (areOptifineShadersEnabled) { GL11.glDisableClientState(32885); GL20.glDisableVertexAttribArray(11); GL20.glDisableVertexAttribArray(12); GL20.glDisableVertexAttribArray(10); } GlStateManager.resetColor(); GlStateManager.popMatrix(); }
Example 9
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 10
Source File: GLState.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
private final void matchGLClientState(int gl_flag, boolean enable) { if (enable) GL11.glEnableClientState(gl_flag); else GL11.glDisableClientState(gl_flag); }