src/video/psp/SDL_pspvideo.c
author Sam Lantinga
Fri, 27 Jan 2017 21:23:27 -0800
changeset 10861 71d8f9afb690
parent 10737 3406a0f8b041
child 10945 1300a3135d61
permissions -rw-r--r--
Fixed bug 3569 - GL_UpdateViewport leaves PROJECTION matrix selected

Tom Seddon

GL_ActivateRenderer may call GL_UpdateViewport, which leaves the GL_PROJECTION matrix selected. But after GL_ResetState, the GL_MODELVIEW matrix is selected, suggesting that's the intended default state.

It seems at least like these should be consistent. Presumably GL_UpdateViewport should be doing a glMatrixMode(GL_MODELVIEW) before it finishes.
kimonline@7009
     1
/*
kimonline@7009
     2
  Simple DirectMedia Layer
slouken@10737
     3
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
kimonline@7009
     4
kimonline@7009
     5
  This software is provided 'as-is', without any express or implied
kimonline@7009
     6
  warranty.  In no event will the authors be held liable for any damages
kimonline@7009
     7
  arising from the use of this software.
kimonline@7009
     8
kimonline@7009
     9
  Permission is granted to anyone to use this software for any purpose,
kimonline@7009
    10
  including commercial applications, and to alter it and redistribute it
kimonline@7009
    11
  freely, subject to the following restrictions:
kimonline@7009
    12
kimonline@7009
    13
  1. The origin of this software must not be misrepresented; you must not
kimonline@7009
    14
     claim that you wrote the original software. If you use this software
kimonline@7009
    15
     in a product, an acknowledgment in the product documentation would be
kimonline@7009
    16
     appreciated but is not required.
kimonline@7009
    17
  2. Altered source versions must be plainly marked as such, and must not be
kimonline@7009
    18
     misrepresented as being the original software.
kimonline@7009
    19
  3. This notice may not be removed or altered from any source distribution.
kimonline@7009
    20
*/
kimonline@7009
    21
icculus@8093
    22
#include "../../SDL_internal.h"
kimonline@7009
    23
kimonline@7009
    24
#if SDL_VIDEO_DRIVER_PSP
kimonline@7009
    25
kimonline@7009
    26
/* SDL internals */
kimonline@7009
    27
#include "../SDL_sysvideo.h"
kimonline@7009
    28
#include "SDL_version.h"
kimonline@7009
    29
#include "SDL_syswm.h"
kimonline@7009
    30
#include "SDL_loadso.h"
kimonline@7009
    31
#include "SDL_events.h"
kimonline@7009
    32
#include "../../events/SDL_mouse_c.h"
kimonline@7009
    33
#include "../../events/SDL_keyboard_c.h"
kimonline@7009
    34
kimonline@7009
    35
kimonline@7009
    36
kimonline@7009
    37
/* PSP declarations */
kimonline@7009
    38
#include "SDL_pspvideo.h"
kimonline@7009
    39
#include "SDL_pspevents_c.h"
kimonline@7009
    40
#include "SDL_pspgl_c.h"
kimonline@7009
    41
kimonline@7009
    42
/* unused
kimonline@7009
    43
static SDL_bool PSP_initialized = SDL_FALSE;
kimonline@7009
    44
*/
kimonline@7009
    45
static int
kimonline@7009
    46
PSP_Available(void)
kimonline@7009
    47
{
kimonline@7009
    48
    return 1;
kimonline@7009
    49
}
kimonline@7009
    50
kimonline@7009
    51
static void
kimonline@7009
    52
