public void paintTex(int glid, int target, int w, int h, int color) { float r, g, b, a; int ir, ig, ib, ia; ia = (color >> 24) & 0xff; ir = (color >> 16) & 0xff; ig = (color >> 8) & 0xff; ib = color & 0xff; a = ia / 255.0f; r = ir / 255.0f; g = ig / 255.0f; b = ib / 255.0f; pushFramebuffer(); setFramebuffer(FBO); FBO.setDrawBuffer(target, glid); saveView(); setOrthographicView(w, h); gl.glColor4f(r, g, b, a); gl.glBegin(GL.GL_QUADS); gl.glVertex2f(0.0f, 0.0f); gl.glVertex2f(w, 0.0f); gl.glVertex2f(w, h); gl.glVertex2f(0.0f, h); gl.glEnd(); restoreView(); popFramebuffer(); }
@Override public void render(GLCanvas canvas) { gui.getGL().glColor4f(bg_col.getR(), bg_col.getG(), bg_col.getB(), bg_col.getA()); renderQuad(pos.x, pos.y, width, height); GL gl = canvas.getGL(); if (texture != null) { texture.bind(0); gl.glColor4f(fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA()); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0, 0); gl.glVertex2f(pos.x, pos.y); gl.glTexCoord2f(texture.getImageWidth() / texture.getWidth(), 0); gl.glVertex2f(pos.x + width, pos.y); gl.glTexCoord2f( texture.getImageWidth() / texture.getWidth(), texture.getImageHeight() / texture.getHeight()); gl.glVertex2f(pos.x + width, pos.y - height); gl.glTexCoord2f(0, texture.getImageHeight() / texture.getHeight()); gl.glVertex2f(pos.x, pos.y - height); gl.glEnd(); texture.unbind(); } gui.getGL() .glColor4f(border_col.getR(), border_col.getG(), border_col.getB(), border_col.getA()); renderOutlinedQuad(pos.x, pos.y, width, height); }
public void copyTex(GLTexture srcTex, GLTexture destTex) { float uscale = srcTex.getMaxTextureCoordS(); float vscale = srcTex.getMaxTextureCoordT(); float cx = 0.0f; float sx = +1.0f; if (destTex.isFlippedX()) { cx = 1.0f; sx = -1.0f; } float cy = 0.0f; float sy = +1.0f; if (destTex.isFlippedY()) { cy = 1.0f; sy = -1.0f; } gl.glEnable(srcTex.getTextureTarget()); gl.glActiveTexture(GL.GL_TEXTURE0); gl.glBindTexture(srcTex.getTextureTarget(), srcTex.getTextureID()); pushFramebuffer(); setFramebuffer(FBO); FBO.setDrawBuffer(destTex.getTextureTarget(), destTex.getTextureID()); saveView(); setOrthographicView(destTex.width, destTex.height); gl.glEnable(srcTex.getTextureTarget()); gl.glActiveTexture(GL.GL_TEXTURE0); gl.glBindTexture(srcTex.getTextureTarget(), srcTex.getTextureID()); gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f((cx + sx * 0.0f) * uscale, (cy + sy * 0.0f) * vscale); gl.glVertex2f(0.0f, 0.0f); gl.glTexCoord2f((cx + sx * 1.0f) * uscale, (cy + sy * 0.0f) * vscale); gl.glVertex2f(srcTex.width, 0.0f); gl.glTexCoord2f((cx + sx * 1.0f) * uscale, (cy + sy * 1.0f) * vscale); gl.glVertex2f(srcTex.width, srcTex.height); gl.glTexCoord2f((cx + sx * 0.0f) * uscale, (cy + sy * 1.0f) * vscale); gl.glVertex2f(0.0f, srcTex.height); gl.glEnd(); gl.glBindTexture(srcTex.getTextureTarget(), 0); restoreView(); popFramebuffer(); }
public void display(GLCanvas canvas) { GL gl = canvas.getGL(); // // render the simulation // try { sim.update(); } catch (Exception e) { Log.println("[Editor] exception in simulation update/calculate paths: " + e.getMessage()); e.printStackTrace(); } renderer.render(sim, canvas); // // render the grid // gl.glColor4f(0.4f, 0.4f, 0.4f, 0.4f); gl.glEnable(GL.GL_BLEND); gl.glBegin(GL.GL_LINES); for (int x = 0; x < 100; x++) { gl.glVertex2f( -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4, -50 * Constants.PLANET_MAX_SIZE * 4); gl.glVertex2f( -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4, 50 * Constants.PLANET_MAX_SIZE * 4); } for (int x = 0; x < 100; x++) { gl.glVertex2f( -50 * Constants.PLANET_MAX_SIZE * 4, -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4); gl.glVertex2f( +50 * Constants.PLANET_MAX_SIZE * 4, -50 * Constants.PLANET_MAX_SIZE * 4 + x * Constants.PLANET_MAX_SIZE * 4); } gl.glDisable(GL.GL_BLEND); gl.glEnd(); // // render rectangle selection // if (drag_start != null && drag_end != null && selected_planets.size() == 0) { gl.glLineWidth(2); gl.glColor4f(1, 1, 1, 1); Widget.renderOutlinedQuad( drag_start.x, drag_start.y, drag_end.x - drag_start.x, -(drag_end.y - drag_start.y)); gl.glLineWidth(1); } // // render reference system // gl.glColor3f(1, 1, 1); gl.glBegin(GL.GL_LINES); gl.glColor3f(1, 0, 0); gl.glVertex2f(Constants.PLANET_MAX_SIZE * 50, 0); gl.glVertex2f(-Constants.PLANET_MAX_SIZE * 50, 0); gl.glColor3f(0, 1, 0); gl.glVertex2f(0, Constants.PLANET_MAX_SIZE * 50); gl.glVertex2f(0, -Constants.PLANET_MAX_SIZE * 50); gl.glEnd(); try { Thread.sleep(5); } catch (InterruptedException e) { } // // check mouse over planet // if (sim.getPlanet( renderer.getCamera().getScreenToWorldX(mouse_pos.x), renderer.getCamera().getScreenToWorldY(mouse_pos.y)) != null && !this.wasGuiIntersected(mouse_pos.x, mouse_pos.y) && drag_start != null) for (WorldAlignementContainer cont : conts) cont.setVisible(false); else for (WorldAlignementContainer cont : conts) cont.setVisible(true); }