Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added (partially implemented) android video backend and associated fi…

…les needed to build
  • Loading branch information
bieh committed Jun 10, 2010
1 parent e9e78ea commit 395db5c4a23c269a0224537427118dcb23dd20cb
@@ -5,7 +5,7 @@ TOOLS_PATH=$(ANDROID_NDK)/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin
ANDROID_INCLUDES = -I$(ANDROID_NDK)/build/platforms/android-4/common/include \
-I$(ANDROID_NDK)/build/platforms/android-4/arch-arm/usr/include
INCLUDE = -I./include
CFLAGS = -g -O2 $(INCLUDE) $(ANDROID_INCLUDES) -DANDROID -static
CFLAGS = -g -O2 $(INCLUDE) $(ANDROID_INCLUDES) -DANDROID -DANDROID_NDK -static

AR = $(TOOLS_PATH)/arm-eabi-ar
RANLIB = $(TOOLS_PATH)/arm-eabi-ranlib
@@ -28,7 +28,7 @@ SOURCES = \
src/video/*.c \
src/power/*.c \
src/audio/dummy/*.c \
src/video/dummy/*.c \
src/video/android/*.c \
src/joystick/dummy/*.c \
src/haptic/dummy/*.c \
src/atomic/dummy/*.c \
@@ -7,9 +7,9 @@ export PATH=$TOOLS_PATH:$PATH
CC="arm-eabi-gcc"

#cflags
ACC_C=" -I$ANDROID_NDK/build/platforms/android-4/common/include \
-I$ANDROID_NDK/build/platforms/android-4/arch-arm/usr/include \
-DANDROID -c"
ACC_C=" -I$ANDROID_NDK/build/platforms/android-8/common/include \
-I$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/include \
-DANDROID -DANDROID_NDK -c"


$CC $CFLAGS $ACC_C $@
@@ -1,18 +1,20 @@
#!/bin/bash
ANDROID_NDK="/home/paul/Projects/gsoc/sdk/android-ndk-r4"
TOOLS_PATH="$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin"
ADDITIONAL_LIBS=`dirname "$0"`/android_libs/

export PATH=$TOOLS_PATH:$PATH

LD="arm-eabi-ld"

#ldflags
ACC_L=" -rpath-link=$ANDROID_NDK/build/platforms/android-4/arch-arm/usr/lib/ \
ACC_L=" -rpath-link=$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/ \
-dynamic-linker=/system/bin/linker \
-L$ANDROID_NDK/build/platforms/android-3/arch-arm/usr/lib/ -lc -nostdlib \
$ANDROID_NDK/build/platforms/android-4/arch-arm/usr/lib/crtbegin_static.o \
-L$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1 "
-lc -nostdlib \
$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/crtbegin_static.o \
-L$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/ \
-L$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1 \
-L$ADDITIONAL_LIBS "

$LD $ACC_L $LDFLAGS $@ -lgcc


Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -63,10 +63,14 @@ typedef unsigned int size_t;

#define SDL_TIMER_UNIX 1

#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_ANDROID 1

#define HAVE_STDIO_H 1
#define HAVE_SYS_TYPES_H 1

#define HAVE_M_PI 1

#define SDL_VIDEO_RENDER_OGL_ES 1

#endif /* _SDL_config_minimal_h */

@@ -643,18 +643,29 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)

/* If we're in OpenGL mode, just create a stub surface and we're done! */
if (flags & SDL_OPENGL) {

printf("1\n");

SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow);
if (!SDL_VideoContext) {
return NULL;
}


printf("2\n");

if (SDL_GL_MakeCurrent(SDL_VideoWindow, SDL_VideoContext) < 0) {
return NULL;
}

printf("3\n");
SDL_VideoSurface =
SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0);
if (!SDL_VideoSurface) {
return NULL;
}

printf("4\n");
SDL_VideoSurface->flags |= surface_flags;
SDL_PublicSurface = SDL_VideoSurface;
return SDL_PublicSurface;
@@ -414,6 +414,9 @@ extern VideoBootStrap NDS_bootstrap;
#if SDL_VIDEO_DRIVER_PANDORA
extern VideoBootStrap PND_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_ANDROID
extern VideoBootStrap Android_bootstrap;
#endif

#define SDL_CurrentDisplay (&_this->displays[_this->current_display])
#define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer)
@@ -99,6 +99,9 @@ static VideoBootStrap *bootstrap[] = {
#endif
#if SDL_VIDEO_DRIVER_PANDORA
&PND_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_ANDROID
&Android_bootstrap,
#endif
NULL
};
@@ -0,0 +1,52 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"

