FAQ Database Discussion Community


glGetProgramiv returns a lower number of active uniforms, why?

java,android,glsl,opengl-es-2.0,uniform
I'm doing a game framework for Android with opengl es 2.0 and glsl in java. I did a method that automatically loads all the active uniform in the GL program to a java map with their locators. The problem I found is that the line GLES20.glGetProgramiv( this.m_GL_Program_ID, GLES20.GL_ACTIVE_UNIFORMS, total, 0);...

GLSurfaceView over Google MapView

android,google-maps,opengl-es-2.0,android-mapview,glsurfaceview
Need to overlay two views. A GLSurfaceView and a MapView. My map view is following the code from the following Github location: Android Google Maps v2 The GLSurfaceView needs to be on top of the map view which I believe I just use zOrderOnTop(true); However, I do not know how...

Setting vectors in shaders, How does it work? OpenGL GLSL

android,opengl-es,glsl,opengl-es-2.0,glsles
I am trying to understand how vertex and fragment shaders work in OpenGL ES 2.0. My shaders look like this: vertex shader: // source code for the vertex shader attribute vec4 vPosition attribute vec2 a_texCoord; varying vec2 v_texCoord; void main() { gl_Position = vPosition; v_texCoord = a_texCoord; } fragment shader:...

How to tell OpenGL ES 2.0 wich vertices to use?

java,android,opengl-es-2.0
I want to draw a simple texture in 2d. Previously i used OpenGL ES 1.0 and i told OpenGL wich vertices to use like this: glEnableClientState(GL10.GL_VERTEX_ARRAY); glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); Now I want to do it in OpenGL ES 2.0, but Eclipse gives me errors when i try it like...

Using video stream as open GL ES 2.0 texture

android,opengl-es-2.0,google-cardboard
I'm trying to capture video and display it to the screen by setting an Open GL ES texture to an android surfaceTexture. I can't use a TextureView and implement SurfaceTextureListener as per this tutorial since I am using Google Cardboard. I have followed the Android documentation on how to initialise...

GLSL Fragment shader won't compile with a texture2D call uncommented

android,opengl-es,glsl,opengl-es-2.0,glsles
I have a N910f note 4 with the last lollipop 5.0.1. Well, the fragment shader isn't compilling, but if i comment out the line of texture sampling (texture2D call) the shader compiles. I don't know what happends to the compiler because of Log.e(TAG, GLES20.glGetShaderInfoLog(shader)) call is not throwing any information....

Check vertex visibility in OpenGL ES 2.0

c++11,matrix,opengl-es-2.0,vertex-shader,frustum
How can I check if vertex is visible in the most simple way? If my vertex shader looks like: void main(void) { vec4 glPosition = vec4(VTPosition.x * VTAspectRatio, VTPosition.y, VTPosition.z, 1.0); gl_Position = VTProjection * VTModelview * glPosition; } Can I check visibility on CPU the same way ? Vector4...

What does parameters mean for GLES20.glViewport(0, 0, width, height)?

android,opengl-es,opengl-es-2.0
Why do we pass 0 as first two parameters in GLES20.glViewport(0, 0, width, height) ? What does it signify?

OpenGL ES 2.0: How to render to a frameBuffer in a lower resolution for environment mapping?

android,opengl-es,opengl-es-2.0
I'm trying to implement dynamic environment reflections on Android using OpenGL ES 2.0. For this I set my camera in the place of my reflective object and render to an off-screen renderbuffer in 6 different directions (two per axis) to build a cube map, but that's very slow, so my...

Using a depth and stencil renderbuffer attachment for framebuffer in OpenGL ES

android,opengl-es,opengl-es-2.0
I want to create a framebuffer in OpenGL ES 2 with a color texture and depth and stencil renderbuffers. However, OpenGL ES doesn't seem to have GL_DEPTH24_STENCIL8 or GL_DEPTH_STENCIL_ATTACHMENT. Using two separate renderbuffers gives the error "Stencil and z buffer surfaces have different formats! Returning GL_FRAMEBUFFER_UNSUPPORTED!" Is this not possible...

getShaderPrecisionFormat return values

webgl,opengl-es-2.0
I'm confused about the method getShaderPrecisionFormat, what it's used for, and what it's telling me because for me it always returns the exact same precision for all arguments, only differences are between INT / FLOAT. to be clear: calls with gl.FRAGMENT_SHADER and gl.VERTEX_SHADER in combinations with gl.LOW_FLOAT, gl.MEDIUM_FLOAT and gl.HIGH_FLOAT...

