src/video/android/SDL_androidgl.c
changeset 4701 d40bb3165d2b
child 4703 c93b44ddc63e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/android/SDL_androidgl.c	Thu Jun 10 18:54:23 2010 +1200
     1.3 @@ -0,0 +1,158 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997-2010 Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Lesser General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2.1 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Lesser General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Lesser General Public
    1.19 +    License along with this library; if not, write to the Free Software
    1.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +#include "SDL_config.h"
    1.26 +
    1.27 +/* Android SDL video driver implementation
    1.28 +*/
    1.29 +
    1.30 +#include "SDL_video.h"
    1.31 +#include "SDL_mouse.h"
    1.32 +#include "../SDL_sysvideo.h"
    1.33 +#include "../SDL_pixels_c.h"
    1.34 +#include "../../events/SDL_events_c.h"
    1.35 +
    1.36 +#include "SDL_androidvideo.h"
    1.37 +#include "SDL_androidevents_c.h"
    1.38 +#include "SDL_androidrender_c.h"
    1.39 +
    1.40 +/* Android header */
    1.41 +#include "egl.h"
    1.42 +
    1.43 +
    1.44 +//EGL globals
    1.45 +static EGLDisplay iEglDisplay; 	
    1.46 +static EGLConfig  iEglConfig;   	
    1.47 +static EGLContext iEglContext; 	
    1.48 +static EGLSurface iEglSurface;	
    1.49 +
    1.50 +EGLint attribList [] = 
    1.51 +{ 
    1.52 +	EGL_BUFFER_SIZE, 16, //16 bit color
    1.53 +	EGL_DEPTH_SIZE, 15,
    1.54 +	EGL_NONE 
    1.55 +};	
    1.56 +
    1.57 +
    1.58 +
    1.59 +
    1.60 +/* GL functions */
    1.61 +int Android_GL_LoadLibrary(_THIS, const char *path){
    1.62 +	printf("[STUB] GL_LoadLibrary\n");
    1.63 +	return 0;
    1.64 +}
    1.65 +
    1.66 +void *Android_GL_GetProcAddress(_THIS, const char *proc){
    1.67 +	printf("[STUB] GL_GetProcAddress\n");
    1.68 +	return 0;
    1.69 +}
    1.70 +
    1.71 +void Android_GL_UnloadLibrary(_THIS){
    1.72 +	printf("[STUB] GL_UnloadLibrary\n");
    1.73 +}
    1.74 +
    1.75 +/*
    1.76 +int *Android_GL_GetVisual(_THIS, Display * display, int screen){
    1.77 +	printf("[STUB] GL_GetVisual\n");
    1.78 +	return 0;
    1.79 +}
    1.80 +*/
    1.81 +
    1.82 +SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window){
    1.83 +	printf("[STUB] GL_CreateContext\n");
    1.84 +
    1.85 +	//Start up the display
    1.86 +	iEglDisplay = eglGetDisplay (EGL_DEFAULT_DISPLAY);
    1.87 +	if(iEglDisplay == EGL_NO_DISPLAY){
    1.88 +		printf("Unable to find a  suitable EGLDisplay\n");
    1.89 +		return NULL;
    1.90 +	}
    1.91 +
    1.92 +	printf("1\n");
    1.93 +		
    1.94 +	if(!eglInitialize(iEglDisplay, 0, 0)){
    1.95 +		printf("Couldn't init display\n");
    1.96 +		return NULL;
    1.97 +	}
    1.98 +
    1.99 +	printf("2\n");
   1.100 +	
   1.101 +	EGLint numConfigs;
   1.102 +	
   1.103 +	if(!eglChooseConfig(iEglDisplay, attribList, &iEglConfig, 1, &numConfigs)){
   1.104 +		printf("Couldn't choose config\n");
   1.105 +		return NULL;
   1.106 +	}
   1.107 +
   1.108 +	printf("3\n");
   1.109 +	 
   1.110 +	iEglContext = eglCreateContext(iEglDisplay, iEglConfig, EGL_NO_CONTEXT, 0);
   1.111 +		
   1.112 +	if(iEglContext == 0){
   1.113 +		printf("Couldn't create context\n");
   1.114 +		return NULL;
   1.115 +	}
   1.116 +
   1.117 +	printf("4\n");
   1.118 +		
   1.119 +	NativeWindowType iWindow = 1; //android_createDisplaySurface();
   1.120 +	
   1.121 +	iEglSurface = eglCreateWindowSurface(iEglDisplay, iEglConfig, iWindow, 0);	
   1.122 +
   1.123 +	printf("5\n");
   1.124 +	
   1.125 +	if(iEglSurface == NULL){
   1.126 +		printf("Couldn't create surface\n");
   1.127 +		return NULL;
   1.128 +	}
   1.129 +
   1.130 +	printf("6\n");
   1.131 +	
   1.132 +	eglMakeCurrent(iEglDisplay, iEglSurface, iEglSurface, iEglContext);
   1.133 +
   1.134 +	printf("fininshed making context\n");
   1.135 +	
   1.136 +	return iEglSurface;
   1.137 +}
   1.138 +
   1.139 +int Android_GL_MakeCurrent(_THIS, SDL_Window * window,
   1.140 +                              SDL_GLContext context){
   1.141 +	printf("[STUB] GL_MakeCurrent\n");
   1.142 +	return 0;
   1.143 +}
   1.144 +
   1.145 +int Android_GL_SetSwapInterval(_THIS, int interval){
   1.146 +	printf("[STUB] GL_SetSwapInterval\n");
   1.147 +	return 0;
   1.148 +}
   1.149 +
   1.150 +int Android_GL_GetSwapInterval(_THIS){
   1.151 +	printf("[STUB] GL_GetSwapInterval\n");
   1.152 +	return 0;
   1.153 +}
   1.154 +
   1.155 +void Android_GL_SwapWindow(_THIS, SDL_Window * window){
   1.156 +	printf("[STUB] GL_SwapWindow\n");
   1.157 +}
   1.158 +
   1.159 +void Android_GL_DeleteContext(_THIS, SDL_GLContext context){
   1.160 +	printf("[STUB] GL_DeleteContext\n");
   1.161 +}