/** Applies fixed function bindings from the context to OpenGL */ private void applyFixedFuncBindings(boolean forLighting) { GL gl = GLContext.getCurrentGL(); if (forLighting) { gl.getGL2().glMaterialf(GL.GL_FRONT_AND_BACK, GLLightingFunc.GL_SHININESS, context.shininess); setMaterialColor(GLLightingFunc.GL_AMBIENT, context.ambient, ColorRGBA.DarkGray); setMaterialColor(GLLightingFunc.GL_DIFFUSE, context.diffuse, ColorRGBA.White); setMaterialColor(GLLightingFunc.GL_SPECULAR, context.specular, ColorRGBA.Black); if (context.useVertexColor) { gl.glEnable(GLLightingFunc.GL_COLOR_MATERIAL); } else { gl.glDisable(GLLightingFunc.GL_COLOR_MATERIAL); } } else { // Ignore other values as they have no effect when // GL_LIGHTING is disabled. ColorRGBA color = context.color; if (color != null) { gl.getGL2().glColor4f(color.r, color.g, color.b, color.a); } else { gl.getGL2().glColor4f(1, 1, 1, 1); } } if (context.alphaTestFallOff > 0f) { gl.glEnable(GL2ES1.GL_ALPHA_TEST); gl.getGL2ES1().glAlphaFunc(GL.GL_GREATER, context.alphaTestFallOff); } else { gl.glDisable(GL2ES1.GL_ALPHA_TEST); } }
/** * レンダリング環境のセットアップ * * @param gcon */ public void begin(GraphicContext gcon) { GraphicContextJogl gc = (GraphicContextJogl) gcon; GL gl = gc.getGL(); if ((state_ & CLEAR) == CLEAR) { gl.glClearColor(r_, g_, b_, 1.0f); // カラープレーン初期値 gl.glClearDepth(1.0); // デプスバッファの初期値 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } gl.glEnable(GL.GL_DEPTH_TEST); // デプスバッファをイネーブル gl.glDepthFunc(GL.GL_LESS); // デプスバッファの計算法指定 gl.glDepthMask(true); // デプスバッファをリードライト gl.glEnable(GL.GL_LIGHTING); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); float right = (float) (near_ * Math.tan(fovx_ / 2)); float left = -right; float top = right * aspect_; float bottom = -top; gl.glFrustum(left, right, bottom, top, near_, far_); buildViewMatrix(); gc.setViewMatrix(viewMatrix_); }
/** * Renders the tile to the given context, in the process building all needed resources. * * @param gl */ public void render(GL gl) { projection = ProjectionFactory.getCurrentProjection(); heightmap = State.getInstance().getLoadedHeightmap(); // BUILD TEXTURES IF NECESSARY if (!gl.glIsTexture(textureID)) { textureID = createTexture(gl, getImage(), false); // prerenderToTexture(gl); } if (!gl.glIsTexture(grainTextureID)) { createGrainTexture(gl); } // RENDER TILE FROM DISPLAY LIST, OR ELSE BUILD DISPLAY LIST if (gl.glIsList(displaylistID)) { gl.glCallList(displaylistID); } else { displaylistID = gl.glGenLists(1); gl.glNewList(displaylistID, GL_COMPILE_AND_EXECUTE); gl.glActiveTexture(GL_TEXTURE0); gl.glEnable(GL_TEXTURE_2D); gl.glBindTexture(GL_TEXTURE_2D, grainTextureID); gl.glActiveTexture(GL_TEXTURE1); gl.glEnable(GL_TEXTURE_2D); gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); gl.glBindTexture(GL_TEXTURE_2D, textureID); gl.glColor3f(1, 1, 1); float[] color = new float[3]; float hRes = HEIGHT_RESOLUTION - 1; float stepSize = bounds.getWidth() / hRes; Coordinates pos = new Coordinates(); for (int x = 0; x < hRes; x++) { gl.glBegin(GL_TRIANGLE_STRIP); for (int y = 0; y <= hRes; y++) { for (int i = 0; i < 2; i++) { pos.setLatitude(bounds.getTop() + y * stepSize); pos.setLongitude(bounds.getLeft() + (x + i) * stepSize); gl.glMultiTexCoord2f( GL_TEXTURE0, (x + i) / (float) GRAIN_RESOLUTION, y / (float) GRAIN_RESOLUTION); gl.glMultiTexCoord2f(GL_TEXTURE1, (x + i) / hRes, y / hRes); float height = heights[x + HEIGHT_BORDER + i][y + HEIGHT_BORDER]; getHeightColor(color, height); float shade = getShade(x + i, y, stepSize); gl.glColor3f(color[0] * shade, color[1] * shade, color[2] * shade); gl.glVertex3f(pos.getLongitude(), pos.getLatitude(), height); } } gl.glEnd(); } gl.glDisable(GL_TEXTURE_2D); gl.glActiveTexture(GL_TEXTURE0); renderPOIs(gl); gl.glEndList(); } }
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(); }
/** paint the portal using gl. */ public void paint(GL gl, GLDrawable glc) { if (fill != null) { setColor(gl, fill); gl.glDisable(GL.GL_TEXTURE_2D); } gl.glLineWidth(lineWidth()); gl.glBegin(GL.GL_LINES); // draw each wall for (int i = 0; i < pts2d.size(); i++) { Point2D p = (Point2D) (pts2d.get(i)); gl.glVertex2d(p.x, p.y); } gl.glEnd(); if (pts2d.size() == 4) { /* Connect mid point of the two line segments with dotted line*/ gl.glLineStipple(1, (short) 0x0F0F); gl.glEnable(GL.GL_LINE_STIPPLE); gl.glLineWidth(1); gl.glBegin(GL.GL_LINES); Point2D mid = pts2d.get(0).interp(pts2d.get(1), 0.5); gl.glVertex2d(mid.x, mid.y); mid = pts2d.get(2).interp(pts2d.get(3), 0.5); gl.glVertex2d(mid.x, mid.y); gl.glEnd(); gl.glDisable(GL.GL_LINE_STIPPLE); } }
public final void init(final GLAutoDrawable drawable) { Debug.print(); final GL gl = drawable.getGL(); gl.glEnable(GL.GL_DEPTH_TEST); TextureManager.clear(); }
/** * Establish the OpenGL state needed to draw text. * * @param dc the current draw context. */ protected void beginDrawing(DrawContext dc) { GL gl = dc.getGL(); int attrMask = GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func | GL.GL_TRANSFORM_BIT // for modelview and perspective | GL.GL_VIEWPORT_BIT // for depth range | GL.GL_CURRENT_BIT // for current color | GL.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend | GL.GL_DEPTH_BUFFER_BIT // for depth func | GL.GL_ENABLE_BIT; // for enable/disable changes this.BEogsh.pushAttrib(gl, attrMask); if (!dc.isPickingMode()) { gl.glEnable(GL.GL_BLEND); OGLUtil.applyBlending(gl, false); } // Do not depth buffer the label. (Labels beyond the horizon are culled above.) gl.glDisable(GL.GL_DEPTH_TEST); gl.glDepthMask(false); // The image is drawn using a parallel projection. this.BEogsh.pushProjectionIdentity(gl); gl.glOrtho( 0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -1d, 1d); this.BEogsh.pushModelviewIdentity(gl); }
@Override public void display(GLContext context) { initializeNewMembers(context, true); validateLayout(context); validateListenerShapes(context); Rectangle b = getBounds(); if (b.width == 0 || b.height == 0) return; GL gl = context.getGL(); try { gl.glEnable(GL.GL_SCISSOR_TEST); // TODO: scissor so as not to overrun the parent viewport // TODO: reconcile viewport with GLGlimpseListener viewport call gl.glViewport(b.x, b.y, b.width, b.height); gl.glScissor(b.x, b.y, b.width, b.height); for (Member m : members) { if (m.callback != null) m.callback.preDisplay(m.listener, context, isHovered()); m.listener.display(context); if (m.callback != null) m.callback.postDisplay(m.listener, context, isHovered()); } } finally { gl.glDisable(GL.GL_SCISSOR_TEST); } }
/** * Init the rendering of this canvas. This function is called right before the first rendering * run. Its used to setup everything correctly. * * @param drawable the drawable object used to access the openGL functions */ @Override public void init(final GLAutoDrawable drawable) { if (drawable.getContext() == null) { return; } displayOpenGLStatusInfo(); // drawable.setGL(new DebugGL(drawable.getGL())); setupViewport(drawable); boolean releaseContext = false; if (GLContext.getCurrent() == null) { drawable.getContext().makeCurrent(); releaseContext = true; } final GL gl = drawable.getGL(); gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // getContext().setSynchronized(true); gl.setSwapInterval(0); // disable vsync if (releaseContext) { drawable.getContext().release(); } }
public void updateSelectedOctant(GL gl, GLU glu, float[] mousePosition, float[] pickRectangle) { // Start Picking mode int capacity = 1 * 4 * visibleLeaves.size(); // Each object take in maximium : 4 * name stack depth IntBuffer hitsBuffer = BufferUtil.newIntBuffer(capacity); gl.glSelectBuffer(hitsBuffer.capacity(), hitsBuffer); gl.glRenderMode(GL.GL_SELECT); gl.glDisable(GL.GL_CULL_FACE); // Disable flags gl.glInitNames(); gl.glPushName(0); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); glu.gluPickMatrix( mousePosition[0], mousePosition[1], pickRectangle[0], pickRectangle[1], drawable.getViewport()); gl.glMultMatrixd(drawable.getProjectionMatrix()); gl.glMatrixMode(GL.GL_MODELVIEW); // Draw the nodes' cube int the select buffer int hitName = 1; for (int i = 0; i < visibleLeaves.size(); i++) { Octant node = visibleLeaves.get(i); gl.glLoadName(hitName); node.displayOctant(gl); hitName++; } // Restoring the original projection matrix gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glFlush(); // Returning to normal rendering mode int nbRecords = gl.glRenderMode(GL.GL_RENDER); if (vizController.getVizModel().isCulling()) { gl.glEnable(GL.GL_CULL_FACE); gl.glCullFace(GL.GL_BACK); } // Clean previous selection selectedLeaves.clear(); // Get the hits and put the node under selection in the selectionArray for (int i = 0; i < nbRecords; i++) { int hit = hitsBuffer.get(i * 4 + 3) - 1; // -1 Because of the glPushName(0) Octant nodeHit = visibleLeaves.get(hit); selectedLeaves.add(nodeHit); } }
/** * Renders the skybox using VBO * * @param drawable current rendering context */ public void display(GLAutoDrawable drawable) { GL gl = drawable.getGL(); // Enable arrays gl.glEnableClientState(GL.GL_VERTEX_ARRAY); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); if (nVertices == 0) { createVBO(gl); } // gl.glDisable(GL.GL_CULL_FACE); gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); gl.glEnable(GL.GL_TEXTURE_2D); texture.load(gl); // Vertex coordinates gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[0]); gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0); gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[1]); gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0); // Render // Draw All Of The Triangles At Once gl.glDrawArrays(GL.GL_TRIANGLES, 0, nVertices); // Disable Vertex Arrays gl.glDisableClientState(GL.GL_VERTEX_ARRAY); gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY); gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); // gl.glEnable(GL.GL_CULL_FACE); }
private void renderPin(GL gl, Coordinates position, float[] color, float size) { float height = heightmap.getHeight(projection.getGeoCoordinates(position)); gl.glPushMatrix(); double[] model = new double[16]; gl.glGetDoublev(GL_MODELVIEW_MATRIX, model, 0); double zoomH = 0.1 / Math.sqrt((model[0] * model[0]) + (model[1] * model[1]) + (model[2] * model[2])); double zoomZ = 0.1 / Math.sqrt((model[8] * model[8]) + (model[9] * model[9]) + (model[10] * model[10])); gl.glTranslatef(position.getLongitude(), position.getLatitude(), height); gl.glScaled(zoomH * size, zoomH * size, zoomZ * size); gl.glDisable(GL_TEXTURE_2D); gl.glRotatef(20, 0.3f, 1, 0); GLU glu = new GLU(); GLUquadric quadric = glu.gluNewQuadric(); // glu.gluQuadricNormals(quadric, GLU.GLU_FLAT); gl.glColor3f(0.5f, 0.5f, 0.5f); gl.glEnable(GL_LIGHTING); glu.gluCylinder(quadric, 0.03, 0.03, 0.6f, 5, 1); gl.glTranslatef(0, 0, 0.6f); gl.glColor3f(color[0], color[1], color[2]); gl.glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glu.gluSphere(quadric, 0.12, 8, 8); // glu.gluCylinder(quadric, 0.2, 0.1, 0.5, 8, 1); gl.glDisable(GL_LIGHTING); glu.gluDeleteQuadric(quadric); gl.glPopMatrix(); }
void glow() { final PGraphicsOpenGL pgl = (PGraphicsOpenGL) g; final GL openGL = pgl.beginGL(); openGL.glDisable(GL.GL_DEPTH_TEST); openGL.glEnable(GL.GL_BLEND); openGL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); pgl.endGL(); }
public void init(GL gl) { // Starts with animation turned off setAnimation(false); // --- OpenGL Initialization // Set background color to sky blue gl.glClearColor(0.58f, 0.74f, 0.98f, 0.0f); // Turn on Z buffer gl.glEnable(GL.GL_DEPTH_TEST); // Turn on Gouraud shaded polygons gl.glShadeModel(GL.GL_SMOOTH); // Turn on automatic normalization for normal vectors gl.glEnable(GL.GL_NORMALIZE); }
public void enableTexture(Texture tex, Polygon texCoords) { if (tex.equals(currentTexture)) return; currentTexture = tex; textureCoords = texCoords; currentTexture.bind(); gl.glEnable(GL.GL_TEXTURE_2D); }
public void init(GLAutoDrawable drawable) { GL gl = drawable.getGL(); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadMatrixd(this._nyar.getGlProjectionMatrix(), 0); gl.glEnable(GL.GL_DEPTH_TEST); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); Animator animator = new Animator(drawable); animator.start(); return; }
/** OpenGL initialization function Called once, on startup */ @Override public void init(GLAutoDrawable auto_drawable) { // initialize OpenGL state, load arrays, etc. // anything needs to be dont before the drawing calls final GL gl = auto_drawable.getGL(); gl.glShadeModel(GL.GL_SMOOTH); gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f); gl.glClearDepth(1.0f); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL); gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); gl.glEnableClientState(GL.GL_VERTEX_ARRAY); // set the texture mode to decal, so textures are rendered independent of // underlying colors gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_DECAL); // initialize vertex arrays initVertexArrays(); // enable 2D texturing gl.glEnable(GL.GL_TEXTURE_2D); // load the question texture question_Texture = loadTexture("Data/Pictures/question_mark.png"); // set up fog effect float fogColor[] = {0.5f, 0.5f, 0.5f, 1.0f}; // Fog Color gl.glFogi(GL.GL_FOG_MODE, GL.GL_LINEAR); // Fog Mode gl.glFogfv(GL.GL_FOG_COLOR, FloatArrayToFloatBuffer(fogColor)); // Set Fog Color gl.glFogf(GL.GL_FOG_DENSITY, 0.35f); // How Dense Will The Fog Be gl.glHint(GL.GL_FOG_HINT, GL.GL_NICEST); // Fog Hint Value gl.glFogf(GL.GL_FOG_START, 0.0f); // Fog Start Depth gl.glFogf(GL.GL_FOG_END, 3.0f); // Fog End Depth gl.glEnable(GL.GL_FOG); // Enables GL_FOG // load all textures LoadAllGuessModelTextures(guess_model_array); }
public void init(GLAutoDrawable gLDrawable) { renderer = new TextRenderer(new Font("SansSerif", Font.BOLD, 36)); // creates textrenderer GL gl = gLDrawable.getGL(); gl.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Black Background gl.glClearDepth(1.0f); // Depth Buffer Setup gl.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing gl.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do // Really Nice Perspective Calculations gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); }
private void enableFog(boolean enable, FogStateRecord record) { final GL gl = GLU.getCurrentGL(); if (record.isValid()) { if (enable && !record.enabled) { gl.glEnable(GL.GL_FOG); record.enabled = true; } else if (!enable && record.enabled) { gl.glDisable(GL.GL_FOG); record.enabled = false; } } else { if (enable) { gl.glEnable(GL.GL_FOG); } else { gl.glDisable(GL.GL_FOG); } record.enabled = enable; } }
private void draw(DrawContext dc) { this.referencePoint = this.computeReferencePoint(dc); this.assembleTiles(dc); // Determine the tiles to draw. if (this.currentTiles.size() >= 1) { MercatorTextureTile[] sortedTiles = new MercatorTextureTile[this.currentTiles.size()]; sortedTiles = this.currentTiles.toArray(sortedTiles); Arrays.sort(sortedTiles, levelComparer); GL gl = dc.getGL(); if (this.isUseTransparentTextures() || this.getOpacity() < 1) { gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL.GL_POLYGON_BIT | GL.GL_CURRENT_BIT); gl.glColor4d(1d, 1d, 1d, this.getOpacity()); gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); } else { gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL.GL_POLYGON_BIT); } gl.glPolygonMode(GL.GL_FRONT, GL.GL_FILL); gl.glEnable(GL.GL_CULL_FACE); gl.glCullFace(GL.GL_BACK); dc.setPerFrameStatistic( PerformanceStatistic.IMAGE_TILE_COUNT, this.tileCountName, this.currentTiles.size()); dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles); gl.glPopAttrib(); if (this.drawTileIDs) this.drawTileIDs(dc, this.currentTiles); if (this.drawBoundingVolumes) this.drawBoundingVolumes(dc, this.currentTiles); this.currentTiles.clear(); } this.sendRequests(); this.requestQ.clear(); }
/** States for texture, smooth and flat models */ public void enableStates() { if (hasTextureCoordinates()) { gl.glEnable(GL.GL_TEXTURE_2D); } if (isSmoothShadingEnabled()) { gl.glShadeModel(GL.GL_SMOOTH); } else { gl.glShadeModel(GL.GL_FLAT); } }
public void desenhar(GL gl, GLUT glut) { gl.glShadeModel(GL.GL_FLAT); gl.glNormal3f(0.0f, 0.0f, 1.0f); gl.glColor3f(1f, 1f, 1f); float corWhite[] = {1.0f, 1.0f, 1.0f, 1.0f}; // base setTexture(Util.loadImage("texture/textureBrick.png")); getTexture().enable(); getTexture().bind(); gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, corWhite, 0); gl.glEnable(GL.GL_LIGHTING); gl.glPushMatrix(); gl.glTranslatef(0f, -dif, 0f); gl.glScalef(getxEscala(), getyEscala(), getzEscala()); glut.glutSolidCube(1f); gl.glPopMatrix(); // esquerda setTexture(Util.loadImage("texture/tijolos/medio2.png")); getTexture().enable(); getTexture().bind(); gl.glPushMatrix(); gl.glTranslatef(-(getxEscala() / 2), (getAltura() / 2) - dif, 0f); gl.glScalef(0.1f, getAltura(), getzEscala()); glut.glutSolidCube(1f); gl.glPopMatrix(); gl.glDisable(GL.GL_LIGHTING); // direita setTexture(Util.loadImage("texture/tijolos/medio2.png")); getTexture().enable(); getTexture().bind(); gl.glPushMatrix(); gl.glTranslatef(getxEscala() / 2, (getAltura() / 2) - dif, 0f); gl.glScalef(0.1f, getAltura(), getzEscala()); glut.glutSolidCube(1f); gl.glPopMatrix(); gl.glDisable(GL.GL_LIGHTING); // fundo setTexture(Util.loadImage("texture/tijolos/fraco.png")); getTexture().enable(); getTexture().bind(); gl.glPushMatrix(); gl.glTranslatef(0f, (getAltura() / 2) - dif, -(getzEscala() / 2)); gl.glScalef(getxEscala(), getAltura(), 0.1f); glut.glutSolidCube(1f); gl.glPopMatrix(); gl.glDisable(GL.GL_LIGHTING); }
private void initOpenGL() { pgl = (PGraphicsOpenGL) g; gl = pgl.gl; gl.setSwapInterval(1); gl.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background gl.glClearDepth(1.0f); // Depth Buffer Setup gl.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing gl.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do gl.glHint( GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations gl.glDisable(GL.GL_TEXTURE_2D); // Set up lighting gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, lightAmbient, 0); gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, lightDiffuse, 0); // gl.glLightfv( GL.GL_LIGHT1, GL.GL_SPECULAR, lightSpecular, 0 ); gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, lightPosition, 0); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT1); }
public void initialize() { GL gl = GLContext.getCurrentGL(); if (gl.isExtensionAvailable("GL_VERSION_1_2")) { gl12 = true; } // workaround, always assume we support GLSL100 // some cards just don't report this correctly caps.add(Caps.GLSL100); // Default values for certain GL state. gl.getGL2ES1().glShadeModel(GLLightingFunc.GL_SMOOTH); gl.getGL2().glColorMaterial(GL.GL_FRONT_AND_BACK, GLLightingFunc.GL_DIFFUSE); gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Enable rescaling/normaling of normal vectors. // Fixes lighting issues with scaled models. if (gl12) { gl.glEnable(GL2ES1.GL_RESCALE_NORMAL); } else { gl.glEnable(GLLightingFunc.GL_NORMALIZE); } if (gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")) { caps.add(Caps.NonPowerOfTwoTextures); } else { logger.log( Level.WARNING, "Your graphics card does not " + "support non-power-of-2 textures. " + "Some features might not work."); } gl.glGetIntegerv(GL2ES1.GL_MAX_LIGHTS, ib1); maxLights = ib1.get(0); gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, ib1); maxTexSize = ib1.get(0); }
public void setClipRect(int x, int y, int width, int height) { GL gl = GLContext.getCurrentGL(); if (!context.clipRectEnabled) { gl.glEnable(GL.GL_SCISSOR_TEST); context.clipRectEnabled = true; } if (clipX != x || clipY != y || clipW != width || clipH != height) { gl.glScissor(x, y, width, height); clipX = x; clipY = y; clipW = width; clipH = height; } }
void texsel(int id) { if (id != sh.curtex) { HavenPanel.texmiss++; if (id == -1) { gl.glDisable(GL.GL_TEXTURE_2D); } else { gl.glEnable(GL.GL_TEXTURE_2D); gl.glBindTexture(GL.GL_TEXTURE_2D, id); } sh.curtex = id; } else { HavenPanel.texhit++; } }
public void updateVisibleOctant(GL gl) { // Limits refreshLimits(); // Switch to OpenGL select mode int capacity = 1 * 4 * leaves.getCount(); // Each object take in maximium : 4 * name stack depth IntBuffer hitsBuffer = BufferUtil.newIntBuffer(capacity); gl.glSelectBuffer(hitsBuffer.capacity(), hitsBuffer); gl.glRenderMode(GL.GL_SELECT); gl.glInitNames(); gl.glPushName(0); gl.glDisable(GL.GL_CULL_FACE); // Disable flags // Draw the nodes cube in the select buffer for (Octant n : leaves) { n .resetUpdatePositionFlag(); // Profit from the loop to do this, because this method is // always after updating position gl.glLoadName(n.getNumber()); n.displayOctant(gl); } int nbRecords = gl.glRenderMode(GL.GL_RENDER); if (vizController.getVizModel().isCulling()) { gl.glEnable(GL.GL_CULL_FACE); gl.glCullFace(GL.GL_BACK); } visibleLeaves.clear(); // Get the hits and add the nodes' objects to the array int depth = Integer.MAX_VALUE; int minDepth = -1; for (int i = 0; i < nbRecords; i++) { int hit = hitsBuffer.get(i * 4 + 3); // -1 Because of the glPushName(0) int minZ = hitsBuffer.get(i * 4 + 1); if (minZ < depth) { depth = minZ; minDepth = hit; } Octant nodeHit = leaves.getItem(hit); visibleLeaves.add(nodeHit); } if (minDepth != -1) { Octant closestOctant = leaves.getItem(minDepth); Vec3f pos = new Vec3f(closestOctant.getPosX(), closestOctant.getPosY(), closestOctant.getPosZ()); limits.setClosestPoint(pos); } // System.out.println(minDepth); }
public void draw() { if (!isTiling) { psys.update(srcImage.getPixels(), dstImage.getPixels()); } tiler.pre(); background(0); srcImage.draw(); // dstImage.draw(); // lights. if (isLightingEnabled) { gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT1); } else { gl.glDisable(GL.GL_LIGHTING); gl.glDisable(GL.GL_LIGHT1); } // START DRAW. pgl.beginGL(); gl.glPushMatrix(); gl.glTranslatef(sceneCenterX, sceneCenterY, sceneCenterZ); drawSomething(); gl.glPopMatrix(); pgl.endGL(); tiler.post(); if (!tiler.checkStatus() && isTiling) { isTiling = false; } if (isRecording) save("export/image" + frameCount + ".png"); }
private void display(GL gl, GLU glu, final JoglFrameBufferObject theFBO) { final int w = theFBO.getPixelWidth(); final int h = theFBO.getPixelHeight(); /* bind position data */ gl.glEnableClientState(GL.GL_VERTEX_ARRAY); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, _myVBO); gl.glVertexPointer(4, GL.GL_FLOAT, 0, 0); /* bind point size data */ _myShaderManager.enable(_myPointSpriteShader); final int myPointSizeAttrib = gl.glGetAttribLocation(_myPointSpriteShader.getOpenGLID(), "vertexAttribute"); gl.glEnableVertexAttribArray(myPointSizeAttrib); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, _myIBO); gl.glVertexAttribPointer(myPointSizeAttrib, 3, GL.GL_FLOAT, false, 0, 0); gl.glEnable(GL.GL_VERTEX_PROGRAM_POINT_SIZE_ARB); /* --- */ final JoglFrameBufferObject READ_FBO = _myFBO; _myShaderManager.setUniform( _myPointSpriteShader, "textureVelocity", READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureUnit() - GL.GL_TEXTURE0); _myShaderManager.setUniform(_myPointSpriteShader, "velocityThreshold", velocity_threshold); _myShaderManager.setUniform(_myPointSpriteShader, "sizeThreshold", size_threshold); _myShaderManager.setUniform(_myPointSpriteShader, "pointSize", point_size); _myShaderManager.setUniform(_myPointSpriteShader, "flowdirection", flow_direction); _myShaderManager.setUniform(_myPointSpriteShader, "collisionratio", collision_ratio); gl.glActiveTexture(READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureUnit()); gl.glBindTexture( READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureTarget(), READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureID()); JoglUtil.printGLError(gl, glu, "binding texture", true); gl.glDrawArrays(GL.GL_POINTS, 0, w * h); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); gl.glDisableClientState(GL.GL_VERTEX_ARRAY); gl.glDisableVertexAttribArray(myPointSizeAttrib); _myShaderManager.disable(); gl.glDisable(GL.GL_VERTEX_PROGRAM_POINT_SIZE_ARB); gl.glBindTexture(READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureTarget(), 0); JoglUtil.printGLError(gl, glu, "display()", true); }
public void displayOctree(GL gl, GLU glu) { gl.glDisable(GL.GL_CULL_FACE); gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); for (Octant o : visibleLeaves) { gl.glColor3f(1, 0.5f, 0.5f); o.displayOctant(gl); o.displayOctantInfo(gl, glu); } if (!vizController.getVizConfig().isWireFrame()) { gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); } if (vizController.getVizModel().isCulling()) { gl.glEnable(GL.GL_CULL_FACE); gl.glCullFace(GL.GL_BACK); } }