opengl-es

Transpose a mat4 in OpenGL ES 2.0 GLSL

孤人 提交于 2020-01-01 03:14:13
问题 I'd like to transpose a matrix in my OpenGL ES 2.0 vertex shader, but apparently my iPad 3 doesn't support GLSL #version 120 , which is needed for the built-in function transpose(mat4) . I know there are options to work around that, like transposing the matrix on the CPU before passing it to the graphics chip, but it would make my shader a lot simpler if I could transpose it there. So, is there an option to transpose a mat4 in a shader on an iOS 6 device? Another thing: The question What

How do you apply light sources using OpenGL ES 2.0?

本小妞迷上赌 提交于 2020-01-01 00:50:14
问题 I am trying to find any tutorial or sample code which explains and shows the usage of lights in OpenGL ES 2.0. Most of the material I have seen online refers to Opengl ES 1.1. Can anyone provide any links or documentation on how to do lighting in OpenGL ES 2.0? 回答1: The difficulty with OpenGL ES 2.0 is that since you can write your own shaders pretty much how you want, there's no one set way to provide lighting to an object. It will depend on how you want to present your content. That said,

How to efficiently copy depth buffer to texture on OpenGL ES

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 00:43:13
问题 I'm trying to get some shadowing effects to work in OpenGL ES 2.0 on iOS by porting some code from standard GL. Part of the sample involves copying the depth buffer to a texture: glBindTexture(GL_TEXTURE_2D, g_uiDepthBuffer); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, 800, 600, 0); However, it appears the glCopyTexImage2D is not supported on ES. Reading a related thread, it seems I can use the frame buffer and fragment shaders to extract the depth data. So I'm trying to

Cocos2D 2.0 OpenGL errors?

只谈情不闲聊 提交于 2019-12-30 15:00:22
问题 In my app it was working fine in Cocos2D version 1.1. When I upgraded to 2.0rc0a, I just see a black screen now and I get the following 4 errors nonstop until I quit the application: OpenGL error 0x0506 in -[CCSprite draw] 532 OpenGL error 0x0506 in -[CCParticleSystemQuad draw] 461 OpenGL error 0x0506 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 543 OpenGL error 0x0506 in -[CCGLView swapBuffers] 280 So I googled this a bit and it seems that the app cannot find the shader files . What

picking in 3D with ray-tracing using NinevehGL or OpenGL i-phone

跟風遠走 提交于 2019-12-30 12:51:48
问题 I couldn't find the correct and understandable expression of picking in 3D with method of ray-tracing. Has anyone implemented this algorithm in any language? Share directly working code, because since pseudocodes can not be compiled, they are genereally written with lacking parts. 回答1: What you have is a position in 2D on the screen. The first thing to do is convert that point from pixels to normalized device coordinates — -1 to 1. Then you need to find the line in 3D space that the point

GLSurfaceView/SurfaceView overlap

≡放荡痞女 提交于 2019-12-30 11:11:09
问题 I asked a question about this earlier but received no responses, so I'm trying again. I need to do a rendered 2D picture with some accompanying labels and graphics on a Motorola Xoom, Android 3.0. Although what I need can be done with just a SurfaceView (Canvas) or just a GLSurfaceView, I would really like to use both because the rendering is faster with the GLSurfaceView, and the labeling and graphics are easier with the SurfaceView. The visual layout is as shown below. I tried to put the

GLSurfaceView/SurfaceView overlap

末鹿安然 提交于 2019-12-30 11:10:03
问题 I asked a question about this earlier but received no responses, so I'm trying again. I need to do a rendered 2D picture with some accompanying labels and graphics on a Motorola Xoom, Android 3.0. Although what I need can be done with just a SurfaceView (Canvas) or just a GLSurfaceView, I would really like to use both because the rendering is faster with the GLSurfaceView, and the labeling and graphics are easier with the SurfaceView. The visual layout is as shown below. I tried to put the

How to draw to GLKit's OpenGL ES context asynchronously from a Grand Central Dispatch Queue on iOS

ぃ、小莉子 提交于 2019-12-30 09:53:22
问题 I'm trying to move lengthy OpenGL draw operations into a GCD queue so I can get other stuff done while the GPU grinds along. I would much rather prefer to do this with GCD vs. adding real threading to my app. Literally all I want to do is be able to Not block on a glDrawArrays() call so the rest of the UI can stay responsive when GL rendering gets very slow. Drop glDrawArrays() calls when we aren't finishing them anyway (don't build up a queue of frames that just grows and grows) On Apple's

How to include model matrix to a VBO?

别说谁变了你拦得住时间么 提交于 2019-12-30 07:23:21
问题 I want to send a buffer list (to the GPU/vertex shader) which contains information about vertex position, world position, color, scale, and rotation. If each of my 3D objects have transformation related information in a matrix, how can i pass this array of matrices (in addition to the other vertex data) to the GPU via the VBO(s) ? Updated Please excuse any typos: // bind & set vertices. gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); gl.vertexAtribPointer(a_Position, 3, gl.FLOAT, false, stride,

Rendering 2D sprites in a 3D world?

寵の児 提交于 2019-12-30 07:08:06
问题 How do I render 2D sprites in OpenGL given that I have a png of the sprite? See images as an example of the effect I'd like to achieve. Also I would like to overlay weapons on the screen like the rifle in the bottom image. Does anyone know how I would achieve the two effects? Any help is greatly appreciated. 回答1: In 3D terms, this is called a "billboard". A billboard is completely flat 2D plane with a texture on it and it always faces the camera. See here for a pure OpenGL implementation: