Example usage for org.lwjgl.opengl GL11 glDisableClientState

List of usage examples for org.lwjgl.opengl GL11 glDisableClientState

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glDisableClientState.

Prototype

public static native void glDisableClientState(@NativeType("GLenum") int cap);

Source Link

Document

Disables a client-side capability.

Usage

From source file:org.ajgl.graphics.Graphics.java

License:Open Source License

/**
 * Disables a OpenGL state.//  www .  j  a  va2  s. c  om
 * @param state - The list of OpenGL states to disable.
 */
public static void disableClientSideState(int... state) {
    for (int i = 0; i < state.length; i++)
        GL11.glDisableClientState(state[i]);
}

From source file:org.craftmania.rendering.ChunkMeshRenderer.java

License:Apache License

public static void renderChunkMesh(Chunk chunk, MeshType meshType) {
    if (chunk.getMesh().getVBO(meshType) <= 0) {
        return;//from   w  w w . j a v  a2  s .c om
    }

    /* Bind the correct texture */
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    TextureStorage.getTexture("terrain").bind();

    if (meshType == MeshType.OPAQUE) {
        GL11.glDisable(GL11.GL_BLEND);
    } else if (meshType == MeshType.TRANSLUCENT) {
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    }

    ChunkMesh mesh = chunk.getMesh();

    /* Bind the buffer */
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, mesh.getVBO(meshType));

    /* Enable the different kinds of data in the buffer */
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    // System.out.println("Chunk Vertices = " + mesh.getVertexCount());

    /* Define the starting positions */
    GL11.glVertexPointer(POSITION_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, POSITION_OFFSET * FLOAT_SIZE);
    GL11.glTexCoordPointer(TEX_COORD_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, TEX_COORD_OFFSET * FLOAT_SIZE);
    GL11.glColorPointer(COLOR_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, COLOR_OFFSET * FLOAT_SIZE);

    /* Draw the buffer */
    GL11.glDrawArrays(GL11.GL_QUADS, 0, mesh.getVertexCount(meshType));

    /* Unbind the buffer */
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);

    /* Disable the different kindds of data */
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    if (meshType == MeshType.TRANSLUCENT) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Mesh.java

License:Open Source License

/**
 * GL_DrawAliasFrameLerp/*from  w  w w.j av  a2 s  . co  m*/
 *
 * interpolates between two frames and origins FIXME: batch lerp all vertexes
 */
