Example usage for org.lwjgl.opengl GL11 GL_MODULATE

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

Introduction

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

Prototype

int GL_MODULATE

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

Click Source Link

Document

TextureEnvMode

Usage

From source file:im.bci.jnuit.lwjgl.LwjglNuitFont.java

License:Open Source License

public static int loadImage(BufferedImage bufferedImage) {
    short width = (short) bufferedImage.getWidth();
    short height = (short) bufferedImage.getHeight();
    // textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ?
    // (byte)32 : (byte)24;
    int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
    ByteBuffer byteBuffer;/*  w w  w.  j a v a2  s.co m*/
    DataBuffer db = bufferedImage.getData().getDataBuffer();
    if (db instanceof DataBufferInt) {
        int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
        byte newI[] = new byte[intI.length * 4];
        for (int i = 0; i < intI.length; i++) {
            byte b[] = intToByteArray(intI[i]);
            int newIndex = i * 4;

            newI[newIndex] = b[1];
            newI[newIndex + 1] = b[2];
            newI[newIndex + 2] = b[3];
            newI[newIndex + 3] = b[0];
        }

        byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                .put(newI);
    } else {
        byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
    }
    byteBuffer.flip();

    int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA;
    IntBuffer textureId = BufferUtils.createIntBuffer(1);
    GL11.glGenTextures(textureId);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);

    GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

    GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE,
            byteBuffer);
    return textureId.get(0);
}

From source file:ion2d.INTexture2D.java

License:Open Source License

/**
 * Creates the actual OpenGL texture to memory
 *///from   w  ww.j  av  a  2 s. co m
protected void createTexture() {
    this.convertToPowerOfTwo();

    if (this.texture != null) {
        IntBuffer tmp = BufferUtils.createIntBuffer(1);
        GL11.glGenTextures(tmp);
        this.id = tmp.get(0);
        this.bind();

        int src = GL11.GL_RGBA;

        if (!this.image.getBufferedImage().getColorModel().hasAlpha()) {
            src = GL11.GL_RGB;
        }

        GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

        this.setAntiAlias();
        GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, src, this.width, this.height, 0, src, GL11.GL_UNSIGNED_BYTE,
                this.texture);
    }
}

From source file:kuake2.render.lwjgl.Main.java

License:Open Source License

/**
 * R_DrawSpriteModel/*ww  w . j a  va2 s. c o m*/
 */
void R_DrawSpriteModel(entity_t e) {
    float alpha = 1.0F;

    qfiles.dsprframe_t frame;
    qfiles.dsprite_t psprite;

    // don't even bother culling, because it's just a single
    // polygon without a surface cache

    psprite = (qfiles.dsprite_t) currentmodel.extradata;

    e.frame %= psprite.numframes;

    frame = psprite.frames[e.frame];

    if ((e.flags & Defines.RF_TRANSLUCENT) != 0)
        alpha = e.alpha;

    if (alpha != 1.0F)
        GL11.glEnable(GL11.GL_BLEND);

    GL11.glColor4f(1, 1, 1, alpha);

    GL_Bind(currentmodel.skins[e.frame].texnum);

    GL_TexEnv(GL11.GL_MODULATE);

    if (alpha == 1.0)
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    else
        GL11.glDisable(GL11.GL_ALPHA_TEST);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(0, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glEnd();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL_TexEnv(GL11.GL_REPLACE);

    if (alpha != 1.0F)
        GL11.glDisable(GL11.GL_BLEND);

    GL11.glColor4f(1, 1, 1, 1);
}

From source file:kuake2.render.lwjgl.Main.java

License:Open Source License

/**
 * GL_DrawParticles/*from   w  w  w.j a v  a2  s. co m*/
 */
void GL_DrawParticles(int num_particles) {
    float origin_x, origin_y, origin_z;

    Math3D.VectorScale(vup, 1.5f, up);
    Math3D.VectorScale(vright, 1.5f, right);

    GL_Bind(r_particletexture.texnum);
    GL11.glDepthMask(false); // no z buffering
    GL11.glEnable(GL11.GL_BLEND);
    GL_TexEnv(GL11.GL_MODULATE);

    GL11.glBegin(GL11.GL_TRIANGLES);

    FloatBuffer sourceVertices = particle_t.vertexArray;
    IntBuffer sourceColors = particle_t.colorArray;
    float scale;
    int color;
    for (int j = 0, i = 0; i < num_particles; i++) {
        origin_x = sourceVertices.get(j++);
        origin_y = sourceVertices.get(j++);
        origin_z = sourceVertices.get(j++);

        // hack a scale up to keep particles from disapearing
        scale = (origin_x - r_origin[0]) * vpn[0] + (origin_y - r_origin[1]) * vpn[1]
                + (origin_z - r_origin[2]) * vpn[2];

        scale = (scale < 20) ? 1 : 1 + scale * 0.004f;

        color = sourceColors.get(i);

        GL11.glColor4ub((byte) ((color) & 0xFF), (byte) ((color >> 8) & 0xFF), (byte) ((color >> 16) & 0xFF),
                (byte) ((color >>> 24)));
        // first vertex
        GL11.glTexCoord2f(0.0625f, 0.0625f);
        GL11.glVertex3f(origin_x, origin_y, origin_z);
        // second vertex
        GL11.glTexCoord2f(1.0625f, 0.0625f);
        GL11.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale);
        // third vertex
        GL11.glTexCoord2f(0.0625f, 1.0625f);
        GL11.glVertex3f(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale);
    }
    GL11.glEnd();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1, 1, 1, 1);
    GL11.glDepthMask(true); // back to normal Z buffering
    GL_TexEnv(GL11.GL_REPLACE);
}

