opengl-es-2.0

In OpenGL ES 2.0, Android, Is it possible to draw line & circle in a custom sized SurfaceView Renderer

心已入冬 提交于 2019-12-06 11:07:21
问题 In developing an app to draw line & circle dynamically using user input through motion event, I like to provide the output of drawing in a custom sized SurfaceView Renderer so that I can use the rest of the screen for some other purpose like menu, etc. I have created a SurfaceView in layout and tried to provide the output, but the line gets drawn from the centre of the surfaceview and doesn't follow exactly with the touch event given. Is there any possibility that we can get output through

Android: OpenGL ES 2.0 - Texture always black

雨燕双飞 提交于 2019-12-06 10:36:56
问题 I'm trying to show a simple texture in OpenGL ES 2.0 (Android 4.0.4, Galaxy Nexus) as fullscreen background using a vertex and a fragment shader. The final result should be to display the camera image there, but for a start, simple texture from a file would be sufficient. I tested many things and for a short while it worked as I used OpenGL ES 1.x but as I plan to use shader for YUV->RGB conversion, I have to go with 2.0. I have the following vertex shader: attribute vec4 position; attribute

Preventing Android GL Context loss

跟風遠走 提交于 2019-12-06 09:27:18
Apologies for raising this issue again as i'm sure its been done to death already. :) However i'm converting a fully native game over to Android and i'm now looking into handling GL context loss. As we maintain a list of 'resources' within our game that contain the GL assets i'm able to spin through them and restore the GL context. However, though this works in a simplified test application i'm a little concerned that as context loss can occur at any time, i suspect i'll have to modify other game areas, (threaded resource handling for a start), to make sure i'm covering everything. At the back

GL Maximum Textures Size Policy

拈花ヽ惹草 提交于 2019-12-06 08:48:54
I'm developing a game with AndEngine. Since I'm doing it for Android and I want to cover as many devices as possible without the textures quality trade off I have 2 texture packs types: the HD and the LOW: HD textures = 2048x2048 LOW textures= 1024x1024 HD camera = 800x1280 LOW camera = 400x640 I've have made all the logic of setting up a HD texture pack or a LOW texture pack, what I need now is a good policy for choosing witch to use when the app starts up. Using AndEngine's: GLState state = new GLState(); int max = state.getInteger(GLES20.GL_MAX_...); I came across some values: Model :

How to create fog using Open GL ES 2.0 or WebGL?

元气小坏坏 提交于 2019-12-06 08:31:31
问题 I would like to create a fog effect for my game but I can't find any tutorials on how to do it using OpenGL ES 2.0. If anyone has links to tutorials, can provide an explanation, or source code I would be grateful. 回答1: There's a section on replicating fixed-function fog using shaders in the OpenGL ES 2.0 Programming Guide on page 224. The source code is available on the google code project (MIT License). It's a gigantic rendermonkey XML file, but the shader source embedded in it is pretty

OpenGL ES 2.0 iPhone - Rendering on background thread block main thread

情到浓时终转凉″ 提交于 2019-12-06 08:25:42
问题 I'm rendering OpenGL Context on a background thread with a different EAGLContext than the main thread. I use something like this: - (void)renderInBackground { EAGLContext *context = [[EAGLContext] alloc] init]; [EAGLContext setCurrentContext:context]; Rendering.. } However, even though this is performed in a background thread, when using a heavy shader, the main thread gets blocked and the UI gets stuck. Why is the background thread blocking the main thread? the methods are not synchronized.

Post processing and resulting texture

巧了我就是萌 提交于 2019-12-06 08:23:37
I'm trying to understand how post processing work. From what I understood, I need to to something like that: -> Bind render texture -> Draw my scene -> Unbind render texture -> Draw a quad full screen using the resulting texture using a shader to apply an effect (blur, …) The problem with that system is: How can I apply multiple effects on the resulting quad? In my mind, I think applying the "effects" (shaders) on the resulting texture then drawing the quad his probably the best solution, but I don't know if it is possible. Can I apply shaders on texture directly? PS: Here is what I've done

Screenshot on android OpenGL ES application

杀马特。学长 韩版系。学妹 提交于 2019-12-06 07:24:36
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 I am passing in is: View content = m_rootActivity.getWindow().getDecorView().getRootView(); Anyone has

Why is glGenVertexArrays defined for a C program but not a C++ program on Linux?

馋奶兔 提交于 2019-12-06 06:01:50
Consider the following file: #include <SDL.h> #include <GLES2/gl2.h> int main() { SDL_Init(SDL_INIT_VIDEO); SDL_Window *window = SDL_CreateWindow("Test", 0, 0, 200, 200, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); SDL_GLContext context = SDL_GL_CreateContext(window); GLuint vao; glGenVertexArrays(1, &vao); } If the above is test.c, then the following line (compiling as C code) works perfectly: gcc test.c -I/usr/include/SDL2 -lGLESv2 -lSDL2 This next one (compiling as C++ code), however, does not: gcc -x c++ test.c -I/usr/include/SDL2 -lGLESv2 -lSDL2 The error that I get is: test.c: In function ‘int

OpenGL ES2.0 glReadPixels() read data from renderbuffer through framebuffer

独自空忆成欢 提交于 2019-12-06 05:17:48
问题 I am doing off-screen processing using opengl es2.0 on Android. I created a renderbuffer, and attached it to a framebuffer FBO, after rendering to the FBO, I try to get the pixels from that FBO by getReadPixels() method. But I got nothing. The code is shown below: GLuint resultFBO;// FBO GLuint rboId; //render buffer id glGenRenderbuffers(1, &rboId); glBindRenderbuffer(GL_RENDERBUFFER, rboId); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, image_width, image_height);