PSP_Destroy(SDL_VideoDevice * device)
kimonline@7009
    53
{
slouken@7191
    54
/*    SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
kimonline@7009
    55
kimonline@7009
    56
    if (device->driverdata != NULL) {
kimonline@7009
    57
        device->driverdata = NULL;
kimonline@7009
    58
    }
kimonline@7009
    59
}
kimonline@7009
    60
kimonline@7009
    61
static SDL_VideoDevice *
kimonline@7009
    62
PSP_Create()
kimonline@7009
    63
{
kimonline@7009
    64
    SDL_VideoDevice *device;
kimonline@7009
    65
    SDL_VideoData *phdata;
kimonline@7009
    66
    SDL_GLDriverData *gldata;
kimonline@7009
    67
    int status;
kimonline@7009
    68
philipp@9325
    69
    /* Check if PSP could be initialized */
kimonline@7009
    70
    status = PSP_Available();
kimonline@7009
    71
    if (status == 0) {
kimonline@7009
    72
        /* PSP could not be used */
kimonline@7009
    73
        return NULL;
kimonline@7009
    74
    }
kimonline@7009
    75
kimonline@7009
    76
    /* Initialize SDL_VideoDevice structure */
kimonline@7009
    77
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
kimonline@7009
    78
    if (device == NULL) {
kimonline@7009
    79
        SDL_OutOfMemory();
kimonline@7009
    80
        return NULL;
kimonline@7009
    81
    }
kimonline@7009
    82
philipp@9325
    83
    /* Initialize internal PSP specific data */
kimonline@7009
    84
    phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
kimonline@7009
    85
    if (phdata == NULL) {
kimonline@7009
    86
        SDL_OutOfMemory();
kimonline@7009
    87
        SDL_free(device);
kimonline@7009
    88
        return NULL;
kimonline@7009
    89
    }
slouken@7191
    90
slouken@7191
    91
        gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
kimonline@7009
    92
    if (gldata == NULL) {
kimonline@7009
    93
        SDL_OutOfMemory();
kimonline@7009
    94
        SDL_free(device);
philipp@10215
    95
        SDL_free(phdata);
kimonline@7009
    96
        return NULL;
slouken@7191
    97
    }
kimonline@7009
    98
    device->gl_data = gldata;
slouken@7191
    99
kimonline@7009
   100
    device->driverdata = phdata;
kimonline@7009
   101
kimonline@7009
   102
    phdata->egl_initialized = SDL_TRUE;
kimonline@7009
   103
kimonline@7009
   104
philipp@10202
   105
    /* Setup amount of available displays */
kimonline@7009
   106
    device->num_displays = 0;
kimonline@7009
   107
kimonline@7009
   108
    /* Set device free function */
kimonline@7009
   109
    device->free = PSP_Destroy;
kimonline@7009
   110
kimonline@7009
   111
    /* Setup all functions which we can handle */
kimonline@7009
   112
    device->VideoInit = PSP_VideoInit;
kimonline@7009
   113
    device->VideoQuit = PSP_VideoQuit;
kimonline@7009
   114
    device->GetDisplayModes = PSP_GetDisplayModes;
kimonline@7009
   115
    device->SetDisplayMode = PSP_SetDisplayMode;
kimonline@7009
   116
    device->CreateWindow = PSP_CreateWindow;
kimonline@7009
   117
    device->CreateWindowFrom = PSP_CreateWindowFrom;
kimonline@7009
   118
    device->SetWindowTitle = PSP_SetWindowTitle;
kimonline@7009
   119
    device->SetWindowIcon = PSP_SetWindowIcon;
kimonline@7009
   120
    device->SetWindowPosition = PSP_SetWindowPosition;
kimonline@7009
   121
    device->SetWindowSize = PSP_SetWindowSize;
kimonline@7009
   122
    device->ShowWindow = PSP_ShowWindow;
kimonline@7009
   123
    device->HideWindow = PSP_HideWindow;
kimonline@7009
   124
    device->RaiseWindow = PSP_RaiseWindow;
kimonline@7009
   125
    device->MaximizeWindow = PSP_MaximizeWindow;
kimonline@7009
   126
    device->MinimizeWindow = PSP_MinimizeWindow;
kimonline@7009
   127
    device->RestoreWindow = PSP_RestoreWindow;
kimonline@7009
   128
    device->SetWindowGrab = PSP_SetWindowGrab;
kimonline@7009
   129
    device->DestroyWindow = PSP_DestroyWindow;
kimonline@7009
   130
    device->GetWindowWMInfo = PSP_GetWindowWMInfo;
kimonline@7009
   131
    device->GL_LoadLibrary = PSP_GL_LoadLibrary;
kimonline@7009
   132
    device->GL_GetProcAddress = PSP_GL_GetProcAddress;
kimonline@7009
   133
    device->GL_UnloadLibrary = PSP_GL_UnloadLibrary;
kimonline@7009
   134
    device->GL_CreateContext = PSP_GL_CreateContext;
kimonline@7009
   135
    device->GL_MakeCurrent = PSP_GL_MakeCurrent;
kimonline@7009
   136
    device->GL_SetSwapInterval = PSP_GL_SetSwapInterval;
kimonline@7009
   137
    device->GL_GetSwapInterval = PSP_GL_GetSwapInterval;
kimonline@7009
   138
    device->GL_SwapWindow = PSP_GL_SwapWindow;
kimonline@7009
   139
    device->GL_DeleteContext = PSP_GL_DeleteContext;
slouken@7191
   140
    device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport;
slouken@7191
   141
    device->ShowScreenKeyboard = PSP_ShowScreenKeyboard;
slouken@7191
   142
    device->HideScreenKeyboard = PSP_HideScreenKeyboard;
slouken@7191
   143
    device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown;
slouken@7191
   144
kimonline@7009
   145
    device->PumpEvents = PSP_PumpEvents;
kimonline@7009
   146
kimonline@7009
   147
    return device;
kimonline@7009
   148
}
kimonline@7009
   149
