Use SDL_renderer_gles.c from SDL 1.3 in SDL 1.2

This commit is contained in:
pelya
2010-09-28 17:36:38 +03:00
parent f58373279e
commit 73dcf3e75e
4 changed files with 31 additions and 1063 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_renderer_gles.c

View File

@@ -34,6 +34,7 @@
#define SDL_VIDEO_DRIVER_ANDROID 1
#define SDL_VIDEO_OPENGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES_GL_CONTEXT_LOSING_IMMUNE 1
#define SDL_AUDIO_DRIVER_ANDROID 1

View File

@@ -20,15 +20,24 @@
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_version.h"
#if SDL_VIDEO_RENDER_OGL_ES
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_video.h"
#include "SDL_opengles.h"
#include "SDL_sysvideo.h"
#else
#include "SDL_video-1.3.h"
#include "SDL_sysvideo-1.3.h"
#endif
#include "SDL_opengles.h"
#include "SDL_pixels_c.h"
#include "SDL_rect_c.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_yuv_sw_c.h"
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
@@ -221,11 +230,13 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
GLint value;
int doublebuffer;
#if SDL_VERSION_ATLEAST(1,3,0)
if (!(window->flags & SDL_WINDOW_OPENGL)) {
if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
return NULL;
}
}
#endif
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
if (!renderer) {
@@ -303,11 +314,15 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
}
#if SDL_VERSION_ATLEAST(1,3,0)
// Always double-buffered
#else
if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
if (!doublebuffer) {
renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
}
}
#endif
#if SDL_VIDEO_DRIVER_PANDORA
data->GL_OES_draw_texture_supported = SDL_FALSE;
data->useDrawTexture = SDL_FALSE;

View File

@@ -55,12 +55,18 @@ static JNIEnv* JavaEnv = NULL;
static jclass JavaRendererClass = NULL;
static jobject JavaRenderer = NULL;
static jmethodID JavaSwapBuffers = NULL;
static int glContextLost = 0;
int SDL_ANDROID_CallJavaSwapBuffers()
{
glContextLost = 0;
SDL_ANDROID_drawTouchscreenKeyboard();
SDL_ANDROID_processAndroidTrackballDampening();
return (*JavaEnv)->CallIntMethod( JavaEnv, JavaRenderer, JavaSwapBuffers );
(*JavaEnv)->CallIntMethod( JavaEnv, JavaRenderer, JavaSwapBuffers );
if( glContextLost )
{
glContextLost = 0;
}
}
@@ -84,6 +90,13 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeDone) ( JNIEnv* env, jobject thiz )
__android_log_print(ANDROID_LOG_INFO, "libSDL", "quit OK");
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextLost ( JNIEnv* env, jobject thiz )
{
__android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context lost, waiting for new OpenGL context");
glContextLost = 1;
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject thiz )
{