List of usage examples for org.lwjgl.opengl GL11 glTexSubImage2D
public static void glTexSubImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int xoffset, @NativeType("GLint") int yoffset, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @NativeType("void const *") double[] pixels)
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.image.TextureHandler.java
License:Apache License
public Texture updateTexture(Texture texture, Image image) { ByteBuffer imageData = prepareImage(image); GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT); GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, texture.getId().intValue()); GL11.glTexSubImage2D(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, image.getWidth(), image.getHeight(), (image.hasAlpha()) ? GL11.GL_RGBA : GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, imageData);//from ww w. j av a2s . co m return new Texture(texture.getId(), image); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void updateTexture(TextureHandle texture, int left, int bottom, int width, int height, ShortBuffer data) throws IllegalBufferException { bindTexture(texture);//www . j a v a 2 s. co m GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, left, bottom, width, height, GL11.GL_RGBA, GL12.GL_UNSIGNED_SHORT_4_4_4_4, data); }
From source file:illarion.graphics.lwjgl.TextureAtlasLWJGL.java
License:Open Source License
/** * Change a area of the texture.// w w w . j a v a 2 s . c o m * * @param x the x coordinate of the origin of the area that is changed * @param y the y coordinate of the origin of the area that is changed * @param w the width of the area that is changed * @param h the height of the area that is changed * @param imageData the image data that shall be updated */ @Override public void updateTextureArea(final int x, final int y, final int w, final int h, final ByteBuffer imageData) { DriverSettingsLWJGL.getInstance().enableTexture(getTextureID()); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, x, y, w, h, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, imageData); Util.checkGLError(); }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glTexSubImage2D(int glTexture2d, int i, int pageX, int pageY, int width, int height, int glBgra, int glUnsignedByte, ByteBuffer scratchByteBuffer) { GL11.glTexSubImage2D(glTexture2d, i, pageX, pageY, width, height, glBgra, glUnsignedByte, scratchByteBuffer);/* ww w . j a v a2 s . c o m*/ }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, Buffer pixels) { if (pixels instanceof ByteBuffer) GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (ByteBuffer) pixels); else if (pixels instanceof ShortBuffer) GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (ShortBuffer) pixels); else if (pixels instanceof IntBuffer) GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (IntBuffer) pixels); else if (pixels instanceof FloatBuffer) GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (FloatBuffer) pixels); else if (pixels instanceof DoubleBuffer) GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (DoubleBuffer) pixels); else/*from w w w.j a v a2 s . c o m*/ throw new RootException("Can't use " + pixels.getClass().getName() + " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. "); }
From source file:jake2.desktop.LWJGLAdapter.java
License:Open Source License
public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, ByteBuffer pixels) { GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); }
From source file:jake2.desktop.LWJGLAdapter.java
License:Open Source License
public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, IntBuffer pixels) { GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setTexSubImage(int level, int xOffset, int yOffset, int width, int height, int format, int type, int textureSize, Buffer buffer) { if (buffer instanceof ByteBuffer || buffer == null) { GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, level, xOffset, yOffset, width, height, textureFormatToGL[format], textureTypeToGL[type], getDirectBuffer(textureSize, (ByteBuffer) buffer)); } else if (buffer instanceof IntBuffer) { GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, level, xOffset, yOffset, width, height, textureFormatToGL[format], textureTypeToGL[type], getDirectBuffer(textureSize, (IntBuffer) buffer)); } else if (buffer instanceof ShortBuffer) { GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, level, xOffset, yOffset, width, height, textureFormatToGL[format], textureTypeToGL[type], getDirectBuffer(textureSize, (ShortBuffer) buffer)); } else if (buffer instanceof FloatBuffer) { GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, level, xOffset, yOffset, width, height, textureFormatToGL[format], textureTypeToGL[type], getDirectBuffer(textureSize, (FloatBuffer) buffer)); } else {/*from www .java2s. c o m*/ throw new IllegalArgumentException(); } }
From source file:kuake2.render.lwjgl.Surf.java
License:Open Source License
/** * R_RenderBrushPoly//from w w w . ja va 2 s .co m */ void R_RenderBrushPoly(msurface_t fa) { c_brush_polys++; image_t image = R_TextureAnimation(fa.texinfo); if ((fa.flags & Defines.SURF_DRAWTURB) != 0) { GL_Bind(image.texnum); // warp texture, no lightmaps GL_TexEnv(GL11.GL_MODULATE); GL11.glColor4f(gl_state.inverse_intensity, gl_state.inverse_intensity, gl_state.inverse_intensity, 1.0F); EmitWaterPolys(fa); GL_TexEnv(GL11.GL_REPLACE); return; } else { GL_Bind(image.texnum); GL_TexEnv(GL11.GL_REPLACE); } // ====== // PGM if ((fa.texinfo.flags & Defines.SURF_FLOWING) != 0) DrawGLFlowingPoly(fa.polys); else DrawGLPoly(fa.polys); // PGM // ====== // ersetzt goto boolean gotoDynamic = false; /* ** check for lightmap modification */ int maps; for (maps = 0; maps < Defines.MAXLIGHTMAPS && fa.styles[maps] != (byte) 255; maps++) { if (r_newrefdef.lightstyles[fa.styles[maps] & 0xFF].white != fa.cached_light[maps]) { gotoDynamic = true; break; } } // this is a hack from cwei if (maps == 4) maps--; // dynamic this frame or dynamic previously boolean is_dynamic = false; if (gotoDynamic || (fa.dlightframe == r_framecount)) { // label dynamic: if (gl_dynamic.value != 0) { if ((fa.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) == 0) { is_dynamic = true; } } } if (is_dynamic) { if (((fa.styles[maps] & 0xFF) >= 32 || fa.styles[maps] == 0) && (fa.dlightframe != r_framecount)) { // ist ersetzt durch temp2: unsigned temp[34*34]; int smax, tmax; smax = (fa.extents[0] >> 4) + 1; tmax = (fa.extents[1] >> 4) + 1; R_BuildLightMap(fa, temp2, smax); R_SetCacheState(fa); GL_Bind(gl_state.lightmap_textures + fa.lightmaptexturenum); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, fa.light_s, fa.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, GL11.GL_UNSIGNED_BYTE, temp2); fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum]; gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa; } else { fa.lightmapchain = gl_lms.lightmap_surfaces[0]; gl_lms.lightmap_surfaces[0] = fa; } } else { fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum]; gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa; } }
From source file:kuake2.render.lwjgl.Surf.java
License:Open Source License
/** * GL_RenderLightmappedPoly//ww w . ja v a2s.c o m * * @param surf */ void GL_RenderLightmappedPoly(msurface_t surf) { // ersetzt goto boolean gotoDynamic = false; int map; for (map = 0; map < Defines.MAXLIGHTMAPS && (surf.styles[map] != (byte) 255); map++) { if (r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map]) { gotoDynamic = true; break; } } // this is a hack from cwei if (map == 4) map--; // dynamic this frame or dynamic previously boolean is_dynamic = false; if (gotoDynamic || (surf.dlightframe == r_framecount)) { // label dynamic: if (gl_dynamic.value != 0) { if ((surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) == 0) { is_dynamic = true; } } } glpoly_t p; image_t image = R_TextureAnimation(surf.texinfo); int lmtex = surf.lightmaptexturenum; if (is_dynamic) { // ist raus gezogen worden int[] temp = new int[128*128]; int smax, tmax; if (((surf.styles[map] & 0xFF) >= 32 || surf.styles[map] == 0) && (surf.dlightframe != r_framecount)) { smax = (surf.extents[0] >> 4) + 1; tmax = (surf.extents[1] >> 4) + 1; R_BuildLightMap(surf, temp, smax); R_SetCacheState(surf); GL_MBind(GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum); lmtex = surf.lightmaptexturenum; GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, surf.light_s, surf.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, GL11.GL_UNSIGNED_BYTE, temp); } else { smax = (surf.extents[0] >> 4) + 1; tmax = (surf.extents[1] >> 4) + 1; R_BuildLightMap(surf, temp, smax); GL_MBind(GL_TEXTURE1, gl_state.lightmap_textures + 0); lmtex = 0; GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, surf.light_s, surf.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, GL11.GL_UNSIGNED_BYTE, temp); } c_brush_polys++; GL_MBind(GL_TEXTURE0, image.texnum); GL_MBind(GL_TEXTURE1, gl_state.lightmap_textures + lmtex); // ========== // PGM if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0) { float scroll; scroll = -64 * ((r_newrefdef.time / 40.0f) - (int) (r_newrefdef.time / 40.0f)); if (scroll == 0.0f) scroll = -64.0f; for (p = surf.polys; p != null; p = p.chain) { p.beginScrolling(scroll); GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); } } else { for (p = surf.polys; p != null; p = p.chain) { GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); } } // PGM // ========== } else { c_brush_polys++; GL_MBind(GL_TEXTURE0, image.texnum); GL_MBind(GL_TEXTURE1, gl_state.lightmap_textures + lmtex); // ========== // PGM if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0) { float scroll; scroll = -64 * ((r_newrefdef.time / 40.0f) - (int) (r_newrefdef.time / 40.0f)); if (scroll == 0.0) scroll = -64.0f; for (p = surf.polys; p != null; p = p.chain) { p.beginScrolling(scroll); GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); } } else { // PGM // ========== for (p = surf.polys; p != null; p = p.chain) { GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); } // ========== // PGM } // PGM // ========== } }