opengl-es-2.0

LibGDX - Shader working on Desktop but not on Android

微笑、不失礼 提交于 2020-01-14 11:48:11
问题 I have written a simple program that renders a sphere in a 3d environment and colores it according to four light sources around the sphere. When I run the program on the desktop it works just fine but on an Android device the sphere is just plain colored. Here are images to illustrate what I am talking about: -> Desktop -> Android And here is the shader code: sphere.vert #ifdef GL_ES precision mediump float; #endif uniform mat4 u_projectionMatrix; uniform mat3 u_normalMatrix; uniform mat4 u

Question about 3D Picking in Android (with OpenGL ES 2)

◇◆丶佛笑我妖孽 提交于 2020-01-14 05:41:06
问题 I need some help on 3D picking. I am using the way it works here. In short, what I have is: normalizedPoint[0] = (x * 2 / screenW) -1; normalizedPoint[1] = 1 - (y * 2 / screenH); normalizedPoint[2] = ? normalizedPoint[3] = ? for 2 and 3, I have no idea what it should be (I put 1, -1 just like the reference, and it doesn't work) Then, for my root object (following just psuedo code): matrix = perspective_matrix x model_matrix inv_matrix = inverse(matrix) outpoint = inv_matrix x normalizedPoint

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

那年仲夏 提交于 2020-01-13 11:22:49
问题 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? 回答1: 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.

BGRA on iPhone glTexImage2D and glReadPixels

别说谁变了你拦得住时间么 提交于 2020-01-13 07:04:06
问题 Looking at the docs, I should be able to use BGRA for the internal format of a texture. I am supplying the texture with BGRA data (using GL_RGBA8_OES for glRenderbufferStorage as it seems BGRA there is not allowed). However, the following does not work: glTexImage2D(GL_TEXTURE_2D, 0, **GL_BGRA**, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer); ... glReadPixels(0, 0, w,h, GL_BGRA, GL_UNSIGNED_BYTE,buffer, 0); While this gives me a black frame: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL

BGRA on iPhone glTexImage2D and glReadPixels

ぐ巨炮叔叔 提交于 2020-01-13 07:04:03
问题 Looking at the docs, I should be able to use BGRA for the internal format of a texture. I am supplying the texture with BGRA data (using GL_RGBA8_OES for glRenderbufferStorage as it seems BGRA there is not allowed). However, the following does not work: glTexImage2D(GL_TEXTURE_2D, 0, **GL_BGRA**, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer); ... glReadPixels(0, 0, w,h, GL_BGRA, GL_UNSIGNED_BYTE,buffer, 0); While this gives me a black frame: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL

EGL linker errors

蓝咒 提交于 2020-01-13 03:37:34
问题 I'm trying to link a really simple GLES2 & EGL program using g++ 4.9.1, on a Ubuntu Trusty system. I'm using the mesa libraries. I'm getting linker errors for EGL functions: test.cpp:(.text+0x342): undefined reference to `eglGetDisplay' test.cpp:(.text+0x389): undefined reference to `eglInitialize' test.cpp:(.text+0x40f): undefined reference to `eglCreateContext' test.cpp:(.text+0x458): undefined reference to `eglCreatePbufferSurface' test.cpp:(.text+0x49e): undefined reference to

Rendering multiple 2D images in OpenGL-ES 2.0

末鹿安然 提交于 2020-01-11 06:49:07
问题 I am new to OpenGL, and trying to learn ES 2.0. To start with, I am working on a card game, where I need to render multiple card images. I followed this http://www.learnopengles.com/android-lesson-four-introducing-basic-texturing/ I have created a few classes to handle the data and actions. MySprite holds the texture information, including the location and scale factors. Batcher draws all the sprites in one go. It is rough implementation. ShaderHelper manages creation of shaders and linking

In OpenGL, (how) can I depth test between two depth buffers?

这一生的挚爱 提交于 2020-01-07 09:02:19
问题 Say I have two depth buffers ("DA" and "DB"). I'd like to attach DA to a framebuffer, and render to it in the normal/"traditional" way (every fragment depth tests against GL_LESS, if it passes, it is drawn and it's depth is written to the depth buffer). Then, I'd like to attach DB- here I'd want to reference/use DB in the traditional way, but also depth test against DA with GL_GREATER. If the fragment passes both tests, I'd still just like to write depth to DB. What this would accomplish is

OpenGL Environment mapping Reflection

此生再无相见时 提交于 2020-01-07 07:09:36
问题 my reflections are wrong. I have changed a lot of the code, but I didn't find the error. It would be great if you can help me. Texture generation: Code : m_cubeMap = new int[1]; m_cubeFB = new int[1]; // create the cube map glGenTextures ( 1, m_cubeMap, 0 ); glBindTexture ( GL_TEXTURE_CUBE_MAP, m_cubeMap[0] ); for( int i = 0; i < 6; i++ ) { glTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA, m_cubeMapSize, m_cubeMapSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, null ); } glTexParameteri( GL

OpenGL stencil (Clip Entity)

核能气质少年 提交于 2020-01-06 19:49:24
问题 I am trying to use a sprite as clip-entity. This means I want that all it's child entities are clipped so that only the parts of the children that overlap the clip-entity (parent) are visible. I'm trying to do that using the OpenGL stencil function. On my emulator I got it working, but on my Android phone it doesn't. What am I doing wrong? GLES20.glEnable(GLES20.GL_STENCIL_TEST); GLES20.glClearStencil(0); GLES20.glStencilMask(1); GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT); // pre draw