Java Code Examples for com.jogamp.opengl.GL2GL3#glGetAttribLocation()
The following examples show how to use
com.jogamp.opengl.GL2GL3#glGetAttribLocation() .
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: Polygon.java From jaamsim with Apache License 2.0 | 6 votes |
public static void init(Renderer r, GL2GL3 gl) { int[] is = new int[1]; gl.glGenBuffers(1, is, 0); _vertBuffer = is[0]; Shader s = r.getShader(ShaderHandle.DEBUG); _progHandle = s.getProgramHandle(); gl.glUseProgram(_progHandle); _modelViewMatVar = gl.glGetUniformLocation(_progHandle, "modelViewMat"); _projMatVar = gl.glGetUniformLocation(_progHandle, "projMat"); _colorVar = gl.glGetUniformLocation(_progHandle, "color"); _cVar = gl.glGetUniformLocation(_progHandle, "C"); _fcVar = gl.glGetUniformLocation(_progHandle, "FC"); _posVar = gl.glGetAttribLocation(_progHandle, "position"); _hasInitialized = true; }
Example 2
Source File: TextureView.java From jaamsim with Apache License 2.0 | 6 votes |
private void updateTexCoordBuffer(Renderer renderer) { GL2GL3 gl = renderer.getGL(); int texCoordBuffSize = _texCoords.size()*2*4; _texCoordHandle = renderer.getTexMemManager().allocateBuffer(texCoordBuffSize, gl); int buffID = _texCoordHandle.bind(); FloatBuffer texData = FloatBuffer.allocate(_texCoords.size()*2); for (Vec2d v : _texCoords) { texData.put((float)v.x); texData.put((float)v.y); } texData.flip(); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, buffID); gl.glBufferData(GL2GL3.GL_ARRAY_BUFFER, texCoordBuffSize, texData, GL2GL3.GL_STATIC_DRAW); int texCoordVar = gl.glGetAttribLocation(progHandle, "texCoord"); gl.glEnableVertexAttribArray(texCoordVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, buffID); gl.glVertexAttribPointer(texCoordVar, 2, GL2GL3.GL_FLOAT, false, 0, 0); }
Example 3
Source File: OverlayPolygon.java From jaamsim with Apache License 2.0 | 6 votes |
private static void initStaticData(Renderer r) { GL2GL3 gl = r.getGL(); // Initialize the shader variables progHandle = r.getShader(Renderer.ShaderHandle.OVERLAY_FLAT).getProgramHandle(); int[] is = new int[1]; gl.glGenBuffers(1, is, 0); glBuff = is[0]; hasTexVar = gl.glGetUniformLocation(progHandle, "useTex"); sizeVar = gl.glGetUniformLocation(progHandle, "size"); offsetVar = gl.glGetUniformLocation(progHandle, "offset"); colorVar = gl.glGetUniformLocation(progHandle, "color"); posVar = gl.glGetAttribLocation(progHandle, "position"); staticInit = true; }
Example 4
Source File: OverlayLine.java From jaamsim with Apache License 2.0 | 6 votes |
private static void initStaticData(Renderer r) { GL2GL3 gl = r.getGL(); // Initialize the shader variables progHandle = r.getShader(Renderer.ShaderHandle.OVERLAY_FLAT).getProgramHandle(); int[] is = new int[1]; gl.glGenBuffers(1, is, 0); lineGLBuff = is[0]; hasTexVar = gl.glGetUniformLocation(progHandle, "useTex"); sizeVar = gl.glGetUniformLocation(progHandle, "size"); offsetVar = gl.glGetUniformLocation(progHandle, "offset"); colorVar = gl.glGetUniformLocation(progHandle, "color"); posVar = gl.glGetAttribLocation(progHandle, "position"); staticInit = true; }
Example 5
Source File: TextureView.java From jaamsim with Apache License 2.0 | 5 votes |
private void setupVAO(int contextID, Renderer renderer) { GL2GL3 gl = renderer.getGL(); int vao = renderer.generateVAO(contextID, gl); VAOMap.put(contextID, vao); gl.glBindVertexArray(vao); // Position int posVar = gl.glGetAttribLocation(progHandle, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, vertBuff); gl.glVertexAttribPointer(posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); // Normals int normalVar = gl.glGetAttribLocation(progHandle, "normal"); gl.glEnableVertexAttribArray(normalVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, normalBuff); gl.glVertexAttribPointer(normalVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); // TexCoords if (_texCoords == null) { // Use default buffer if custom coords have not been included int texCoordVar = gl.glGetAttribLocation(progHandle, "texCoord"); gl.glEnableVertexAttribArray(texCoordVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, texCoordBuff); gl.glVertexAttribPointer(texCoordVar, 2, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); } gl.glBindVertexArray(0); }
Example 6
Source File: MeshProto.java From jaamsim with Apache License 2.0 | 5 votes |
private static void initBSInfo(Renderer r, GL2GL3 gl) { BatchShaderInfo si = bsInfo; si.progHandle = r.getShader(ShaderHandle.MESH_BATCH).getProgramHandle(); int ph = bsInfo.progHandle; gl.glUseProgram(ph); si.instSpaceMatVar = gl.glGetAttribLocation(ph, "instSpaceMat"); si.instSpaceNorMatVar = gl.glGetAttribLocation(ph, "instSpaceNorMat"); // Bind the shader variables si.modelViewMatVar = gl.glGetUniformLocation(ph, "modelViewMat"); si.projMatVar = gl.glGetUniformLocation(ph, "projMat"); si.normalMatVar = gl.glGetUniformLocation(ph, "normalMat"); si.posVar = gl.glGetAttribLocation(ph, "position"); si.norVar = gl.glGetAttribLocation(ph, "normal"); si.texCoordVar = gl.glGetAttribLocation(ph, "texCoord"); si.diffTexVar = gl.glGetUniformLocation(ph, "diffTexs"); si.diffuseColorVar = gl.glGetAttribLocation(ph, "diffuseColorV"); si.diffTexIndexVar = gl.glGetAttribLocation(ph, "diffTexIndexV"); si.ambientColorVar = gl.glGetAttribLocation(ph, "ambientColorV"); si.specColorVar = gl.glGetAttribLocation(ph, "specColorV"); si.shininessVar = gl.glGetAttribLocation(ph, "shininessV"); si.lightDirVar = gl.glGetUniformLocation(ph, "lightDir"); si.lightIntVar = gl.glGetUniformLocation(ph, "lightIntensity"); si.numLightsVar = gl.glGetUniformLocation(ph, "numLights"); si.cVar = gl.glGetUniformLocation(ph, "C"); si.fcVar = gl.glGetUniformLocation(ph, "FC"); }
Example 7
Source File: Skybox.java From jaamsim with Apache License 2.0 | 4 votes |
private void setupVAO(int contextID, Renderer renderer) { GL2GL3 gl = renderer.getGL(); int vao = renderer.generateVAO(contextID, gl); VAOMap.put(contextID, vao); gl.glBindVertexArray(vao); // Position int posVar = gl.glGetAttribLocation(progHandle, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, vertBuff); gl.glVertexAttribPointer(posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); gl.glBindVertexArray(0); }
Example 8
Source File: OverlayTexture.java From jaamsim with Apache License 2.0 | 4 votes |
private void setupVAO(int contextID, Renderer renderer) { GL2GL3 gl = renderer.getGL(); int vao = renderer.generateVAO(contextID, gl); VAOMap.put(contextID, vao); gl.glBindVertexArray(vao); // Position int posVar = gl.glGetAttribLocation(progHandle, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, vertBuff); gl.glVertexAttribPointer(posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); // TexCoords int texCoordVar = gl.glGetAttribLocation(progHandle, "texCoordVert"); gl.glEnableVertexAttribArray(texCoordVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, texCoordBuff); gl.glVertexAttribPointer(texCoordVar, 2, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindVertexArray(0); }
Example 9
Source File: HullProto.java From jaamsim with Apache License 2.0 | 4 votes |
private void setupVAO(int contextID, Renderer renderer, int progHandle, int vertexBuffer, int indexBuffer) { GL2GL3 gl = renderer.getGL(); int vao = renderer.generateVAO(contextID, gl); _vaoMap.put(contextID, vao); gl.glBindVertexArray(vao); gl.glUseProgram(progHandle); int posVar = gl.glGetAttribLocation(progHandle, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, vertexBuffer); gl.glVertexAttribPointer(posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ELEMENT_ARRAY_BUFFER, indexBuffer); gl.glBindVertexArray(0); }
Example 10
Source File: MeshProto.java From jaamsim with Apache License 2.0 | 4 votes |
private void setupVAOForSubMeshImp(int contextID, int shaderID, SubMesh sub, Renderer renderer) { GL2GL3 gl = renderer.getGL(); int vao = renderer.generateVAO(contextID, gl); sub.vaoMaps[shaderID].put(contextID, vao); gl.glBindVertexArray(vao); int progHandle = sInfos[shaderID].meshProgHandle; gl.glUseProgram(progHandle); int texCoordVar = gl.glGetAttribLocation(progHandle, "texCoord"); // For some shaders the texCoordVar may be optimized away if (texCoordVar != -1) { if (sub._texCoordBuffer != 0) { // Texture coordinates gl.glEnableVertexAttribArray(texCoordVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, sub._texCoordBuffer); gl.glVertexAttribPointer(texCoordVar, 2, GL2GL3.GL_FLOAT, false, 0, 0); } else { gl.glVertexAttrib2f(texCoordVar, 0, 0); } } int posVar = gl.glGetAttribLocation(progHandle, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, sub._vertexBuffer); gl.glVertexAttribPointer(posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); // Normals int normalVar = gl.glGetAttribLocation(progHandle, "normal"); gl.glEnableVertexAttribArray(normalVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, sub._normalBuffer); gl.glVertexAttribPointer(normalVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); if (!flattenBuffers) { gl.glBindBuffer(GL2GL3.GL_ELEMENT_ARRAY_BUFFER, sub._indexBuffer); } gl.glBindVertexArray(0); }
Example 11
Source File: MeshProto.java From jaamsim with Apache License 2.0 | 4 votes |
private void setupVAOForSubLine(int contextID, SubLine sub, Renderer renderer) { GL2GL3 gl = renderer.getGL(); int vao = renderer.generateVAO(contextID, gl); sub.vaoMap.put(contextID, vao); gl.glBindVertexArray(vao); int prog = sub._progHandle; gl.glUseProgram(prog); int posVar = gl.glGetAttribLocation(prog, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, sub._vertexBuffer); gl.glVertexAttribPointer(posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindVertexArray(0); }
Example 12
Source File: MeshProto.java From jaamsim with Apache License 2.0 | 4 votes |
private void setupVAOForStaticLines(int contextID, Renderer renderer) { GL2GL3 gl = renderer.getGL(); int vao = renderer.generateVAO(contextID, gl); _lineVAOs.put(contextID, vao); gl.glBindVertexArray(vao); Shader s= renderer.getShader(ShaderHandle.DEBUG_BATCH); assert(s.isGood()); int prog = s.getProgramHandle(); gl.glUseProgram(prog); int posVar = gl.glGetAttribLocation(prog, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, linePosBuffer); gl.glVertexAttribPointer(posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); int colVar = gl.glGetAttribLocation(prog, "vertColor"); gl.glEnableVertexAttribArray(colVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, lineInstColorBuffer); gl.glVertexAttribPointer(colVar, 4, GL2GL3. GL_UNSIGNED_BYTE, true, 0, 0); gl.glVertexAttribDivisor(colVar, 1); int instMatVar = gl.glGetAttribLocation(prog, "instMat"); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, lineTransBuffer); for (int i = 0; i < 4; ++i) { // Enable 4 variables because this is a matrix int varInd = instMatVar + i; gl.glEnableVertexAttribArray(varInd); gl.glVertexAttribPointer(varInd, 4, GL2GL3.GL_FLOAT, false, 16*4, i*4*4); gl.glVertexAttribDivisor(varInd, 1); // Per instance } gl.glBindVertexArray(0); }
Example 13
Source File: DebugUtils.java From jaamsim with Apache License 2.0 | 4 votes |
/** * Initialize the GL assets needed, this should be called with the shared GL context * @param gl */ public static void init(Renderer r, GL2GL3 gl) { int[] is = new int[3]; gl.glGenBuffers(3, is, 0); _aabbVertBuffer = is[0]; _boxVertBuffer = is[1]; _lineVertBuffer = is[2]; Shader s = r.getShader(ShaderHandle.DEBUG); _debugProgHandle = s.getProgramHandle(); gl.glUseProgram(_debugProgHandle); _modelViewMatVar = gl.glGetUniformLocation(_debugProgHandle, "modelViewMat"); _projMatVar = gl.glGetUniformLocation(_debugProgHandle, "projMat"); _colorVar = gl.glGetUniformLocation(_debugProgHandle, "color"); _posVar = gl.glGetAttribLocation(_debugProgHandle, "position"); _cVar = gl.glGetAttribLocation(_debugProgHandle, "C"); _fcVar = gl.glGetAttribLocation(_debugProgHandle, "FC"); // Build up a buffer of vertices for lines in a box gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, _aabbVertBuffer); FloatBuffer fb = FloatBuffer.allocate(3 * 2 * 12); // 12 line segments // Top lines app( 1, 1, 1, fb); app( 1, -1, 1, fb); app( 1, -1, 1, fb); app(-1, -1, 1, fb); app(-1, -1, 1, fb); app(-1, 1, 1, fb); app(-1, 1, 1, fb); app( 1, 1, 1, fb); // Bottom lines app( 1, 1, -1, fb); app( 1, -1, -1, fb); app( 1, -1, -1, fb); app(-1, -1, -1, fb); app(-1, -1, -1, fb); app(-1, 1, -1, fb); app(-1, 1, -1, fb); app( 1, 1, -1, fb); // Side lines app( 1, 1, 1, fb); app( 1, 1, -1, fb); app(-1, 1, 1, fb); app(-1, 1, -1, fb); app( 1, -1, 1, fb); app( 1, -1, -1, fb); app(-1, -1, 1, fb); app(-1, -1, -1, fb); fb.flip(); gl.glBufferData(GL2GL3.GL_ARRAY_BUFFER, 3 * 2 * 12 * 4, fb, GL2GL3.GL_STATIC_DRAW); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); // Create a buffer for drawing rectangles // Build up a buffer of vertices for lines in a box gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, _boxVertBuffer); fb = FloatBuffer.allocate(3 * 2 * 4); // 4 line segments // lines app( 0.5f, 0.5f, 0, fb); app( 0.5f, -0.5f, 0, fb); app( 0.5f, -0.5f, 0, fb); app(-0.5f, -0.5f, 0, fb); app(-0.5f, -0.5f, 0, fb); app(-0.5f, 0.5f, 0, fb); app(-0.5f, 0.5f, 0, fb); app( 0.5f, 0.5f, 0, fb); fb.flip(); gl.glBufferData(GL2GL3.GL_ARRAY_BUFFER, 3 * 2 * 4 * 4, fb, GL2GL3.GL_STATIC_DRAW); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); }
Example 14
Source File: BillboardString.java From jaamsim with Apache License 2.0 | 4 votes |
/** * Note: render() and renderForView() are mutually non-reentrant due to shared temporaries. This should be fine * because neither should ever be called by any thread other than the render thread. */ @Override public void render(int contextID, Renderer renderer, double windowWidth, double windowHeight, Camera cam, Ray pickRay) { GL2GL3 gl = renderer.getGL(); if (!VAOMap.containsKey(contextID)) { setupVAO(contextID, renderer); } int vao = VAOMap.get(contextID); gl.glBindVertexArray(vao); // Render the string Shader s = renderer.getShader(Renderer.ShaderHandle.OVERLAY_FONT); s.useShader(gl); int prog = s.getProgramHandle(); // Work out the billboard position cam.getViewMat4d(tempViewMat); // Build up the projection*view matrix tempViewMat.mult4(cam.getProjMat4d(), tempViewMat); tempPos.x = _pos.x; tempPos.y = _pos.y; tempPos.z = _pos.z; tempPos.w = 1.0; tempPos.mult4(tempViewMat, tempPos); tempPos.x /= tempPos.w; tempPos.y /= tempPos.w; // TempPos x and y are now in normalized coordinate space (after the projection) int colorVar = gl.glGetUniformLocation(prog, "color"); gl.glUniform4fv(colorVar, 1, _color, 0); int posVar = gl.glGetAttribLocation(prog, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, _font.getGLBuffer(gl)); gl.glVertexAttribPointer(posVar, 2, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); int offsetVar = gl.glGetUniformLocation(prog, "offset"); float scaleY = (float)(2 * _height / (windowHeight * _font.getNominalHeight())); float scaleX = scaleY * (float)(windowHeight/windowWidth); int scaleVar = gl.glGetUniformLocation(prog, "scale"); gl.glUniform2f(scaleVar, scaleX, scaleY); float offsetX = (float)tempPos.x; float offsetY = (float)tempPos.y; offsetX += _xOffset*2.0/windowWidth; offsetY += _yOffset*2.0/windowHeight; gl.glDisable(GL2GL3.GL_CULL_FACE); for (int cp : RenderUtils.stringToCodePoints(_contents)) { TessChar tc = _font.getTessChar(cp); if (tc == null) { assert(false); continue; } gl.glUniform2f(offsetVar, offsetX, offsetY); gl.glDrawArrays(GL2GL3.GL_TRIANGLES, tc.getStartIndex(), tc.getNumVerts()); offsetX += tc.getAdvance()*scaleX; } gl.glEnable(GL2GL3.GL_CULL_FACE); }
Example 15
Source File: TessString.java From jaamsim with Apache License 2.0 | 4 votes |
@Override public void render(int contextID, Renderer renderer, Camera cam, Ray pickRay) { GL2GL3 gl = renderer.getGL(); if (!VAOMap.containsKey(contextID)) { setupVAO(contextID, renderer); } int vao = VAOMap.get(contextID); gl.glBindVertexArray(vao); // Render the string Shader s = renderer.getShader(Renderer.ShaderHandle.FONT); s.useShader(gl); int prog = s.getProgramHandle(); // Setup uniforms for this object Mat4d modelViewProjMat = new Mat4d(); cam.getViewMat4d(modelViewProjMat); modelViewProjMat.mult4(_trans); Mat4d projMat = cam.getProjMat4d(); modelViewProjMat.mult4(projMat, modelViewProjMat); int modelViewProjMatVar = gl.glGetUniformLocation(prog, "modelViewProjMat"); gl.glUniformMatrix4fv(modelViewProjMatVar, 1, false, RenderUtils.MarshalMat4d(modelViewProjMat), 0); int colorVar = gl.glGetUniformLocation(prog, "color"); gl.glUniform4fv(colorVar, 1, _color, 0); int cVar = gl.glGetUniformLocation(prog, "C"); gl.glUniform1f(cVar, Camera.C); int fcVar = gl.glGetUniformLocation(prog, "FC"); gl.glUniform1f(fcVar, Camera.FC); int advanceVar = gl.glGetUniformLocation(prog, "advance"); int posVar = gl.glGetAttribLocation(prog, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, _font.getGLBuffer(gl)); gl.glVertexAttribPointer(posVar, 2, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); // Send out one draw call per character float advance = 0; gl.glDisable(GL2GL3.GL_CULL_FACE); for (int i = 0; i < _contents.length; ++i) { gl.glUniform1f(advanceVar, advance); gl.glDrawArrays(GL2GL3.GL_TRIANGLES, starts[i], numVerts[i]); advance += advances[i]; } gl.glEnable(GL2GL3.GL_CULL_FACE); // Cleanup gl.glDisableVertexAttribArray(posVar); }
Example 16
Source File: OverlayString.java From jaamsim with Apache License 2.0 | 4 votes |
@Override public void render(int contextID, Renderer renderer, double windowWidth, double windowHeight, Camera cam, Ray pickRay) { Vec3d renderedSize = _font.getStringSize(_height, _contents); double x = _x; double y = _y; if (_alignRight) { x = windowWidth - _x - renderedSize.x; } if (!_alignBottom) { y = windowHeight - _y - renderedSize.y; } GL2GL3 gl = renderer.getGL(); if (!VAOMap.containsKey(contextID)) { setupVAO(contextID, renderer); } int vao = VAOMap.get(contextID); gl.glBindVertexArray(vao); // Render the string Shader s = renderer.getShader(Renderer.ShaderHandle.OVERLAY_FONT); s.useShader(gl); int prog = s.getProgramHandle(); int colorVar = gl.glGetUniformLocation(prog, "color"); gl.glUniform4fv(colorVar, 1, _color, 0); int posVar = gl.glGetAttribLocation(prog, "position"); gl.glEnableVertexAttribArray(posVar); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, _font.getGLBuffer(gl)); gl.glVertexAttribPointer(posVar, 2, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); int offsetVar = gl.glGetUniformLocation(prog, "offset"); float scaleY = (float)(2 * _height / (windowHeight * _font.getNominalHeight())); float scaleX = scaleY * (float)(windowHeight/windowWidth); int scaleVar = gl.glGetUniformLocation(prog, "scale"); gl.glUniform2f(scaleVar, scaleX, scaleY); float offsetX = (float)(2*x/windowWidth - 1); float offsetY = (float)(2*y/windowHeight - 1); gl.glDisable(GL2GL3.GL_CULL_FACE); for (int cp : RenderUtils.stringToCodePoints(_contents)) { TessChar tc = _font.getTessChar(cp); if (tc == null) { assert(false); continue; } gl.glUniform2f(offsetVar, offsetX, offsetY); gl.glDrawArrays(GL2GL3.GL_TRIANGLES, tc.getStartIndex(), tc.getNumVerts()); offsetX += tc.getAdvance()*scaleX; } gl.glEnable(GL2GL3.GL_CULL_FACE); }