From source file:kuake2.render.lwjgl.Mesh.java

License:Open Source License

/**
 * R_DrawAliasModel/* ww  w  . ja  v  a 2 s  .co  m*/
 */
void R_DrawAliasModel(entity_t e) {
    if ((e.flags & Defines.RF_WEAPONMODEL) == 0) {
        if (R_CullAliasModel(e))
            return;
    }

    if ((e.flags & Defines.RF_WEAPONMODEL) != 0) {
        if (r_lefthand.value == 2.0f)
            return;
    }

    qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata;

    //
    // get lighting information
    //
    // PMM - rewrote, reordered to handle new shells & mixing
    // PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy
    //
    int i;
    if ((currententity.flags & (Defines.RF_SHELL_HALF_DAM | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_RED
            | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0) {
        Math3D.VectorClear(shadelight);
        if ((currententity.flags & Defines.RF_SHELL_HALF_DAM) != 0) {
            shadelight[0] = 0.56f;
            shadelight[1] = 0.59f;
            shadelight[2] = 0.45f;
        }
        if ((currententity.flags & Defines.RF_SHELL_DOUBLE) != 0) {
            shadelight[0] = 0.9f;
            shadelight[1] = 0.7f;
        }
        if ((currententity.flags & Defines.RF_SHELL_RED) != 0)
            shadelight[0] = 1.0f;
        if ((currententity.flags & Defines.RF_SHELL_GREEN) != 0)
            shadelight[1] = 1.0f;
        if ((currententity.flags & Defines.RF_SHELL_BLUE) != 0)
            shadelight[2] = 1.0f;
    } else if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) {
        for (i = 0; i < 3; i++)
            shadelight[i] = 1.0f;
    } else {
        R_LightPoint(currententity.origin, shadelight);

        // player lighting hack for communication back to server
        // big hack!
        if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0) {
            // pick the greatest component, which should be the same
            // as the mono value returned by software
            if (shadelight[0] > shadelight[1]) {
                if (shadelight[0] > shadelight[2])
                    r_lightlevel.value = 150 * shadelight[0];
                else
                    r_lightlevel.value = 150 * shadelight[2];
            } else {
                if (shadelight[1] > shadelight[2])
                    r_lightlevel.value = 150 * shadelight[1];
                else
                    r_lightlevel.value = 150 * shadelight[2];
            }
        }

        if (gl_monolightmap.string.charAt(0) != '0') {
            float s = shadelight[0];

            if (s < shadelight[1])
                s = shadelight[1];
            if (s < shadelight[2])
                s = shadelight[2];

            shadelight[0] = s;
            shadelight[1] = s;
            shadelight[2] = s;
        }
    }

    if ((currententity.flags & Defines.RF_MINLIGHT) != 0) {
        for (i = 0; i < 3; i++)
            if (shadelight[i] > 0.1f)
                break;
        if (i == 3) {
            shadelight[0] = 0.1f;
            shadelight[1] = 0.1f;
            shadelight[2] = 0.1f;
        }
    }

    if ((currententity.flags & Defines.RF_GLOW) != 0) { // bonus items will pulse with time
        float scale;
        float min;

        scale = (float) (0.1f * Math.sin(r_newrefdef.time * 7));
        for (i = 0; i < 3; i++) {
            min = shadelight[i] * 0.8f;
            shadelight[i] += scale;
            if (shadelight[i] < min)
                shadelight[i] = min;
        }
    }

    // =================
    // PGM   ir goggles color override
    if ((r_newrefdef.rdflags & Defines.RDF_IRGOGGLES) != 0
            && (currententity.flags & Defines.RF_IR_VISIBLE) != 0) {
        shadelight[0] = 1.0f;
        shadelight[1] = 0.0f;
        shadelight[2] = 0.0f;
    }
    // PGM
    // =================

    shadedots = r_avertexnormal_dots[((int) (currententity.angles[1] * (SHADEDOT_QUANT / 360.0)))
            & (SHADEDOT_QUANT - 1)];

    float an = (float) (currententity.angles[1] / 180 * Math.PI);
    shadevector[0] = (float) Math.cos(-an);
    shadevector[1] = (float) Math.sin(-an);
    shadevector[2] = 1;
    Math3D.VectorNormalize(shadevector);

    //
    // locate the proper data
    //

    c_alias_polys += paliashdr.num_tris;

    //
    // draw all the triangles
    //
    if ((currententity.flags & Defines.RF_DEPTHHACK) != 0) // hack the depth range to prevent view model from poking into walls
        GL11.glDepthRange(gldepthmin, gldepthmin + 0.3 * (gldepthmax - gldepthmin));

    if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0f)) {
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glScalef(-1, 1, 1);
        MYgluPerspective(r_newrefdef.fov_y, (float) r_newrefdef.width / r_newrefdef.height, 4, 4096);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);

        GL11.glCullFace(GL11.GL_BACK);
    }

    GL11.glPushMatrix();
    e.angles[PITCH] = -e.angles[PITCH]; // sigh.
    R_RotateForEntity(e);
    e.angles[PITCH] = -e.angles[PITCH]; // sigh.

    image_t skin;
    // select skin
    if (currententity.skin != null)
        skin = currententity.skin; // custom player skin
    else {
        if (currententity.skinnum >= qfiles.MAX_MD2SKINS)
            skin = currentmodel.skins[0];
        else {
            skin = currentmodel.skins[currententity.skinnum];
            if (skin == null)
                skin = currentmodel.skins[0];
        }
    }
    if (skin == null)
        skin = r_notexture; // fallback...
    GL_Bind(skin.texnum);

    // draw it

    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL_TexEnv(GL11.GL_MODULATE);
    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glEnable(GL11.GL_BLEND);
    }

    if ((currententity.frame >= paliashdr.num_frames) || (currententity.frame < 0)) {
        VID.Printf(Defines.PRINT_ALL,
                "R_DrawAliasModel " + currentmodel.name + ": no such frame " + currententity.frame + '\n');
        currententity.frame = 0;
        currententity.oldframe = 0;
    }

    if ((currententity.oldframe >= paliashdr.num_frames) || (currententity.oldframe < 0)) {
        VID.Printf(Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name + ": no such oldframe "
                + currententity.oldframe + '\n');
        currententity.frame = 0;
        currententity.oldframe = 0;
    }

    if (r_lerpmodels.value == 0.0f)
        currententity.backlerp = 0;

    GL_DrawAliasFrameLerp(paliashdr, currententity.backlerp);

    GL_TexEnv(GL11.GL_REPLACE);
    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glPopMatrix();

    if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0F)) {
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glCullFace(GL11.GL_FRONT);
    }

    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glDisable(GL11.GL_BLEND);
    }

    if ((currententity.flags & Defines.RF_DEPTHHACK) != 0)
        GL11.glDepthRange(gldepthmin, gldepthmax);

    if (gl_shadows.value != 0.0f
            && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0) {
        GL11.glPushMatrix();
        R_RotateForEntity(e);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glColor4f(0, 0, 0, 0.5f);
        GL_DrawAliasShadow(paliashdr, currententity.frame);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    }
    GL11.glColor4f(1, 1, 1, 1);
}

