Java Code Examples for net.minecraft.client.renderer.OpenGlHelper#setClientActiveTexture()

The following examples show how to use net.minecraft.client.renderer.OpenGlHelper#setClientActiveTexture() . 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: VboRenderListSchematic.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void setupArrayPointersBlocks()
{
    GlStateManager.glVertexPointer(3, GL11.GL_FLOAT, 28, 0);
    GlStateManager.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 28, 12);
    GlStateManager.glTexCoordPointer(2, GL11.GL_FLOAT, 28, 16);
    OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
    GlStateManager.glTexCoordPointer(2, GL11.GL_SHORT, 28, 24);
    OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
}
 
Example 2
Source File: RenderGlobalSchematic.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void renderBlockOverlayBuffers(OverlayRenderType type)
{
    this.mc.entityRenderer.enableLightmap();

    if (OpenGlHelper.useVbo())
    {
        GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GlStateManager.glEnableClientState(GL11.GL_COLOR_ARRAY);
    }

    this.renderContainer.renderBlockOverlays(type);

    if (OpenGlHelper.useVbo())
    {
        for (VertexFormatElement element : DefaultVertexFormats.POSITION_COLOR.getElements())
        {
            VertexFormatElement.EnumUsage usage = element.getUsage();

            switch (usage)
            {
                case POSITION:
                    GlStateManager.glDisableClientState(GL11.GL_VERTEX_ARRAY);
                    break;
                case UV:
                    OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + element.getIndex());
                    GlStateManager.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
                    OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
                    break;
                case COLOR:
                    GlStateManager.glDisableClientState(GL11.GL_COLOR_ARRAY);
                    GlStateManager.resetColor();
                default:
            }
        }
    }

    this.mc.entityRenderer.disableLightmap();
}
 
Example 3
Source File: RenderGlobalSchematic.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderBlockLayer(BlockRenderLayer layer)
{
    this.mc.entityRenderer.enableLightmap();

    if (OpenGlHelper.useVbo())
    {
        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);
    }

    this.renderContainer.renderChunkLayer(layer);

    if (OpenGlHelper.useVbo())
    {
        for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements())
        {
            VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage();
            int index = vertexformatelement.getIndex();

            switch (vertexformatelement$enumusage)
            {
                case POSITION:
                    GlStateManager.glDisableClientState(GL11.GL_VERTEX_ARRAY);
                    break;
                case UV:
                    OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + index);
                    GlStateManager.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
                    OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
                    break;
                case COLOR:
                    GlStateManager.glDisableClientState(GL11.GL_COLOR_ARRAY);
                    GlStateManager.resetColor();
                default:
            }
        }
    }

    this.mc.entityRenderer.disableLightmap();
}
 
Example 4
Source File: FastBlockModelRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
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();
}