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.meanworks.engine.gui.Image.java
License:Open Source License
/** * Draw the image/*from w w w.ja v a2 s. co m*/ */ @Override public void render() { if (imageTexture != null) { GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glEnable(GL11.GL_TEXTURE_2D); imageTexture.bind(); GLImmediate.drawTexturedQuad(getX(), getY(), imageTexture.getWidth(), imageTexture.getHeight()); } }
From source file:org.meanworks.engine.gui.impl.radialmenu.RadialMenu.java
License:Open Source License
/** * Renders the radial menu//from w w w . j a v a2 s . c o m */ @Override public void render() { if (showMenu) { glDisable(GL_TEXTURE_2D); glBegin(GL_QUADS); { glColor4f(0.6f, 0.6f, 0.6f, 0.8f); drawQuad(menuOpenX - 20, menuOpenY - 20, 40, 40); } glEnd(); // Draw a line GL11.glColor3f(1.0f, 0.0f, 0.0f); drawLine(menuOpenX, menuOpenY, getMouseX(), getMouseY()); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); //Get sub components int menuX = menuOpenX - 140; int menuY = menuOpenY - 80; for (Component component : this.getComponents()) { if (component instanceof RadialButton) { RadialButton button = (RadialButton) component; button.setPosition(menuX, menuY); menuX -= 20; menuY += 50; } } } }
From source file:org.meanworks.engine.RenderState.java
License:Open Source License
/** * Clear the drawing state/*from w w w.j ava2 s . c o m*/ */ public static void clearState() { if (getBoundShader() != null) { ShaderProgram.bindNone(); setBoundShader(null); } // Clear all texture units for (int i = 0; i < boundTextures.length; i++) { boundTextures[i] = null; } // Update parameters GL11.glColor3f(1.0f, 1.0f, 1.0f); }
From source file:org.minetweak.world.World.java
License:Apache License
private void renderOverlay() { Configuration conf = Game.getInstance().getConfiguration(); Game.getInstance().initOverlayRendering(); GL11.glColor3f(1, 1, 1); if (Game.RENDER_INFORMATION_OVERLAY) { GLFont infoFont = FontStorage.getFont("Monospaced_20"); /* Down Left Info */ infoFont.print(4, 4, "CraftMania"); infoFont.print(4, 30, _player.coordinatesToString()); infoFont.print(4, 45, "Visible Chunks: " + _visibleChunks.size()); infoFont.print(4, 60, "Updading Blocks: " + _updatingBlocks); infoFont.print(4, 75, "Total Chunks in RAM: " + _chunkManager.getTotalChunkCount()); infoFont.print(4, 90, "Local Chunks: " + _localChunks.size()); infoFont.print(4, 105, "Total Local Blocks: " + _localBlockCount); infoFont.print(4, 120, "Time: " + _time); infoFont.print(4, 135, "Sunlight: " + _sunlight); }//from w w w.j a v a 2 s. c o m /** RENDER **/ if (currentGui != null) { Game.getInstance().renderTransculentOverlayLayer(); currentGui.render(); } else { int width = conf.getWidth(); int height = conf.getHeight(); // Center Cross GL11.glDisable(GL11.GL_TEXTURE_2D); if (CENTER_CROSS_CALL_LIST == 0) { CENTER_CROSS_CALL_LIST = GL11.glGenLists(1); GL11.glNewList(CENTER_CROSS_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE); int crossSize = 10; int crossHole = 5; GL11.glLineWidth(2.5f); GL11.glColor3f(0, 0, 0); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3f(width / 2f - crossSize - crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f - crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f + crossSize + crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f + crossHole, height / 2f, 0); GL11.glVertex3f(width / 2f, height / 2f - crossSize - crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f - crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f + crossSize + crossHole, 0); GL11.glVertex3f(width / 2f, height / 2f + crossHole, 0); GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(CENTER_CROSS_CALL_LIST); } GL11.glEnable(GL11.GL_TEXTURE_2D); // Inventory bar GL11.glPushMatrix(); Texture texGui = TextureStorage.getTexture("gui.gui"); texGui.bind(); float tileSize = 20.0f / texGui.getImageWidth(); if (INVENTORY_BAR_CALL_LIST == 0) { INVENTORY_BAR_CALL_LIST = GL11.glGenLists(2); /* Bar */ GL11.glNewList(INVENTORY_BAR_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE); GL11.glTranslatef(width / 2.0f - 9 * 20, 10, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 40); GL11.glTexCoord2f(tileSize * 9, 0); GL11.glVertex2f(9 * 40, 40); GL11.glTexCoord2f(tileSize * 9, tileSize); GL11.glVertex2f(9 * 40, 0); GL11.glTexCoord2f(0, tileSize); GL11.glVertex2f(0, 0); GL11.glEnd(); GL11.glEndList(); /* Little frame around selected item */ float frameTileSize = 24.0f / texGui.getImageWidth(); float frameTileY = 22.0f / texGui.getImageHeight(); GL11.glNewList(INVENTORY_BAR_CALL_LIST + 1, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, frameTileY); GL11.glVertex2f(0, 48); GL11.glTexCoord2f(frameTileSize, frameTileY); GL11.glVertex2f(48, 48); GL11.glTexCoord2f(frameTileSize, frameTileY + frameTileSize); GL11.glVertex2f(48, 0); GL11.glTexCoord2f(0, frameTileY + frameTileSize); GL11.glVertex2f(0, 0); GL11.glEnd(); GL11.glEndList(); } else { GL11.glCallList(INVENTORY_BAR_CALL_LIST); } /* Content */ GL11.glPushMatrix(); GL11.glTranslatef(20, 20, 0); for (int i = 0; i < 9; ++i) { Inventory.InventoryPlace place = getActivePlayer().getInventory().getInventoryPlace(i); if (place != null) { place.render(); } GL11.glTranslatef(40, 0, 0); } texGui.bind(); GL11.glPopMatrix(); GL11.glTranslatef(getActivePlayer().getSelectedInventoryItemIndex() * 40.0f - 4, -4, 0); GL11.glCallList(INVENTORY_BAR_CALL_LIST + 1); GL11.glPopMatrix(); } }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private void drawWireframeCube() { GL11.glDisable(GL11.GL_FOG);// w w w. j a v a 2 s . co m GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor3f(0.9f, 0.9f, 0.9f); GLUT.glutWireCube(3.1f); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_FOG); }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private void drawSceneCubes() { GL11.glTranslatef(-(MapCube.getCubeSize() / 2), -(MapCube.getCubeSize() / 2), -(MapCube.getCubeSize() / 2)); GL11.glBegin(GL11.GL_QUADS);/*from w w w . j a va2 s . c o m*/ int[] planeStep = new int[] { MapCube.D / 2, MapCube.D / 2, MapCube.D / 2 }; float x1; float x2; float x3; x1 = 0f; int xlim = Math.min(MapCube.W, planeStep[0] + MapCube.D / 2); for (int x = 0; x < xlim; x++) { x1 += MapCube.getCubeSize(); x2 = 0f; for (int y = 0; y < MapCube.H; y++) { x2 += MapCube.getCubeSize(); x3 = 0; for (int localz = 0; localz < MapCube.D; localz++) { x3 += MapCube.getCubeSize(); int cl = mapCube.getElement(x, y, localz); int n = mapCube.getNeighbours(x, y, localz); if (n != 63) { if (cl != 0) { incrementDrawCubeCount(); GL11.glColor3f((float) colors[cl][0], (float) colors[cl][1], (float) colors[cl][2]); if (x == xlim - 1) { GLUT.drawWholeCube(MapCube.getCubeSize() / 2, x1, x2, x3, x, y, localz); } else { GLUT.drawCube(x1, x2, x3, MapCube.getCubeSize() / 2, mapCube.getNeighbours(x, y, localz)); } } } } } } GL11.glEnd(); GL11.glTranslatef(MapCube.getCubeSize() / 2, MapCube.getCubeSize() / 2, MapCube.getCubeSize() / 2); }
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 ww w .j a va 2s . c o m 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 drawGround() { GL11.glDisable(GL11.GL_LIGHTING);//from w w w . j a va 2 s. c o m GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); // GL11.glDepthRange (1,1); if (use_textures) { GL11.glEnable(GL11.GL_TEXTURE_2D); ground_texture.bind(false); } else { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(GROUND_R, GROUND_G, GROUND_B); } // ground fog seems to cause problems with TNT2 under windows /* GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1}; GL11.glEnable (GL_FOG); GL11.glFogi (GL_FOG_MODE, GL_EXP2); GL11.glFogfv (GL_FOG_COLOR, fogColor); GL11.glFogf (GL_FOG_DENSITY, 0.05f); GL11.glHint (GL_FOG_HINT, GL_NICEST); // GL_DONT_CARE); GL11.glFogf (GL_FOG_START, 1.0); GL11.glFogf (GL_FOG_END, 5.0); */ final float gsize = 100.0f; final float offset = 0; // -0.001f; ... polygon offsetting doesn't work well GL11.glBegin(GL11.GL_QUADS); GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz); GL11.glVertex3f(-gsize, offset, gsize); GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz); GL11.glVertex3f(gsize, offset, gsize); GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz); GL11.glVertex3f(gsize, offset, -gsize); GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz); GL11.glVertex3f(-gsize, offset, -gsize); GL11.glEnd(); GL11.glDisable(GL11.GL_FOG); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
@Override // void dsDrawFrame (int width, int height, dsFunctions *fn, int pause) void dsDrawFrame(int width, int height, dsFunctions fn, boolean pause) { if (current_state < 1) dsDebug("internal error"); current_state = 2;//from w w w .jav a 2s . com // setup stuff GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glFrontFace(GL11.GL_CCW); // setup viewport GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); final float vnear = 0.1f; final float vfar = 100.0f; final float k = 0.8f; // view scale, 1 = +/- 45 degrees if (width >= height) { float k2 = (float) height / (float) width; GL11.glFrustum(-vnear * k, vnear * k, -vnear * k * k2, vnear * k * k2, vnear, vfar); } else { float k2 = (float) width / (float) height; GL11.glFrustum(-vnear * k * k2, vnear * k * k2, -vnear * k, vnear * k, vnear, vfar); } // setup lights. it makes a difference whether this is done in the // GL_PROJECTION matrix mode (lights are scene relative) or the // GL_MODELVIEW matrix mode (lights are camera relative, bad!). // static GLfloat light_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; // static GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; // static GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light_ambient); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light_diffuse); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, light_specular); GL11.glColor3f(1.0f, 1.0f, 1.0f); // clear the window GL11.glClearColor(0.5f, 0.5f, 0.5f, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // snapshot camera position (in MS Windows it is changed by the GUI thread) float[] view2_xyz = view_xyz.clone(); float[] view2_rxyz = view_rxyz.clone(); // memcpy (view2_xyz,view_xyz);//,sizeof(float)*3); // memcpy (view2_hpr,view_hpr);//,sizeof(float)*3); // go to GL_MODELVIEW matrix mode and set the camera GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); setCamera(view2_xyz[0], view2_xyz[1], view2_xyz[2], view2_rxyz[0], view2_rxyz[1], view2_rxyz[2]); // set the light position (for some reason we have to do this in model view. // static GLfloat light_position[] = { LIGHTX, LIGHTY, 1.0, 0.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light_position); // draw the background (ground, sky etc) drawSky(view2_xyz); drawGround(); // draw the little markers on the ground drawPyramidGrid(); // leave openGL in a known state - flat shaded white, no textures GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glColor3f(1, 1, 1); setColor(1, 1, 1, 1); // draw the rest of the objects. set drawing state first. color[0] = 1; color[1] = 1; color[2] = 1; color[3] = 1; tnum = DS_TEXTURE_NUMBER.DS_NONE; //if (fn.step) fn.step(pause); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void setShadowDrawingMode() { GL11.glDisable(GL11.GL_LIGHTING);//from w w w . ja v a 2 s. 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); }