List of usage examples for org.lwjgl.opengl GL11 glBegin
public static native void glBegin(@NativeType("GLenum") int mode);
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawCube(float r) { r /= 2f;/*from ww w . j a v a 2 s . co m*/ GL11.glBegin(GL11.GL_QUADS); // Front Face GL11.glNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(-r, -r, r); // Point 1 (Front) GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(r, -r, r); // Point 2 (Front) GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(r, r, r); // Point 3 (Front) GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(-r, r, r); // Point 4 (Front) // Back Face GL11.glNormal3f(0.0f, 0.0f, -1.0f); // Normal Pointing Away From Viewer GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(-r, -r, -r); // Point 1 (Back) GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(-r, r, -r); // Point 2 (Back) GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(r, r, -r); // Point 3 (Back) GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(r, -r, -r); // Point 4 (Back) // Top Face GL11.glNormal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(-r, r, -r); // Point 1 (Top) GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(-r, r, r); // Point 2 (Top) GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(r, r, r); // Point 3 (Top) GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(r, r, -r); // Point 4 (Top) // Bottom Face GL11.glNormal3f(0.0f, -1.0f, 0.0f); // Normal Pointing Down GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(-r, -r, -r); // Point 1 (Bottom) GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(r, -r, -r); // Point 2 (Bottom) GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(r, -r, r); // Point 3 (Bottom) GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(-r, -r, r); // Point 4 (Bottom) // Right face GL11.glNormal3f(1.0f, 0.0f, 0.0f); // Normal Pointing Right GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(r, -r, -r); // Point 1 (Right) GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(r, r, -r); // Point 2 (Right) GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(r, r, r); // Point 3 (Right) GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(r, -r, r); // Point 4 (Right) // Left Face GL11.glNormal3f(-1.0f, 0.0f, 0.0f); // Normal Pointing Left GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(-r, -r, -r); // Point 1 (Left) GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(-r, -r, r); // Point 2 (Left) GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(-r, r, r); // Point 3 (Left) GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(-r, r, -r); // Point 4 (Left) // Done Drawing Quads GL11.glEnd(); }
From source file:fi.conf.ae.gl.GLGraphicRoutines.java
License:LGPL
public static void drawLine(float x0, float y0, float x1, float y1, float z0, float z1, float lineWidth) { GL11.glLineWidth(lineWidth);// w ww. j av a2 s .com GL11.glBegin(GL11.GL_LINES); GL11.glVertex3f(x0, y0, z0); GL11.glVertex3f(x1, y1, z1); GL11.glEnd(); }
From source file:fi.conf.ae.gl.text.GLBitmapFontBlitter.java
License:LGPL
public static void drawString(String string, String textureIdentifier, float charWidth, float charHeight, Alignment align) {/*from w w w . j a v a 2s. c o m*/ float hOverlap = 0.01f; float vOverlap = 0.0f; float xfix = 0; if (align.equals(Alignment.CENTERED)) { xfix = string.length() * charWidth * 0.5f; } else if (align.equals(Alignment.RIGHT)) { xfix = string.length() * charWidth - hOverlap; } GL11.glPushMatrix(); GL11.glTranslatef(0, -0.5f * charHeight, 0); GLTextureManager.getInstance().bindTexture(textureIdentifier); GL11.glBegin(GL11.GL_QUADS); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); float x1 = (c % 16f) / 16f; float x2 = x1 + 1f / 16f; float y1 = (c / 16) / 16f; float y2 = y1 + 1f / 16f; GL11.glTexCoord2d(x1 + hOverlap, y1 + vOverlap); GL11.glVertex3d(i * charWidth - xfix, 0, 0); GL11.glTexCoord2d(x1 + hOverlap, y2 - vOverlap); GL11.glVertex3d(i * charWidth - xfix, charHeight, 0); GL11.glTexCoord2d(x2 - hOverlap, y2 - vOverlap); GL11.glVertex3d(i * charWidth + charWidth - xfix, charHeight, 0); GL11.glTexCoord2d(x2 - hOverlap, y1 + vOverlap); GL11.glVertex3d(i * charWidth + charWidth - xfix, 0, 0); } GL11.glEnd(); GL11.glPopMatrix(); }
From source file:fi.conf.ae.gl.text.GLBitmapFontBlitter.java
License:LGPL
public static void drawScrollerString(String string, float charWidth, float charHeight, float freq, float amplitude, float phase, String font) { float overlap = 0.2f; float fix = 0; GL11.glPushMatrix();// w w w. ja va 2s . co m GLTextureManager.getInstance().bindTexture(font); //GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID); GL11.glEnable(GL11.GL_DEPTH_TEST); //GLRoutines.drawSprite(0f, 0f, 2f, 2f, 1f); GL11.glBegin(GL11.GL_QUADS); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); float s = (float) Math.sin(phase + freq * 2 * Math.PI * i / string.length()) * amplitude; float x1 = (c % 16f) / 16f; float x2 = (c % 16f) / 16f + 1f / 16f; float y1 = (c / 16) / 16f; float y2 = (c / 16) / 16f + 1f / 16f; //drawSprite(x1, y1, x2, y2, 0); //GL11.glColor3f((float)Math.random()*1.3f, (float)Math.random()*1.3f, (float)Math.random()*1.3f); GL11.glTexCoord2d(x1, y1); GL11.glVertex3d(i * charWidth - fix - overlap, s, 0); GL11.glTexCoord2d(x1, y2); GL11.glVertex3d(i * charWidth - fix - overlap, charHeight + s, 0); GL11.glTexCoord2d(x2, y2); GL11.glVertex3d(i * charWidth + charWidth - fix, charHeight + s, 0); GL11.glTexCoord2d(x2, y1); GL11.glVertex3d(i * charWidth + charWidth - fix, s, 0); } GL11.glEnd(); GL11.glPopMatrix(); }
From source file:fi.conf.ae.gl.text.GLBitmapFontBlitter.java
License:LGPL
public static void drawCircleString(String string, float charHeight, float freq, float radius, float phase, String font) {/*w w w .j a v a 2 s. c o m*/ GL11.glPushMatrix(); GLTextureManager.getInstance().bindTexture(font); //GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID); GL11.glEnable(GL11.GL_DEPTH_TEST); //GLRoutines.drawSprite(0f, 0f, 2f, 2f, 1f); //GL11.glTranslatef(charWidth/2, -charHeight/2, 0); for (int i = 0; i < string.length(); i++) { char c = string.charAt(string.length() - 1 - i); float vx1 = (float) Math.sin(phase + freq * 2 * Math.PI * i / string.length()) * radius; float vy1 = (float) Math.cos(phase + freq * 2 * Math.PI * i / string.length()) * radius; float vx2 = (float) Math.sin(phase + freq * 2 * Math.PI * i / string.length()) * radius * charHeight; float vy2 = (float) Math.cos(phase + freq * 2 * Math.PI * i / string.length()) * radius * charHeight; float vx3 = (float) Math.sin(phase + freq * 2 * Math.PI * (i + 1) / string.length()) * radius; float vy3 = (float) Math.cos(phase + freq * 2 * Math.PI * (i + 1) / string.length()) * radius; float vx4 = (float) Math.sin(phase + freq * 2 * Math.PI * (i + 1) / string.length()) * radius * charHeight; float vy4 = (float) Math.cos(phase + freq * 2 * Math.PI * (i + 1) / string.length()) * radius * charHeight; float x1 = (c % 16f) / 16f; float x2 = (c % 16f) / 16f + 1f / 16f; float y1 = (c / 16) / 16f; float y2 = (c / 16) / 16f + 1f / 16f; //GL11.glColor3f((float)Math.random()*1.3f, (float)Math.random()*1.3f, (float)Math.random()*1.3f); //GL11.glBindTexture(GL11.GL_TEXTURE_2D, -1); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2d(x1, y1); GL11.glVertex3d(vy4, vx4, 0); GL11.glTexCoord2d(x1, y2); GL11.glVertex3d(vy3, vx3, 0); GL11.glTexCoord2d(x2, y2); GL11.glVertex3d(vy1, vx1, 0); GL11.glTexCoord2d(x2, y1); GL11.glVertex3d(vy2, vx2, 0); GL11.glEnd(); } GL11.glPopMatrix(); }
From source file:fi.conf.prograts.ar.gl.GLBitmapFontBlitter.java
License:LGPL
public static void drawString(String string, String textureIdentifier, float charWidth, float charHeight, Alignment align) {//from ww w . j a v a 2s . c o m float fix = 0; float overlap = 0.01f; if (align.equals(Alignment.CENTERED)) { fix = string.length() * charWidth * 0.5f; } else if (align.equals(Alignment.RIGHT)) { fix = string.length() * charWidth - overlap; } GL11.glPushMatrix(); GL11.glTranslatef(0, -0.5f * charHeight, 0); // System.out.println(textureID); GLTextureManager.getInstance().bindTexture(textureIdentifier); GL11.glBegin(GL11.GL_QUADS); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); float x1 = (c % 16f) / 16f; float x2 = x1 + 1f / 16f; float y1 = (c / 16) / 16f; float y2 = y1 + 1f / 16f; GL11.glTexCoord2d(x1 + overlap, y1); GL11.glVertex3d(i * charWidth - fix, 0, 0); GL11.glTexCoord2d(x1 + overlap, y2); GL11.glVertex3d(i * charWidth - fix, charHeight, 0); GL11.glTexCoord2d(x2 - overlap, y2); GL11.glVertex3d(i * charWidth + charWidth - fix, charHeight, 0); GL11.glTexCoord2d(x2 - overlap, y1); GL11.glVertex3d(i * charWidth + charWidth - fix, 0, 0); } GL11.glEnd(); GL11.glPopMatrix(); }
From source file:fi.conf.prograts.ar.gl.GLBitmapFontBlitter.java
License:LGPL
public static void blitScrollerString(String string, float charWidth, float charHeight, float freq, float amplitude, float phase, String font) { float overlap = 0.2f; float fix = 0; GL11.glPushMatrix();/* ww w .j a v a 2s . c o m*/ GLTextureManager.getInstance().bindTexture(font); //GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID); GL11.glEnable(GL11.GL_DEPTH_TEST); //GLRoutines.drawSprite(0f, 0f, 2f, 2f, 1f); GL11.glBegin(GL11.GL_QUADS); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); float s = (float) Math.sin(phase + freq * 2 * Math.PI * i / string.length()) * amplitude; float x1 = (c % 16f) / 16f; float x2 = (c % 16f) / 16f + 1f / 16f; float y1 = (c / 16) / 16f; float y2 = (c / 16) / 16f + 1f / 16f; //drawSprite(x1, y1, x2, y2, 0); //GL11.glColor3f((float)Math.random()*1.3f, (float)Math.random()*1.3f, (float)Math.random()*1.3f); GL11.glTexCoord2d(x1, y1); GL11.glVertex3d(i * charWidth - fix - overlap, s, 0); GL11.glTexCoord2d(x1, y2); GL11.glVertex3d(i * charWidth - fix - overlap, charHeight + s, 0); GL11.glTexCoord2d(x2, y2); GL11.glVertex3d(i * charWidth + charWidth - fix, charHeight + s, 0); GL11.glTexCoord2d(x2, y1); GL11.glVertex3d(i * charWidth + charWidth - fix, s, 0); } GL11.glEnd(); GL11.glPopMatrix(); }
From source file:fi.conf.prograts.ar.gl.GLBitmapFontBlitter.java
License:LGPL
public static void blitSinString(String string, float charWidth, float charHeight, float freq, float amplitude, float phase, String font) { float overlap = 0.2f; float fix = 0; GL11.glPushMatrix();// www . j av a2 s. c o m GLTextureManager.getInstance().bindTexture(font); //GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID); GL11.glEnable(GL11.GL_DEPTH_TEST); //GLRoutines.drawSprite(0f, 0f, 2f, 2f, 1f); //GL11.glTranslatef(charWidth/2, -charHeight/2, 0); for (int i = 0; i < string.length(); i++) { char c = string.charAt(string.length() - 1 - i); float vx1 = (float) Math.sin(phase + freq * 2 * Math.PI * i / string.length()) * amplitude; float vy1 = (float) Math.cos(phase + freq * 2 * Math.PI * i / string.length()) * amplitude; float vx2 = (float) Math.sin(phase + freq * 2 * Math.PI * i / string.length()) * amplitude * charHeight; float vy2 = (float) Math.cos(phase + freq * 2 * Math.PI * i / string.length()) * amplitude * charHeight; float vx3 = (float) Math.sin(phase + freq * 2 * Math.PI * (i + 1) / string.length()) * amplitude; float vy3 = (float) Math.cos(phase + freq * 2 * Math.PI * (i + 1) / string.length()) * amplitude; float vx4 = (float) Math.sin(phase + freq * 2 * Math.PI * (i + 1) / string.length()) * amplitude * charHeight; float vy4 = (float) Math.cos(phase + freq * 2 * Math.PI * (i + 1) / string.length()) * amplitude * charHeight; float x1 = (c % 16f) / 16f; float x2 = (c % 16f) / 16f + 1f / 16f; float y1 = (c / 16) / 16f; float y2 = (c / 16) / 16f + 1f / 16f; //GL11.glColor3f((float)Math.random()*1.3f, (float)Math.random()*1.3f, (float)Math.random()*1.3f); //GL11.glBindTexture(GL11.GL_TEXTURE_2D, -1); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2d(x1, y1); GL11.glVertex3d(vy4, vx4, 0); GL11.glTexCoord2d(x1, y2); GL11.glVertex3d(vy3, vx3, 0); GL11.glTexCoord2d(x2, y2); GL11.glVertex3d(vy1, vx1, 0); GL11.glTexCoord2d(x2, y1); GL11.glVertex3d(vy2, vx2, 0); GL11.glEnd(); } GL11.glPopMatrix(); }
From source file:fr.def.iss.vd2.lib_v3d.camera.V3DSimple2DCamera.java
License:Open Source License
private void displayTarget() { GL11.glColor4f(1.0f, 0.5f, 0.5f, 0.8f); GL11.glLineWidth(1.2f);/*from w w w . ja v a2 s . c om*/ GL11.glBegin(GL11.GL_LINES); { GL11.glColor4f(1.0f, 0.0f, 0.0f, 0.8f); GL11.glVertex3d(-1, 0, 0); GL11.glVertex3d(1, 0, 0); GL11.glVertex3d(0.9, 0.1, 0); GL11.glVertex3d(1, 0, 0); GL11.glVertex3d(0.9, -0.1, 0); GL11.glVertex3d(1, 0, 0); //y GL11.glColor4f(0.0f, 1.0f, 0.0f, 0.8f); GL11.glVertex3d(0, -1, 0); GL11.glVertex3d(0, 1, 0); GL11.glVertex3d(0.1, 0.9, 0); GL11.glVertex3d(0, 1, 0); GL11.glVertex3d(-0.1, 0.9, 0); GL11.glVertex3d(0, 1, 0); //z GL11.glColor4f(0.0f, 0.0f, 1.0f, 0.8f); GL11.glVertex3d(0, 0, -1); GL11.glVertex3d(0, 0, 1); GL11.glVertex3d(0.1, 0, 0.9); GL11.glVertex3d(0, 0, 1); GL11.glVertex3d(-0.1, 0, 0.9); GL11.glVertex3d(0, 0, 1); } GL11.glEnd(); GL11.glPointSize(1.2f); GL11.glBegin(GL11.GL_POINTS); { GL11.glVertex3d(position.x, position.y, 0); } GL11.glEnd(); }
From source file:fr.def.iss.vd2.lib_v3d.camera.V3DSimple3DCamera.java
License:Open Source License
private void displayTarget() { GL11.glColor4f(1.0f, 0.5f, 0.5f, 0.8f); GL11.glLineWidth(1.2f);/*from w w w . j a va2 s. com*/ GL11.glBegin(GL11.GL_LINES); { GL11.glColor4f(1.0f, 0.0f, 0.0f, 0.8f); GL11.glVertex3d(-1, 0, 0); GL11.glVertex3d(1, 0, 0); GL11.glVertex3d(0.9, 0.1, 0); GL11.glVertex3d(1, 0, 0); GL11.glVertex3d(0.9, -0.1, 0); GL11.glVertex3d(1, 0, 0); //y GL11.glColor4f(0.0f, 1.0f, 0.0f, 0.8f); GL11.glVertex3d(0, -1, 0); GL11.glVertex3d(0, 1, 0); GL11.glVertex3d(0.1, 0.9, 0); GL11.glVertex3d(0, 1, 0); GL11.glVertex3d(-0.1, 0.9, 0); GL11.glVertex3d(0, 1, 0); //z GL11.glColor4f(0.0f, 0.0f, 1.0f, 0.8f); GL11.glVertex3d(0, 0, -1); GL11.glVertex3d(0, 0, 1); GL11.glVertex3d(0.1, 0, 0.9); GL11.glVertex3d(0, 0, 1); GL11.glVertex3d(-0.1, 0, 0.9); GL11.glVertex3d(0, 0, 1); } GL11.glEnd(); GL11.glPointSize(1.2f); GL11.glBegin(GL11.GL_POINTS); { GL11.glVertex3d(position.x, position.y, position.z); } GL11.glEnd(); }