List of usage examples for org.lwjgl.opengl GL11 glDepthRange
public static void glDepthRange(@NativeType("GLdouble") double zNear, @NativeType("GLdouble") double zFar)
From source file:org.free.jake2.render.lwjgl.Main.java
License:Open Source License
/** * R_Clear/*w w w. j av a2 s .c o m*/ */ void R_Clear() { if (gl_ztrick.value != 0.0f) { if (gl_clear.value != 0.0f) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); } trickframe++; if ((trickframe & 1) != 0) { gldepthmin = 0; gldepthmax = 0.49999f; GL11.glDepthFunc(GL11.GL_LEQUAL); } else { gldepthmin = 1; gldepthmax = 0.5f; GL11.glDepthFunc(GL11.GL_GEQUAL); } } else { if (gl_clear.value != 0.0f) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); } else { GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); } gldepthmin = 0; gldepthmax = 1; GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDepthRange(gldepthmin, gldepthmax); }
From source file:org.free.jake2.render.lwjgl.Mesh.java
License:Open Source License
/** * R_DrawAliasModel/*w w w .ja v a2s . c o 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:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void drawSky(float[] view_xyz) { GL11.glDisable(GL11.GL_LIGHTING);//from www .j a va 2s . c om if (use_textures) { GL11.glEnable(GL11.GL_TEXTURE_2D); sky_texture.bind(false); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(0f, 0.5f, 1.0f); } // make sure sky depth is as far back as possible GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDepthRange(1, 1); final float ssize = 1000.0f; float x = ssize * sky_scale; float y = view_xyz[1] + sky_height; GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, -1, 0); GL11.glTexCoord2f(x + offset, -x + offset); GL11.glVertex3f(ssize + view_xyz[0], y, -ssize + view_xyz[2]); GL11.glTexCoord2f(x + offset, x + offset); GL11.glVertex3f(ssize + view_xyz[0], y, ssize + view_xyz[2]); GL11.glTexCoord2f(-x + offset, x + offset); GL11.glVertex3f(-ssize + view_xyz[0], y, ssize + view_xyz[2]); GL11.glTexCoord2f(-x + offset, -x + offset); GL11.glVertex3f(-ssize + view_xyz[0], y, -ssize + view_xyz[2]); GL11.glEnd(); offset = offset + 0.002f; if (offset > 1) offset -= 1; GL11.glDepthFunc(GL11.GL_LESS); GL11.glDepthRange(0, 1); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void setShadowDrawingMode() { GL11.glDisable(GL11.GL_LIGHTING);/* www. j a v a 2s . c om*/ 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:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
@Override public void dsDrawBox(final float[] pos, final float[] R, final float[] sides) { if (current_state != 2) dsError("drawing function called outside simulation loop"); setupDrawingMode();//from ww w . j a va 2s. c o m GL11.glShadeModel(GL11.GL_FLAT); setTransform(pos, R); drawBox(sides); GL11.glPopMatrix(); if (use_shadows) { setShadowDrawingMode(); setShadowTransform(); setTransform(pos, R); drawBox(sides); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glDepthRange(0, 1); } }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
void dsDrawConvex(final float[] pos, final float[] R, float[] _planes, int _planecount, float[] _points, int _pointcount, int[] _polygons) { if (current_state != 2) dsError("drawing function called outside simulation loop"); setupDrawingMode();/*from w w w . java 2 s. c o m*/ GL11.glShadeModel(GL11.GL_FLAT); setTransform(pos, R); drawConvex(_planes, _planecount, _points, _pointcount, _polygons); GL11.glPopMatrix(); if (use_shadows) { setShadowDrawingMode(); setShadowTransform(); setTransform(pos, R); drawConvex(_planes, _planecount, _points, _pointcount, _polygons); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glDepthRange(0, 1); } }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
@Override public void dsDrawSphere(final float[] pos, final float[] R, float radius) { if (current_state != 2) dsError("drawing function called outside simulation loop"); setupDrawingMode();/*w ww. j a v a2s .co m*/ GL11.glEnable(GL11.GL_NORMALIZE); GL11.glShadeModel(GL11.GL_SMOOTH); setTransform(pos, R); GL11.glScaled(radius, radius, radius); drawSphere(); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_NORMALIZE); // draw shadows if (use_shadows) { GL11.glDisable(GL11.GL_LIGHTING); if (use_textures) { ground_texture.bind(true); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glColor3f(SHADOW_INTENSITY, SHADOW_INTENSITY, SHADOW_INTENSITY); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(GROUND_R * SHADOW_INTENSITY, GROUND_G * SHADOW_INTENSITY, GROUND_B * SHADOW_INTENSITY); } GL11.glShadeModel(GL11.GL_FLAT); GL11.glDepthRange(0, 0.9999); drawSphereShadow(pos[0], pos[1], pos[2], radius); GL11.glDepthRange(0, 1); } }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
/** * @see DrawStuffApi#dsDrawCylinder(float[], float[], float, float) *//*from w ww. j a v a2s. c o m*/ @Override public void dsDrawCylinder(final float[] pos, final float[] R, float length, float radius) { if (current_state != 2) dsError("drawing function called outside simulation loop"); setupDrawingMode(); GL11.glShadeModel(GL11.GL_SMOOTH); setTransform(pos, R); drawCylinder(length, radius, 0); GL11.glPopMatrix(); if (use_shadows) { setShadowDrawingMode(); setShadowTransform(); setTransform(pos, R); drawCylinder(length, radius, 0); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glDepthRange(0, 1); } }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
/** * @see DrawStuffApi#dsDrawCapsule(float[], float[], float, float) *///from w w w . j a v a2 s . c om @Override public void dsDrawCapsule(final float[] pos, final float[] R, float length, float radius) { if (current_state != 2) dsError("drawing function called outside simulation loop"); setupDrawingMode(); GL11.glShadeModel(GL11.GL_SMOOTH); setTransform(pos, R); drawCapsule(length, radius); GL11.glPopMatrix(); if (use_shadows) { setShadowDrawingMode(); setShadowTransform(); setTransform(pos, R); drawCapsule(length, radius); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glDepthRange(0, 1); } }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
/** * @see DrawStuffApi#dsDrawConvex(DVector3C, DMatrix3C, double[], int, double[], int, int[]) *///from w w w . j a v a 2 s .c o m @Override public void dsDrawConvex(DVector3C pos, DMatrix3C R, double[] _planes, int _planecount, double[] _points, int _pointcount, int[] _polygons) { if (current_state != 2) dsError("drawing function called outside simulation loop"); setupDrawingMode(); GL11.glShadeModel(GL11.GL_FLAT); setTransform(pos, R); drawConvexD(_planes, _planecount, _points, _pointcount, _polygons); GL11.glPopMatrix(); if (use_shadows) { setShadowDrawingMode(); setShadowTransform(); setTransform(pos, R); drawConvexD(_planes, _planecount, _points, _pointcount, _polygons); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glDepthRange(0, 1); } }