void GL_DrawAliasFrameLerp(qfiles.dmdl_t paliashdr, float backlerp) {
    qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame];

    int[] verts1 = frame.verts;

    qfiles.daliasframe_t oldframe = paliashdr.aliasFrames[currententity.oldframe];

    int[] ov = oldframe.verts;

    float alpha;
    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        alpha = currententity.alpha;
    } else {
        alpha = 1.0f;
    }

    // PMM - added double shell
    if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE
            | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
    }

    float frontlerp = 1.0f - backlerp;

    // move should be the delta back to the previous frame * backlerp
    Math3D.VectorSubtract(currententity.oldorigin, currententity.origin, frontv);
    Math3D.AngleVectors(currententity.angles, vectors[0], vectors[1], vectors[2]);

    move[0] = Math3D.DotProduct(frontv, vectors[0]); // forward
    move[1] = -Math3D.DotProduct(frontv, vectors[1]); // left
    move[2] = Math3D.DotProduct(frontv, vectors[2]); // up

    Math3D.VectorAdd(move, oldframe.translate, move);

    for (int i = 0; i < 3; i++) {
        move[i] = backlerp * move[i] + frontlerp * frame.translate[i];
        frontv[i] = frontlerp * frame.scale[i];
        backv[i] = backlerp * oldframe.scale[i];
    }

    // ab hier wird optimiert
    GL_LerpVerts(paliashdr.num_xyz, ov, verts1, move, frontv, backv);

    //GL11.glEnableClientState( GL11.GL_VERTEX_ARRAY );
    GL11.glVertexPointer(3, 0, vertexArrayBuf);

    // PMM - added double damage shell
    if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE
            | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) {
        GL11.glColor4f(shadelight[0], shadelight[1], shadelight[2], alpha);
    } else {
        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
        GL11.glColorPointer(4, 0, colorArrayBuf);

        //
        // pre light everything
        //
        FloatBuffer color = colorArrayBuf;
        float l;
        int size = paliashdr.num_xyz;
        int j = 0;
        for (int i = 0; i < size; i++) {
            l = shadedots[(verts1[i] >>> 24) & 0xFF];
            color.put(j, l * shadelight[0]);
            color.put(j + 1, l * shadelight[1]);
            color.put(j + 2, l * shadelight[2]);
            color.put(j + 3, alpha);
            j += 4;
        }
    }

    GL13.glClientActiveTexture(GL_TEXTURE0);
    GL11.glTexCoordPointer(2, 0, textureArrayBuf);
    //GL11.glEnableClientState( GL11.GL_TEXTURE_COORD_ARRAY);

    int pos = 0;
    int[] counts = paliashdr.counts;

    IntBuffer srcIndexBuf = null;

    FloatBuffer dstTextureCoords = textureArrayBuf;
    FloatBuffer srcTextureCoords = paliashdr.textureCoordBuf;

    int dstIndex = 0;
    int srcIndex = 0;
    int count;
    int mode;
    int size = counts.length;
    for (int j = 0; j < size; j++) {

        // get the vertex count and primitive type
        count = counts[j];
        if (count == 0) {
            break; // done
        }
        srcIndexBuf = paliashdr.indexElements[j];

        mode = GL11.GL_TRIANGLE_STRIP;
        if (count < 0) {
            mode = GL11.GL_TRIANGLE_FAN;
            count = -count;
        }
        srcIndex = pos << 1;
        srcIndex--;
        for (int k = 0; k < count; k++) {
            dstIndex = srcIndexBuf.get(k) << 1;
            dstTextureCoords.put(dstIndex, srcTextureCoords.get(++srcIndex));
            dstTextureCoords.put(++dstIndex, srcTextureCoords.get(++srcIndex));
        }

        GL11.glDrawElements(mode, srcIndexBuf);
        pos += count;
    }

    // PMM - added double damage shell
    if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE
            | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
}

From source file:org.free.jake2.render.lwjgl.Surf.java

License:Open Source License

/**
 * R_DrawBrushModel//from ww w  .  ja v  a 2s .  com
 */
void R_DrawBrushModel(entity_t e) {
    if (currentmodel.nummodelsurfaces == 0) {
        return;
    }

    currententity = e;
    gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1;

    boolean rotated;
    if (e.angles[0] != 0 || e.angles[1] != 0 || e.angles[2] != 0) {
        rotated = true;
        for (int i = 0; i < 3; i++) {
            mins[i] = e.origin[i] - currentmodel.radius;
            maxs[i] = e.origin[i] + currentmodel.radius;
        }
    } else {
        rotated = false;
        Math3D.VectorAdd(e.origin, currentmodel.mins, mins);
        Math3D.VectorAdd(e.origin, currentmodel.maxs, maxs);
    }

    if (R_CullBox(mins, maxs)) {
        return;
    }

    GL11.glColor3f(1, 1, 1);

    // memset (gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces));

    // TODO wird beim multitexturing nicht gebraucht
    //gl_lms.clearLightmapSurfaces();

    Math3D.VectorSubtract(r_newrefdef.vieworg, e.origin, modelorg);
    if (rotated) {
        Math3D.VectorCopy(modelorg, org);
        Math3D.AngleVectors(e.angles, forward, right, up);
        modelorg[0] = Math3D.DotProduct(org, forward);
        modelorg[1] = -Math3D.DotProduct(org, right);
        modelorg[2] = Math3D.DotProduct(org, up);
    }

    GL11.glPushMatrix();

    e.angles[0] = -e.angles[0]; // stupid quake bug
    e.angles[2] = -e.angles[2]; // stupid quake bug
    R_RotateForEntity(e);
    e.angles[0] = -e.angles[0]; // stupid quake bug
    e.angles[2] = -e.angles[2]; // stupid quake bug

    GL_EnableMultitexture(true);
    GL_SelectTexture(GL_TEXTURE0);
    GL_TexEnv(GL11.GL_REPLACE);
    GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf);
    GL_SelectTexture(GL_TEXTURE1);
    GL_TexEnv(GL11.GL_MODULATE);
    GL11.glTexCoordPointer(2, Polygon.BYTE_STRIDE, globalPolygonTexCoord1Buf);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    R_DrawInlineBModel();

    GL13.glClientActiveTexture(GL_TEXTURE1);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    GL_EnableMultitexture(false);

    GL11.glPopMatrix();
}

