src/video/android/SDL_androidgl.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 02 Aug 2017 10:22:48 -0700
changeset 11175 cbc6a8a5b701
parent 10737 3406a0f8b041
child 11811 5d94cb6b24d3
permissions -rw-r--r--
Fixed bug 3690 - SDL2 KMS/DRM render context support

Manuel

The attached patch adds support for KMS/DRM context graphics.

It builds with no problem on X86_64 GNU/Linux systems, provided the needed libraries are present, and on ARM GNU/Linux systems that have KMS/DRM support and a GLES2 implementation.
Tested on Raspberry Pi: KMS/DRM is what the Raspberry Pi will use as default in the near future, once the propietary DispmanX API by Broadcom is overtaken by open graphics stack, it's possible to boot current Raspbian system in KMS mode by adding "dtoverlay=vc4-kms-v3d" to config.txt on Raspbian's boot partition.
X86 systems use KMS right away in every current GNU/Linux system.

Simple build instructions:

$./autogen.sh
$./configure --enable-video-kmsdrm
$make
paul@4701
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@10737
     3
  Copyright (C) 1997-2017 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
*/
icculus@8093
    21
#include "../../SDL_internal.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"
gabomdq@8021
    28
#include "../SDL_egl_c.h"
gabomdq@7659
    29
#include "SDL_androidwindow.h"
paul@4701
    30
paul@4701
    31
#include "SDL_androidvideo.h"
slouken@10672
    32
#include "SDL_androidgl.h"
slouken@5090
    33
#include "../../core/android/SDL_android.h"
paul@4701
    34
paul@4707
    35
#include <android/log.h>
paul@4701
    36
icculus@5992
    37
#include <dlfcn.h>
icculus@5992
    38
gabomdq@7659
    39
SDL_EGL_CreateContext_impl(Android)
gabomdq@7659
    40
SDL_EGL_MakeCurrent_impl(Android)
paul@4701
    41
slouken@10695
    42
int
gabomdq@7659
    43
Android_GLES_SwapWindow(_THIS, SDL_Window * window)
slouken@4989
    44
{
gabomdq@8700
    45
    /* The following two calls existed in the original Java code
gabomdq@8700
    46
     * If you happen to have a device that's affected by their removal,
gabomdq@8700
    47
     * please report to Bugzilla. -- Gabriel
gabomdq@8700
    48
     */
gabomdq@8700
    49
    
gabomdq@8700
    50
    /*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
gabomdq@8700
    51
    _this->egl_data->eglWaitGL();*/
slouken@10695
    52
    return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
paul@4701
    53
}
paul@4701
    54
slouken@4989
    55
int
gabomdq@7659
    56
Android_GLES_LoadLibrary(_THIS, const char *path) {
slouken@11175
    57
    return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) 0, 0);
paul@4701
    58
}
slouken@5222
    59
slouken@6044
    60
#endif /* SDL_VIDEO_DRIVER_ANDROID */
slouken@6044
    61
slouken@5222
    62
/* vi: set ts=4 sw=4 expandtab: */