OpenGL ES 2.0 Texture Won't Display

ios,objective-c,opengl-es,opengl-es-2.0
So I am currently learning OpenGL ES 2.0 with iOS and working on a maze game. The maze is randomly generated (so not a loaded model) and my struggle is texturing the walls and floor of the maze. My approach is to just treat the maze as a series of...

normal matrix for non uniform scaling

opengl-es-2.0,glsles
Im trying to calculate the normal matrix for my GLSL shaders on OpenGL 2.0. The theory is : a normal matrix is the top left 3x3 matrix of the ModelView, transposed and inverted. It seems to be correct as I have been rendering my scenes correctly, until I imported a...

Page Curl with best quality

android,opengl-es,opengl-es-2.0
I am working with Harism Page Curl(Open GL) https://github.com/harism/android_page_curl and its works fine. Output is something like this: It's not smooth too much. I want something like this: ...

Using a FrameBufferObject with several Color Texture attachments

opengl-es,opengl-es-2.0,shader,fbo
I'm implementing in my program the gaussian blur effect. To do the job I need to render the first blur information (the one on Y axis) in a specific texture (let's call it tex_1) and use this same information contained in tex_1 as input information for a second render pass...

Android OpenGL es 2.0 Can not reload textures on object.

android,textures,opengl-es-2.0,reload
I've managed to load textures and free rotate a sphere thanks to several tutorials, questions and answers asked here but i stumbled upon the need of texture reloading at runtime (get a bitmap image, process it and then apply it as a new texture to an object). I didnt find...

Fast Screen Flicker while NOT drawing on Android OpenGL

android,opengl-es,screen,opengl-es-2.0,flicker
I wanted to save battery life time. My app only needs to be drawn sometimes. So I added this code to my Renderer in the onDraw method: boolean dirty = true; public void onDrawFrame(GL10 arg0) { if (!dirty) return; dirty = false; ..... draw images .... } So my app...

GLFW with GLES in simple C++ Emscripten file wont build

webgl,opengl-es-2.0,glfw,emscripten
I'm trying to setup an OpenGL Context with a window and viewport using the minimum code to do this with emscripten. I've started coding, this with the following code: #include<stdio.h> #include<stdlib.h> #include<GLES2/gl2.h> #include<GL/glfw.h> #include<emscripten/emscripten.h> int init_gl() { const int width = 480, height = 800; if (glfwInit() != GL_TRUE) {...

Android OpenGL 2 Scrolling Texture Loses Quality Over Time

android,textures,opengl-es-2.0
I'm trying to create a simple game for Android, using OpenGL 2 ES, that utilizes a repeating scrolling texture for the background. I managed to draw the texture, scroll it, and repeat. It works really well for the first few seconds, then the quality of the image starts to degrade...

Use Android 4x5 ColorMatrix in OpenGL ES 2 Shader

