Example usage for org.lwjgl.opengl GL11 GL_TEXTURE_GEN_MODE

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

Introduction

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

Prototype

int GL_TEXTURE_GEN_MODE

To view the source code for org.lwjgl.opengl GL11 GL_TEXTURE_GEN_MODE.

Click Source Link

Document

TextureGenParameter

Usage

From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java

License:Open Source License

public static void applyTexCoordGeneration(final Texture texture, final TextureUnitRecord unitRecord,
        final int unit, final TextureStateRecord record, final ContextCapabilities caps) {
    switch (texture.getEnvironmentalMapMode()) {
    case None://from   ww w .j a  v  a 2s . c o  m
        // No coordinate generation
        setTextureGen(unitRecord, unit, record, caps, false, false, false, false);
        break;
    case SphereMap:
        // generate spherical texture coordinates
        if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL11.GL_SPHERE_MAP) {
            checkAndSetUnit(unit, record, caps);

            GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_SPHERE_MAP);
            unitRecord.textureGenSMode = GL11.GL_SPHERE_MAP;

            GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_SPHERE_MAP);
            unitRecord.textureGenTMode = GL11.GL_SPHERE_MAP;
        }

        setTextureGen(unitRecord, unit, record, caps, true, true, false, false);
        break;
    case NormalMap:
        // generate normals based texture coordinates
        if (!unitRecord.isValid() || unitRecord.textureGenSMode != ARBTextureCubeMap.GL_NORMAL_MAP_ARB) {
            checkAndSetUnit(unit, record, caps);
            GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, ARBTextureCubeMap.GL_NORMAL_MAP_ARB);
            unitRecord.textureGenSMode = ARBTextureCubeMap.GL_NORMAL_MAP_ARB;

            GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, ARBTextureCubeMap.GL_NORMAL_MAP_ARB);
            unitRecord.textureGenTMode = ARBTextureCubeMap.GL_NORMAL_MAP_ARB;

            GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, ARBTextureCubeMap.GL_NORMAL_MAP_ARB);
            unitRecord.textureGenRMode = ARBTextureCubeMap.GL_NORMAL_MAP_ARB;
        }

        setTextureGen(unitRecord, unit, record, caps, true, true, true, false);
        break;
    case ReflectionMap:
        // generate reflection texture coordinates
        if (!unitRecord.isValid() || unitRecord.textureGenSMode != ARBTextureCubeMap.GL_REFLECTION_MAP_ARB) {
            checkAndSetUnit(unit, record, caps);

            GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, ARBTextureCubeMap.GL_REFLECTION_MAP_ARB);
            unitRecord.textureGenSMode = ARBTextureCubeMap.GL_REFLECTION_MAP_ARB;

            GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, ARBTextureCubeMap.GL_REFLECTION_MAP_ARB);
            unitRecord.textureGenTMode = ARBTextureCubeMap.GL_REFLECTION_MAP_ARB;

            GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, ARBTextureCubeMap.GL_REFLECTION_MAP_ARB);
            unitRecord.textureGenRMode = ARBTextureCubeMap.GL_REFLECTION_MAP_ARB;
        }

        setTextureGen(unitRecord, unit, record, caps, true, true, true, false);
        break;
    case EyeLinear:
        // do here because we don't check planes
        checkAndSetUnit(unit, record, caps);

        // generate eye linear texture coordinates
        if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL11.GL_EYE_LINEAR) {
            GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
            unitRecord.textureGenSMode = GL11.GL_EYE_LINEAR;

            GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
            unitRecord.textureGenTMode = GL11.GL_EYE_LINEAR;

            GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
            unitRecord.textureGenRMode = GL11.GL_EYE_LINEAR;

            GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
            unitRecord.textureGenQMode = GL11.GL_EYE_LINEAR;
        }

        record.prepPlane(texture.getEnvPlaneS(), TextureStateRecord.DEFAULT_S_PLANE);
        GL11.glTexGen(GL11.GL_S, GL11.GL_EYE_PLANE, record.plane);
        record.prepPlane(texture.getEnvPlaneT(), TextureStateRecord.DEFAULT_T_PLANE);
        GL11.glTexGen(GL11.GL_T, GL11.GL_EYE_PLANE, record.plane);
        record.prepPlane(texture.getEnvPlaneR(), TextureStateRecord.DEFAULT_R_PLANE);
        GL11.glTexGen(GL11.GL_R, GL11.GL_EYE_PLANE, record.plane);
        record.prepPlane(texture.getEnvPlaneQ(), TextureStateRecord.DEFAULT_Q_PLANE);
        GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, record.plane);

        setTextureGen(unitRecord, unit, record, caps, true, true, true, true);
        break;
    case ObjectLinear:
        // do here because we don't check planes
        checkAndSetUnit(unit, record, caps);

        // generate object linear texture coordinates
        if (!unitRecord.isValid() || unitRecord.textureGenSMode != GL11.GL_OBJECT_LINEAR) {
            GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
            unitRecord.textureGenSMode = GL11.GL_OBJECT_LINEAR;

            GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
            unitRecord.textureGenTMode = GL11.GL_OBJECT_LINEAR;

            GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
            unitRecord.textureGenRMode = GL11.GL_OBJECT_LINEAR;

            GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
            unitRecord.textureGenQMode = GL11.GL_OBJECT_LINEAR;
        }

        record.prepPlane(texture.getEnvPlaneS(), TextureStateRecord.DEFAULT_S_PLANE);
        GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, record.plane);
        record.prepPlane(texture.getEnvPlaneT(), TextureStateRecord.DEFAULT_T_PLANE);
        GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, record.plane);
        record.prepPlane(texture.getEnvPlaneR(), TextureStateRecord.DEFAULT_R_PLANE);
        GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, record.plane);
        record.prepPlane(texture.getEnvPlaneQ(), TextureStateRecord.DEFAULT_Q_PLANE);
        GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, record.plane);

        setTextureGen(unitRecord, unit, record, caps, true, true, true, true);
        break;
    }
}

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

License:Open Source License

@Override
public void setTextureEnvironmentMapping(int u, int v) {
    GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_SPHERE_MAP);
    GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_SPHERE_MAP);
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

private void setupDrawingMode() {
    GL11.glEnable(GL11.GL_LIGHTING);//  www  .j av a  2  s .  com
    if (tnum != DS_TEXTURE_NUMBER.DS_NONE) {
        if (use_textures) {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            texture[tnum.ordinal()].bind(true);
            GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
            GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
            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);
            //            static GLfloat s_params[4] = {1.0f,1.0f,0.0f,1};
            //            static GLfloat t_params[4] = {0.817f,-0.817f,0.817f,1};
            GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, s_params_SDM);
            GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, t_params_SDM);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
    } else {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
    }
    setColor(color[0], color[1], color[2], color[3]);

    if (color[3] < 1) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    } else {
        GL11.glDisable(GL11.GL_BLEND);
    }
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

private void setShadowDrawingMode() {
    GL11.glDisable(GL11.GL_LIGHTING);// ww  w . j ava  2s.c o  m
    if (use_textures) {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        ground_texture.bind(true);
        GL11.glColor3f(SHADOW_INTENSITY, SHADOW_INTENSITY, SHADOW_INTENSITY);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
        GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
        GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
        //         static GLfloat s_params[4] = {ground_scale,0,0,ground_ofsx};
        //         static GLfloat t_params[4] = {0,ground_scale,0,ground_ofsy};
        GL11.glTexGen(GL11.GL_S, GL11.GL_EYE_PLANE, s_params_SSDM);
        GL11.glTexGen(GL11.GL_T, GL11.GL_EYE_PLANE, t_params_SSDM);
    } else {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glColor3f(GROUND_R * SHADOW_INTENSITY, GROUND_G * SHADOW_INTENSITY, GROUND_B * SHADOW_INTENSITY);
    }
    GL11.glDepthRange(0, 0.9999);
}

From source file:vazkii.botania.client.render.tile.RenderTileStarfield.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_,
        double p_147500_6_, float p_147500_8_) {
    float f1 = (float) field_147501_a.field_147560_j;
    float f2 = (float) field_147501_a.field_147561_k;
    float f3 = (float) field_147501_a.field_147558_l;
    GL11.glDisable(GL11.GL_LIGHTING);//from  ww w. j av a2s .c  o  m
    field_147527_e.setSeed(31100L);
    float f4 = 0.24F;

    for (int i = 0; i < 16; ++i) {
        GL11.glPushMatrix();
        float f5 = 16 - i;
        float f6 = 0.0625F;
        float f7 = 1.0F / (f5 + 1.0F);

        if (i == 0) {
            bindTexture(field_147529_c);
            f7 = 0.1F;
            f5 = 65.0F;
            f6 = 0.125F;
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        }

        if (i == 1) {
            bindTexture(field_147526_d);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
            f6 = 0.5F;
        }

        float f8 = (float) -(p_147500_4_ + f4);
        float f9 = f8 + ActiveRenderInfo.objectY;
        float f10 = f8 + f5 + ActiveRenderInfo.objectY;
        float f11 = f9 / f10;
        f11 += (float) (p_147500_4_ + f4);
        GL11.glTranslatef(f1, f11, f3);
        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.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
        GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR);
        GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, func_147525_a(1.0F, 0.0F, 0.0F, 0.0F));
        GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 1.0F, 0.0F));
        GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, func_147525_a(0.0F, 0.0F, 0.0F, 1.0F));
        GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, func_147525_a(0.0F, 1.0F, 0.0F, 0.0F));
        GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_R);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_Q);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glTranslatef(0.0F, Minecraft.getSystemTime() % 20000L / 20000.0F, 0.0F);
        GL11.glScalef(f6, f6, f6);
        GL11.glTranslatef(0.5F, 0.5F, 0.0F);
        GL11.glRotatef((i * i * 4321 + i * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
        GL11.glTranslatef(-0.5F, -0.5F, 0.0F);
        GL11.glTranslatef(-f1, -f3, -f2);
        f9 = f8 + ActiveRenderInfo.objectY;
        GL11.glTranslatef(ActiveRenderInfo.objectX * f5 / f9, ActiveRenderInfo.objectZ * f5 / f9, -f2);
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();

        Color color = Color.getHSBColor(Minecraft.getSystemTime() / 20F % 360 / 360F, 1F, 1F);
        f11 = color.getRed() / 255F;
        float f12 = color.getGreen() / 255F;
        float f13 = color.getBlue() / 255F;

        tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F);
        tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_);
        tessellator.addVertex(p_147500_2_, p_147500_4_ + f4, p_147500_6_ + 1.0D);
        tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_ + 1.0D);
        tessellator.addVertex(p_147500_2_ + 1.0D, p_147500_4_ + f4, p_147500_6_);
        tessellator.draw();
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
    }

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_R);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_Q);
    GL11.glEnable(GL11.GL_LIGHTING);
}