Example usage for org.lwjgl.opengl GL11 glNormalPointer

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

Introduction

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

Prototype

public static void glNormalPointer(@NativeType("GLenum") int type, @NativeType("GLsizei") int stride,
        @NativeType("void const *") FloatBuffer pointer) 

Source Link

Document

Specifies the location and organization of a normal array.

Usage

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

public void setupNormalDataVBO(final FloatBufferData data) {
    final RenderContext context = ContextManager.getCurrentContext();
    final RendererRecord rendRecord = context.getRendererRecord();

    final int vboID = setupVBO(data, context);

    if (vboID != 0) {
        GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
        LwjglRendererUtil.setBoundVBO(rendRecord, vboID);
        GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0);
    } else {/*from w  ww.  j  av a  2 s  .co m*/
        GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
    }
}

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

public void setupInterleavedDataVBO(final FloatBufferData interleaved, final FloatBufferData vertexCoords,
        final FloatBufferData normalCoords, final FloatBufferData colorCoords,
        final List<FloatBufferData> textureCoords) {
    final RenderContext context = ContextManager.getCurrentContext();
    final RendererRecord rendRecord = context.getRendererRecord();
    final ContextCapabilities caps = context.getCapabilities();

    final int lengthBytes = getTotalInterleavedSize(context, vertexCoords, normalCoords, colorCoords,
            textureCoords);//from   w  ww .j  a  v  a 2  s.  c om
    int currLengthBytes = 0;
    if (interleaved.getBufferLimit() > 0) {
        interleaved.getBuffer().rewind();
        currLengthBytes = Math.round(interleaved.getBuffer().get());
    }

    if (lengthBytes != currLengthBytes || interleaved.getVBOID(context.getGlContextRep()) == 0
            || interleaved.isNeedsRefresh()) {
        initializeInterleavedVBO(context, interleaved, vertexCoords, normalCoords, colorCoords, textureCoords,
                lengthBytes);
    }

    final int vboID = interleaved.getVBOID(context.getGlContextRep());
    LwjglRendererUtil.setBoundVBO(rendRecord, vboID);

    int offsetBytes = 0;

    if (normalCoords != null) {
        updateVBO(normalCoords, rendRecord, vboID, offsetBytes);
        GL11.glNormalPointer(GL11.GL_FLOAT, 0, offsetBytes);
        GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
        offsetBytes += normalCoords.getBufferLimit() * 4;
    } else {
        GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
    }

    if (colorCoords != null) {
        updateVBO(colorCoords, rendRecord, vboID, offsetBytes);
        GL11.glColorPointer(colorCoords.getValuesPerTuple(), GL11.GL_FLOAT, 0, offsetBytes);
        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
        offsetBytes += colorCoords.getBufferLimit() * 4;
    } else {
        GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
    }

    if (textureCoords != null) {
        final TextureState ts = (TextureState) context.getCurrentState(RenderState.StateType.Texture);
        int enabledTextures = rendRecord.getEnabledTextures();
        final boolean valid = rendRecord.isTexturesValid();
        boolean exists, wasOn;
        if (ts != null) {
            final int max = caps.isMultitextureSupported()
                    ? Math.min(caps.getNumberOfFragmentTexCoordUnits(), TextureState.MAX_TEXTURES)
                    : 1;
            for (int i = 0; i < max; i++) {
                wasOn = (enabledTextures & (2 << i)) != 0;
                exists = textureCoords != null && i < textureCoords.size() && textureCoords.get(i) != null
                        && i <= ts.getMaxTextureIndexUsed();

                if (!exists) {
                    if (valid && !wasOn) {
                        continue;
                    } else {
                        checkAndSetTextureArrayUnit(i, rendRecord, caps);

                        // disable bit in tracking int
                        enabledTextures &= ~(2 << i);

                        // disable state
                        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

                        continue;
                    }

                } else {
                    checkAndSetTextureArrayUnit(i, rendRecord, caps);

                    // grab a vboID and make sure it exists and is up to date.
                    final FloatBufferData textureBufferData = textureCoords.get(i);
                    updateVBO(textureBufferData, rendRecord, vboID, offsetBytes);

                    if (!valid || !wasOn) {
                        // enable bit in tracking int
                        enabledTextures |= (2 << i);

                        // enable state
                        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
                    }

                    // send data
                    GL11.glTexCoordPointer(textureBufferData.getValuesPerTuple(), GL11.GL_FLOAT, 0,
                            offsetBytes);
                    offsetBytes += textureBufferData.getBufferLimit() * 4;
                }
            }
        }

        rendRecord.setEnabledTextures(enabledTextures);
        rendRecord.setTexturesValid(true);
    }

    if (vertexCoords != null) {
        updateVBO(vertexCoords, rendRecord, vboID, offsetBytes);
        GL11.glVertexPointer(vertexCoords.getValuesPerTuple(), GL11.GL_FLOAT, 0, offsetBytes);
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    } else {
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    }
}