/* Being a null driver, there's no event stream. We just define stubs for
most of the API. */

#include <stdio.h>
#include <stdlib.h>

#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"

void
Android_PumpEvents(_THIS)
{

//scanKeys();
/* TODO: defer click-age */
/*
if (keysDown() & KEY_TOUCH) {
SDL_SendMouseButton(0, SDL_PRESSED, 0);
} else if (keysUp() & KEY_TOUCH) {
SDL_SendMouseButton(0, SDL_RELEASED, 0);
}
if (keysHeld() & KEY_TOUCH) {
touchPosition t = touchReadXY();
SDL_SendMouseMotion(0, 0, t.px, t.py, 1);
}
*/
}

/* vi: set ts=4 sw=4 expandtab: */
@@ -0,0 +1,28 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"

#include "SDL_androidvideo.h"

extern void Android_PumpEvents(_THIS);

/* vi: set ts=4 sw=4 expandtab: */
@@ -0,0 +1,158 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"

/* Android SDL video driver implementation
*/

#include "SDL_video.h"
#include "SDL_mouse.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"

#include "SDL_androidvideo.h"
#include "SDL_androidevents_c.h"
#include "SDL_androidrender_c.h"

/* Android header */
#include "egl.h"


//EGL globals
static EGLDisplay iEglDisplay;
static EGLConfig iEglConfig;
static EGLContext iEglContext;
static EGLSurface iEglSurface;

EGLint attribList [] =
{
EGL_BUFFER_SIZE, 16, //16 bit color
EGL_DEPTH_SIZE, 15,
EGL_NONE
};




/* GL functions */
int Android_GL_LoadLibrary(_THIS, const char *path){
printf("[STUB] GL_LoadLibrary\n");
return 0;
}

void *Android_GL_GetProcAddress(_THIS, const char *proc){
printf("[STUB] GL_GetProcAddress\n");
return 0;
}

void Android_GL_UnloadLibrary(_THIS){
printf("[STUB] GL_UnloadLibrary\n");
}

/*
int *Android_GL_GetVisual(_THIS, Display * display, int screen){
printf("[STUB] GL_GetVisual\n");
return 0;
}
*/

SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window){
printf("[STUB] GL_CreateContext\n");

//Start up the display
iEglDisplay = eglGetDisplay (EGL_DEFAULT_DISPLAY);
if(iEglDisplay == EGL_NO_DISPLAY){
printf("Unable to find a suitable EGLDisplay\n");
return NULL;
}

printf("1\n");

if(!eglInitialize(iEglDisplay, 0, 0)){
printf("Couldn't init display\n");
return NULL;
}

printf("2\n");

EGLint numConfigs;

if(!eglChooseConfig(iEglDisplay, attribList, &iEglConfig, 1, &numConfigs)){
printf("Couldn't choose config\n");
return NULL;
}

printf("3\n");

iEglContext = eglCreateContext(iEglDisplay, iEglConfig, EGL_NO_CONTEXT, 0);

if(iEglContext == 0){
printf("Couldn't create context\n");
return NULL;
}

printf("4\n");

NativeWindowType iWindow = 1; //android_createDisplaySurface();

iEglSurface = eglCreateWindowSurface(iEglDisplay, iEglConfig, iWindow, 0);

printf("5\n");

if(iEglSurface == NULL){
printf("Couldn't create surface\n");
return NULL;
}

printf("6\n");

eglMakeCurrent(iEglDisplay, iEglSurface, iEglSurface, iEglContext);

printf("fininshed making context\n");

return iEglSurface;
}

int Android_GL_MakeCurrent(_THIS, SDL_Window * window,
SDL_GLContext context){
printf("[STUB] GL_MakeCurrent\n");
return 0;
}

int Android_GL_SetSwapInterval(_THIS, int interval){
printf("[STUB] GL_SetSwapInterval\n");
return 0;
}

int Android_GL_GetSwapInterval(_THIS){
printf("[STUB] GL_GetSwapInterval\n");
return 0;
}

void Android_GL_SwapWindow(_THIS, SDL_Window * window){
printf("[STUB] GL_SwapWindow\n");
}

void Android_GL_DeleteContext(_THIS, SDL_GLContext context){
printf("[STUB] GL_DeleteContext\n");
}

0 comments on commit 395db5c

Please sign in to comment.