From source file:org.free.jake2.render.lwjgl.Surf.java

License:Open Source License

/**
 * R_DrawWorld//from w ww  .jav  a 2 s.c  om
 */
void R_DrawWorld() {
    if (r_drawworld.value == 0) {
        return;
    }

    if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) {
        return;
    }

    currentmodel = r_worldmodel;

    Math3D.VectorCopy(r_newrefdef.vieworg, modelorg);

    entity_t ent = worldEntity;
    // auto cycle the world frame for texture animation
    ent.clear();
    ent.frame = (int) (r_newrefdef.time * 2);
    currententity = ent;

    gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1;

    GL11.glColor3f(1, 1, 1);
    // memset (gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces));
    // TODO wird bei multitexture nicht gebraucht
    //gl_lms.clearLightmapSurfaces();

    R_ClearSkyBox();

    GL_EnableMultitexture(true);

    GL_SelectTexture(GL_TEXTURE0);
    GL_TexEnv(GL11.GL_REPLACE);
    GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf);
    GL_SelectTexture(GL_TEXTURE1);
    GL11.glTexCoordPointer(2, Polygon.BYTE_STRIDE, globalPolygonTexCoord1Buf);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    if (gl_lightmap.value != 0) {
        GL_TexEnv(GL11.GL_REPLACE);
    } else {
        GL_TexEnv(GL11.GL_MODULATE);
    }

    R_RecursiveWorldNode(r_worldmodel.nodes[0]); // root node

    GL13.glClientActiveTexture(GL_TEXTURE1);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    GL_EnableMultitexture(false);

    DrawTextureChains();
    R_DrawSkyBox();
    R_DrawTriangleOutlines();
}

From source file:org.jogamp.glg2d.VertexBuffer.java

License:Apache License

/**
 * Draws the vertices and rewinds the buffer to be ready to draw next time.
 * /*from  w w w. j a  va 2  s.c  om*/
 * @param gl
 *          The graphics context to use to draw
 * @param mode
 *          The mode, e.g. {@code GL#GL_LINE_STRIP}
 */
public void drawBuffer(int mode) {
    if (buffer.position() == 0) {
        return;
    }

    int count = buffer.position();
    buffer.rewind();

    GL11.glVertexPointer(2, 0, buffer);

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDrawArrays(mode, 0, count / 2);
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);

    buffer.position(count);
}

From source file:org.terasology.rendering.nui.internal.Line.java

License:Apache License

