@Override public void updateTexture(TextureHandle texture, int left, int bottom, int width, int height, ShortBuffer data) { bindTexture(texture); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, left, bottom, width, height, GL11.GL_RGBA, GL12.GL_UNSIGNED_SHORT_4_4_4_4, data); }
@Override public TextureHandle generateTexture(int width, int height, ShortBuffer data, String name) { int texture = GL11.glGenTextures(); if (texture == 0) { return null; } //fix strange alpha test problem (minimap and landscape are unaffected) ShortBuffer bfr = BufferUtils.createShortBuffer(data.capacity()); int cap = data.capacity(); for(int i = 0;i != cap;i++) bfr.put(i, data.get(i)); TextureHandle textureHandle = new TextureHandle(this, texture); bindTexture(textureHandle); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL12.GL_UNSIGNED_SHORT_4_4_4_4, bfr); setTextureParameters(); setObjectLabel(GL11.GL_TEXTURE, texture, name + "-tex"); return textureHandle; }
public void drawTrianglesWithTextureColored(TextureHandle textureid, GeometryHandle shapeHandle, GeometryHandle colorHandle, int offset, int lines, int width, int stride, float x, float y) { bindTexture(textureid); int starti = offset < 0 ? (int)Math.ceil(-offset/(float)stride) : 0; if(lsz != -1) GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslatef(x, y, -.1f); GL11.glScalef(1, 1, 0); GL11.glMultMatrixf(heightMatrix); if(!tex_coord_on) { GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); tex_coord_on = true; } bindGeometry(shapeHandle); GL11.glVertexPointer(3, GL11.GL_FLOAT, 5 * 4, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 5 * 4, 3 * 4); bindGeometry(colorHandle); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, 0); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); for (int i = starti; i != lines; i++) { GL11.glDrawArrays(GL11.GL_TRIANGLES, (offset + stride * i) * 3, width * 3); } GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glPopMatrix(); lsz = -1; }
public void draw2D(GeometryHandle geometry, TextureHandle texture, int primitive, int offset, int vertices, float x, float y, float z, float sx, float sy, float sz, AbstractColor color, float intensity) { if(lx != x || ly != y || lz != z || lsx != sx || lsy != sy || lsz != sz) { if(lsz != -1) GL11.glPopMatrix(); GL11.glPushMatrix(); if(x != 0 || y != 0 || z != 0) GL11.glTranslatef(x, y, z); if(sx != 1 || sy != 1 || sz != 1) GL11.glScalef(sx, sy, sz); lx = x; lsx = sx; ly = y; lsy = sy; lz = z; lsz = sz; } if(color != null) { float r = color.red*intensity; float g = color.green*intensity; float b = color.blue*intensity; float a = color.alpha; if(lr != r || lg != g || lb != b || la != a) GL11.glColor4f(lr=r, lg=g, lb=b, la=a); } else { if(lr != lg || lr != lb || lr != intensity || la != 1) GL11.glColor4f(intensity, intensity, intensity, 1); lr = lg = lb = intensity; la = 1; } bindTexture(texture); bindGeometry(geometry); EGeometryFormatType format = geometry.getFormat(); if(format.getTexCoordPos() == -1) GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); specifyFormat(format); GL11.glDrawArrays(primitive, offset * vertices, vertices); if(format.getTexCoordPos() == -1) GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }