opengl-es-2.0

OpenGL ES 2.0 drawing line based on motion, Line always starts in origin

末鹿安然 提交于 2019-12-05 14:38:22
I've just started learning OpenGL for Android and I'm having a weird problem when drawing lines. All i want to do is to draw a line based on a finger motion. Now as soon as I start swiping I always get a line folowing my motion from the origin(0,0). here a picture: http://imageshack.us/photo/my-images/137/screenshot2012061312174.jpg/ The arrow symbols my finger motion and the line starting in the origin (red circle) is the mentioned line folowing my entire motion. Don't get bothered with the Coords array I know this isn't best practice but I debuged the entire programm and couldn't finde any

Manual selection lod of mipmaps in a fragment shader using three.js

戏子无情 提交于 2019-12-05 14:29:50
I'm writing a physically based shader using glsl es in three.js. For the addition of specular global illumination I use a cubemap dds texture with mipmap chain inside (precalculate with CubeMapGen as it's explained here ). I need to access this texture in fragment shader and I would like to select manually the index of mipmap. The correct function for doing this is vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod) but it's available only in vertex shader. In my fragment shader I'm using the similar function vec4 textureCube(samplerCube sampler, vec3 coord, float bias) but it

Can an OpenGLES 2.0 framebuffer be bound to a texture and a renderbuffer at the same time?

两盒软妹~` 提交于 2019-12-05 14:27:11
Brad Larson provides some great code here and here for 'rendering your scene into a texture-backed framebuffer', but it's not clear whether this is the same framebuffer that I use for the rest of the drawing. If you attach a renderbuffer to a framebuffer, can the framebuffer also render into a texture with the same call? Arttu Peltonen Sounds like you might be a bit confused with FBO usage. If you need it, this should get you started: Apple Developer - Drawing offscreen . This could help too. Renderbuffer is something you can bind to an FBO (framebuffer object). FBO is something you create

for-loop in shader code working with hardcoded number but not with uniform variable

[亡魂溺海] 提交于 2019-12-05 13:17:38
I asked for help about an OpenGL ES 2.0 Problem in this question . What seems to be the answer is very odd to me. Therefore I decided to ask this question in hope of being able to understand what is going on. Here is the piece of faulty vertex-shader code: // a bunch of uniforms and stuff... uniform int u_lights_active; void main() { // some code... for ( int i = 0; i < u_lights_active; ++i ) { // do some stuff using u_lights_active } // some other code... } I know this looks odd but this is really all code that is needed to explain the problem / faulty behavior. My question is: Why is the

iPhone iOS 5.0 OpenGl ES 2.0

感情迁移 提交于 2019-12-05 12:43:30
Seriously i've been looking for weeks, even months for some serious help with OpenGl on the iPhone with XCode 4.2, I need a good tutorial on how to begin with the 'OpenGL Game' template with the new XCode 4.2 and then progress from there to actually understand how to make my game come to life. I have a lot of experience with Windows and XNA with shaders and all the maths involved and i already have an app on the App Store that doesn't use OpenGL but i just can't get started with it, please help, thanks in advance These video tutorials are quite old, but are clear and helpful and I found them

Using OpenGL ES texture caches instead of glReadPixels to get texture data

最后都变了- 提交于 2019-12-05 12:41:00
In iOS 5, OpenGL ES Texture caches were introduced to provide a direct way from the camera video data to OpenGL without the need of copying the buffers. There was a brief introduction to texture caches in session 414 - Advances in OpenGL ES for iOS 5 of WWDC 2011 . I found an interesting article which abuses this concept further in the end and circumvents a call to glReadPixels by simply locking the texture, and then accessing the buffer directly. glReadPixels is really slow due to the tile-based renderer which is used in iPad 2 (even when you use only 1x1 textures). However, the described

OpenGL ES 1.1 to 2.0 a major change?

99封情书 提交于 2019-12-05 10:48:08
I'm creating an iPhone app with cocos2d and I'm trying to make use of the following OpenGL ES 1.1 code. However, I'm not good with OpenGL and my app makes use of OpenGL ES 2.0 so I need to convert it. Thus I was wondering, how difficult would it be to convert the following code from ES 1.1 to ES 2.0? Is there some source that could tell me which methods need replacing etc? -(void) draw { glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisable(GL_TEXTURE_2D); glColor4ub(_color.r, _color.g, _color.b, _opacity); glLineWidth(1.0f); glEnable(GL_LINE_SMOOTH); if

onSurfaceChanged called twice

柔情痞子 提交于 2019-12-05 10:08:46
I'm creating an Android application using openGL ES, and I have following problem: When I minimize the application, then reopen it, onSurfaceChanged in my GLSurfaceView.Renderer is called 2 times. I have the following code in onSurfaceChanged (and similar code in onSurfaceCreated,onDrawFrame): Log.e("onSurfaceChanged",Integer.toString(width)+" "+Integer.toString(height)); So I get the following log: onSurfaceCreated onSurfaceChanged 480 800 onDrawFrame onSurfaceChanged 480 800 onDrawFrame onDrawFrame onDrawFrame onDrawFrame onDrawFrame onDrawFrame (...) When I minimize, change screen

Android OpenGL ES 2, Drawing squares

为君一笑 提交于 2019-12-05 09:18:03
问题 EDIT: Problem solved! So I've been going through the official OpenGL ES 2 tutorials for Android, and I've gotten to the part that involves drawing shapes, but I can't seem to get a square to work. It draws a right triangle instead. I've included the code that I'm using to define and draw the shape, which is copied almost exactly from the tutorial. The Renderer class simply creates an instance of this shape and calls the draw method. For some reason, the tutorial does not give the values

OpenGLES 2.0: gl_VertexID equivalent?

放肆的年华 提交于 2019-12-05 08:16:18
I'm trying to create a grid of points by calculating vertex positions dynamically, based on their index in the array of vertices sent to the shader. Is there an equivalent of the gl_VertexID variable that I can call from within my shader? Or another way of accessing their position in the array without having to send more data to the GPU? Thank, Josh. Here's my vertex shader: attribute vec4 vertexPosition; uniform mat4 modelViewProjectionMatrix; vec4 temp; uniform float width; void main() { temp = vertexPosition; // Calculate x and y values based on index: temp.y = floor(gl_VertexID/width);