android,matrix,colors,filter,opengl-es-2.0
I am trying to use Android Color Matrix in OpenGL ES 2. I have been able to use a 4x4 Matrix using the following code in the Shader (this adds also an intensity parameter): varying vec2 textureCoordinate; uniform lowp mat4 colorMatrix; uniform lowp float intensity; void main() { vec4 textureColor...

Opengl ES 2.0 : Get texture size and other info

java,android,opengl-es,opengl-es-2.0
The context of the question is OpenGL ES 2.0 in the Android environment. I have a texture. No problem to display or use it. Is there a method to know its width and height and other info (like internal format) simply starting from its binding id? I need to save...

Are OpenGL indices and locations the same thing for uniforms and vertex attributes?

opengl,opengl-es,opengl-es-2.0,opengl-3,opengl-4
In the OpenGL Reference Pages, some functions are marked as using uniform locations, while other functions are marked as using uniform indices. Are these the same thing? Similarly for vertex attributes, some functions are marked as using vertex attribute indices, while other functions are marked as using vertex attribute locations....

Clean C++ OpenGL for iOS

ios,objective-c,xcode,opengl-es,opengl-es-2.0
Can I use clean c++ version of openGL in my iOS App? I want write some basic wrapper, then connect my code in c++ with this wrapper and App. Or I must use only openGLES? With GLKit. Describe me all variants.

How to egl offscreen render to an image on linux?

opengl-es,opengl-es-2.0,egl
I'm trying to use egl to do offscreen rendering to an image. my code doesn't generate any error. the egl part seems to be correct, the fbo is also complete. but when I read pixels using glReadPixels, I always get a black image (I cleared the entire scene with red,...

Cube in OpenGL ES 2.0 does not draw the given textures

java,android,textures,opengl-es-2.0,cube
Normally I would not bother you with my questions, but this time I'm rather desperate. First of all, I'm fairly new to OpenGL so please don't shoot me if I've made some rookie mistakes. I've seen some examples already, but some of the example code is not understandable for me....

How to draw a star in iOS OpenGL ES 2.0

ios,opengl-es-2.0,vertex-shader
This question has been asked before but the quite a few years ago in my searches. The answer was always to use texture mapping but what I really want to do is represent the star as a single vertex - you may think I'm copping out with a simplistic method...

Align vertex data

ios,opengl,opengl-es-2.0
I've read this post about vertex alignement and I'm not sure to understand everything. The article say that I need to add an offset after each attributs to have aligned data (By the way, the article talk about 4 bytes but in his picture, they add two bytes). In my...

GLSurfaceView not appearing over MapView

android,android-layout,opengl-es,opengl-es-2.0,glsurfaceview
My goal is to use OpenGL ES 2.0 with Google Maps. I would like to create an app that follows the user as they are traveling from point A to point B. I realize that this can be done using Google Maps addPolyline to draw a line, but I want...

WebGL: INVALID_OPERATION: vertexAttribPointer: stride or offset not valid for type

opengl-es,webgl,opengl-es-2.0
I learn WebGL. I get some errors, when I try to draw three points, when each of this has own location, size and color. I try to do it through the same buffer. // To draw three points. Each of this has own location, size and color. function start(gl){ if(!initShaders(gl,...

OpenGL framebuffer android without GL_OES_packed_depth_stencil (on Nexus 7 2012)

android,c++,android-ndk,opengl-es-2.0,framebuffer
How do I init the framebuffer with depth and stencil on a device which does not support GL_OES_packed_depth_stencil (In my case a Nexus 7 2012)? This does not work: glGenRenderbuffers(1, &depthStencil); glBindRenderbuffer(GL_RENDERBUFFER, depthStencil); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthStencil); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthStencil); GLenum status =...

Fastest way to draw sprites in opengles 2.0 on android

android,performance,opengl-es,opengl-es-2.0
So Im trying to figure out how to draw a single textured quad many times. My issue is that since these are create and deleted and every one of them has a unique position and rotation. Im not sure a vbo is the best solution as I've heard modifying buffers...

glClearColor not working correct (android opengl)

java,android,opengl-es,opengl-es-2.0
I want to change the background color of my app on runtime. So on button click I first call: GLES20.glClearColor(color[0], color[1], color[2], color[3]); Then I call: GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); And it does nothing! It keeps the current background color - doesnt change it. But when I then pause my app...

OpenGL ES 2.0 Framebuffer with render to texture iOS: nothing shown

c++,ios,opengl-es,opengl-es-2.0,framebuffer
I'm using a Framebuffer to do post processing. Creating and drawing to the buffer (tested via glReadPixels and glCheckFramebufferStatus) is working fine. But now I want to render the this texture with a quad to the screen. But the screen remains black. The same code (for drawing) is working fine...

OpenGL es 2, Shaders not compiling

java,android,opengl-es-2.0,shader
I'm trying to make a very simple point light and I'm failing miserably. All I know is that my shaders doesn't compile correctly (I don't seem to get much error information). My shaders are: Vertex Shader Code "uniform mat4 u_MVPMatrix;" + "uniform mat4 u_MVMatrix;" + "attribute vec4 a_Position;" + "varying...

OpenGL ES 2.0 Invalid operation on framebuffer creation

java,android,opengl-es-2.0
I'm trying to render to a texture, and then draw a texture into a square. While creating the framebuffer, I get Invalid operation after glFramebufferRenderbuffer and glFramebufferTexture2D calls. Here is the function that should create the framebuffer: private void createFrameBuffer() { final int[] texture = new int[1]; frameTextureID = texture[0];...

How to get OpenGL-ES working on Raspberry Pi with SDL2?

