opengl-es-2.0

OpenGL ES2.0 glReadPixels() read data from renderbuffer through framebuffer

吃可爱长大的小学妹 提交于 2019-12-04 11:27:45
I am doing off-screen processing using opengl es2.0 on Android. I created a renderbuffer, and attached it to a framebuffer FBO, after rendering to the FBO, I try to get the pixels from that FBO by getReadPixels() method. But I got nothing. The code is shown below: GLuint resultFBO;// FBO GLuint rboId; //render buffer id glGenRenderbuffers(1, &rboId); glBindRenderbuffer(GL_RENDERBUFFER, rboId); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, image_width, image_height); glBindRenderbuffer(GL_RENDERBUFFER, 0); glGenFramebuffers(1, &resultFBO); glBindFramebuffer(GL_FRAMEBUFFER,

How to create multiple stop gradient fragment shader?

老子叫甜甜 提交于 2019-12-04 11:22:03
问题 I'm trying to create an OpenGL ES 2.0 fragment shader that outputs multiple stop gradient along one axis. It should interpolate between multiple colors at points defined in percents. I've achieved this by using if s the fragment shader, like this: float y = gl_FragCoord.y; float step1 = resolution.y * 0.20; float step2 = resolution.y * 0.50; if (y < step1) { color = white; } else if (y < step2) { float x = smoothstep(step1, step2, y); color = mix(white, red, x); } else { float x = smoothstep

Stenciling using OpenGl ES 2.0

假如想象 提交于 2019-12-04 11:04:25
I am trying to figure out a way to cut out a certain region of a background texture such that a certain custom pattern is not rendered on the screen for that background. For example: This square can be any pattern. I am using Frame Buffer Object and Stencil Buffer to achieve this kind of effect. Here is the code: fbo.begin(); //Disables ColorMask and DepthMask so that all the rendering is done on the Stencil Buffer Gdx.gl20.glColorMask(false, false, false, false); Gdx.gl20.glDepthMask(false); Gdx.gl20.glEnable(GL20.GL_STENCIL_TEST); Gdx.gl20.glStencilFunc(GL20.GL_ALWAYS, 1, 0xFFFFFFFF); Gdx

Multi-pass shaders in OpenGL ES 2.0

☆樱花仙子☆ 提交于 2019-12-04 10:40:49
First - Does subroutines require GLSL 4.0+? So it unavailable in GLSL version of OpenGL ES 2.0? I quite understand what multi-pass shaders are. Well what is my picture: Draw group of something (e.g. sprites) to FBO using some shader. Think of FBO as big texture for big screen sized quad and use another shader, which, for example, turn texture colors to grayscale. Draw FBO textured quad to screen with grayscaled colors. Or is this called else? So multi-pass = use another shader output to another shader input? So we render one object twice or more? How shader output get to another shader input?

OpenGL ES 2: Are vertex and fragment shaders necessary for simple drawing?

纵然是瞬间 提交于 2019-12-04 10:25:50
I'm currently working on some drawing routines using geometry generated at runtime and only flat colored. While searching for a minimal GL setup to do my drawing (I'm matching the screen resolution and on I'm iOS, but the question holds for other ES 2 platforms as well) , I'm seeing that most examples use vertex and fragment shaders, but not all of them. If I don't plan to use any textures or lighting (just direct color copying/blending) and I don't plan on doing any transformations that can't be done by manipulating the view matrix, do I really need to set up vertex and/or fragment shaders?

Passing an array of vectors to a uniform

我怕爱的太早我们不能终老 提交于 2019-12-04 09:36:14
问题 I am trying to implement multiple lights in my shader but I have trouble to fill the uniform with my light data. My vertex shader: attribute vec3 aVertex; attribute vec3 aNormal; attribute vec2 aTexture; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; uniform mat4 uNMatrix; uniform vec3 uAmbientColor; uniform vec3 uPointLightingLocation[16]; uniform vec3 uPointLightingColor[16]; varying vec2 vTexture; varying vec3 vLightWeighting; void main(void) { vec4 mvPosition = uMVMatrix * vec4(aVertex, 1

OpenGL ES2.0 offscreen context for FBO rendering

别来无恙 提交于 2019-12-04 09:32:21
问题 I would like to do offscreen rendering (in console environment without any WS) with FBOs. I know that it is necessary to create an OpenGL context, and at least a dummy window for any operation, therefore I did the following initialization: // Step 1 - Get the default display. eglDisplay = eglGetDisplay((EGLNativeDisplayType)0); // Step 2 - Initialize EGL. EGLint iMajorVersion, iMinorVersion; if (!eglInitialize(eglDisplay, &iMajorVersion, &iMinorVersion)) { printf("Error: eglInitialize()

Shader optimization for retina screen on iOS

旧城冷巷雨未停 提交于 2019-12-04 09:11:29
I make a 3D iphone application which use many billboards. My frame buffer is twice larger on retina screen because I want to increase their quality on iPhone 4. The problem is that fragment shaders consume much more time due to the framebuffer size. Is there a way to manage retina screen and high definition textures without increase shader precision ? Brad Larson If you're rendering with a framebuffer at the full resolution of the Retina display, it will have four times as many pixels to raster over when compared with the same physical area of a non-Retina display. If you are fill-rate limited

OpenGL Fixed function shader implementation

喜欢而已 提交于 2019-12-04 08:18:54
Is there any wrapper which emulates the OpenGL ES 1.1 API on top of OpenGL ES 2.0? I was searching quite a bit but could not find any actual implementation. I'm currently investigating same question, just stumbled upon this project: https://github.com/p3/regal#readme (OpenGL portability layer for OpenGL 2.x, 3.x, 4.x, Core contexts and ES 2.0). Only going to try it myself, but after reading the article http://www.gamasutra.com/view/news/177233/Indepth_Bringing_Regal_OpenGL_to_Native_Client.php , I believe this library may be solution to the problem. you might like this tutorial: Recreating

First steps in creating a chroma key effect using android camera

前提是你 提交于 2019-12-04 08:09:51
I'd like to create a chroma key effect using the android camera. I don't need a step by step, but I'd like to know the best way to hijack the android camera and apply the filters. I've checked out the API and haven't found anything super definitive on how to manipulate data coming from the camera. At first I looked into using a surface texture, but I'm not fully aware how that helps or how to even use it. Then I checked out using a GLSurfaceView, which may be the right direction, but not really sure. Also, to add to my question, how would I handle both preview and saving of the image? Would I