kimonline@7009
   150
VideoBootStrap PSP_bootstrap = {
kimonline@7009
   151
    "PSP",
kimonline@7009
   152
    "PSP Video Driver",
kimonline@7009
   153
    PSP_Available,
kimonline@7009
   154
    PSP_Create
kimonline@7009
   155
};
kimonline@7009
   156
kimonline@7009
   157
/*****************************************************************************/
kimonline@7009
   158
/* SDL Video and Display initialization/handling functions                   */
kimonline@7009
   159
/*****************************************************************************/
kimonline@7009
   160
int
kimonline@7009
   161
PSP_VideoInit(_THIS)
kimonline@7009
   162
{
kimonline@7009
   163
    SDL_VideoDisplay display;
kimonline@7009
   164
    SDL_DisplayMode current_mode;
kimonline@7009
   165
kimonline@7009
   166
    SDL_zero(current_mode);
slouken@7191
   167
kimonline@7009
   168
    current_mode.w = 480;
kimonline@7009
   169
    current_mode.h = 272;
slouken@7191
   170
kimonline@7009
   171
    current_mode.refresh_rate = 60;
slouken@7191
   172
    /* 32 bpp for default */
kimonline@7009
   173
    current_mode.format = SDL_PIXELFORMAT_ABGR8888;
slouken@7191
   174
kimonline@7009
   175
    current_mode.driverdata = NULL;
kimonline@7009
   176
kimonline@7009
   177
    SDL_zero(display);
kimonline@7009
   178
    display.desktop_mode = current_mode;
kimonline@7009
   179
    display.current_mode = current_mode;
kimonline@7009
   180
    display.driverdata = NULL;
kimonline@7009
   181
kimonline@7009
   182
    SDL_AddVideoDisplay(&display);
kimonline@7009
   183
kimonline@7009
   184
    return 1;
kimonline@7009
   185
}
kimonline@7009
   186
kimonline@7009
   187
void
kimonline@7009
   188
PSP_VideoQuit(_THIS)
kimonline@7009
   189
{
kimonline@7009
   190
kimonline@7009
   191
}
kimonline@7009
   192
kimonline@7009
   193
void
kimonline@7009
   194
PSP_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
kimonline@7009
   195
{
kimonline@7009
   196
kimonline@7009
   197
}
kimonline@7009
   198
kimonline@7009
   199
int
kimonline@7009
   200
PSP_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
kimonline@7009
   201
{
kimonline@7009
   202
    return 0;
kimonline@7009
   203
}
slouken@7191
   204
#define EGLCHK(stmt)                            \
slouken@7191
   205
    do {                                        \
slouken@7191
   206
        EGLint err;                             \
slouken@7191
   207
                                                \
slouken@7191
   208
        stmt;                                   \
slouken@7191
   209
        err = eglGetError();                    \
slouken@7191
   210
        if (err != EGL_SUCCESS) {               \
slouken@7191
   211
            SDL_SetError("EGL error %d", err);  \
slouken@7191
   212
            return 0;                           \
slouken@7191
   213
        }                                       \
slouken@7191
   214
    } while (0)
slouken@7191
   215
kimonline@7009
   216
int
kimonline@7009
   217
PSP_CreateWindow(_THIS, SDL_Window * window)
kimonline@7009
   218
{
kimonline@7009
   219
    SDL_WindowData *wdata;
kimonline@7009
   220
kimonline@7009
   221
    /* Allocate window internal data */
kimonline@7009
   222
    wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
kimonline@7009
   223
    if (wdata == NULL) {
icculus@7037
   224
        return SDL_OutOfMemory();
kimonline@7009
   225
    }
kimonline@7009
   226
kimonline@7009
   227
    /* Setup driver data for this window */
kimonline@7009
   228
    window->driverdata = wdata;
kimonline@7009
   229
kimonline@7009
   230
kimonline@7009
   231
    /* Window has been successfully created */
kimonline@7009
   232
    return 0;
kimonline@7009
   233
}
kimonline@7009
   234