public void draw(float x1, float y1, float x2, float y2, float width, Color color, Color background,
        float alpha) {
    GL20.glUseProgram(0);/*from www.  ja va  2 s.co  m*/
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);

    float t = 0;
    float r = 0;
    float f = width - (int) width;
    float a;
    boolean alphaBlend = alpha > 0;
    float cRed = color.rf();
    float cGreen = color.gf();
    float cBlue = color.bf();
    float bRed = background.rf();
    float bGreen = background.gf();
    float bBlue = background.bf();

    if (alphaBlend) {
        a = alpha;
    } else {
        a = 1.f;
    }

    if (width >= 0.0 && width < 1.0) {
        t = 0.05f;
        r = 0.48f + 0.32f * f;
        if (!alphaBlend) {
            cRed += 0.88 * (1 - f);
            cGreen += 0.88 * (1 - f);
            cBlue += 0.88 * (1 - f);
            if (cRed > 1.0f) {
                cRed = 1.0f;
            }
            if (cGreen > 1.0f) {
                cGreen = 1.0f;
            }
            if (cBlue > 1.0f) {
                cBlue = 1.0f;
            }
        } else {
            a *= f;
        }
    } else if (width >= 1.0 && width < 2.0) {
        t = 0.05f + f * 0.33f;
        r = 0.768f + 0.312f * f;
    } else if (width >= 2.0 && width < 3.0) {
        t = 0.38f + f * 0.58f;
        r = 1.08f;
    } else if (width >= 3.0 && width < 4.0) {
        t = 0.96f + f * 0.48f;
        r = 1.08f;
    } else if (width >= 4.0 && width < 5.0) {
        t = 1.44f + f * 0.46f;
        r = 1.08f;
    } else if (width >= 5.0 && width < 6.0) {
        t = 1.9f + f * 0.6f;
        r = 1.08f;
    } else if (width >= 6.0) {
        float ff = width - 6.0f;
        t = 2.5f + ff * 0.50f;
        r = 1.08f;
    }

    //determine angle of the line to horizontal
    float tx = 0; //core thinkness of a line
    float ty = 0;
    float rx = 0; //fading edge of a line
    float ry = 0;
    float cx = 0; //cap of a line
    float cy = 0;
    float epsilon = 0.01f;
    float dx = x2 - x1;
    float dy = y2 - y1;
    if (Math.abs(dx) < epsilon) {
        //vertical
        tx = t;
        ty = 0;
        rx = r;
        ry = 0;
        if (width > 0.0 && width < 1.0) {
            tx *= 8;
        } else if (width == 1.0) {
            tx *= 10;
        }
    } else if (Math.abs(dy) < epsilon) {
        //horizontal
        tx = 0;
        ty = t;
        rx = 0;
        ry = r;
        if (width > 0.0 && width < 1.0) {
            ty *= 8;
        } else if (width == 1.0) {
            ty *= 10;
        }
    } else {
        if (width < 3) { //approximate to make things even faster
            float m = dy / dx;
            //and calculate tx,ty,rx,ry
            if (m > -0.4142 && m <= 0.4142) {
                // -22.5< angle <= 22.5, approximate to 0 (degree)
                tx = t * 0.1f;
                ty = t;
                rx = r * 0.6f;
                ry = r;
            } else if (m > 0.4142 && m <= 2.4142) {
                // 22.5< angle <= 67.5, approximate to 45 (degree)
                tx = t * -0.7071f;
                ty = t * 0.7071f;
                rx = r * -0.7071f;
                ry = r * 0.7071f;
            } else if (m > 2.4142 || m <= -2.4142) {
                // 67.5 < angle <=112.5, approximate to 90 (degree)
                tx = t;
                ty = t * 0.1f;
                rx = r;
                ry = r * 0.6f;
            } else if (m > -2.4142 && m < -0.4142) {
                // 112.5 < angle < 157.5, approximate to 135 (degree)
                tx = t * 0.7071f;
                ty = t * 0.7071f;
                rx = r * 0.7071f;
                ry = r * 0.7071f;
            }
        } else { //calculate to exact
            dx = y1 - y2;
            dy = x2 - x1;
            float len = (float) Math.sqrt(dx * dx + dy * dy);
            dx /= len;
            dy /= len;
            cx = -0.6f * dy;
            cy = 0.6f * dx;
            tx = t * dx;
            ty = t * dy;
            rx = r * dx;
            ry = r * dy;
        }
    }

    //draw the line by triangle strip
    float[] lineVertex = { x1 - tx - rx, y1 - ty - ry, //fading edge1
            x2 - tx - rx, y2 - ty - ry, x1 - tx, y1 - ty, //core
            x2 - tx, y2 - ty, x1 + tx, y1 + ty, x2 + tx, y2 + ty, x1 + tx + rx, y1 + ty + ry, //fading edge2
            x2 + tx + rx, y2 + ty + ry };
    GL11.glVertexPointer(2, 0, wrap(lineVertex));

    if (!alphaBlend) {
        float[] lineColor = { bRed, bGreen, bBlue, bRed, bGreen, bBlue, cRed, cGreen, cBlue, cRed, cGreen,
                cBlue, cRed, cGreen, cBlue, cRed, cGreen, cBlue, bRed, bGreen, bBlue, bRed, bGreen, bBlue };
        GL11.glColorPointer(3, 0, wrap(lineColor));
    } else {
        float[] lineColor = { cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, a, cRed,
                cGreen, cBlue, a, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, 0, cRed,
                cGreen, cBlue, 0 };
        GL11.glColorPointer(4, 0, wrap(lineColor));
    }

    if ((Math.abs(dx) < epsilon || Math.abs(dy) < epsilon) && width <= 1.0) {
        GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 6);
    } else {
        GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 8);
    }

    //cap (do not draw if too thin)
    if (width >= 3) {
        //draw cap
        lineVertex = new float[] { x1 - rx + cx, y1 - ry + cy, //cap1
                x1 + rx + cx, y1 + ry + cy, x1 - tx - rx, y1 - ty - ry, x1 + tx + rx, y1 + ty + ry,
                x2 - rx - cx, y2 - ry - cy, //cap2
                x2 + rx - cx, y2 + ry - cy, x2 - tx - rx, y2 - ty - ry, x2 + tx + rx, y2 + ty + ry };
        GL11.glVertexPointer(2, 0, wrap(lineVertex));

        if (!alphaBlend) {
            float[] lineColor = { bRed, bGreen, bBlue, //cap1
                    bRed, bGreen, bBlue, cRed, cGreen, cBlue, cRed, cGreen, cBlue, bRed, bGreen, bBlue, //cap2
                    bRed, bGreen, bBlue, cRed, cGreen, cBlue, cRed, cGreen, cBlue };
            GL11.glColorPointer(3, 0, wrap(lineColor));
        } else {
            float[] lineColor = { cRed, cGreen, cBlue, 0, //cap1
                    cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue,
                    0, //cap2
                    cRed, cGreen, cBlue, 0, cRed, cGreen, cBlue, a, cRed, cGreen, cBlue, a };
            GL11.glColorPointer(4, 0, wrap(lineColor));
        }

        GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4);
        GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 4, 4);
    }

    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glEnable(GL11.GL_CULL_FACE);

}

