private void prepareTexturedModel(TexturedModel model) { RawModel rawModel = model.getRawModel(); GL30.glBindVertexArray(rawModel.getVaoID()); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); ModelTexture texture = model.getTexture(); if(texture.isHasTransparency()) { MasterRenderer.disableCulling(); } shader.loadFakeLightingVariable(texture.isUseFakeLighting()); shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity()); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID()); }
public static void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, int level) { if (framebufferSupported) { switch (framebufferType) { case BASE: GL30.glFramebufferTexture2D(target, attachment, textarget, texture, level); break; case ARB: ARBFramebufferObject.glFramebufferTexture2D(target, attachment, textarget, texture, level); break; case EXT: EXTFramebufferObject.glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); } } }
/** * Renders the world to the water framebuffer. * @param worldCamera * @param world */ public void preRender(final PerspectiveCamera camera, final World world) { GL11.glEnable(GL30.GL_CLIP_DISTANCE0); framebuffer.bind(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Render to reflection texture. float verticalDistance = camera.getPosition().y - WATER_HEIGHT; camera.getPosition().y -= verticalDistance * 2; camera.invertPitch(); camera.update(); world.renderWithoutWater(camera, true); camera.invertPitch(); camera.getPosition().y += verticalDistance * 2; camera.update(); FrameBuffer.unbind(); GL11.glDisable(GL30.GL_CLIP_DISTANCE0); }
/** * Calls the appropriate glGenFramebuffers method and returns the newly created fbo, or returns -1 if not supported. */ public static int glGenFramebuffers() { if (!framebufferSupported) { return -1; } else { switch (framebufferType) { case BASE: return GL30.glGenFramebuffers(); case ARB: return ARBFramebufferObject.glGenFramebuffers(); case EXT: return EXTFramebufferObject.glGenFramebuffersEXT(); default: return -1; } } }
public static void glDeleteRenderbuffers(int renderbuffer) { if (framebufferSupported) { switch (framebufferType) { case BASE: GL30.glDeleteRenderbuffers(renderbuffer); break; case ARB: ARBFramebufferObject.glDeleteRenderbuffers(renderbuffer); break; case EXT: EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffer); } } }
private void prepareTexturedModel(final TexturedModel model) { GL30.glBindVertexArray(model.getRawModel().getVaoId()); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); if (model.getTexture().isHasTransparency()) { MasterRenderer.disableCulling(); } shader.loadFakeLightingVariable(model.getTexture().isUseFakeLighting()); shader.loadShineVariables( model.getTexture().getShineDamper(), model.getTexture().getReflectivity() ); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureId()); }
public static void glBindFramebuffer(int target, int framebufferIn) { if (framebufferSupported) { switch (framebufferType) { case BASE: GL30.glBindFramebuffer(target, framebufferIn); break; case ARB: ARBFramebufferObject.glBindFramebuffer(target, framebufferIn); break; case EXT: EXTFramebufferObject.glBindFramebufferEXT(target, framebufferIn); } } }
public static void glRenderbufferStorage(int target, int internalFormat, int width, int height) { if (framebufferSupported) { switch (framebufferType) { case BASE: GL30.glRenderbufferStorage(target, internalFormat, width, height); break; case ARB: ARBFramebufferObject.glRenderbufferStorage(target, internalFormat, width, height); break; case EXT: EXTFramebufferObject.glRenderbufferStorageEXT(target, internalFormat, width, height); } } }
public static void glFramebufferRenderbuffer(int target, int attachment, int renderBufferTarget, int renderBuffer) { if (framebufferSupported) { switch (framebufferType) { case BASE: GL30.glFramebufferRenderbuffer(target, attachment, renderBufferTarget, renderBuffer); break; case ARB: ARBFramebufferObject.glFramebufferRenderbuffer(target, attachment, renderBufferTarget, renderBuffer); break; case EXT: EXTFramebufferObject.glFramebufferRenderbufferEXT(target, attachment, renderBufferTarget, renderBuffer); } } }
public static void glBindRenderbuffer(int target, int renderbuffer) { if (framebufferSupported) { switch (framebufferType) { case 0: GL30.glBindRenderbuffer(target, renderbuffer); break; case 1: ARBFramebufferObject.glBindRenderbuffer(target, renderbuffer); break; case 2: EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer); } } }
public static void glDeleteRenderbuffers(int renderbuffer) { if (framebufferSupported) { switch (framebufferType) { case 0: GL30.glDeleteRenderbuffers(renderbuffer); break; case 1: ARBFramebufferObject.glDeleteRenderbuffers(renderbuffer); break; case 2: EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffer); } } }
public static void glDeleteFramebuffers(int framebufferIn) { if (framebufferSupported) { switch (framebufferType) { case 0: GL30.glDeleteFramebuffers(framebufferIn); break; case 1: ARBFramebufferObject.glDeleteFramebuffers(framebufferIn); break; case 2: EXTFramebufferObject.glDeleteFramebuffersEXT(framebufferIn); } } }
public static void glRenderbufferStorage(int target, int internalFormat, int width, int height) { if (framebufferSupported) { switch (framebufferType) { case 0: GL30.glRenderbufferStorage(target, internalFormat, width, height); break; case 1: ARBFramebufferObject.glRenderbufferStorage(target, internalFormat, width, height); break; case 2: EXTFramebufferObject.glRenderbufferStorageEXT(target, internalFormat, width, height); } } }
public static void glBindRenderbuffer(int target, int renderbuffer) { if (framebufferSupported) { switch (framebufferType) { case BASE: GL30.glBindRenderbuffer(target, renderbuffer); break; case ARB: ARBFramebufferObject.glBindRenderbuffer(target, renderbuffer); break; case EXT: EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer); } } }
public static int glCheckFramebufferStatus(int target) { if (!framebufferSupported) { return -1; } else { switch (framebufferType) { case 0: return GL30.glCheckFramebufferStatus(target); case 1: return ARBFramebufferObject.glCheckFramebufferStatus(target); case 2: return EXTFramebufferObject.glCheckFramebufferStatusEXT(target); default: return -1; } } }
public static void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, int level) { if (framebufferSupported) { switch (framebufferType) { case 0: GL30.glFramebufferTexture2D(target, attachment, textarget, texture, level); break; case 1: ARBFramebufferObject.glFramebufferTexture2D(target, attachment, textarget, texture, level); break; case 2: EXTFramebufferObject.glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); } } }
/** * Creates an OpenGL texture based on a given Image * @param id OpenGL reference id to create texture in * @param image */ private void createTexture(int id, Image image) { // Set as texture 0 GL13.glActiveTexture(GL13.GL_TEXTURE0); bind(); // Set pixel storage mode GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); // Setup texture GL11.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GL11.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GL11.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width, image.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image.buffer); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); unbind(); }
public static void genCompositeMipmap() { if (hasGlGenMipmap) { for (int i = 0; i < usedColorBuffers; ++i) { if ((activeCompositeMipmapSetting & 1 << i) != 0) { GlStateManager.setActiveTexture(33984 + colorTextureTextureImageUnit[i]); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GL30.glGenerateMipmap(3553); } } GlStateManager.setActiveTexture(33984); } }
public static final void render(final Vec3 position, final float scale) { shader.start(); GL30.glBindVertexArray(model.id); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); shader.loadTransformationMatrix(MatrixCreation.createTransformationMatrix(position, new Vec3(), new Vec3(scale, 1, scale))); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, model.vertexCount); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); shader.stop(); }
public static void glDeleteFramebuffers(int framebufferIn) { if (framebufferSupported) { switch (framebufferType) { case BASE: GL30.glDeleteFramebuffers(framebufferIn); break; case ARB: ARBFramebufferObject.glDeleteFramebuffers(framebufferIn); break; case EXT: EXTFramebufferObject.glDeleteFramebuffersEXT(framebufferIn); } } }
public static void glBindFramebuffer(int target, int framebufferIn) { if (framebufferSupported) { switch (framebufferType) { case 0: GL30.glBindFramebuffer(target, framebufferIn); break; case 1: ARBFramebufferObject.glBindFramebuffer(target, framebufferIn); break; case 2: EXTFramebufferObject.glBindFramebufferEXT(target, framebufferIn); } } }
/** * Calls the appropriate glGenFramebuffers method and returns the newly created fbo, or returns -1 if not supported. */ public static int glGenFramebuffers() { if (!framebufferSupported) { return -1; } else { switch (framebufferType) { case 0: return GL30.glGenFramebuffers(); case 1: return ARBFramebufferObject.glGenFramebuffers(); case 2: return EXTFramebufferObject.glGenFramebuffersEXT(); default: return -1; } } }
public void add(float[] vertices, float[] texCoords, int[] indices) { indicesSize = indices.length; GL30.glBindVertexArray(vao); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, Util.flip(vertices), GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboTexture); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, Util.flip(texCoords), GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboi); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, Util.flip(indices), GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); }
public static void glFramebufferRenderbuffer(int target, int attachment, int renderBufferTarget, int renderBuffer) { if (framebufferSupported) { switch (framebufferType) { case 0: GL30.glFramebufferRenderbuffer(target, attachment, renderBufferTarget, renderBuffer); break; case 1: ARBFramebufferObject.glFramebufferRenderbuffer(target, attachment, renderBufferTarget, renderBuffer); break; case 2: EXTFramebufferObject.glFramebufferRenderbufferEXT(target, attachment, renderBufferTarget, renderBuffer); } } }