kimonline@7009
   235
int
kimonline@7009
   236
PSP_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
kimonline@7009
   237
{
philipp@10135
   238
    return SDL_Unsupported();
kimonline@7009
   239
}
kimonline@7009
   240
kimonline@7009
   241
void
kimonline@7009
   242
PSP_SetWindowTitle(_THIS, SDL_Window * window)
kimonline@7009
   243
{
kimonline@7009
   244
}
kimonline@7009
   245
void
kimonline@7009
   246
PSP_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
kimonline@7009
   247
{
kimonline@7009
   248
}
kimonline@7009
   249
void
kimonline@7009
   250
PSP_SetWindowPosition(_THIS, SDL_Window * window)
kimonline@7009
   251
{
kimonline@7009
   252
}
kimonline@7009
   253
void
kimonline@7009
   254
PSP_SetWindowSize(_THIS, SDL_Window * window)
kimonline@7009
   255
{
kimonline@7009
   256
}
kimonline@7009
   257
void
kimonline@7009
   258
PSP_ShowWindow(_THIS, SDL_Window * window)
kimonline@7009
   259
{
kimonline@7009
   260
}
kimonline@7009
   261
void
kimonline@7009
   262
PSP_HideWindow(_THIS, SDL_Window * window)
kimonline@7009
   263
{
kimonline@7009
   264
}
kimonline@7009
   265
void
kimonline@7009
   266
PSP_RaiseWindow(_THIS, SDL_Window * window)
kimonline@7009
   267
{
kimonline@7009
   268
}
kimonline@7009
   269
void
kimonline@7009
   270
PSP_MaximizeWindow(_THIS, SDL_Window * window)
kimonline@7009
   271
{
kimonline@7009
   272
}
kimonline@7009
   273
void
kimonline@7009
   274
PSP_MinimizeWindow(_THIS, SDL_Window * window)
kimonline@7009
   275
{
kimonline@7009
   276
}
kimonline@7009
   277
void
kimonline@7009
   278
PSP_RestoreWindow(_THIS, SDL_Window * window)
kimonline@7009
   279
{
kimonline@7009
   280
}
kimonline@7009
   281
void
kimonline@7009
   282
PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
kimonline@7009
   283
{
kimonline@7009
   284
kimonline@7009
   285
}
kimonline@7009
   286
void
kimonline@7009
   287
PSP_DestroyWindow(_THIS, SDL_Window * window)
kimonline@7009
   288
{
kimonline@7009
   289
}
kimonline@7009
   290
kimonline@7009
   291
/*****************************************************************************/
kimonline@7009
   292
/* SDL Window Manager function                                               */
kimonline@7009
   293
/*****************************************************************************/
kimonline@7009
   294
SDL_bool
kimonline@7009
   295
PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
kimonline@7009
   296
{
kimonline@7009
   297
    if (info->version.major <= SDL_MAJOR_VERSION) {
kimonline@7009
   298
        return SDL_TRUE;
kimonline@7009
   299
    } else {
kimonline@7009
   300
        SDL_SetError("application not compiled with SDL %d.%d\n",
kimonline@7009
   301
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
kimonline@7009
   302
        return SDL_FALSE;
kimonline@7009
   303
    }
kimonline@7009
   304
kimonline@7009
   305
    /* Failed to get window manager information */
kimonline@7009
   306
    return SDL_FALSE;
kimonline@7009
   307
}
kimonline@7009
   308
kimonline@7009
   309
gabomdq@7677
   310
/* TO Write Me */
philipp@7135
   311
SDL_bool PSP_HasScreenKeyboardSupport(_THIS)
kimonline@7009
   312
{
philipp@7147
   313
    return SDL_FALSE;
kimonline@7009
   314
}
philipp@7135
   315
void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
kimonline@7009
   316
{
kimonline@7009
   317
}
philipp@7135
   318
void PSP_HideScreenKeyboard(_THIS, SDL_Window *window)
kimonline@7009
   319
{
kimonline@7009
   320
}
philipp@7135
   321
SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window)
kimonline@7009
   322
{
slouken@7191
   323
    return SDL_FALSE;
kimonline@7009
   324
}
kimonline@7009
   325
kimonline@7009
   326
kimonline@7009
   327
#endif /* SDL_VIDEO_DRIVER_PSP */
kimonline@7009
   328
kimonline@7009
   329
/* vi: set ts=4 sw=4 expandtab: */