List of usage examples for org.lwjgl.opengl GL11 glEnableClientState
public static native void glEnableClientState(@NativeType("GLenum") int cap);
From source file:com.owens.oobjloader.lwjgl.VBO.java
License:BSD License
public void render() { GL11.glEnable(GL11.GL_TEXTURE_2D);/*from w w w . j a va2 s . c o m*/ GL11.glBindTexture(GL11.GL_TEXTURE_2D, textId); // Bind The Texture GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, verticeAttributesID); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, ATTR_V_STRIDE2_BYTES, ATTR_V_OFFSET_BYTES); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glNormalPointer(GL11.GL_FLOAT, ATTR_N_STRIDE2_BYTES, ATTR_N_OFFSET_BYTES); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, ATTR_T_STRIDE2_BYTES, ATTR_T_OFFSET_BYTES); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesID); GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_INT, 0); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glDisable(GL11.GL_TEXTURE_2D); }
From source file:com.timvisee.voxeltex.module.mesh.Mesh.java
License:Open Source License
/** * Render or draw the mesh using OpenGL. *///from w w w .j a va 2 s.co m public void draw(Material material) { // Bind the vertex buffer glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle); GL11.glVertexPointer(this.raw.getVertexAxisCount(), GL11.GL_FLOAT, 0, 0L); // Bind the normal coordinate buffer if available if (hasNormalData()) { glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle); GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0L); } // Bind the texture coordinate buffer if available if (hasTextureData()) { glBindBuffer(GL_ARRAY_BUFFER, vboTextureHandle); GL11.glTexCoordPointer(this.raw.getTextureAxisCount(), GL11.GL_FLOAT, 0, 0L); } // Enable the client states for the buffers that were bound GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); if (hasNormalData()) GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); if (hasTextureData()) GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // Draw the mesh GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.vertexCount); // Disable the client used states GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); if (hasNormalData()) GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY); if (hasTextureData()) GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); // Unbind all buffers GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:de.codesourcery.flocking.LWJGLRenderer.java
License:Apache License
private void renderWorld(World world) { final double modelMax = world.getSimulationParameters().modelMax; xInc = Display.getWidth() / modelMax; yInc = Display.getHeight() / modelMax; GL11.glEnable(GL11.GL_DEPTH_TEST);//from ww w . j a va2 s . com GL11.glDepthMask(true); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glColor3f(0.5f, 0.5f, 1.0f); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); final int triangleCount = world.getPopulationCount(); // setup vertex data final int vertexArrayLen = triangleCount * 3 * 2; // one triangle = 3 vertices * 2 int's per vertex final MyIntBuffer vertexBuffer = getVertexBuffer(vertexArrayLen); final IntBuffer vertexIntBuffer = vertexBuffer.getBuffer(); final IBoidVisitor visitor = new IBoidVisitor() { @Override public void visit(Boid boid) { drawBoid(boid, vertexIntBuffer); } }; world.visitAllBoids(visitor); vertexBuffer.rewind(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBuffer.getHandle()); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuffer.getBuffer(), GL15.GL_DYNAMIC_DRAW); GL11.glVertexPointer(2, GL11.GL_INT, 0, 0); // setup index data MyIntBuffer indexBuffer = getIndexBuffer(triangleCount * 3); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getHandle()); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getBuffer(), GL15.GL_STATIC_DRAW); GL11.glDrawElements(GL11.GL_TRIANGLES, triangleCount * 3, GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
public void initSolidAndLineRendering() { GL11.glDepthMask(true);/* w w w . j a v a 2 s. c o m*/ GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Set Perspective Calculations To Most Accurate disableAllTextureUnits(); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
public void initTexturedRendering() { // GL11.glDepthMask(true); // GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing // GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do GL11.glDepthMask(true);//from w w w.j a v a2 s . c o m GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do GL11.glDisable(GL11.GL_BLEND); ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:game.states.State_PREFAB_EDITOR.java
License:Open Source License
@Override protected void Init() { ButtonGUILayer = new GUI_Layer(); ButtonGUILayer.SetEnabled(true);// w w w. j a v a2s .c o m MenuGUILayer = new GUI_Layer(); MenuGUILayer.SetEnabled(false); int ButtonStartX = 712; int ButtonStartY = 600; float xScale = 1.5f; float yScale = 1.5f; int Spacing = 145; int menuButtonStartX = 640 - 128; int menuButtonStartY = 150; float menuXScale = 1f; float menuYScale = 1f; int menuSpacing = 110; try { GL11.glEnable(GL11.GL_TEXTURE_2D); BackGroundImage = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/GUIPrefab.png")); Texture button1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/SaveIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 0, ButtonStartY, (int) (button1.getImageWidth() * xScale), (int) (button1.getImageHeight() * yScale), button1); Texture button2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/LoadIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 1, ButtonStartY, (int) (button2.getImageWidth() * xScale), (int) (button2.getImageHeight() * yScale), button2); Texture button3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/OptionsIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 2, ButtonStartY, (int) (button3.getImageWidth() * xScale), (int) (button3.getImageHeight() * yScale), button3); Texture button4 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/UI/HelpIconButton.png"), false, GL11.GL_NEAREST); ButtonGUILayer.AddButton(ButtonStartX + Spacing * 3, ButtonStartY, (int) (button4.getImageWidth() * xScale), (int) (button4.getImageHeight() * yScale), button4); Texture mButton0 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/ReturnButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 0, (int) (mButton0.getImageWidth() * menuXScale), (int) (mButton0.getImageHeight() * menuYScale), mButton0); Texture mButton1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/LoadButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 1, (int) (mButton1.getImageWidth() * menuXScale), (int) (mButton1.getImageHeight() * menuYScale), mButton1); Texture mButton2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/SaveButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 2, (int) (mButton2.getImageWidth() * menuXScale), (int) (mButton2.getImageHeight() * menuYScale), mButton2); Texture mButton3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Materials/GUI/Buttons/BackButton.png"), false, GL11.GL_NEAREST); MenuGUILayer.AddButton(menuButtonStartX, menuButtonStartY + menuSpacing * 3, (int) (mButton3.getImageWidth() * menuXScale), (int) (mButton3.getImageHeight() * menuYScale), mButton3); } catch (IOException e) { e.printStackTrace(); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 600.0f); GLU.gluLookAt(0, 20, 50, 0, -2, -100, 0, -1, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:game.states.State_SINGLEPLAYER.java
License:Open Source License
@Override protected void Init() { if (CreateNewGame) { CurrentSave = new GameSave(); Worlds = new TileMap[] { new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap(), new TileMap() }; t = Worlds[0];/*from w ww .ja v a 2 s. c o m*/ CreateGUI(); System.out.println("Loading worlds"); for (int i = 0; i < Worlds.length; i++) { Worlds[i].Load(i == Worlds.length - 1, i == 0, i); CurrentSave.setIntMapData(TileMapGenerator.Map, i); } } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 600.0f); GLU.gluLookAt(0, 20, 50, 0, -2, -100, 0, -1, 0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); if (CreateNewGame) { player = t.SpawnPlayer(); PlayerGridX = player.getX(); PlayerGridY = player.getY(); PlayerY = 52 - CameraDisplacement * (PlayerGridY - 1); PlayerX = -6 + CameraDisplacement * (PlayerGridX - 1); PlayerZ = 0; SetGUI(); } CreateNewGame = true; GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
public LWJGLDrawContext(GLCapabilities glcaps) { this.glcaps = glcaps; GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND);/*from ww w. j av a2 s . co m*/ GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); canUseVBOs = glcaps.GL_ARB_vertex_buffer_object; }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void fillQuad(float x1, float y1, float x2, float y2) { ByteBuffer quadPoints = ByteBuffer.allocateDirect(4 * 2 * 4); quadPoints.order(ByteOrder.nativeOrder()); FloatBuffer floatBuff = quadPoints.asFloatBuffer(); floatBuff.put(x1);/*from ww w .j a v a 2 s. c om*/ floatBuff.put(y1); floatBuff.put(x1); floatBuff.put(y2); floatBuff.put(x2); floatBuff.put(y2); floatBuff.put(x2); floatBuff.put(y1); floatBuff.position(0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, floatBuff); GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawLine(float[] points, boolean loop) { if (points.length % 3 != 0) { throw new IllegalArgumentException("Point array length needs to be multiple of 3."); }// ww w .ja v a 2 s . c o m ByteBuffer floatBuff = generateTemporaryFloatBuffer(points); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, floatBuff); GL11.glDrawArrays(loop ? GL11.GL_LINE_LOOP : GL11.GL_LINE_STRIP, 0, points.length / 3); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }