List of usage examples for org.lwjgl.opengl GL11 glColor3f
public static native void glColor3f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green, @NativeType("GLfloat") float blue);
From source file:org.free.jake2.render.lwjgl.Light.java
License:Open Source License
/** * R_RenderDlight// w w w .java 2s . c o m */ void R_RenderDlight(dlight_t light) { float rad = light.intensity * 0.35f; Math3D.VectorSubtract(light.origin, r_origin, v); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glColor3f(light.color[0] * 0.2f, light.color[1] * 0.2f, light.color[2] * 0.2f); int i; for (i = 0; i < 3; i++) { v[i] = light.origin[i] - vpn[i] * rad; } GL11.glVertex3f(v[0], v[1], v[2]); GL11.glColor3f(0, 0, 0); int j; float a; for (i = 16; i >= 0; i--) { a = (float) (i / 16.0f * Math.PI * 2); for (j = 0; j < 3; j++) { v[j] = (float) (light.origin[j] + vright[j] * Math.cos(a) * rad + vup[j] * Math.sin(a) * rad); } GL11.glVertex3f(v[0], v[1], v[2]); } GL11.glEnd(); }
From source file:org.free.jake2.render.lwjgl.Light.java
License:Open Source License
/** * R_RenderDlights/* w w w . jav a 2s .com*/ */ void R_RenderDlights() { if (gl_flashblend.value == 0) { return; } r_dlightframecount = r_framecount + 1; // because the count hasn't // advanced yet for this frame GL11.glDepthMask(false); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); for (int i = 0; i < r_newrefdef.num_dlights; i++) { R_RenderDlight(r_newrefdef.dlights[i]); } GL11.glColor3f(1, 1, 1); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthMask(true); }
From source file:org.free.jake2.render.lwjgl.Surf.java
License:Open Source License
/** * R_DrawBrushModel/*from www . j a v a 2 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(); GL13.glClientActiveTexture(GL_TEXTURE1); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL_EnableMultitexture(false); GL11.glPopMatrix(); }
From source file:org.free.jake2.render.lwjgl.Surf.java
License:Open Source License
/** * R_DrawWorld/* w w w .j a va 2 s. co m*/ */ 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 GL13.glClientActiveTexture(GL_TEXTURE1); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL_EnableMultitexture(false); DrawTextureChains(); R_DrawSkyBox(); R_DrawTriangleOutlines(); }
From source file:org.jackhuang.watercraft.client.render.RecolorableItemRenderer.java
License:Minecraft Mod Public
@Override public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { int meta = stack.getItemDamage(); ItemRecolorable item = (ItemRecolorable) stack.getItem(); GL11.glEnable(GL11.GL_BLEND);//from w w w . j a v a 2s .c o m if (type == ItemRenderType.ENTITY) { if (RenderItem.renderInFrame) { GL11.glScalef(0.85F, 0.85F, 0.85F); GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslated(-0.5D, -0.42D, 0.0D); } else { GL11.glTranslated(-0.5D, -0.42D, 0.0D); } } GL11.glColor3f(1.0F, 1.0F, 1.0F); IIconContainer iconContainer = item.getIconContainer(meta); IIcon icon = stack.getIconIndex(); if (icon == null) return; Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); GL11.glBlendFunc(770, 771); short[] rgb = item.getRGBA(stack); GL11.glColor3f(rgb[0] / 255.0F, rgb[1] / 255.0F, rgb[2] / 255.0F); if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); else ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); GL11.glColor3f(1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); }
From source file:org.joge.core.draw.font.Font.java
License:Open Source License
public void render(String text, Color color, float xpos, float ypos) { Texture tex;/*from w w w. j a va 2 s. c om*/ char[] chars = text.toCharArray(); float textWidth = 0; for (int i = 0; i < chars.length; i++) { tex = charArray[(int) chars[i]]; width = tex.getImageWidth(); height = tex.getImageHeight(); tWidth = tex.getWidth(); tHeight = tex.getHeight(); tex.bind(); GL11.glTranslatef(xpos + textWidth, ypos, 0); GL11.glColor3f(color.r, color.g, color.b); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f(tOffsetX, tOffsetY); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(tOffsetX, tHeight + tOffsetY); GL11.glVertex2f(0, height); GL11.glTexCoord2f(tWidth + tOffsetX, tHeight + tOffsetY); GL11.glVertex2f(width, height); GL11.glTexCoord2f(tWidth + tOffsetX, tOffsetY); GL11.glVertex2f(width, 0); } GL11.glEnd(); GL11.glLoadIdentity(); textWidth += tex.getWidth() * fontSize; } }
From source file:org.joge.core.draw.Image.java
License:Open Source License
public void draw(float xpos, float ypos, Color col) { texture.bind(); GL11.glColor3f(col.r, col.g, col.b); drawGL(xpos, ypos); }
From source file:org.jtrfp.mtmx.tools.internal.WorldViewerConfiguration.java
License:Open Source License
@Override public void draw() { GL11.glClearColor(0.8f, 0.8f, 0.8f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity();/*from ww w.j a v a 2s. c om*/ float e = terrainDrawer.getTerrainMap().getElevationAt(1, 1) * IDrawer.WORLD_SCALE_XZ; GLU.gluLookAt(-1.0f + lookX * IDrawer.WORLD_SCALE_XZ, 1.0f + e, -1.0f + lookZ * IDrawer.WORLD_SCALE_XZ, 0.0f + lookX * IDrawer.WORLD_SCALE_XZ, 0.0f + e, 0.0f + lookZ * IDrawer.WORLD_SCALE_XZ, 0.0f, 1.0f, 0.0f); GL11.glColor3f(0.0f, 1.0f, 0.0f); terrainDrawer.draw(); Keyboard.poll(); while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { return; } if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) { lookX -= 5; } if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) { lookX += 5; } if (Keyboard.getEventKey() == Keyboard.KEY_UP) { lookZ += 5; } if (Keyboard.getEventKey() == Keyboard.KEY_DOWN) { lookZ -= 5; } if (Keyboard.getEventKey() == Keyboard.KEY_T) { if (terrainDrawer.getRenderMode() == GL11.GL_TRIANGLES) { terrainDrawer.setRenderMode(GL11.GL_LINE_LOOP); } else { terrainDrawer.setRenderMode(GL11.GL_TRIANGLES); } } } } }
From source file:org.lwjgl.info.LWJGLTestView.java
License:Open Source License
/** * {@inheritDoc}//from w w w.ja va 2s . com * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ @Override public void createPartControl(Composite parent) { String strVersion = getFeatureVersion("org.lwjgl"); this.setPartName("org.lwjgl " + strVersion); IStatusLineManager statusLine = this.getViewSite().getActionBars().getStatusLineManager(); fpsstatuslineitem = new FpsStatusLineItem(); statusLine.add(fpsstatuslineitem); GLData data = new GLData(); data.doubleBuffer = true; canvas = new GLCanvas(parent, SWT.NONE, data); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } canvas.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle bounds = canvas.getBounds(); float fAspect = (float) bounds.width / (float) bounds.height; canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glViewport(0, 0, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); } }); GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); GL11.glLineWidth(2); GL11.glEnable(GL11.GL_DEPTH_TEST); Display.getCurrent().asyncExec(initRunnable()); }
From source file:org.lwjgl.info.LWJGLTestView.java
License:Open Source License
Runnable initRunnable() { return new Runnable() { int rot = 0; public void run() { if (!canvas.isDisposed() && canvas.isVisible()) { fpsstatuslineitem.renderPassStarted(); canvas.setCurrent();//from w w w . j av a 2s .c o m try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glClearColor(.2f, .7f, .2f, 1.0f); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -10.0f); float frot = rot; GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f); GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f); rot++; GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); canvas.swapBuffers(); fpsstatuslineitem.renderPassFinished(); Display.getCurrent().asyncExec(this); } } }; }