From source file:kuake2.render.lwjgl.Surf.java

License:Open Source License

/**
 * R_RenderBrushPoly/*from w  w w. ja  v a 2s  . com*/
 */
void R_RenderBrushPoly(msurface_t fa) {
    c_brush_polys++;

    image_t image = R_TextureAnimation(fa.texinfo);

    if ((fa.flags & Defines.SURF_DRAWTURB) != 0) {
        GL_Bind(image.texnum);

        // warp texture, no lightmaps
        GL_TexEnv(GL11.GL_MODULATE);
        GL11.glColor4f(gl_state.inverse_intensity, gl_state.inverse_intensity, gl_state.inverse_intensity,
                1.0F);
        EmitWaterPolys(fa);
        GL_TexEnv(GL11.GL_REPLACE);

        return;
    } else {
        GL_Bind(image.texnum);
        GL_TexEnv(GL11.GL_REPLACE);
    }

    //     ======
    //     PGM
    if ((fa.texinfo.flags & Defines.SURF_FLOWING) != 0)
        DrawGLFlowingPoly(fa.polys);
    else
        DrawGLPoly(fa.polys);
    //     PGM
    //     ======

    // ersetzt goto
    boolean gotoDynamic = false;
    /*
    ** check for lightmap modification
    */
    int maps;
    for (maps = 0; maps < Defines.MAXLIGHTMAPS && fa.styles[maps] != (byte) 255; maps++) {
        if (r_newrefdef.lightstyles[fa.styles[maps] & 0xFF].white != fa.cached_light[maps]) {
            gotoDynamic = true;
            break;
        }
    }

    // this is a hack from cwei
    if (maps == 4)
        maps--;

    // dynamic this frame or dynamic previously
    boolean is_dynamic = false;
    if (gotoDynamic || (fa.dlightframe == r_framecount)) {
        //   label dynamic:
        if (gl_dynamic.value != 0) {
            if ((fa.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66
                    | Defines.SURF_WARP)) == 0) {
                is_dynamic = true;
            }
        }
    }

    if (is_dynamic) {
        if (((fa.styles[maps] & 0xFF) >= 32 || fa.styles[maps] == 0) && (fa.dlightframe != r_framecount)) {
            // ist ersetzt durch temp2:   unsigned   temp[34*34];
            int smax, tmax;

            smax = (fa.extents[0] >> 4) + 1;
            tmax = (fa.extents[1] >> 4) + 1;

            R_BuildLightMap(fa, temp2, smax);
            R_SetCacheState(fa);

            GL_Bind(gl_state.lightmap_textures + fa.lightmaptexturenum);

            GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, fa.light_s, fa.light_t, smax, tmax, GL_LIGHTMAP_FORMAT,
                    GL11.GL_UNSIGNED_BYTE, temp2);

            fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum];
            gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa;
        } else {
            fa.lightmapchain = gl_lms.lightmap_surfaces[0];
            gl_lms.lightmap_surfaces[0] = fa;
        }
    } else {
        fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum];
        gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa;
    }
}

