src/video/android/SDL_androidgl.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 04 Aug 2013 23:38:25 +0200
changeset 7575 930f21eaacd7
parent 7567 52da75545aaa
child 7659 ac4ce59c40e7
permissions -rw-r--r--
Added missing function prototype and changed its signature.
Signature was changed to prevent a header for SDL_GLContext.
paul@4701
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
paul@4701
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
paul@4701
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
paul@4701
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
paul@4701
    20
*/
paul@4701
    21
#include "SDL_config.h"
paul@4701
    22
slouken@6044
    23
#if SDL_VIDEO_DRIVER_ANDROID
slouken@6044
    24
slouken@4980
    25
/* Android SDL video driver implementation */
paul@4701
    26
paul@4701
    27
#include "SDL_video.h"
paul@4701
    28
paul@4701
    29
#include "SDL_androidvideo.h"
slouken@5090
    30
#include "../../core/android/SDL_android.h"
paul@4701
    31
paul@4707
    32
#include <android/log.h>
paul@4701
    33
icculus@5992
    34
#include <dlfcn.h>
icculus@5992
    35
icculus@5992
    36
static void* Android_GLHandle = NULL;
paul@4701
    37
paul@4701
    38
/* GL functions */
slouken@4989
    39
int
slouken@4989
    40
Android_GL_LoadLibrary(_THIS, const char *path)
slouken@4989
    41
{
icculus@5992
    42
    if (!Android_GLHandle) {
icculus@5992
    43
        Android_GLHandle = dlopen("libGLESv1_CM.so",RTLD_GLOBAL);
icculus@5992
    44
        if (!Android_GLHandle) {
icculus@7037
    45
            return SDL_SetError("Could not initialize GL ES library\n");
icculus@5992
    46
        }
icculus@5992
    47
    }
slouken@4989
    48
    return 0;
paul@4701
    49
}
paul@4701
    50
slouken@4989
    51
void *
slouken@4989
    52
Android_GL_GetProcAddress(_THIS, const char *proc)
slouken@4989
    53
{
icculus@5992
    54
    /*
icculus@5992
    55
       !!! FIXME: this _should_ use eglGetProcAddress(), but it appears to be
icculus@5992
    56
       !!! FIXME:  busted on Android at the moment...
icculus@5992
    57
       !!! FIXME:  http://code.google.com/p/android/issues/detail?id=7681
icculus@5992
    58
       !!! FIXME: ...so revisit this later.  --ryan.
icculus@5992
    59
    */
icculus@5992
    60
    return dlsym(Android_GLHandle, proc);
paul@4701
    61
}
paul@4701
    62
slouken@4989
    63
void
slouken@4989
    64
Android_GL_UnloadLibrary(_THIS)
slouken@4989
    65
{
icculus@5992
    66
    if(Android_GLHandle) {
icculus@5992
    67
        dlclose(Android_GLHandle);
icculus@5992
    68
        Android_GLHandle = NULL;
icculus@5992
    69
    }
paul@4701
    70
}
paul@4701
    71
slouken@4989
    72
SDL_GLContext
slouken@4989
    73
Android_GL_CreateContext(_THIS, SDL_Window * window)
slouken@4989
    74
{
slouken@5222
    75
    if (!Android_JNI_CreateContext(_this->gl_config.major_version,
slouken@6792
    76
                                   _this->gl_config.minor_version,
slouken@6792
    77
                                   _this->gl_config.red_size,
slouken@6792
    78
                                   _this->gl_config.green_size,
slouken@6792
    79
                                   _this->gl_config.blue_size,
slouken@6792
    80
                                   _this->gl_config.alpha_size,
slouken@6792
    81
                                   _this->gl_config.buffer_size,
slouken@6792
    82
                                   _this->gl_config.depth_size,
slouken@6792
    83
                                   _this->gl_config.stencil_size,
slouken@6792
    84
                                   _this->gl_config.multisamplebuffers,
slouken@6792
    85
                                   _this->gl_config.multisamplesamples)) {
slouken@5222
    86
        SDL_SetError("Couldn't create OpenGL context - see Android log for details");
slouken@5222
    87
        return NULL;
slouken@5222
    88
    }
slouken@5204
    89
    return (SDL_GLContext)1;
paul@4701
    90
}
paul@4701
    91
slouken@4989
    92
int
slouken@4989
    93
Android_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
slouken@4989
    94
{
slouken@4989
    95
    /* There's only one context, nothing to do... */
slouken@4989
    96
    return 0;
paul@4701
    97
}
paul@4701
    98
slouken@4989
    99
int
slouken@4989
   100
Android_GL_SetSwapInterval(_THIS, int interval)
slouken@4989
   101
{
slouken@4989
   102
    __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SetSwapInterval\n");
slouken@4989
   103
    return 0;
paul@4701
   104
}
paul@4701
   105
slouken@4989
   106
int
slouken@4989
   107
Android_GL_GetSwapInterval(_THIS)
slouken@4989
   108
{
slouken@4989
   109
    __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_GetSwapInterval\n");
slouken@4989
   110
    return 0;
paul@4701
   111
}
paul@4701
   112
slouken@4989
   113
void
slouken@4989
   114
Android_GL_SwapWindow(_THIS, SDL_Window * window)
slouken@4989
   115
{
slouken@4989
   116
    Android_JNI_SwapWindow();
paul@4701
   117
}
paul@4701
   118
slouken@4989
   119
void
slouken@4989
   120
Android_GL_DeleteContext(_THIS, SDL_GLContext context)
slouken@4989
   121
{
gabomdq@7567
   122
    if (context) {
philipp@7575
   123
        Android_JNI_DeleteContext();
gabomdq@7567
   124
    }
paul@4701
   125
}
slouken@5222
   126
slouken@6044
   127
#endif /* SDL_VIDEO_DRIVER_ANDROID */
slouken@6044
   128
slouken@5222
   129
/* vi: set ts=4 sw=4 expandtab: */