From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL11.java

License:Apache License

public void glNormalPointer(int type, int stride, int pointer) {
    GL11.glNormalPointer(type, stride, pointer);
}

From source file:com.owens.oobjloader.lwjgl.VBO.java

License:BSD License

public void render() {

    GL11.glEnable(GL11.GL_TEXTURE_2D);/*from w  w  w  .j ava  2 s  .  com*/
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textId); // Bind The Texture

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, verticeAttributesID);

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, ATTR_V_STRIDE2_BYTES, ATTR_V_OFFSET_BYTES);

    GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
    GL11.glNormalPointer(GL11.GL_FLOAT, ATTR_N_STRIDE2_BYTES, ATTR_N_OFFSET_BYTES);

    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    GL11.glTexCoordPointer(2, GL11.GL_FLOAT, ATTR_T_STRIDE2_BYTES, ATTR_T_OFFSET_BYTES);

    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesID);
    GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_INT, 0);

    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
}

From source file:com.timvisee.voxeltex.module.mesh.Mesh.java

License:Open Source License

/**
 * Render or draw the mesh using OpenGL.
 *//*from   w  ww  .  j a va2s .  c  o m*/
public void draw(Material material) {
    // Bind the vertex buffer
    glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
    GL11.glVertexPointer(this.raw.getVertexAxisCount(), GL11.GL_FLOAT, 0, 0L);

    // Bind the normal coordinate buffer if available
    if (hasNormalData()) {
        glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle);
        GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0L);
    }

    // Bind the texture coordinate buffer if available
    if (hasTextureData()) {
        glBindBuffer(GL_ARRAY_BUFFER, vboTextureHandle);
        GL11.glTexCoordPointer(this.raw.getTextureAxisCount(), GL11.GL_FLOAT, 0, 0L);
    }

    // Enable the client states for the buffers that were bound
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    if (hasNormalData())
        GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
    if (hasTextureData())
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    // Draw the mesh
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.vertexCount);

    // Disable the client used states
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    if (hasNormalData())
        GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
    if (hasTextureData())
        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    // Unbind all buffers
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}

From source file:game.level.map.TileMap.java

License:Open Source License

public void Render() {
    GL11.glPushMatrix();/*from   w  w  w.j  a  va2  s .c om*/
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOVertexHandle);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0L);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOColorHandle);
    GL11.glColorPointer(3, GL11.GL_FLOAT, 0, 0L);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBONormalHandle);
    GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0L);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    if (DebugMode) {
        GL11.glDrawArrays(GL11.GL_LINE_LOOP, 0, Quads * 16);
    } else {
        GL11.glDrawArrays(GL11.GL_QUADS, 0, Quads * 16);
    }

    for (int y = 0; y < tiles.length; y++) {
        for (int x = 0; x < tiles[0].length; x++) {
            if (tiles[y][x].IsFloor) {
                try {
                    tiles[y][x].Render(x, y);
                } catch (Exception e) {

                }

            }
        }
    }
    GL11.glPopMatrix();
    // }
}

From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java

License:Open Source License

@Override
public void setNormalPointer(int type, int stride, long offset) {
    GL11.glNormalPointer(pointerTypeToGL[type], stride, offset);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexArrayHelper.java

License:Apache License

public void bindNormals(int type, ByteBuffer byteBuffer) {
    GL11.glNormalPointer(type, 0, byteBuffer);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

public void bindNormals(int vboID, int type, int strideBytes, int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL11.glNormalPointer(type, strideBytes, offsetBytes);
}

From source file:org.jtrfp.mtmx.draw.TerrainDrawer.java

License:Open Source License

private void bindBuffers() {
    // normals/*from   w  w w .  j a va2s .  c o m*/
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, normalBufferId);
    GL11.glNormalPointer(GL_FLOAT, 0, 0);

    // vertexes
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBufferId);
    glVertexPointer(3, GL_FLOAT, 0, 0);

    // textures
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, texCoordBufferId);
    GL11.glTexCoordPointer(2, GL_FLOAT, 0, 0);

    // indexes
    glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexBufferId);
}