comparison src/video/android/SDL_androidgl.c @ 4701:d40bb3165d2b

Added (partially implemented) android video backend and associated files needed to build
author Paul Hunkin <paul@bieh.net>
date Thu, 10 Jun 2010 18:54:23 +1200
parents
children c93b44ddc63e
comparison
equal deleted inserted replaced
4700:cf23d9b8e606 4701:d40bb3165d2b
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22 #include "SDL_config.h"
23
24 /* Android SDL video driver implementation
25 */
26
27 #include "SDL_video.h"
28 #include "SDL_mouse.h"
29 #include "../SDL_sysvideo.h"
30 #include "../SDL_pixels_c.h"
31 #include "../../events/SDL_events_c.h"
32
33 #include "SDL_androidvideo.h"
34 #include "SDL_androidevents_c.h"
35 #include "SDL_androidrender_c.h"
36
37 /* Android header */
38 #include "egl.h"
39
40
41 //EGL globals
42 static EGLDisplay iEglDisplay;
43 static EGLConfig iEglConfig;
44 static EGLContext iEglContext;
45 static EGLSurface iEglSurface;
46
47 EGLint attribList [] =
48 {
49 EGL_BUFFER_SIZE, 16, //16 bit color
50 EGL_DEPTH_SIZE, 15,
51 EGL_NONE
52 };
53
54
55
56
57 /* GL functions */
58 int Android_GL_LoadLibrary(_THIS, const char *path){
59 printf("[STUB] GL_LoadLibrary\n");
60 return 0;
61 }
62
63 void *Android_GL_GetProcAddress(_THIS, const char *proc){
64 printf("[STUB] GL_GetProcAddress\n");
65 return 0;
66 }
67
68 void Android_GL_UnloadLibrary(_THIS){
69 printf("[STUB] GL_UnloadLibrary\n");
70 }
71
72 /*
73 int *Android_GL_GetVisual(_THIS, Display * display, int screen){
74 printf("[STUB] GL_GetVisual\n");
75 return 0;
76 }
77 */
78
79 SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window){
80 printf("[STUB] GL_CreateContext\n");
81
82 //Start up the display
83 iEglDisplay = eglGetDisplay (EGL_DEFAULT_DISPLAY);
84 if(iEglDisplay == EGL_NO_DISPLAY){
85 printf("Unable to find a suitable EGLDisplay\n");
86 return NULL;
87 }
88
89 printf("1\n");
90
91 if(!eglInitialize(iEglDisplay, 0, 0)){
92 printf("Couldn't init display\n");
93 return NULL;
94 }
95
96 printf("2\n");
97
98 EGLint numConfigs;
99
100 if(!eglChooseConfig(iEglDisplay, attribList, &iEglConfig, 1, &numConfigs)){
101 printf("Couldn't choose config\n");
102 return NULL;
103 }
104
105 printf("3\n");
106
107 iEglContext = eglCreateContext(iEglDisplay, iEglConfig, EGL_NO_CONTEXT, 0);
108
109 if(iEglContext == 0){
110 printf("Couldn't create context\n");
111 return NULL;
112 }
113
114 printf("4\n");
115
116 NativeWindowType iWindow = 1; //android_createDisplaySurface();
117
118 iEglSurface = eglCreateWindowSurface(iEglDisplay, iEglConfig, iWindow, 0);
119
120 printf("5\n");
121
122 if(iEglSurface == NULL){
123 printf("Couldn't create surface\n");
124 return NULL;
125 }
126
127 printf("6\n");
128
129 eglMakeCurrent(iEglDisplay, iEglSurface, iEglSurface, iEglContext);
130
131 printf("fininshed making context\n");
132
133 return iEglSurface;
134 }
135
136 int Android_GL_MakeCurrent(_THIS, SDL_Window * window,
137 SDL_GLContext context){
138 printf("[STUB] GL_MakeCurrent\n");
139 return 0;
140 }
141
142 int Android_GL_SetSwapInterval(_THIS, int interval){
143 printf("[STUB] GL_SetSwapInterval\n");
144 return 0;
145 }
146
147 int Android_GL_GetSwapInterval(_THIS){
148 printf("[STUB] GL_GetSwapInterval\n");
149 return 0;
150 }
151
152 void Android_GL_SwapWindow(_THIS, SDL_Window * window){
153 printf("[STUB] GL_SwapWindow\n");
154 }
155
156 void Android_GL_DeleteContext(_THIS, SDL_GLContext context){
157 printf("[STUB] GL_DeleteContext\n");
158 }