raspberry-pi,opengl-es-2.0,sdl-2
I am trying to get OpenGL-ES working on a Raspberry Pi, but so far no luck. I compiled SDL 2.0.3 from source with this, as the version in Rasbian is missing Raspberry Pi support: ./configure --prefix=/home/pi/run/SDL2-2.0.3/ \ --disable-video-x11 \ --disable-pulseaudio \ --disable-esd \ --disable-video-opengl The code below should create a...

Android OpenGL ES 2.0 shader texture2d RGB value range

android,opengl-es-2.0,texture2d
I use OpenGL ES 2.0 on Android and I wrote a sample shader that uses texture2d to get an image RGB value. vec4 v1 = texture2D(sTexture,textCoord); float r = v1.r; so , is the value of r in the range [0.0, 1.0] or [0.0 255.0] ?...

LibGDX - perspective camera smooth translation & direction

java,3d,libgdx,opengl-es-2.0,perspectivecamera
I am trying to implement smooth 3D camera in my game. So, I have a few reserved positions and directions and I want to change view of my camera by applying them to my camera. Now I am doing it like below: //Reserved positions and directions //View #1 Vector3 pos1...

LibGDX FrameBuffer quirk on iOS

ios,opengl-es,libgdx,opengl-es-2.0,framebuffer
I've got dynamic textures for a word game that I create and keep on a FrameBuffer. I then use TextureRegions backed by that FrameBuffer to draw to the screen. This code works fine on Android, but I'm having problems on iOS. You can see below a screenshot with the FrameBuffer...

Texture not rendering properly in openGL ES 2 on Android

android,textures,opengl-es-2.0
I'm having an issue rendering textures in openGL ES 2 on Android. The image is being drawn but the texture ism't wrapping correctly by the look of it. I have tried all the usual things to fix the issue but nothing has worked. Here's how one of the images should...

Generating a sphere in OpenGL without high level libraries - what's wrong with my code?

opengl-es,geometry,opengl-es-2.0
I've tried to implement an inefficient function to generate the points, normals, tex coords, and index list of a sphere. Ignoring the lines, when I draw the sphere with OpenGL I get the following output which is clearly wrong: Can anyone help me understand what's wrong with my code? public...

I have created a triangular body with physicsbox2d andengine Extention..how to add face or sprite to the body

