List of usage examples for org.lwjgl.opengl GL11 glBindTexture
public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture)
From source file:net.neilcsmith.praxis.video.opengl.internal.Texture.java
License:Apache License
private void init() { glHandle = createGLHandle();//from ww w . j av a2s .c o m GL11.glBindTexture(GL11.GL_TEXTURE_2D, glHandle); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, dstImageFormat, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, BufferUtils.createIntBuffer(width * height)); setFilter(minFilter, magFilter); setWrap(uWrap, vWrap); getFrameBuffer(); }
From source file:net.neilcsmith.praxis.video.opengl.internal.Texture.java
License:Apache License
/** Binds this texture. The texture will be bound to the currently active texture unit specified via * {@link GLCommon#glActiveTexture(int)}. */ public void bind() { GL11.glBindTexture(GL11.GL_TEXTURE_2D, glHandle); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
void drawSprite(float x, float y, int flipmode, SpriteGL sprite) { flipmode = getflipMode(flipmode);/* w ww. j a v a2 s . c om*/ float x2 = x + sprite.width; float y2 = y + sprite.height; float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2; float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2; float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1; float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1; if (sprite.textureID != currentTexture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID); currentTexture = sprite.textureID; } GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x, y); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x, y2); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(x2, y); GL11.glEnd(); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
private void drawSprite(float x, float y, float r, float g, float b, float a, int flipmode, SpriteGL sprite) { flipmode = getflipMode(flipmode);// w w w . j ava2 s . c o m float x2 = x + sprite.width; float y2 = y + sprite.height; float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2; float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2; float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1; float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1; if (sprite.textureID != currentTexture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID); currentTexture = sprite.textureID; } GL11.glColor4f(r, g, b, a); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x, y); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x, y2); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(x2, y); GL11.glEnd(); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
private void drawTransformedSprite(float x, float y, float angle, float scaleX, float scaleY, int flipmode, SpriteGL sprite) {/*from w w w . j av a2s. com*/ flipmode = getflipMode(flipmode); float s_half_x = sprite.width / 2.0f; float s_half_y = sprite.height / 2.0f; float x1 = -s_half_x; float y1 = -s_half_y; float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2; float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2; float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1; float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1; if (sprite.textureID != currentTexture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID); currentTexture = sprite.textureID; } GL11.glPushMatrix(); GL11.glTranslatef(x, y, 0.0f); GL11.glScalef(scaleX, scaleY, 1.0f); GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, y1); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x1, s_half_y); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(s_half_x, s_half_y); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(s_half_x, y1); GL11.glEnd(); GL11.glPopMatrix(); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
private void drawTransformedSprite(float x, float y, float angle, float scaleX, float scaleY, float r, float g, float b, float a, int flipmode, SpriteGL sprite) { flipmode = getflipMode(flipmode);//from w w w .ja v a2s. c om float s_half_x = sprite.width / 2.0f; float s_half_y = sprite.height / 2.0f; float x1 = -s_half_x; float y1 = -s_half_y; float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2; float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2; float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1; float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1; if (sprite.textureID != currentTexture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID); currentTexture = sprite.textureID; } GL11.glColor4f(r, g, b, a); GL11.glPushMatrix(); GL11.glTranslatef(x, y, 0.0f); GL11.glScalef(scaleX, scaleY, 1.0f); GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, y1); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x1, s_half_y); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(s_half_x, s_half_y); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(s_half_x, y1); GL11.glEnd(); GL11.glPopMatrix(); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawSpriteOnLine(int x1, int y1, int x2, int y2, int width, int type) { SpriteGL sprite = glowImages.getSprite(type % glowImages.getNumImages()); // Only change active texture when there is a need // Speeds up the rendering by batching textures if (sprite.textureID != currentTexture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID); currentTexture = sprite.textureID; }/*from w w w .java2 s. c o m*/ float u1 = sprite.u1; float v1 = sprite.v1; float u2 = sprite.u2; float v2 = sprite.v2; float uh = (u1 + u2) / 2.0f; float nx, ny; nx = -(y2 - y1); ny = (x2 - x1); float leng; leng = (float) Math.sqrt(nx * nx + ny * ny); nx = nx / leng; ny = ny / leng; nx *= width / 2.0; ny *= width / 2.0; float lx1, ly1, lx2, ly2, lx3, ly3, lx4, ly4; lx1 = x2 + nx; ly1 = y2 + ny; lx2 = x2 - nx; ly2 = y2 - ny; lx3 = x1 - nx; ly3 = y1 - ny; lx4 = x1 + nx; ly4 = y1 + ny; // MAIN GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(uh, v1); GL11.glVertex3f(lx1, ly1, 0.0f); GL11.glTexCoord2f(uh, v2); GL11.glVertex3f(lx2, ly2, 0.0f); GL11.glTexCoord2f(uh, v2); GL11.glVertex3f(lx3, ly3, 0.0f); GL11.glTexCoord2f(uh, v1); GL11.glVertex3f(lx4, ly4, 0.0f); GL11.glEnd(); //RIGHT float lx5, ly5, lx6, ly6, vx, vy; vx = (x2 - x1); vy = (y2 - y1); leng = (float) Math.sqrt(vx * vx + vy * vy); vx = vx / leng; vy = vy / leng; vx *= width / 2.0; vy *= width / 2.0; lx5 = lx1 + vx; ly5 = ly1 + vy; lx6 = lx2 + vx; ly6 = ly2 + vy; GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(uh, v1); GL11.glVertex3f(lx1, ly1, 0.0f); GL11.glTexCoord2f(u2, v1); GL11.glVertex3f(lx5, ly5, 0.0f); GL11.glTexCoord2f(u2, v2); GL11.glVertex3f(lx6, ly6, 0.0f); GL11.glTexCoord2f(uh, v2); GL11.glVertex3f(lx2, ly2, 0.0f); GL11.glEnd(); // LEFT lx5 = lx4 - vx; ly5 = ly4 - vy; lx6 = lx3 - vx; ly6 = ly3 - vy; GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(uh, v1); GL11.glVertex3f(lx4, ly4, 0.0f); GL11.glTexCoord2f(uh, v2); GL11.glVertex3f(lx3, ly3, 0.0f); GL11.glTexCoord2f(u2, v2); GL11.glVertex3f(lx6, ly6, 0.0f); GL11.glTexCoord2f(u2, v1); GL11.glVertex3f(lx5, ly5, 0.0f); GL11.glEnd(); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawSpriteOnLine(int x1, int y1, int x2, int y2, int width, int type, float r, float g, float b, float a) { SpriteGL sprite = glowImages.getSprite(type % glowImages.getNumImages()); // Only change active texture when there is a need // Speeds up the rendering by batching textures if (sprite.textureID != currentTexture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID); currentTexture = sprite.textureID; }/* w ww. j av a2s. co m*/ GL11.glColor4f(r, g, b, a); float u1 = sprite.u1; float v1 = sprite.v1; float u2 = sprite.u2; float v2 = sprite.v2; float uh = (u1 + u2) / 2.0f; float nx, ny; nx = -(y2 - y1); ny = (x2 - x1); float leng; leng = (float) Math.sqrt(nx * nx + ny * ny); nx = nx / leng; ny = ny / leng; nx *= width / 2.0; ny *= width / 2.0; float lx1, ly1, lx2, ly2, lx3, ly3, lx4, ly4; lx1 = x2 + nx; ly1 = y2 + ny; lx2 = x2 - nx; ly2 = y2 - ny; lx3 = x1 - nx; ly3 = y1 - ny; lx4 = x1 + nx; ly4 = y1 + ny; // MAIN GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(uh, v1); GL11.glVertex3f(lx1, ly1, 0.0f); GL11.glTexCoord2f(uh, v2); GL11.glVertex3f(lx2, ly2, 0.0f); GL11.glTexCoord2f(uh, v2); GL11.glVertex3f(lx3, ly3, 0.0f); GL11.glTexCoord2f(uh, v1); GL11.glVertex3f(lx4, ly4, 0.0f); GL11.glEnd(); //RIGHT float lx5, ly5, lx6, ly6, vx, vy; vx = (x2 - x1); vy = (y2 - y1); leng = (float) Math.sqrt(vx * vx + vy * vy); vx = vx / leng; vy = vy / leng; vx *= width / 2.0; vy *= width / 2.0; lx5 = lx1 + vx; ly5 = ly1 + vy; lx6 = lx2 + vx; ly6 = ly2 + vy; GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(uh, v1); GL11.glVertex3f(lx1, ly1, 0.0f); GL11.glTexCoord2f(u2, v1); GL11.glVertex3f(lx5, ly5, 0.0f); GL11.glTexCoord2f(u2, v2); GL11.glVertex3f(lx6, ly6, 0.0f); GL11.glTexCoord2f(uh, v2); GL11.glVertex3f(lx2, ly2, 0.0f); GL11.glEnd(); // LEFT lx5 = lx4 - vx; ly5 = ly4 - vy; lx6 = lx3 - vx; ly6 = ly3 - vy; GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(uh, v1); GL11.glVertex3f(lx4, ly4, 0.0f); GL11.glTexCoord2f(uh, v2); GL11.glVertex3f(lx3, ly3, 0.0f); GL11.glTexCoord2f(u2, v2); GL11.glVertex3f(lx6, ly6, 0.0f); GL11.glTexCoord2f(u2, v1); GL11.glVertex3f(lx5, ly5, 0.0f); GL11.glEnd(); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
private void drawScrolledSprite(float x, float y, float scaleX, float scaleY, float u, float v, int flipmode, SpriteGL sprite) {/* ww w .j a v a 2 s. c o m*/ flipmode = getflipMode(flipmode); float x2 = x + sprite.width; float y2 = y + sprite.height; float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2; float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2; float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1; float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1; if (sprite.textureID != currentTexture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID); currentTexture = sprite.textureID; } GL11.glPushMatrix(); GL11.glScalef(scaleX, scaleY, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1 + u, v1 + v); GL11.glVertex2f(x, y); GL11.glTexCoord2f(u1 + u, v2 + v); GL11.glVertex2f(x, y2); GL11.glTexCoord2f(u2 + u, v2 + v); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2 + u, v1 + v); GL11.glVertex2f(x2, y); GL11.glEnd(); GL11.glPopMatrix(); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
private void drawScrolledSprite(float x, float y, float scaleX, float scaleY, float u, float v, float r, float g, float b, float a, int flipmode, SpriteGL sprite) { flipmode = getflipMode(flipmode);// w w w . ja v a 2s.c om float x2 = x + sprite.width; float y2 = y + sprite.height; float u1 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u1 : sprite.u2; float v1 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v1 : sprite.v2; float u2 = ((flipmode & SpriteGL.FLIP_H) == 0) ? sprite.u2 : sprite.u1; float v2 = ((flipmode & SpriteGL.FLIP_V) == 0) ? sprite.v2 : sprite.v1; if (sprite.textureID != currentTexture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.textureID); currentTexture = sprite.textureID; } GL11.glColor4f(r, g, b, a); GL11.glPushMatrix(); GL11.glScalef(scaleX, scaleY, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1 + u, v1 + v); GL11.glVertex2f(x, y); GL11.glTexCoord2f(u1 + u, v2 + v); GL11.glVertex2f(x, y2); GL11.glTexCoord2f(u2 + u, v2 + v); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2 + u, v1 + v); GL11.glVertex2f(x2, y); GL11.glEnd(); GL11.glPopMatrix(); }