From source file:kuake2.render.lwjgl.Surf.java

License:Open Source License

/**
 * R_DrawAlphaSurfaces//from ww  w. j  a  v a2s.c  om
 * Draw water surfaces and windows.
 * The BSP tree is waled front to back, so unwinding the chain
 * of alpha_surfaces will draw back to front, giving proper ordering.
 */
void R_DrawAlphaSurfaces() {
    r_world_matrix.clear();
    //
    // go back to the world matrix
    //
    GL11.glLoadMatrix(r_world_matrix);

    GL11.glEnable(GL11.GL_BLEND);
    GL_TexEnv(GL11.GL_MODULATE);

    // the textures are prescaled up for a better lighting range,
    // so scale it back down
    float intens = gl_state.inverse_intensity;

    GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf);

    for (msurface_t s = r_alpha_surfaces; s != null; s = s.texturechain) {
        GL_Bind(s.texinfo.image.texnum);
        c_brush_polys++;
        if ((s.texinfo.flags & Defines.SURF_TRANS33) != 0)
            GL11.glColor4f(intens, intens, intens, 0.33f);
        else if ((s.texinfo.flags & Defines.SURF_TRANS66) != 0)
            GL11.glColor4f(intens, intens, intens, 0.66f);
        else
            GL11.glColor4f(intens, intens, intens, 1);
        if ((s.flags & Defines.SURF_DRAWTURB) != 0)
            EmitWaterPolys(s);
        else if ((s.texinfo.flags & Defines.SURF_FLOWING) != 0) // PGM   9/16/98
            DrawGLFlowingPoly(s.polys); // PGM
        else
            DrawGLPoly(s.polys);
    }

    GL_TexEnv(GL11.GL_REPLACE);
    GL11.glColor4f(1, 1, 1, 1);
    GL11.glDisable(GL11.GL_BLEND);

    r_alpha_surfaces = null;
}

