Java Code Examples for org.lwjgl.opengl.GL11#glTexCoord2f()
The following examples show how to use
org.lwjgl.opengl.GL11#glTexCoord2f() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtils.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Game loop render */ public void render() { Color.white.bind(); texture.bind(); // or GL11.glBind(texture.getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0,0); GL11.glVertex2f(100,100); GL11.glTexCoord2f(1,0); GL11.glVertex2f(100+texture.getTextureWidth(),100); GL11.glTexCoord2f(1,1); GL11.glVertex2f(100+texture.getTextureWidth(),100+texture.getTextureHeight()); GL11.glTexCoord2f(0,1); GL11.glVertex2f(100,100+texture.getTextureHeight()); GL11.glEnd(); font.drawString(150, 300, "HELLO LWJGL WORLD", Color.yellow); }
Example 2
Source File: CFont.java From ForgeHax with MIT License | 6 votes |
protected void drawQuad( float x, float y, float width, float height, float srcX, float srcY, float srcWidth, float srcHeight) { float renderSRCX = srcX / imgSize; float renderSRCY = srcY / imgSize; float renderSRCWidth = srcWidth / imgSize; float renderSRCHeight = srcHeight / imgSize; GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY); GL11.glVertex2d(x + width, y); GL11.glTexCoord2f(renderSRCX, renderSRCY); GL11.glVertex2d(x, y); GL11.glTexCoord2f(renderSRCX, renderSRCY + renderSRCHeight); GL11.glVertex2d(x, y + height); GL11.glTexCoord2f(renderSRCX, renderSRCY + renderSRCHeight); GL11.glVertex2d(x, y + height); GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY + renderSRCHeight); GL11.glVertex2d(x + width, y + height); GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY); GL11.glVertex2d(x + width, y); }
Example 3
Source File: GUIImage.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
protected final void renderGeometry() { int width = getWidth(); int height = getHeight(); GL11.glEnd(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getHandle()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex3f(0, 0, 0); GL11.glTexCoord2f(u2, v1); GL11.glVertex3f(width, 0, 0); GL11.glTexCoord2f(u2, v2); GL11.glVertex3f(width, height, 0); GL11.glTexCoord2f(u1, v2); GL11.glVertex3f(0, height, 0); GL11.glEnd(); Skin.getSkin().bindTexture(); GL11.glBegin(GL11.GL_QUADS); }
Example 4
Source File: EmitterRenderer.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
private static void render2DParticle(Particle particle, Emitter emitter) { float x = particle.getPosX(); float y = particle.getPosY(); float z = particle.getPosZ(); float radius_x = particle.getRadiusX()*emitter.getScaleX(); float radius_y = particle.getRadiusY()*emitter.getScaleY(); float radius_z = particle.getRadiusZ()*emitter.getScaleZ(); GL11.glColor4f(particle.getColorR(), particle.getColorG(), particle.getColorB(), particle.getColorA()); GL11.glTexCoord2f(particle.getU1(), particle.getV1()); GL11.glVertex3f(x - right_plus_up.getX()*radius_x, y - right_plus_up.getY()*radius_y, z - right_plus_up.getZ()*radius_z); GL11.glTexCoord2f(particle.getU2(), particle.getV2()); GL11.glVertex3f(x + right_minus_up.getX()*radius_x, y + right_minus_up.getY()*radius_y, z + right_minus_up.getZ()*radius_z); GL11.glTexCoord2f(particle.getU3(), particle.getV3()); GL11.glVertex3f(x + right_plus_up.getX()*radius_x, y + right_plus_up.getY()*radius_y, z + right_plus_up.getZ()*radius_z); GL11.glTexCoord2f(particle.getU4(), particle.getV4()); GL11.glVertex3f(x - right_minus_up.getX()*radius_x, y - right_minus_up.getY()*radius_y, z - right_minus_up.getZ()*radius_z); }
Example 5
Source File: LightningRenderer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
private static void render2DParticle(StretchParticle particle) { float src_x = particle.getSrcX(); float src_y = particle.getSrcY(); float src_z = particle.getSrcZ(); float dst_x = particle.getDstX(); float dst_y = particle.getDstY(); float dst_z = particle.getDstZ(); /* GL11.glColor4f(particle.getColorR(), particle.getColorG(), particle.getColorB(), particle.getColorA()); GL11.glTexCoord2f(0f, 0f); GL11.glVertex3f(dst_x - right_vector.getX()*particle.getDstWidth(), dst_y - right_vector.getY()*particle.getDstWidth(), dst_z); GL11.glTexCoord2f(1f, 0f); GL11.glVertex3f(dst_x + right_vector.getX()*particle.getDstWidth(), dst_y + right_vector.getY()*particle.getDstWidth(), dst_z); GL11.glTexCoord2f(1f, 1f); GL11.glVertex3f(src_x + right_vector.getX()*particle.getSrcWidth(), src_y + right_vector.getY()*particle.getSrcWidth(), src_z); GL11.glTexCoord2f(0f, 1f); GL11.glVertex3f(src_x - right_vector.getX()*particle.getSrcWidth(), src_y - right_vector.getY()*particle.getSrcWidth(), src_z); */ GL11.glColor4f(particle.getColorR(), particle.getColorG(), particle.getColorB(), particle.getColorA()); GL11.glTexCoord2f(0f, 0f); GL11.glVertex3f(dst_x - particle.getDstWidth(), dst_y, dst_z); GL11.glTexCoord2f(1f, 0f); GL11.glVertex3f(dst_x + particle.getDstWidth(), dst_y, dst_z); GL11.glTexCoord2f(1f, 1f); GL11.glVertex3f(src_x + particle.getSrcWidth(), src_y, src_z); GL11.glTexCoord2f(0f, 1f); GL11.glVertex3f(src_x - particle.getSrcWidth(), src_y, src_z); GL11.glTexCoord2f(0f, 0f); GL11.glVertex3f(dst_x, dst_y - particle.getDstWidth(), dst_z); GL11.glTexCoord2f(1f, 0f); GL11.glVertex3f(dst_x, dst_y + particle.getDstWidth(), dst_z); GL11.glTexCoord2f(1f, 1f); GL11.glVertex3f(src_x, src_y + particle.getSrcWidth(), src_z); GL11.glTexCoord2f(0f, 1f); GL11.glVertex3f(src_x, src_y - particle.getSrcWidth(), src_z); }
Example 6
Source File: VAOGLRenderer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Flush the currently cached data down to the card */ private void flushBuffer() { if (vertIndex == 0) { return; } if (currentType == NONE) { return; } if (vertIndex < TOLERANCE) { GL11.glBegin(currentType); for (int i=0;i<vertIndex;i++) { GL11.glColor4f(cols[(i*4)+0], cols[(i*4)+1], cols[(i*4)+2], cols[(i*4)+3]); GL11.glTexCoord2f(texs[(i*2)+0], texs[(i*2)+1]); GL11.glVertex3f(verts[(i*3)+0], verts[(i*3)+1], verts[(i*3)+2]); } GL11.glEnd(); currentType = NONE; return; } vertices.clear(); colors.clear(); textures.clear(); vertices.put(verts,0,vertIndex*3); colors.put(cols,0,vertIndex*4); textures.put(texs,0,vertIndex*2); vertices.flip(); colors.flip(); textures.flip(); GL11.glVertexPointer(3,0,vertices); GL11.glColorPointer(4,0,colors); GL11.glTexCoordPointer(2,0,textures); GL11.glDrawArrays(currentType, 0, vertIndex); currentType = NONE; }
Example 7
Source File: Gui.java From Slyther with MIT License | 5 votes |
public void drawTexture(float x, float y, float width, float height) { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBegin(GL11.GL_QUADS); GL11.glShadeModel(GL11.GL_FLAT); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(x, y); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(x + width, y); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(x + width, y + height); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(x, y + height); GL11.glEnd(); }
Example 8
Source File: MainMenu.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
private void drawMenuButton( Image img, int x, int y, int clipxtop, int clipxbot, Color col) { col.bind(); final Texture t = img.getTexture(); t.bind(); final int width = img.getWidth(); final int height = img.getHeight(); final float twidth = t.getWidth(); final float theight = t.getHeight(); y -= height / 2; final float texXtop = clipxtop > 0 ? (float) clipxtop / width * twidth : 0f; final float texXbot = clipxbot > 0 ? (float) clipxbot / width * twidth : 0f; GL11.glBegin(SGL.GL_QUADS); GL11.glTexCoord2f(texXtop, 0); GL11.glVertex3i(x + clipxtop, y, 0); GL11.glTexCoord2f(twidth, 0); GL11.glVertex3i(x + width, y, 0); GL11.glTexCoord2f(twidth, theight); GL11.glVertex3i(x + width, y + height, 0); GL11.glTexCoord2f(texXbot, theight); GL11.glVertex3i(x + clipxbot, y + height, 0); GL11.glEnd(); }
Example 9
Source File: Graphics.java From AnyaBasic with MIT License | 4 votes |
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; } 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(); }
Example 10
Source File: Gui.java From Slyther with MIT License | 4 votes |
public void drawVertex(float x, float y, float u, float v, float uMultiplier, float vMultiplier) { GL11.glTexCoord2f(u * uMultiplier, v * vMultiplier); GL11.glVertex2f(x, y); }
Example 11
Source File: Test.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
public final static void main(String[] args) { try { Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH, DISPLAY_HEIGHT)); Display.create(); initGL(); // Load font InputStream font_is = Utils.makeURL("/fonts/tahoma.ttf").openStream(); java.awt.Font src_font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, font_is); java.awt.Font font = src_font.deriveFont(14f); // Load text InputStreamReader text_is = new InputStreamReader(Utils.makeURL("/test_text.txt").openStream()); StringBuffer str_buffer = new StringBuffer(); int c = text_is.read(); do { str_buffer.append((char)c); c = text_is.read(); } while (c != -1); String str = str_buffer.toString(); // Build texture int[] pixels = new int[WIDTH*HEIGHT]; // ByteBuffer pixel_data = ByteBuffer.wrap(pixels); // NEW // pixelDataFromString(WIDTH, HEIGHT, str, font, pixels); // NEW IntBuffer pixel_data = BufferUtils.createIntBuffer(WIDTH*HEIGHT); // OLD pixel_data.put(pixels); // OLD pixel_data.rewind(); int texture_handle = createTexture(WIDTH, HEIGHT, pixel_data); FontRenderContext frc = g2d.getFontRenderContext(); AttributedString att_str = new AttributedString(str); att_str.addAttribute(TextAttribute.FONT, font); AttributedCharacterIterator iterator = att_str.getIterator(); LineBreakMeasurer measurer = new LineBreakMeasurer(iterator, frc); while (!Display.isCloseRequested()) { long start_time = System.currentTimeMillis(); for (int i = 0; i < 10; i++) { pixelDataFromString(WIDTH, HEIGHT, str, font, pixels, measurer); pixel_data.put(pixels); // OLD pixel_data.rewind(); //texture_handle = createTexture(WIDTH, HEIGHT, pixel_data); updateTexture(WIDTH, HEIGHT, pixel_data); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity(); // Background /* GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4f(.1f, .1f, .1f, 1f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f); GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f); GL11.glEnd(); */ // Text GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1f, 1f, 1f, 1f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0f, 1f); GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glTexCoord2f(1f, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glTexCoord2f(1f, 0f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f); GL11.glTexCoord2f(0f, 0f); GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f); GL11.glEnd(); Display.update(); } long total_time = System.currentTimeMillis() - start_time; System.out.println("total_time = " + total_time); } Display.destroy(); } catch (Exception t) { t.printStackTrace(); } }
Example 12
Source File: BlurPane.java From LWJGUI with MIT License | 4 votes |
@Override public void render(Context context, int x, int y, int w, int h) { if ( !isVisible() ) return; if ( this.quad == null || quadDirty ) { if ( this.quad != null ) { this.quad.cleanup(); } quad = new TexturedQuad(0, 0, w, h, source.getTexId()); } GL11.glViewport(x, y, w, h); this.quadDirty = false; quadShader.bind(); quadShader.projectOrtho(0, h, w, -h); // bind stuff GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, source.getTexId()); if ( internalBackground instanceof BackgroundSolid ) { BackgroundSolid bg = (BackgroundSolid)internalBackground; GL20.glUniform4f(GL20.glGetUniformLocation(quadShader.getProgram(), "uColor"), bg.getColor().getRed()/255f-0.5f, bg.getColor().getGreen()/255f-0.5f, bg.getColor().getBlue()/255f-0.5f, bg.getColor().getAlpha()/255f); } GL20.glUniform1f(GL20.glGetUniformLocation(quadShader.getProgram(), "uBlurSize"), blurRadius); GL20.glUniform2f(GL20.glGetUniformLocation(quadShader.getProgram(), "uTexelSize"), 1.0f/(float)w, 1.0f/(float)h); GL20.glUniform4f(GL20.glGetUniformLocation(quadShader.getProgram(), "uCornerRadii"), (float)Math.max(BlurPane.this.getBorderRadii()[0], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[1], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[2], 0.1), (float)Math.max(BlurPane.this.getBorderRadii()[3], 0.1)); // Draw quad if ( context.isCoreOpenGL() ) { if ( quad != null ) { quad.render(); } } else { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, source.getTexId()); GL11.glBegin(GL11.GL_QUADS); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(w, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(w, h); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(0, h); GL11.glEnd(); } }
Example 13
Source File: Graphics.java From AnyaBasic with MIT License | 4 votes |
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; } 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(); }
Example 14
Source File: LegacyCurveRenderState.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Draw a curve to the screen that's tinted with `color`. The first time * this is called this caches the image result of the curve and on subsequent * runs it just draws the cached copy to the screen. * @param color tint of the curve * @param borderColor the curve border color * @param from index to draw from * @param to index to draw to (exclusive) */ public void draw(Color color, Color borderColor, int from, int to) { float alpha = color.a; if (fbo == null) initFBO(); if (lastPointDrawn != to || firstPointDrawn != from) { int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); //glGetInteger requires a buffer of size 16, even though just 4 //values are returned in this specific case IntBuffer oldViewport = BufferUtils.createIntBuffer(16); GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID()); GL11.glViewport(0, 0, fbo.width, fbo.height); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); this.renderCurve(color, borderColor, from, to, firstPointDrawn != from); lastPointDrawn = to; firstPointDrawn = from; color.a = 1f; GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb); GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3)); } // draw a fullscreen quad with the texture that contains the curve GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i(fbo.width, 0); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(0, fbo.height); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(fbo.width, fbo.height); GL11.glEnd(); }
Example 15
Source File: LwjglRasteriser.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void texCoord(final float u, final float v) { GL11.glTexCoord2f(u, v); }
Example 16
Source File: StenciledTextureRenderer.java From OpenModsLib with MIT License | 4 votes |
@Override public void render(RenderGlobal context, float partialTickTime) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glOrtho(-1, +1, -1, +1, -1, +1); GL11.glEnable(GL11.GL_STENCIL_TEST); GL11.glStencilMask(stencilMask); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); GL11.glStencilFunc(GL11.GL_EQUAL, stencilMask, stencilMask); TextureUtils.bindTextureToClient(texture); RenderUtils.disableLightmap(); GlStateManager.disableLighting(); GlStateManager.color(1, 1, 1); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex3f(-1, -1, 0); GL11.glTexCoord2f(1, 0); GL11.glVertex3f(+1, -1, 0); GL11.glTexCoord2f(1, 1); GL11.glVertex3f(+1, +1, 0); GL11.glTexCoord2f(0, 1); GL11.glVertex3f(-1, +1, 0); GL11.glEnd(); // mask should prevent this command from clearing other bits GL11.glClearStencil(0); GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); GL11.glDisable(GL11.GL_STENCIL_TEST); RenderUtils.enableLightmap(); GlStateManager.enableLighting(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); }
Example 17
Source File: GuiComponentTankLevel.java From OpenModsLib with MIT License | 4 votes |
private static void addVertexWithUV(double x, double y, double z, float u, float v) { GL11.glTexCoord2f(u, v); GL11.glVertex3d(x, y, z); }
Example 18
Source File: CurveRenderState.java From opsu-dance with GNU General Public License v3.0 | 4 votes |
/** * Draw a curve to the screen that's tinted with `color`. The first time * this is called this caches the image result of the curve and on subsequent * runs it just draws the cached copy to the screen. * @param color tint of the curve * @param borderColor the curve border color * @param from index to draw from * @param to index to draw to (exclusive) */ public void draw(Color color, Color borderColor, int from, int to) { float alpha = color.a; if (fbo == null) { // this should not be null, but issue #106 claims it is possible, at least 3 people had this... // debugging shows that the draw was called after discardGeometry was, which does not really make sense initFBO(); } if (lastPointDrawn != to || firstPointDrawn != from) { int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); //glGetInteger requires a buffer of size 16, even though just 4 //values are returned in this specific case IntBuffer oldViewport = BufferUtils.createIntBuffer(16); GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID()); GL11.glViewport(0, 0, fbo.width, fbo.height); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); this.renderCurve(color, borderColor, from, to, firstPointDrawn != from); lastPointDrawn = to; firstPointDrawn = from; color.a = 1f; GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb); GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3)); } // draw a fullscreen quad with the texture that contains the curve GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i(fbo.width, 0); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(0, fbo.height); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(fbo.width, fbo.height); GL11.glEnd(); }
Example 19
Source File: ImmediateModeOGLRenderer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @see org.newdawn.slick.opengl.renderer.SGL#glTexCoord2f(float, float) */ public void glTexCoord2f(float u, float v) { GL11.glTexCoord2f(u, v); }
Example 20
Source File: OffscreenBuffer.java From LWJGUI with MIT License | 4 votes |
public void render(Context context, int x, int y, int w, int h) { if (quadShader == null) { quadShader = new GenericShader(); } float pixelRatio = LWJGUI.getThreadWindow().getPixelRatio(); x *= pixelRatio; y *= pixelRatio; GL11.glViewport(x, y,(int) (w*pixelRatio),(int) (h*pixelRatio)); quadShader.bind(); quadShader.projectOrtho(0, 0, w, h); if (quadDirty) { quadDirty = false; if (quad != null) { quad.cleanup(); } quad = new TexturedQuad(0, 0, w, h, texId); } if ( context.isCoreOpenGL() ) { if ( quad != null ) { quad.render(); } } else { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); GL11.glBegin(GL11.GL_QUADS); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(1, 0); GL11.glVertex2f(w, 0); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(1, 1); GL11.glVertex2f(w, h); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glTexCoord2f(0, 1); GL11.glVertex2f(0, h); GL11.glEnd(); } }