Mercurial > sdl-ios-xcode
annotate src/video/android/SDL_androidgl.c @ 5280:bad04e4710f6
Fixed bug #1116
Don't allocate the window's texture data until after creating the renderer, in case the renderer recreates the window.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 12 Feb 2011 17:51:47 -0800 |
parents | b530ef003506 |
children |
rev | line source |
---|---|
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
1 /* |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
5267 | 3 Copyright (C) 1997-2011 Sam Lantinga |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
4 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
9 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
14 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
18 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
19 Sam Lantinga |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
20 slouken@libsdl.org |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
21 */ |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
23 |
4980
d9fdff945ec9
A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
4959
diff
changeset
|
24 /* Android SDL video driver implementation */ |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
25 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
26 #include "SDL_video.h" |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
27 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
28 #include "SDL_androidvideo.h" |
5092
327f181542f1
Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
Sam Lantinga <slouken@libsdl.org>
parents:
4989
diff
changeset
|
29 #include "../../core/android/SDL_android.h" |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
30 |
4707
8b109f0dcd2f
Removed old video subsystem, along with (now-unncessary) egl files.
Paul Hunkin <paul@bieh.net>
parents:
4703
diff
changeset
|
31 #include <android/log.h> |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
32 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
33 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
34 /* GL functions */ |
4989 | 35 int |
36 Android_GL_LoadLibrary(_THIS, const char *path) | |
37 { | |
38 __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_LoadLibrary\n"); | |
39 return 0; | |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
40 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
41 |
4989 | 42 void * |
43 Android_GL_GetProcAddress(_THIS, const char *proc) | |
44 { | |
45 __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetProcAddress\n"); | |
46 return 0; | |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
47 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
48 |
4989 | 49 void |
50 Android_GL_UnloadLibrary(_THIS) | |
51 { | |
52 __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_UnloadLibrary\n"); | |
53 } | |
54 | |
55 SDL_GLContext | |
56 Android_GL_CreateContext(_THIS, SDL_Window * window) | |
57 { | |
5227
c66b2a778b7e
Try to create an OpenGL ES 2.0 context on Android and successfully fall back to OpenGL ES 1.1 if that fails.
Sam Lantinga <slouken@libsdl.org>
parents:
5207
diff
changeset
|
58 if (!Android_JNI_CreateContext(_this->gl_config.major_version, |
c66b2a778b7e
Try to create an OpenGL ES 2.0 context on Android and successfully fall back to OpenGL ES 1.1 if that fails.
Sam Lantinga <slouken@libsdl.org>
parents:
5207
diff
changeset
|
59 _this->gl_config.minor_version)) { |
c66b2a778b7e
Try to create an OpenGL ES 2.0 context on Android and successfully fall back to OpenGL ES 1.1 if that fails.
Sam Lantinga <slouken@libsdl.org>
parents:
5207
diff
changeset
|
60 SDL_SetError("Couldn't create OpenGL context - see Android log for details"); |
c66b2a778b7e
Try to create an OpenGL ES 2.0 context on Android and successfully fall back to OpenGL ES 1.1 if that fails.
Sam Lantinga <slouken@libsdl.org>
parents:
5207
diff
changeset
|
61 return NULL; |
c66b2a778b7e
Try to create an OpenGL ES 2.0 context on Android and successfully fall back to OpenGL ES 1.1 if that fails.
Sam Lantinga <slouken@libsdl.org>
parents:
5207
diff
changeset
|
62 } |
5207
daa5463466c5
Fixed building on Android, added SDL_opengles2.h, removed unnecessary SDL_glesfuncs.h
Sam Lantinga <slouken@libsdl.org>
parents:
5092
diff
changeset
|
63 return (SDL_GLContext)1; |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
64 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
65 |
4989 | 66 int |
67 Android_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) | |
68 { | |
69 /* There's only one context, nothing to do... */ | |
70 return 0; | |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
71 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
72 |
4989 | 73 int |
74 Android_GL_SetSwapInterval(_THIS, int interval) | |
75 { | |
76 __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SetSwapInterval\n"); | |
77 return 0; | |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
78 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
79 |
4989 | 80 int |
81 Android_GL_GetSwapInterval(_THIS) | |
82 { | |
83 __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetSwapInterval\n"); | |
84 return 0; | |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
85 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
86 |
4989 | 87 void |
88 Android_GL_SwapWindow(_THIS, SDL_Window * window) | |
89 { | |
90 Android_JNI_SwapWindow(); | |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
91 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
92 |
4989 | 93 void |
94 Android_GL_DeleteContext(_THIS, SDL_GLContext context) | |
95 { | |
96 __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_DeleteContext\n"); | |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
97 } |
5227
c66b2a778b7e
Try to create an OpenGL ES 2.0 context on Android and successfully fall back to OpenGL ES 1.1 if that fails.
Sam Lantinga <slouken@libsdl.org>
parents:
5207
diff
changeset
|
98 |
c66b2a778b7e
Try to create an OpenGL ES 2.0 context on Android and successfully fall back to OpenGL ES 1.1 if that fails.
Sam Lantinga <slouken@libsdl.org>
parents:
5207
diff
changeset
|
99 /* vi: set ts=4 sw=4 expandtab: */ |