List of usage examples for org.lwjgl.opengl GL11 glBegin
public static native void glBegin(@NativeType("GLenum") int mode);
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawBoxFilled(int x1, int y1, int x2, int y2, float r, float g, float b, float a) { GL11.glDisable(GL11.GL_TEXTURE_2D);/* w ww. j a va 2s .co m*/ GL11.glColor4f(r, g, b, a); x2++; y2++; GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x1, y1); GL11.glVertex2i(x1, y2); GL11.glVertex2i(x2, y2); GL11.glVertex2i(x2, y1); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1, 1, 1, 1); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawBoxFilled(int x1, int y1, int x2, int y2) { GL11.glDisable(GL11.GL_TEXTURE_2D);//from ww w. j a v a 2s .c o m x2++; y2++; GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x1, y1); GL11.glVertex2i(x1, y2); GL11.glVertex2i(x2, y2); GL11.glVertex2i(x2, y1); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawEllipse(int x, int y, int a, int b, int degrees, float red, float green, float blue, float alpha) { // these constants decide the quality of the ellipse final float pi = (float) Math.PI; final float twopi = 2 * pi; // two pi (radians in a circle) final int face_length = 8; // approx. face length in pixels final int max_faces = 256; // maximum number of faces in ellipse final int min_faces = 16; // minimum number of faces in ellipse // approx. ellipse circumference (hudson's method) float h = (a - b * a - b) / (float) (a + b * a + b); float circumference = 0.25f * pi * (a + b) * (3 * (1 + h * 0.25f) + 1 / (1 - h * 0.25f)); // number of faces in ellipse int num_faces = (int) (circumference / (float) face_length); // clamp number of faces if (num_faces > max_faces) num_faces = max_faces;/*from w w w . j a v a2s . c om*/ if (num_faces < min_faces) num_faces = min_faces; // keep number of faces divisible by 4 num_faces -= (num_faces & 3); // precalc cosine theta float angle = degrees * pi / 180.0f; float s = (float) Math.sin(twopi / (float) num_faces); float c = (float) Math.cos(twopi / (float) num_faces); float xx = 1; float yy = 0; float xt; float ax = (float) Math.cos(angle); float ay = (float) Math.sin(angle); // draw ellipse GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4f(red, green, blue, alpha); int i; GL11.glBegin(GL11.GL_LINE_LOOP); for (i = 0; i < num_faces; i++) { xt = xx; xx = c * xx - s * yy; yy = s * xt + c * yy; GL11.glVertex2f(x + a * xx * ax - b * yy * ay, y + a * xx * ay + b * yy * ax); } GL11.glVertex2f(x + a * ax, y + a * ay); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1, 1, 1, 1); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawEllipse(int x, int y, int a, int b, int degrees) { // these constants decide the quality of the ellipse final float pi = (float) Math.PI; final float twopi = 2 * pi; // two pi (radians in a circle) final int face_length = 8; // approx. face length in pixels final int max_faces = 256; // maximum number of faces in ellipse final int min_faces = 16; // minimum number of faces in ellipse // approx. ellipse circumference (hudson's method) float h = (a - b * a - b) / (float) (a + b * a + b); float circumference = 0.25f * pi * (a + b) * (3 * (1 + h * 0.25f) + 1 / (1 - h * 0.25f)); // number of faces in ellipse int num_faces = (int) (circumference / (float) face_length); // clamp number of faces if (num_faces > max_faces) num_faces = max_faces;/*from w ww .j a v a 2 s. c om*/ if (num_faces < min_faces) num_faces = min_faces; // keep number of faces divisible by 4 num_faces -= (num_faces & 3); // precalc cosine theta float angle = degrees * pi / 180.0f; float s = (float) Math.sin(twopi / (float) num_faces); float c = (float) Math.cos(twopi / (float) num_faces); float xx = 1; float yy = 0; float xt; float ax = (float) Math.cos(angle); float ay = (float) Math.sin(angle); // draw ellipse GL11.glDisable(GL11.GL_TEXTURE_2D); int i; GL11.glBegin(GL11.GL_LINE_LOOP); for (i = 0; i < num_faces; i++) { xt = xx; xx = c * xx - s * yy; yy = s * xt + c * yy; GL11.glVertex2f(x + a * xx * ax - b * yy * ay, y + a * xx * ay + b * yy * ax); } GL11.glVertex2f(x + a * ax, y + a * ay); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawEllipseFilled(int x, int y, int a, int b, int degrees, float red, float green, float blue, float alpha) { // these constants decide the quality of the ellipse final float pi = (float) Math.PI; final float twopi = 2 * pi; // two pi (radians in a circle) final int face_length = 8; // approx. face length in pixels final int max_faces = 256; // maximum number of faces in ellipse final int min_faces = 16; // minimum number of faces in ellipse // approx. ellipse circumference (hudson's method) float h = (a - b * a - b) / (float) (a + b * a + b); float circumference = 0.25f * pi * (a + b) * (3 * (1 + h * 0.25f) + 1 / (1 - h * 0.25f)); // number of faces in ellipse int num_faces = (int) (circumference / (float) face_length); // clamp number of faces if (num_faces > max_faces) num_faces = max_faces;/* w w w . ja v a2 s .c om*/ if (num_faces < min_faces) num_faces = min_faces; // keep number of faces divisible by 4 num_faces -= (num_faces & 3); // precalc cosine theta float angle = degrees * pi / 180.0f; float s = (float) Math.sin(twopi / (float) num_faces); float c = (float) Math.cos(twopi / (float) num_faces); float xx = 1; float yy = 0; float xt; float ax = (float) Math.cos(angle); float ay = (float) Math.sin(angle); // draw ellipse GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4f(red, green, blue, alpha); int i; GL11.glBegin(GL11.GL_TRIANGLE_FAN); for (i = 0; i < num_faces; i++) { xt = xx; xx = c * xx - s * yy; yy = s * xt + c * yy; GL11.glVertex2f(x + a * xx * ax - b * yy * ay, y + a * xx * ay + b * yy * ax); } GL11.glVertex2f(x + a * ax, y + a * ay); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1, 1, 1, 1); }
From source file:net.phatcode.rel.multimedia.Graphics.java
License:Open Source License
public void drawEllipseFilled(int x, int y, int a, int b, int degrees) { // these constants decide the quality of the ellipse final float pi = (float) Math.PI; final float twopi = 2 * pi; // two pi (radians in a circle) final int face_length = 8; // approx. face length in pixels final int max_faces = 256; // maximum number of faces in ellipse final int min_faces = 16; // minimum number of faces in ellipse // approx. ellipse circumference (hudson's method) float h = (a - b * a - b) / (float) (a + b * a + b); float circumference = 0.25f * pi * (a + b) * (3 * (1 + h * 0.25f) + 1 / (1 - h * 0.25f)); // number of faces in ellipse int num_faces = (int) (circumference / (float) face_length); // clamp number of faces if (num_faces > max_faces) num_faces = max_faces;/* ww w . j a va 2s.c om*/ if (num_faces < min_faces) num_faces = min_faces; // keep number of faces divisible by 4 num_faces -= (num_faces & 3); // precalc cosine theta float angle = degrees * pi / 180.0f; float s = (float) Math.sin(twopi / (float) num_faces); float c = (float) Math.cos(twopi / (float) num_faces); float xx = 1; float yy = 0; float xt; float ax = (float) Math.cos(angle); float ay = (float) Math.sin(angle); // draw ellipse GL11.glDisable(GL11.GL_TEXTURE_2D); int i; GL11.glBegin(GL11.GL_TRIANGLE_FAN); for (i = 0; i < num_faces; i++) { xt = xx; xx = c * xx - s * yy; yy = s * xt + c * yy; GL11.glVertex2f(x + a * xx * ax - b * yy * ay, y + a * xx * ay + b * yy * ax); } GL11.glVertex2f(x + a * ax, y + a * ay); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); }
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);// www . ja v a 2s .co 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.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);/*from www. j a v a 2s.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 a v a 2s . co m 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 ww .j a va2s . com*/ 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(); }