From source file:org.voxels.platform.LWJGLOpenGLAdapter.java

License:Open Source License

@Override
public void glDisableClientState(final int cap) {
    GL11.glDisableClientState(cap);
}

From source file:org.xmlvm.iphone.gl.GL.java

License:Open Source License

public static void glDisableClientState(int param) {
    GL11.glDisableClientState(param);
}

From source file:RediscoveredMod.MD3Renderer.java

License:Open Source License

public final void render(int var1, int var2, float var3) {
    if ((this.displayList == 0) || (this.useAnimation)) {
        if (!this.useAnimation) {
            this.displayList = GL11.glGenLists(1);
        }//from  ww  w .  java  2 s.  co m

        GL11.glEnableClientState(32884);
        GL11.glEnableClientState(32888);
        GL11.glEnableClientState(32885);
        if (!this.useAnimation) {
            GL11.glNewList(this.displayList, 4864);
        }

        for (int i = 0; i < this.model.surfaces.length; i++) {
            MD3Surface surface = this.model.surfaces[i];
            if (this.useAnimation)
                surface.setFrame(var1, var2, var3);
            else {
                surface.setFrame(0, 0, 0.0F);
            }

            surface.triangles.position(0);

            surface.d.position(0);
            GL11.glVertexPointer(3, 0, surface.vertices);
            GL11.glNormalPointer(0, surface.normals);
            GL11.glTexCoordPointer(2, 0, surface.d);
            GL11.glDrawElements(4, surface.triangles);
        }

        if (!this.useAnimation) {
            GL11.glEndList();
        }
        GL11.glDisableClientState(32884);
        GL11.glDisableClientState(32888);
        GL11.glDisableClientState(32885);
    }

    if (!this.useAnimation)
        GL11.glCallList(this.displayList);
}