opengl-es

How do I display a non-power-of-2-texture as sprite in OpenGL (ES) with no stretching?

空扰寡人 提交于 2019-12-06 08:49:27
问题 I want to draw an arbitrary size sprite as a png, say something TOTALLY CRAZY like 56 wide x 30 high. Not a power of 2 in either dimension. Also I may want to draw another different sprite that's 72 wide x 33 high. Indicating this because no 'tricks' are acceptable here, I need to handle general case. So I have this png (with transparency) and I want to draw it as a sprite with absolutely no stretching, interpolation, etc. I want it to map 1:1 with pixels on the screen. Pretend these sprites

Drawing a circle with a sector cut out in OpenGL ES 1.1

六月ゝ 毕业季﹏ 提交于 2019-12-06 08:28:53
问题 I'm trying to draw the following shape using OpenGL ES 1.1. And well, I'm stuck, I don't really know how to go about it. My game currently uses Android's Canvas API, which isn't hardware accelerated, so I'm rewriting it with OpenGL ES. The Canvas class has a method called drawArc which makes drawing this shape very very easy; Canvas.drawArc Any advice/hints on doing the same with OpenGL ES? Thank you for reading. 回答1: void gltDrawArc(unsigned int const segments, float angle_start, float angle

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.

How do I shut down OpenGL tasks in applicationWillResignActive?

流过昼夜 提交于 2019-12-06 08:19:08
I have nearly completed my first app. In testing on the device, I am getting a crash when I press the home button, with the error message libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient: Based on these posts: https://stackoverflow.com/search?q=how+to+shut+down+OpenGL OpenGL ES crash on move background, iOS 5.1 I am pretty sure the problem is that my app is an extension of software that uses some sample code involving OpenGL (about which I have very little understanding) and that the OpenGL tasks are not shutting down properly on resignActive. I tried the following in my

Trying to render to texture using framebuffer always results in white texture

ⅰ亾dé卋堺 提交于 2019-12-06 08:18:53
问题 Using a couple of posts here in StackOverflow, I created what is supposed to be a simple render-to-texture using a framebuffer. The problem here is that it's not working. Something is broken in the mix, as my final texture is just a white square. I am not getting any gl errors whatsoever. Here is my code. Declare instance variables. GLuint texture; GLuint textureFrameBuffer; Generate the texture and framebuffer. glGetError(); //Generate the texture that we will draw to (saves us a lot of

How can I create a new NativeWindow in Android NDK without needing the Android OS source code?

假如想象 提交于 2019-12-06 08:15:53
问题 I want to compile an Android OpenGL console application that you can run directly from console boot Android x86, or from the Android terminal application inside Android x86 GUI. This post ( How can I create a new NativeWindow in Android NDK? ) asks a similar question. However, the answer says to download and build the entire android source code because the tests here ( https://android.googlesource.com/platform/frameworks/base/+/refs/heads/gingerbread-release/opengl/tests ) such as ( https:/

OpenGL and QtQuick Texture Problems

我的梦境 提交于 2019-12-06 08:06:19
问题 I'm developing a simple QQuickItem implementation in C++ based on the "openglunderqml" example that came with Qt. I made some modifications to use different shaders and two textures that I load in. The idea is that the shaders will crossfade between the two textures (which are essentially just images I have loaded into the textures). When I put this QQuickItem alone inside a QML file and run it, everything works fine. The images crossfade between each other (I've setup a property animation to

Android MediaCodec appears to buffer H264 frames

China☆狼群 提交于 2019-12-06 07:37:04
I'm manually reading a RTP/H264 stream and pass the H264 frames to the Android MediaCodec. I use the "markerBit" as a border for the frames. The MediaCodec is tied to a OpenGL Texture (SurfaceTexture). In general everything works fine. But the Decoder appears to buffer frames. If I put a frame in the decoder it is not rendered immediately to the texture. After I put 2-3 frames more in the decoder the first frame is rendered to the texture. I'm implementing against Android 4.4.4. private static final int INFINITE_TIMEOUT = -1; private static final int TIMEOUT_OUTPUT_BUFFER_MEDIA_CODEC = 1000; .

android getResources() from non-Activity class

只愿长相守 提交于 2019-12-06 07:21:16
问题 I'm trying to load my vertices array from assets/model.txt I have OpenGLActivity, GLRenderer and Mymodel classes i added this line to the OpenGLActivity: public static Context context; And this to Mymodel class: Context context = OpenGLActivity.context; AssetManager am = context.getResources().getAssets(); InputStream is = null; try { is = am.open("model.txt"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Scanner s = new Scanner(is); long numfloats = s

MediaCodec simultaneous encoding and decoding

别说谁变了你拦得住时间么 提交于 2019-12-06 07:16:49
问题 I am trying to apply effects to the frames of a video using the GPU and then to re-encode those frames into a new result video. In the interest of performance I have implemented the following flow: There are 3 different threads, each with it's own OpenGL context. These contexts are set up in such a way that they share textures between them. Thread 1 extracts frames from the video and holds them in the GPU memory as textures, similar to this example. Thread 2 processes the textures using a