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