From source file:kuake2.render.lwjgl.Surf.java

License:Open Source License

/**
 * R_DrawInlineBModel//from  w w w . j a  v a2  s .c  o m
 */
void R_DrawInlineBModel() {
    // calculate dynamic lighting for bmodel
    if (gl_flashblend.value == 0) {
        dlight_t lt;
        for (int k = 0; k < r_newrefdef.num_dlights; k++) {
            lt = r_newrefdef.dlights[k];
            R_MarkLights(lt, 1 << k, currentmodel.nodes[currentmodel.firstnode]);
        }
    }

    // psurf = &currentmodel->surfaces[currentmodel->firstmodelsurface];
    int psurfp = currentmodel.firstmodelsurface;
    msurface_t[] surfaces = currentmodel.surfaces;
    //psurf = surfaces[psurfp];

    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glColor4f(1, 1, 1, 0.25f);
        GL_TexEnv(GL11.GL_MODULATE);
    }

    //
    // draw texture
    //
    msurface_t psurf;
    cplane_t pplane;
    float dot;
    for (int i = 0; i < currentmodel.nummodelsurfaces; i++) {
        psurf = surfaces[psurfp++];
        // find which side of the node we are on
        pplane = psurf.plane;

        dot = Math3D.DotProduct(modelorg, pplane.normal) - pplane.dist;

        // draw the polygon
        if (((psurf.flags & Defines.SURF_PLANEBACK) != 0 && (dot < -BACKFACE_EPSILON))
                || ((psurf.flags & Defines.SURF_PLANEBACK) == 0 && (dot > BACKFACE_EPSILON))) {
            if ((psurf.texinfo.flags & (Defines.SURF_TRANS33 | Defines.SURF_TRANS66)) != 0) { // add to the translucent chain
                psurf.texturechain = r_alpha_surfaces;
                r_alpha_surfaces = psurf;
            } else if ((psurf.flags & Defines.SURF_DRAWTURB) == 0) {
                GL_RenderLightmappedPoly(psurf);
            } else {
                GL_EnableMultitexture(false);
                R_RenderBrushPoly(psurf);
                GL_EnableMultitexture(true);
            }
        }
    }

    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glColor4f(1, 1, 1, 1);
        GL_TexEnv(GL11.GL_REPLACE);
    }
}

From source file:kuake2.render.lwjgl.Surf.java

License:Open Source License

/**
 * R_DrawBrushModel// ww w  .  j a v a2  s .  c  o  m
 */
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();

    ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE1);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    GL_EnableMultitexture(false);

    GL11.glPopMatrix();
}

From source file:kuake2.render.lwjgl.Surf.java

License:Open Source License

/**
 * R_DrawWorld// w w  w.j  a v  a2s  .com
 */
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

    ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE1);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    GL_EnableMultitexture(false);

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