List of usage examples for org.lwjgl.opengl GL11 glTexParameteri
public static void glTexParameteri(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint") int param)
From source file:opengl.test.object.image.java
@Override protected void initVertex() { GL30.glBindVertexArray(vao);//bind vao // position color texCoord float[] data = new float[] { -x, -y, z, 1f, 1f, 1f, 0f, 0f, x, -y, z, 1f, 1f, 1f, 1f, 0f, -x, y, z, 1f, 1f, 1f, 0f, 1f, x, y, z, 1f, 1f, 1f, 1f, 1f }; dataBuffer = BufferUtils.createFloatBuffer(data.length); dataBuffer.put(data);// w ww .j a v a 2s. c o m dataBuffer.flip(); Logger.getGlobal().log(Level.SEVERE, "FloatBuffer capacity : " + dataBuffer.capacity()); this.vbo = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, dataBuffer, GL15.GL_STATIC_DRAW); this.VertexAttribPointer(); int[] indices = { 0, 1, 2, 2, 1, 3 }; IntBuffer indicesBuffer = BufferUtils.createIntBuffer(indices.length); indicesBuffer.put(indices); indicesBuffer.flip(); this.ebo = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_DYNAMIC_DRAW); IntBuffer w = BufferUtils.createIntBuffer(1); IntBuffer h = BufferUtils.createIntBuffer(1); IntBuffer comp = BufferUtils.createIntBuffer(1); STBImage.stbi_set_flip_vertically_on_load(1); ByteBuffer image = STBImage.stbi_load(this.link, w, h, comp, 0); int weight = w.get(0); int height = h.get(0); int compe = comp.get(0); Logger.getGlobal().log(Level.FINEST, "STBImage load status : " + weight + " " + height + " " + compe + " " + image); textureID = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, weight, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, image); GL30.glBindVertexArray(0);//unbind vao }
From source file:opengl.test.object.table.table.java
@Override protected void initVertex() { GL30.glBindVertexArray(vao);//bind vao Object[] dataInput = objLoad.Wavefront( table.class.getClassLoader().getResourceAsStream("opengl/test/object/table/table.obj"), 1.0f, 1.0f, 1.0f);//ww w . j av a 2 s .com super.dataBuffer = (FloatBuffer) dataInput[0]; this.size = (int) dataInput[1]; this.vbo = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, super.dataBuffer, GL15.GL_STATIC_DRAW); this.VertexAttribPointer(); IntBuffer w = BufferUtils.createIntBuffer(1); IntBuffer h = BufferUtils.createIntBuffer(1); IntBuffer comp = BufferUtils.createIntBuffer(1); STBImage.stbi_set_flip_vertically_on_load(1); ByteBuffer image = STBImage.stbi_load("resource/wood2.png", w, h, comp, 0); int weight = w.get(0); int height = h.get(0); int compe = comp.get(0); Logger.getGlobal().log(Level.FINEST, "STBImage load status : " + weight + " " + height + " " + compe + " " + image); textureID = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, weight, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, image); GL30.glBindVertexArray(0);//unbind vao }
From source file:opengl.test.object.tivi.tivi.java
@Override protected void initVertex() { GL30.glBindVertexArray(vao);//bind vao Object[] dataInput = objLoad.Wavefront( tivi.class.getClassLoader().getResourceAsStream("opengl/test/object/tivi/tivi.obj"), 1.0f, 1.0f, 1.0f);//from w w w. j a v a2 s. c o m super.dataBuffer = (FloatBuffer) dataInput[0]; this.size = (int) dataInput[1]; this.vbo = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, super.dataBuffer, GL15.GL_STATIC_DRAW); this.VertexAttribPointer(); IntBuffer w = BufferUtils.createIntBuffer(1); IntBuffer h = BufferUtils.createIntBuffer(1); IntBuffer comp = BufferUtils.createIntBuffer(1); STBImage.stbi_set_flip_vertically_on_load(1); ByteBuffer image = STBImage.stbi_load("resource/success.png", w, h, comp, 0); textureID = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, w.get(0), h.get(0), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, image); GL30.glBindVertexArray(0);//unbind vao }
From source file:org.agpu.oc.client.ClientProxy.java
@Override public int setup2DScreenTextureTarget(int w, int h) { //Generate Texture Space int texture = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); //Generate Blank Texture GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, w, h, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_INT, (IntBuffer) null);//from w w w . j a v a2s . c o m //Poor filtering. Needed! GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); System.out.println("Generated AGPU output texture"); return texture; }
From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java
License:Open Source License
public void setupStateVariables(boolean depthTestEnabled) { GL11.glEnable(GL11.GL_BLEND);//from w w w . j a va 2 s . c om // GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (depthTestEnabled) GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_DITHER); GL11.glEnable(GL11.GL_SCISSOR_TEST); //GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glDisable(GL11.GL_LINE_STIPPLE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL); //GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_CULL_FACE); // GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glFrontFace(GL11.GL_CW); GL11.glCullFace(GL11.GL_BACK); // disabling textures after setting state values. They would // be ignored otherwise (i think) GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); }
From source file:org.fenggui.render.lwjgl.LWJGLOpenGL.java
License:Open Source License
public void setupStateVariables(boolean depthTestEnabled) { GL11.glEnable(GL11.GL_BLEND);/*from w w w . j av a 2s .c o m*/ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (depthTestEnabled) GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_DITHER); GL11.glEnable(GL11.GL_SCISSOR_TEST); //GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glDisable(GL11.GL_LINE_STIPPLE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL); //GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glFrontFace(GL11.GL_CW); GL11.glCullFace(GL11.GL_BACK); // disabling textures after setting state values. They would // be ignored otherwise (i think) GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); }
From source file:org.free.jake2.render.lwjgl.Image.java
License:Open Source License
void GL_TextureMode(String string) { int i;//from w ww .j ava 2 s .co m for (i = 0; i < NUM_GL_MODES; i++) { if (modes[i].name.equalsIgnoreCase(string)) { break; } } if (i == NUM_GL_MODES) { VID.Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n"); return; } gl_filter_min = modes[i].minimize; gl_filter_max = modes[i].maximize; image_t glt; // change all the existing mipmap texture objects for (i = 0; i < numgltextures; i++) { glt = gltextures[i]; if (glt.type != it_pic && glt.type != it_sky) { GL_Bind(glt.texnum); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); } } }
From source file:org.fusfoundation.kranion.ImageLabel.java
License:Open Source License
private void buildTexture(String resource) { BufferedImage img = null;/*from ww w . jav a2 s .co m*/ try { InputStream rstm = this.getClass().getResourceAsStream(resource); img = ImageIO.read(rstm); } catch (IOException e) { return; } try { //Create the PNGDecoder object and decode the texture to a buffer int width = img.getWidth(), height = img.getHeight(); bounds.width = width; bounds.height = height; byte buf[] = (byte[]) img.getRaster().getDataElements(0, 0, width, height, null); ByteBuffer pixelData = ByteBuffer.allocateDirect(buf.length); pixelData.put(buf, 0, buf.length); pixelData.flip(); if (texName != 0) { deleteTexture(); } //Generate and bind the texture texName = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texName); //Upload the buffer's content to the VRAM GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, pixelData); //Apply filters GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.getspout.spout.config.MipMapUtils.java
License:Open Source License
public static void initalizeTexture(int textureId) { GL11.glBindTexture(3553, textureId); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); int textureWidth = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); int tileWidth = textureWidth / 16; setMipmapLevels(textureId, (int) Math.round(Math.log((double) tileWidth) / Math.log(2D))); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, getMipmapLevels(textureId)); ContextCapabilities capabilities = GLContext.getCapabilities(); if (capabilities.OpenGL30) { MipMapUtils.mode = 1;//from w w w . ja v a2 s . c o m } else if (capabilities.GL_EXT_framebuffer_object) { MipMapUtils.mode = 2; } else if (capabilities.OpenGL14) { MipMapUtils.mode = 3; GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE); } }
From source file:org.getspout.spout.config.MipMapUtils.java
License:Open Source License
public static void update(int texture) { GL11.glPushMatrix();// w w w. j a v a 2 s .c o m if (MipMapUtils.mode == 3) { MipMapUtils.updateTerrain = ConfigReader.mipmapsPercent > 0F; GL11.glBindTexture(3553, texture); if (ConfigReader.mipmapsPercent > 0F) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); } GL11.glPopMatrix(); return; } if (ConfigReader.mipmapsPercent > 0F) { MipMapUtils.updateTerrain = true; GL11.glBindTexture(3553, texture); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); } GL11.glPopMatrix(); }