opengl-es-2.0

OpenGL - Should I store Attribute/Uniform locations?

谁说胖子不能爱 提交于 2020-01-03 09:03:32
问题 Are glGetUniformLocation and glGetAttribLocation time consuming? Which way is better? Call glGetAttribLocation or glGetUniformLocation every time I need it ? Store locations in varables and use them when needed ? 回答1: Whether on Android or iPhone, for an opengl surface you will have methods like: onSurfaceCreated and onSurfaceChanged , get into the habit of fetching uniforms and attributes here in these 2 methods. The only way you can make rendering faster (which will soon become your

OpenGL - Should I store Attribute/Uniform locations?

烈酒焚心 提交于 2020-01-03 09:01:15
问题 Are glGetUniformLocation and glGetAttribLocation time consuming? Which way is better? Call glGetAttribLocation or glGetUniformLocation every time I need it ? Store locations in varables and use them when needed ? 回答1: Whether on Android or iPhone, for an opengl surface you will have methods like: onSurfaceCreated and onSurfaceChanged , get into the habit of fetching uniforms and attributes here in these 2 methods. The only way you can make rendering faster (which will soon become your

Fragment shader: No uniform with name in shader

£可爱£侵袭症+ 提交于 2020-01-03 05:09:06
问题 I have problem with fragment shader in libgdx. Below is my fragment shader. #ifdef GL_ES precision mediump float; #endif uniform float u_aspectRatio; varying vec2 v_texCoords; uniform sampler2D u_texture; void main() { gl_FragColor = texture2D(u_texture, v_texCoords); } In program I do shader.setUniformi("u_texture", 0); // work fine shader.setUniformf("u_aspectRatio", 0.0f); //no uniform with name 'u_aspectRatio' in shader shader.isCompiled() return true and first set work fine, but in

Android OpenGL 2.0 Sprite Optimization

拟墨画扇 提交于 2020-01-03 04:50:27
问题 Hej, I'm creating simple game for Android in OpenGL ES 2.0. The game will contain few types of different sprites, but these will occur more than once. For now let's say I have 1 object (sprite). So far I've implemented VBO and Index buffering, so an object as whole is stored on GPU, as I understand. What I would like to do now is to draw this object multiple times, only thing differing it's position. As for now, this is implemented as follows: glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer

Is there any alternative for GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT)?

谁说我不能喝 提交于 2020-01-03 03:27:27
问题 I get a fill rate of about 30fps in my application. I know that GLES20.glClear() is used to clear the screen for every draw. If i comment it i get a fps of about 60fps. But the output is not as expected. I have a content to be redrawn for the whole screen in every frame. Is there any alternative where i can redraw the whole screen with out using the GLES20.glClear(). Please let me know if there is any way to play around with GLES20.glClear() to improve the performance? 回答1: If you overwrite

Screenshot on android OpenGL ES application

时光毁灭记忆、已成空白 提交于 2020-01-02 14:13:07
问题 I have a basic openGL ES 20 application running with on a GLSurfaceView that has been added: GLSurfaceView view = new GLSurfaceView(this); view.setRenderer(new OpenGLRenderer()); setContentView(view); Basically I am trying get a screenshot with the following method: private static Bitmap getScreenshot(View v) { Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); v.draw(c); return b; } But it seems the bitmap is transparent. The view

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

岁酱吖の 提交于 2020-01-02 05:12:42
问题 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

Recoding one H.264 video to another using opengl surfaces is very slow on my android

喜你入骨 提交于 2020-01-01 19:58:53
问题 I'm developing function of translating one video into another with additional effects for each frame. I decided to use opengl-es for applying effects on each frame. My input and output videos are in MP4 using H.264 codec. I use MediaCodec API (android api 18+) for decoding H.264 into the opengl texture, then draw on the surface using this texture with my shader. I thought that using MediaCodec with H.264 will do hardware decoding on android and it will be fast. But appeared that it is not.

How to convert an Open GL ES 2.0 application to a Live Wallpaper?

十年热恋 提交于 2020-01-01 18:57:03
问题 I have a class which implements GLSurfaceView.Renderer and uses Open GL ES 2.0, and works perfectly as a standard application. However I'd like to expand this so that its a live wallpaper. Naturyally I've got a service class which exteds WallPaperservice, and in turn a engine class which extends WallpaperService.Engine. In the normal version of the code I can just do mGLSView = new GLSurfaceView(this); // in the engine this becomes 'new GLSurfaceView(getBaseContext());' mGLSView

Stenciling using OpenGl ES 2.0

ε祈祈猫儿з 提交于 2020-01-01 12:08:09
问题 I am trying to figure out a way to cut out a certain region of a background texture such that a certain custom pattern is not rendered on the screen for that background. For example: This square can be any pattern. I am using Frame Buffer Object and Stencil Buffer to achieve this kind of effect. Here is the code: fbo.begin(); //Disables ColorMask and DepthMask so that all the rendering is done on the Stencil Buffer Gdx.gl20.glColorMask(false, false, false, false); Gdx.gl20.glDepthMask(false);