List of usage examples for org.lwjgl.opengl GL11 glGetError
@NativeType("GLenum") public static int glGetError()
From source file:org.meanworks.engine.render.geometry.mesh.renderers.VAOMeshRenderer.java
License:Open Source License
/** * Compiles this mesh and makes sure all attributes are set up correctly. *///from www. ja v a2s. c o m public boolean compile() { // Preliminary check for (BufferEntry bufferEntry : vertexBuffers) { if (bufferEntry == null || bufferEntry.buffer == null || bufferEntry.bufferAttributes.size() == 0) { EngineLogger.error("Could not compile Mesh, invalid buffer entry."); return false; } } if (vertexBufferArray == null) { vertexBufferArray = new VertexBufferArray(); } vertexBufferArray.bind(); { for (BufferEntry bufferEntry : vertexBuffers) { bufferEntry.buffer.bind(); for (BufferAttribute bufferAttribute : bufferEntry.bufferAttributes) { GL20.glEnableVertexAttribArray(bufferAttribute.index); GL20.glVertexAttribPointer(bufferAttribute.index, bufferAttribute.size, bufferAttribute.type, bufferAttribute.normalized, bufferAttribute.stride, bufferAttribute.bufferOffset); } } if (indexBuffer != null) { indexBuffer.bind(); } } vertexBufferArray.unbind(); int error = GL11.glGetError(); if (error != 0) { EngineLogger.error("Could not compile Mesh, " + GLU.gluErrorString(error)); return false; } return true; }
From source file:org.minetweak.rendering.ChunkMeshBuilder.java
License:Apache License
public static void generateChunkMesh(Chunk chunk, MeshType meshType) { if (DEBUG) {//w w w .ja v a 2 s . c o m System.out.println("Building " + meshType.name() + " Mesh for " + chunk.toString() + "..."); } /* Make sure there are no list edits anymore */ chunk.performListChanges(); ChunkMesh mesh = chunk.getMesh(); mesh.destroy(meshType); /* Compute vertex count */ int vertexCount = chunk.getVertexCount(meshType); if (DEBUG) { System.out.println("\tVertex Count = " + vertexCount); } /* * If there are no faces visible yet (because of generating busy), don't * create a buffer */ if (vertexCount == 0) { return; } mesh.setVertexCount(meshType, vertexCount); /* Create a buffer */ int vbo = BufferManager.getInstance().createBuffer(); mesh.setVBO(meshType, vbo); /* Bind the buffer */ GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo); /* Allocate size for the buffer */ int size = vertexCount * STRIDE * FLOAT_SIZE; GL15.glBufferData(GL15.GL_ARRAY_BUFFER, size, GL15.GL_STATIC_DRAW); if (DEBUG) { System.out.println( "\tCreate VBO: " + vbo + " with size = " + size + " (ERROR: " + GL11.glGetError() + ")"); } /* Get the native buffer to write to */ ByteBuffer byteBuffer = GL15.glMapBuffer(GL15.GL_ARRAY_BUFFER, GL15.GL_WRITE_ONLY, size, null); if (byteBuffer == null) { System.out.println("\tCouldn't create a native VBO!: GL Error Code = " + GL11.glGetError()); GL15.glUnmapBuffer(GL15.GL_ARRAY_BUFFER); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); mesh.destroy(meshType); Thread.dumpStack(); mesh.setVBO(meshType, -1); mesh.setVertexCount(meshType, 0); return; } FloatBuffer vertexBuffer = byteBuffer.asFloatBuffer(); /* Store all vertices in the buffer */ USED_SIZE = 0; /* Local temporary variables, used to speed up */ IntList blockList = chunk.getVisibleBlocks(); int blockIndex = -1; byte blockType = 0; boolean special = false; Vec3i vec = new Vec3i(); BlockType type; Block block = null; LightBuffer lightBuffer = chunk.getLightBuffer(); byte faceMask = 0; /* Iterate over the blocks */ for (int i = 0; i < blockList.size(); ++i) { blockIndex = blockList.get(i); blockType = chunk.getChunkData().getBlockType(blockIndex); if (blockType == 0) { continue; } special = chunk.getChunkData().isSpecial(blockIndex); type = _blockManager.getBlockType(blockType); if ((meshType == MeshType.OPAQUE && !type.isTranslucent() && type.hasNormalAABB()) || (meshType == MeshType.TRANSLUCENT && (type.isTranslucent() || !type.hasNormalAABB()))) { ChunkData.indexToPosition(blockIndex, vec); /* Build the light buffer */ vec.setX(vec.x() + chunk.getAbsoluteX()); vec.setZ(vec.z() + chunk.getAbsoluteZ()); lightBuffer.setReferencePoint(vec.x(), vec.y(), vec.z()); if (special) { block = chunk.getChunkData().getSpecialBlock(blockIndex); if (block.isVisible()) { block.storeInVBO(vertexBuffer, lightBuffer); } } else { if (type.isCrossed()) { type.getCrossedBlockBrush().storeInVBO(vertexBuffer, vec.x() + 0.5f, vec.y() + 0.5f, vec.z() + 0.5f, lightBuffer); } else { faceMask = chunk.getChunkData().getFaceMask(blockIndex); type.getDefaultBlockBrush().setFaceMask(faceMask); type.getBrush().storeInVBO(vertexBuffer, vec.x() + 0.5f, vec.y() + 0.5f, vec.z() + 0.5f, lightBuffer); } } } } /* Perform a check */ if (USED_SIZE != STRIDE * FLOAT_SIZE * mesh.getVertexCount(meshType)) { System.out.println("\t[WARNING!]: Used size = " + USED_SIZE); System.out.println("\t[WARNING!]: Vertex count = " + USED_SIZE / STRIDE / FLOAT_SIZE); mesh.setVertexCount(meshType, USED_SIZE / STRIDE / FLOAT_SIZE); } byteBuffer.flip(); GL15.glUnmapBuffer(GL15.GL_ARRAY_BUFFER); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:processing.opengl.PLWJGL.java
License:Open Source License
@Override public int getError() { return GL11.glGetError(); }
From source file:thebounzer.org.lwgldemo.glutils.ShaderProgram.java
License:Open Source License
private boolean validateProgram(int programId) { GL20.glLinkProgram(programId);//from w w w .j a v a 2 s.com GL20.glValidateProgram(programId); boolean result = true; int errorCheckValue = GL11.glGetError(); if (errorCheckValue != GL11.GL_NO_ERROR) { logger.log(Level.SEVERE, "ERROR - Could not create the shaders:{0}", GLU.gluErrorString(errorCheckValue)); result = false; } return result; }
From source file:uk.co.ifs_studios.engine.shader.ShaderProgram.java
License:Open Source License
/** * Link and validate shader program.//from ww w . j ava 2s. c om */ public void link() { GL20.glLinkProgram(this.id); GL20.glValidateProgram(this.id); int error = GL11.glGetError(); if (error != GL11.GL_NO_ERROR) { EngineLogger.error(new ShaderException("Couldn't link and validate shader program.", null)); } }
From source file:zsawyer.mods.stereoscopic3d.DebugUtil.java
License:Open Source License
/** * Checks for an OpenGL error. If there is one, throws a runtime exception. *//*from ww w. ja v a2 s .c om*/ public static void checkGLError() throws RuntimeException { int var2 = GL11.glGetError(); if (var2 != 0) { String var3 = GLU.gluErrorString(var2); throw new RuntimeException("GL ERROR: " + var3 + "(" + var2 + ")"); } }