opengl-es-2.0

Passing an array of vectors to a uniform

浪子不回头ぞ 提交于 2019-12-03 03:34:43
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.0); gl_Position = uPMatrix * mvPosition; vTexture = aTexture; int i; for (i = 0; i < 16; i++) { vec3

GPU Profiling and callbacks in OpenGL ES

心不动则不痛 提交于 2019-12-03 03:34:18
Is there a way to add callbacks in OpenGL ES similar to what DirectX has? I'm trying to profile the GPU performance, so I'm trying to figure out how long it took to execute certain parts of the GPU. Ideally, I "push" a marker/callback, then call a bunch of GL draw calls, then push another marker, and then find out how many milliseconds passed inbetween those two markers a frame later. (Any other ways to profile GPU performance would be helpful too.) GPU maker provides nice profiler for Android. As far as my experience, it requires root privilege. ADRENO™ PROFILER for Qualcomm Snapdragon

OpenGL ES 2.0 Equivalent for ES 1.0 Circles Using GL_POINT_SMOOTH?

谁都会走 提交于 2019-12-03 03:28:58
OpenGL ES 2.0 doesn't have the GL_POINT_SMOOTH definition which ES 1.0 does. This means code I was using to draw circles no longer works: glEnable(GL_POINT_SMOOTH); glPointSize(radius*2); glDrawArrays(GL_POINTS,0,nPoints); Is there an equivalent in ES 2.0, perhaps something to go in the vertex shader, or must I use polygons for each circle? You can use point sprites to emulate this. Just enable point sprites and you get a special variable gl_PointCoord that you can read in the fragment shader. This gives you the coordinates of the fragment in the square of the current point. You can just use

Getting default frame buffer id from GLKView/GLKit

半世苍凉 提交于 2019-12-03 03:06:39
I use GLkit/GLKView in my IOS OpenGL ES 2.0 project to manage default FBO/life cycle of my app. In desktop OpenGL in order to bind default FBO (the front buffer) I can just call glBindFrameBuffer(GL_FRAMEBUFFER,0) but this is not the case in IOS app since you have to create the default FBO yourself and it will have a unique ID; The problem is GLKit/GLKView coding style force me to use GLKView's "bindDrawable" function to activate default FBO which make the design of my cross platform rendering system a little ugly (have to store GLKView pointer as void* in my c++ engine class and bridge cast

OpenGL ES 2.0 Multiple Programs or Multiple Shaders or what? How does it work?

自古美人都是妖i 提交于 2019-12-03 03:01:38
问题 The Problem (TL;DR) My problem, fundamentally, is that I do not know how OpenGL ES 2.0 expects me to write and use multiple shaders; or if it is even advisable/expected that a person will do so. The fundamental question here is: if I have an apple, a glowing rock and a fuzzy mesh, all in the same 3D world, all best drawn with different shader programs but using the same mvpMatrix then how would I go about using all of them in the same OpenGL render such that they all use their most

Low performance when execute eglSwapBuffer and eglMakeCurrent

独自空忆成欢 提交于 2019-12-03 03:00:09
I'm developing an Android Unity Plugin that allows user to record his/her gameplay Overview of my solution: Using OpenGl FrameBufferObject (FBO) to make Unity render offscreen to this FBO Get the offscreen texture of this FBO then using for 2 purposes: Render to video surface Redraw to device screen Execute flow per frame: bind my FBO render scene to FBO (Unity code) unbind my FBO set up video surface configure surface size (execute first time only) save egl state make video surface current draw to video surface using offscreen texture of my FBO restore to default surface set presentation time

Render multiple objects with OpenGL ES 2.0

坚强是说给别人听的谎言 提交于 2019-12-03 02:40:54
问题 I am trying to learn OpenGL ES 2.0 to do some iPhone game development. I have read through multiple tutorials and some of the OpenGL ES 2.0 spec. All of the examples I have seen have created a single mesh, loaded it into a vertex buffer and then rendered it (with the expected translation, rotation, gradient, etc.) My question is this: how do you render multiple objects in your scene that have different meshes and are moving independently? If I have a car and a motorcycle for example, can I

Simple GLSL convolution shader is atrociously slow

不羁岁月 提交于 2019-12-03 02:27:41
问题 I'm trying to implement a 2D outline shader in OpenGL ES2.0 for iOS. It is insanely slow. As in 5fps slow. I've tracked it down to the texture2D() calls. However, without those any convolution shader is undoable. I've tried using lowp instead of mediump, but with that everything is just black, although it does give another 5fps, but it's still unusable. Here is my fragment shader. varying mediump vec4 colorVarying; varying mediump vec2 texCoord; uniform bool enableTexture; uniform sampler2D

How to share a Renderscript allocation with OpenGL in Android

拟墨画扇 提交于 2019-12-03 01:38:08
I have a Renderscript which processes an image that is given in output to an Allocation. I want to use this Allocation as a texture in my OpenGL program but I don't know how to get a texture ID from the Allocation. On the other hand, I know I could use a graphic Renderscript, but since it has been deprecated, I guess there must be some other way to achieve the same result. Specify USAGE_IO_OUTPUT when you create the Allocation. Assuming you are generating the texture data in a script you would also add USAGE_SCRIPT. You can then call Allocation.setSurface(theGLSurface) to link the allocation

How to draw anti aliased lines in OpenGL ES 2.0?

我与影子孤独终老i 提交于 2019-12-03 00:32:46
I am trying to draw some contours that I have stored as vertex arrays: typedef struct { float* vertices; int nrPoints; }VertexCurve; list<VertexCurve> CurveList; I am using some samples from an opengl es 2.0 book : http://opengles-book.com/ The drawing method looks like this: void Draw ( ESContext *esContext ) { UserData *userData = (UserData*)esContext->userData; // Set the viewport glViewport ( 0, 0, esContext->width, esContext->height ); // Clear the color buffer glClear ( GL_COLOR_BUFFER_BIT ); // Use the program object glUseProgram ( userData->programObject ); //glEnable(GL_SAMPLE_ALPHA