opengl-es-2.0

Draw Sphere - order of vertices

北城以北 提交于 2019-12-09 20:39:59
问题 I would like draw sphere in pure OpenGL ES 2.0 without any engines. I write next code: int GenerateSphere (int Slices, float radius, GLfloat **vertices, GLfloat **colors) { srand(time(NULL)); int i=0, j = 0; int Parallels = Slices ; float tempColor = 0.0f; int VerticesCount = ( Parallels + 1 ) * ( Slices + 1 ); float angleStep = (2.0f * M_PI) / ((float) Slices); // Allocate memory for buffers if ( vertices != NULL ) { *vertices = malloc ( sizeof(GLfloat) * 3 * VerticesCount ); } if ( colors !

Ray-picking in OpenGL ES 2.0

微笑、不失礼 提交于 2019-12-09 20:08:38
问题 I'm trying to implement ray-picking in OpenGL ES 2.0 to determine if an object has been clicked or not. So far I'm just trying to check if a specific triangle has been pressed. I`m using this site as a motivation http://android-raypick.blogspot.ca/2012/04/first-i-want-to-state-this-is-my-first.html This is what I have so far: public void onClick(float x, float y) { float[] temp = new float[4]; float[] temp2 = new float[4]; System.out.println("X coordinate: " + x); System.out.println("Y

-[EAGLContext renderbufferStorage:fromDrawable:] Failing the second time on?

混江龙づ霸主 提交于 2019-12-09 16:39:43
问题 I'm developing an iOS openGL ES application. I'm doing the usual EAGLView / ES2Render stuff. On startup, frambuffer creation succeeds, using the following code: - (BOOL) createFramebuffers { [EAGLContext setCurrentContext:_mainContext]; // [ A ] On-screen // 1. Framebuffer glGenFramebuffers(1, &_mainFramebuffer); bindFramebuffer(_mainFramebuffer); // 2. Color buffer glGenRenderbuffers(1, &_mainColorbuffer); bindRenderbuffer(_mainColorbuffer); // Adjust size to view's layer: CAEAGLLayer* layer

Loading 4-channel texture data in iOS

耗尽温柔 提交于 2019-12-09 12:55:30
问题 I want to load 4-channel texture data from a file in iOS, so I consider the texture as a (continuous) map [0,1]x[0,1] -> [0,1]x[0,1]x[0,1]x[0,1] If I use the fileformat .png , XCode/iOS consider the file as an image, and so multiplies each component rgb with a (premultiplied alpha), corrupting my data. How should I solve this? Examples may be use two textures with components rgb (3-channel) postdivide alpha use another file format Of these, I consider the best solution to be to use another

Use of undeclared identifier 'gl_InstanceID'

て烟熏妆下的殇ゞ 提交于 2019-12-09 04:03:29
Hi everyone, i have been trying Instanced drawing in OpenGLES2.0, in IOS platform. My rendering code glEnableVertexAttribArray(...); glVertexAttribPointer(...) glDrawElementsInstancedEXT(GL_TRIANGLES,IndicesCount, GL_UNSIGNED_SHORT, 0, 5); And my Vertex Shader attribute vec4 VertPosition; uniform mat4 mvpMatrix[600]; void main() { gl_Position = (mvpMatrix[gl_InstanceID]) * VertPosition; } I'm getting ERROR: Use of undeclared identifier 'gl_InstanceID' my glsl version is 1.0, if version is the issue then how can i upgrade ? Any other way to use "gl_InstanceID" in GLSL ? BDL gl_InstanceID is

Is it Possible to give effect like Vertex Shader and Fragment Shader to the Android Camera Preview , and Save the Captured image with OpenGLES?

谁说我不能喝 提交于 2019-12-09 01:13:46
问题 This two are My VertexShader and Fragment Shader file: Vertex Shader File: attribute vec4 position; attribute vec4 inputTextureCoordinate; varying vec2 textureCoordinate; varying vec4 co; void main() { gl_Position = position; textureCoordinate = inputTextureCoordinate.xy; co = inputTextureCoordinate; } Fragment Shader File: uniform sampler2D videoFrame; // the texture with the scene you want to blur varying mediump vec2 textureCoordinate; varying mediump vec4 co; precision mediump float; vec4

Does iOS5 support both GL_STENCIL_INDEX and GL_STENCIL_INDEX8?

烈酒焚心 提交于 2019-12-08 20:10:44
With the following code: GLuint viewRenderbuffer, viewFramebuffer, viewDepthbuffer, stencilBuffer; // Create the framebuffer object glGenFramebuffers(1, &viewFramebuffer); glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer); // Create a render buffer and bind it to the FBO. glGenRenderbuffers(1, &viewRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer); [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer]; glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, viewRenderbuffer); glGetRenderbufferParameteriv(GL_RENDERBUFFER

How important is alignment in opengl vertex data in iOS

♀尐吖头ヾ 提交于 2019-12-08 16:51:38
问题 The OpenGL ES Programming guide discusses that you should avoid misaligned vertex data and gives an example of aligning the data to 4 byte blocks. OpenGL ES Programming Guide However in most demo material and tutorials I've found online I don't see anyone doing this. Example below is from a demo project on 71 Squared: static const SSTexturedVertexData3D EnemyFighterVertexData[] = { {/*v:*/{1.987003, -0.692074, -1.720503}, /*n:*/{0.946379, -0.165685, -0.277261}, /*t:*/{0.972816, 0.024320}},

Android OpenGLES 2.0 Texture Mapping Does Not Work

耗尽温柔 提交于 2019-12-08 14:32:25
I'm trying to texture map some quads. I can render the quads with solid colors just fine. I've been following this page: http://www.learnopengles.com/android-lesson-four-introducing-basic-texturing/ Everything compiles and runs, but the texture is simply not being applied. The only difference between my code and the page linked is that I do not do glBindAttribLocation, and I use glDrawElements instead of glDrawArrays. EDIT: Converting my vertex and tex coord data to use glDrawArrays did not fix anything. All of my shader handles seem correct. The problem must be in one of my draws. If anyone

Morphing in WebGL shaders with mix() between more then two targets

∥☆過路亽.° 提交于 2019-12-08 13:02:08
问题 I am trying to build an image slider using three.js and am having difficulties with wrapping my head around passing the appropriate state to the glsl shaders so I can transition between the slides. I can easily do it between two targets (be it textures or models) with simply easing between 0 and 1 and passing it as an attrib float like this: attribute float mix; vec4 color = mix(tex1, tex2, mix); But I can't understand how to approach it with more then 2 targets. Should I pass a number and do