opengl-es-2.0

Rendering an image texture into a cubemap in openGL android

心已入冬 提交于 2019-12-11 11:10:04
问题 I have a bitmap on my device(which is a 6x1 cubemap), which I want to render on all the faces of the cube InputStream is = getContext().getResources().openRawResource(R.raw.photo); Bitmap bitmap = BitmapFactory.decodeStream(is); int bytes = bitmap.getByteCount(); ByteBuffer pixels = ByteBuffer.allocate(bytes); bitmap.copyPixelsToBuffer(pixels); Here is my vertex shader: uniform mat4 uMVPMatrix; uniform mat4 uSTMatrix; attribute vec4 aPosition; attribute vec4 aTextureCoord; attribute vec4

MTKView vs GLKView performance on old devices

痴心易碎 提交于 2019-12-11 11:00:14
问题 I am running into weird performance issues on older device (iPad Mini 2 of year 2014) ever since migrating to MTKView from OpenGLES based views. To summarize, I am rendering live video preview using MTKView and also optionally record videos (like in RosyWriter sample code). My new app version is written in Swift and supports both Metal & OpenGLES. So I have both Open GL and Metal rendering code to compare. I also have a legacy version of app written in Objective C & uses OpenGLES for all

Errors after changed OpenGL code from ES 1.0 to ES 2.0

泄露秘密 提交于 2019-12-11 10:58:02
问题 I changed code from ES 1.0 to ES 2.0 in cocos2d-x Code in ES 1.0 version const float DARK=30.0f; int n = m_sGridSize.x * m_sGridSize.y; glEnable(GL_CULL_FACE); glDisableClientState(GL_COLOR_ARRAY); glVertexPointer(3, GL_FLOAT, 0, m_pVertices); glTexCoordPointer(2, GL_FLOAT, 0, m_pTexCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, m_pIndices); glFrontFace(GL_CW); glDisable(GL_TEXTURE_2D); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glColor4ub(255-(m

Can a texture be updated in background thread but printed in foreground thread?

帅比萌擦擦* 提交于 2019-12-11 10:54:15
问题 In webRTC, in SurfaceTextureHelper the surfaceTexture (with handle the creation/update of the openGL texture) is created inside a background thread: final HandlerThread thread = new HandlerThread(threadName); thread.start(); an inside this newly created thread we do oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES); surfaceTexture = new SurfaceTexture(oesTextureId); The problem is that the OnFrameAvailableListener of the surfacetexture will be called in the thread where

Is using GL_NEAREST_MIPMAP_* or GL_LINEAR_MIPMAP_* for GL_TEXTURE_MIN_FILTER considered erroneous if MIP maps have not been generated?

和自甴很熟 提交于 2019-12-11 10:43:08
问题 I have a feeling this is one of those situations that will depend on the driver implementation since this scenario is not described in the OpenGL specification. However, I'm hoping that someone will know if using GL_(LINEAR/NEAREST)_ MIPMAP_* without generating MIP maps would be treated the same as using GL_(LINEAR/NEAREST)? 回答1: Define "without any active MIP textures"? I'm not sure how you would, since there's no such thing as a "mip texture" (a texture contains mipmaps, but mipmaps are not

Bitmap texture does not show up in framebuffer surface on Android

让人想犯罪 __ 提交于 2019-12-11 09:42:52
问题 I'm trying to use the new EffectFactory/Effect to add effects to images off screen (i.e. framebuffer). I've looked at the HelloEffects.java example provided in the SDK and I've tried it out and it works. Except it obviously uses a GLSurfaceView and that isn't what I want. So I've taken tests/effect/src/android/effect/cts/GLEnv.java to setup the EGL stuff and I've also grabbed TextureRenderer.java and GLToolbox from the HelloEffects example. Mashed them all up and I've got the code below. (On

How to properly use GL_HALF_FLOAT_OES for textures?

心不动则不痛 提交于 2019-12-11 09:31:28
问题 I'm using OpenGL ES 2.0 on an iPad 2 / 3. I'd like to use GL_FLOAT when creating textures: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, rawData); but the problem is that GL_LINEAR is not supported as a GL_TEXTURE_MAG_FILTER when GL_FLOAT is used if you don't have GL_OES_texture_float_linear showing up in your list of supported extensions. (None of the iPads do.) But I do have GL_OES_texture_half_float_linear in my list of extensions. So using a half-float

OpenGL ES 2.0 draw Fullscreen Quad very slow

我的梦境 提交于 2019-12-11 09:25:39
问题 When I'm rendering my content onto a FBO with a texture bound to it and then render this bound texture to a fullscreen quad using a basic shader the performance drops ridiculously. For example: Render to screen directly (with basic shader): And when render to texture first, then render texture with fullscreen quad: (with same basic shader, would be something like blur or bloom normally): Anyone got an idea how to speed this up? Since the current performance is not usable. Also I'm using GLKit

How do I set up the viewable area in a scene within OpenGL ES 2.0?

試著忘記壹切 提交于 2019-12-11 09:19:57
问题 I have done programming in OpenGL and I know how to set the viewable area in it with gluOrtho() , but a function like this does not exist in OpenGL ES 2.0. How would I do this in OpenGL ES 2.0? P.S : I am doing my OpenGL ES 2.0 development in Ubuntu 10.10 with the PowerVR SDK emulator. 回答1: As Nicol suggests, you'll want to set up an orthographic projection matrix. For example, an Objective-C method I use to do this is as follows: - (void)loadOrthoMatrix:(GLfloat *)matrix left:(GLfloat)left