android,opengl-es-2.0,andengine
I have created a triangular body with physicsbox2d andengine Extention. it looks gud ..now i am not able to add face or sprite to this triangular body ...here is code ..thankx in advance.` List<Vector2> UniqueBodyVertices = new ArrayList<Vector2>(); UniqueBodyVertices.addAll((List<Vector2>) ListUtils.toList( new Vector2[] { new Vector2(-93f,-75f), new Vector2(-107f,-14f), new Vector2(-101f,41f), new...

QOpenGLShader Can't Compile GLSL 120 On Android

qt,opengl-es-2.0,shader
I have programed OpenGL code on Qt5 for Mac OS 10.10. The GLSL version is 120 and there is no problem to run. #version 120 attribute highp vec4 vVertex; attribute vec3 vNormal; uniform mat4 mvpMatrix; uniform mat4 mvMatrix; uniform mat4 normalMatrix; uniform vec3 vLightPosition; varying vec3 vVaryingNormal; varying vec3 vVaryingLightDir;...

Undo/Redo for iOS Painting App

ios,drawing,opengl-es-2.0,paint,undo-redo
I have been doing research on what the best way to achieve undo/redo functionality is for a painting app. I am using OpenGL ES 2.0 on iOS. The most popular approach seems to be to save a list of commands and VBOs to re-generate the painting to its previous state...

Multiple objects with same texture

android,opengl-es-2.0
I'm trying to texture an ArrayList of rectangle "bricks" for my game. I have code that works perfectly when there's only one rectangle to texture, but anytime I add more, the fragment shader only applies the texture to the last rectangle drawn, and the others are rendered invisible. I don't...

Width is shrink after increasing the width & height 2 times openGL C++

android,c++,opengl-es,opengl-es-2.0
I am rendering video on GLSurfaceView by openGL. The openGL portion is written on C++ in native portion. This is my render routine: void VideoRenderOpenGL2::Render(const unsigned char *pData) { ...................... // GL_OPERATION is a macro, nothing special GL_OPERATION(glUseProgram(m_program)) UpdateTextures(pData); // other routine, I will post the function if needed bool...

Drawing on multiple surfaces by using only EGLSurface?

opengl,opengl-es,opengl-es-2.0,egl
Is it possible to draw from the same application on multiple surfaces, one by one, by using only the handler returned by eglCreateWindowSurface ? What i want to achieve is to create two or more surfaces and pass them to a client who will draw on them, and then, when...

Pixel Shader performance in Directx9 not equivalent to Opengl ES2.0

opengl-es-2.0,slimdx,hlsl2glsl
I am using a drop effect by the help of pixel shader in directx-9 to be specific SlimDX.Direct3D9 written in hlsl used for transition between two images. I have written the same pixel shader in glsl language to be used in an android project using java 6.0. The issue here...

How does OpenGL render YUV video on Android?

java,android,opengl-es-2.0,webrtc
I am working on some webrtc staff on Android and trying to figure out how does VideoRendererGui.java works. Unfortunately, I have some trouble with understanding how the following OpenGL code work: private final String VERTEX_SHADER_STRING = "varying vec2 interp_tc;\n" + "attribute vec4 in_pos;\n" + "attribute vec2 in_tc;\n" + "\n" +...

Why is there a light area between edges when rendering an inner shadow by calculating the nearest distance to an edge?

opengl-es,glsl,opengl-es-2.0,glsles
I'm rendering an inner shadow (same idea as an inner glow, but dark instead of light) by calculating the nearest distance to an edge for each pixel. This is done in the fragment shader by interpolating the vertex position from the vertex shader (using varying), passing the shape's edge points...

Issue with Google Maps toScreenLocation() method Android

android,google-maps,opengl-es-2.0,google-maps-api-2
As the title mentions, I'm having issues with the toScreenLocation() with Google Maps. I'm trying to pick arbitrary points on Google Maps that I am broadcasting to my Google Maps fragment. Within the fragment, I want to get the Screen Point this LatLng coordinate corresponds with. However, most of the...

Porting OpenGL ES Framebuffer to OpenGL

opengl,opengl-es-2.0,opengl-3
I got the following code working perfectly fine on iOS and Android: unsigned int depth_texture = 0, framebuffer = 0; glGenTextures( 1, &depth_texture ); glBindTexture( GL_TEXTURE_2D, depth_texture ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,...

Rendering multiple 2D images in OpenGL-ES 2.0

android,opengl-es,2d,opengl-es-2.0
I am new to OpenGL, and trying to learn ES 2.0. To start with, I am working on a card game, where I need to render multiple card images. I followed this http://www.learnopengles.com/android-lesson-four-introducing-basic-texturing/ I have created a few classes to handle the data and actions. MySprite holds the texture information,...

How to render a texture to an Android GLSurfaceView

android,opengl-es-2.0,glsurfaceview,textureview
I have a standard GLSurfaceView class: public class TestSurfaceView extends GLSurfaceView { public MainRenderer mRenderer; public GStreamerSurfaceView(Context context) { super(context); setEGLContextClientVersion(2); mRenderer = new MainRenderer(context); setRenderer(mRenderer); setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY); } } I have a Renderer class that implements GLSurfaceView.Renderer: public class MainRenderer implements GLSurfaceView.Renderer { private int[] hTex; private SurfaceTexture mSTexture; private...

OpenGL ES: define triangles color in shader?

android,opengl-es,opengl-es-2.0,shader
I'm making an Android game using OpenGL ES 2.0, and I have a question on what would be the best strategy: I want to have a plane (the ground) made of multiple triangles (like a chessboard, with each case as 2 triangles), and I want each triangle to have a...

Android OpenGL es 2.0 error when modifying multiple objects on scene

android,opengl-es,opengl-es-2.0
I am having some problems with proper scene manipulations with OpenGL ES 2.0. On my screen I want to draw a rectangle and a cube. Rectangle should be moved to the bottom and scaled while cube should be moved to the top and scaled. What's more, I want to rotate...

glMapBuffer is missing from opengl es 2

opengl-es,opengl-es-2.0
Why glMapBuffer is missing from opengl es 2.0? Who we can get access to buffer data to change it efficiently? Only glBufferSubData is the best way to modify the buffer?

Colored Vignette Shader (the outer part) - LIBGDX

opengl-es,libgdx,opengl-es-2.0,shader,vertex-shader
I've seen lots of tutorials on vignette shaders just like these but none of them say how to change the color of the vignette, they only talk about applying sepia or grey shaders to the whole composite image. For example the video above gives the below code for the vignette...