test/testgl2.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 9998 f67cf37e9cd4
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     1
/*
9998
f67cf37e9cd4 Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents: 9966
diff changeset
     2
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     3
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     4
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     6
  arising from the use of this software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     7
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
    10
  freely.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
    11
*/
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
#include <stdlib.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
#include <stdio.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
#include <string.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
#include <math.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6382
diff changeset
    17
#include "SDL_test_common.h"
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
#ifdef __MACOS__
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
#define HAVE_OPENGL
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#endif
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#ifdef HAVE_OPENGL
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "SDL_opengl.h"
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    27
typedef struct GL_Context
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    28
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    29
#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    30
#include "../src/render/opengl/SDL_glfuncs.h"
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    31
#undef SDL_PROC
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    32
} GL_Context;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    33
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    34
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
/* Undefine this if you want a flat cube instead of a rainbow cube */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
#define SHADED_CUBE
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6382
diff changeset
    38
static SDLTest_CommonState *state;
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    39
static SDL_GLContext context;
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    40
static GL_Context ctx;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    41
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    42
static int LoadContext(GL_Context * data)
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    43
{
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    44
#if SDL_VIDEO_DRIVER_UIKIT
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    45
#define __SDL_NOGETPROCADDR__
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    46
#elif SDL_VIDEO_DRIVER_ANDROID
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    47
#define __SDL_NOGETPROCADDR__
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    48
#elif SDL_VIDEO_DRIVER_PANDORA
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    49
#define __SDL_NOGETPROCADDR__
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    50
#endif
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    51
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    52
#if defined __SDL_NOGETPROCADDR__
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    53
#define SDL_PROC(ret,func,params) data->func=func;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    54
#else
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    55
#define SDL_PROC(ret,func,params) \
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    56
    do { \
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    57
        data->func = SDL_GL_GetProcAddress(#func); \
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    58
        if ( ! data->func ) { \
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    59
            return SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    60
        } \
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    61
    } while ( 0 );
9966
cae9c97fabbd Fixed a comment in two test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9922
diff changeset
    62
#endif /* __SDL_NOGETPROCADDR__ */
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    63
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    64
#include "../src/render/opengl/SDL_glfuncs.h"
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    65
#undef SDL_PROC
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    66
    return 0;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    67
}
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
    68
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    70
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    71
static void
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    72
quit(int rc)
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
{
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    74
    if (context) {
2328
91e601d9df8b re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
Bob Pendleton <bob@pendleton.com>
parents: 2232
diff changeset
    75
        /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    76
        SDL_GL_DeleteContext(context);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
    }
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6382
diff changeset
    78
    SDLTest_CommonQuit(state);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    79
    exit(rc);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    82
static void
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    83
Render()
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
{
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    85
    static float color[8][3] = {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    86
        {1.0, 1.0, 0.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    87
        {1.0, 0.0, 0.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    88
        {0.0, 0.0, 0.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    89
        {0.0, 1.0, 0.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    90
        {0.0, 1.0, 1.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    91
        {1.0, 1.0, 1.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    92
        {1.0, 0.0, 1.0},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    93
        {0.0, 0.0, 1.0}
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    94
    };
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    95
    static float cube[8][3] = {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    96
        {0.5, 0.5, -0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    97
        {0.5, -0.5, -0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    98
        {-0.5, -0.5, -0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
    99
        {-0.5, 0.5, -0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   100
        {-0.5, 0.5, 0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   101
        {0.5, 0.5, 0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   102
        {0.5, -0.5, 0.5},
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   103
        {-0.5, -0.5, 0.5}
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   104
    };
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   105
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   106
    /* Do our drawing, too. */
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   107
    ctx.glClearColor(0.0, 0.0, 0.0, 1.0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   108
    ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   109
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   110
    ctx.glBegin(GL_QUADS);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   111
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   112
#ifdef SHADED_CUBE
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   113
    ctx.glColor3fv(color[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   114
    ctx.glVertex3fv(cube[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   115
    ctx.glColor3fv(color[1]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   116
    ctx.glVertex3fv(cube[1]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   117
    ctx.glColor3fv(color[2]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   118
    ctx.glVertex3fv(cube[2]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   119
    ctx.glColor3fv(color[3]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   120
    ctx.glVertex3fv(cube[3]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   121
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   122
    ctx.glColor3fv(color[3]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   123
    ctx.glVertex3fv(cube[3]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   124
    ctx.glColor3fv(color[4]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   125
    ctx.glVertex3fv(cube[4]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   126
    ctx.glColor3fv(color[7]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   127
    ctx.glVertex3fv(cube[7]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   128
    ctx.glColor3fv(color[2]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   129
    ctx.glVertex3fv(cube[2]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   130
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   131
    ctx.glColor3fv(color[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   132
    ctx.glVertex3fv(cube[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   133
    ctx.glColor3fv(color[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   134
    ctx.glVertex3fv(cube[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   135
    ctx.glColor3fv(color[6]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   136
    ctx.glVertex3fv(cube[6]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   137
    ctx.glColor3fv(color[1]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   138
    ctx.glVertex3fv(cube[1]);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   140
    ctx.glColor3fv(color[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   141
    ctx.glVertex3fv(cube[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   142
    ctx.glColor3fv(color[4]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   143
    ctx.glVertex3fv(cube[4]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   144
    ctx.glColor3fv(color[7]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   145
    ctx.glVertex3fv(cube[7]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   146
    ctx.glColor3fv(color[6]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   147
    ctx.glVertex3fv(cube[6]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   148
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   149
    ctx.glColor3fv(color[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   150
    ctx.glVertex3fv(cube[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   151
    ctx.glColor3fv(color[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   152
    ctx.glVertex3fv(cube[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   153
    ctx.glColor3fv(color[3]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   154
    ctx.glVertex3fv(cube[3]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   155
    ctx.glColor3fv(color[4]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   156
    ctx.glVertex3fv(cube[4]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   157
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   158
    ctx.glColor3fv(color[6]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   159
    ctx.glVertex3fv(cube[6]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   160
    ctx.glColor3fv(color[1]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   161
    ctx.glVertex3fv(cube[1]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   162
    ctx.glColor3fv(color[2]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   163
    ctx.glVertex3fv(cube[2]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   164
    ctx.glColor3fv(color[7]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   165
    ctx.glVertex3fv(cube[7]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   166
#else /* flat cube */
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   167
    ctx.glColor3f(1.0, 0.0, 0.0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   168
    ctx.glVertex3fv(cube[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   169
    ctx.glVertex3fv(cube[1]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   170
    ctx.glVertex3fv(cube[2]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   171
    ctx.glVertex3fv(cube[3]);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   173
    ctx.glColor3f(0.0, 1.0, 0.0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   174
    ctx.glVertex3fv(cube[3]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   175
    ctx.glVertex3fv(cube[4]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   176
    ctx.glVertex3fv(cube[7]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   177
    ctx.glVertex3fv(cube[2]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   178
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   179
    ctx.glColor3f(0.0, 0.0, 1.0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   180
    ctx.glVertex3fv(cube[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   181
    ctx.glVertex3fv(cube[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   182
    ctx.glVertex3fv(cube[6]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   183
    ctx.glVertex3fv(cube[1]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   184
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   185
    ctx.glColor3f(0.0, 1.0, 1.0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   186
    ctx.glVertex3fv(cube[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   187
    ctx.glVertex3fv(cube[4]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   188
    ctx.glVertex3fv(cube[7]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   189
    ctx.glVertex3fv(cube[6]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   190
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   191
    ctx.glColor3f(1.0, 1.0, 0.0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   192
    ctx.glVertex3fv(cube[5]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   193
    ctx.glVertex3fv(cube[0]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   194
    ctx.glVertex3fv(cube[3]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   195
    ctx.glVertex3fv(cube[4]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   196
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   197
    ctx.glColor3f(1.0, 0.0, 1.0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   198
    ctx.glVertex3fv(cube[6]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   199
    ctx.glVertex3fv(cube[1]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   200
    ctx.glVertex3fv(cube[2]);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   201
    ctx.glVertex3fv(cube[7]);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   202
#endif /* SHADED_CUBE */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   203
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   204
    ctx.glEnd();
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   205
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   206
    ctx.glMatrixMode(GL_MODELVIEW);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   207
    ctx.glRotatef(5.0, 1.0, 1.0, 1.0);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
int
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   211
main(int argc, char *argv[])
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
{
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   213
    int fsaa, accel;
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   214
    int value;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   215
    int i, done;
1967
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   216
    SDL_DisplayMode mode;
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   217
    SDL_Event event;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   218
    Uint32 then, now, frames;
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   219
    int status;
7746
6a05d7352575 add in High DPI support (aka Retina)
Edward Rudd <urkle@outoforder.cc>
parents: 7639
diff changeset
   220
    int dw, dh;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   222
    /* Enable standard application logging */
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   223
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   224
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   225
    /* Initialize parameters */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   226
    fsaa = 0;
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   227
    accel = -1;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   229
    /* Initialize test framework */
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6382
diff changeset
   230
    state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   231
    if (!state) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   232
        return 1;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
    }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   234
    for (i = 1; i < argc;) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   235
        int consumed;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6382
diff changeset
   237
        consumed = SDLTest_CommonArg(state, i);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   238
        if (consumed == 0) {
7381
aa0d6c66e3fa change fsaa argument for testgl to accept a # of samples for FSAA
Edward Rudd <urkle@outoforder.cc>
parents: 7194
diff changeset
   239
            if (SDL_strcasecmp(argv[i], "--fsaa") == 0 && i+1 < argc) {
aa0d6c66e3fa change fsaa argument for testgl to accept a # of samples for FSAA
Edward Rudd <urkle@outoforder.cc>
parents: 7194
diff changeset
   240
                fsaa = atoi(argv[i+1]);
aa0d6c66e3fa change fsaa argument for testgl to accept a # of samples for FSAA
Edward Rudd <urkle@outoforder.cc>
parents: 7194
diff changeset
   241
                consumed = 2;
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   242
            } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) {
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   243
                accel = atoi(argv[i+1]);
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   244
                consumed = 2;
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   245
            } else {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   246
                consumed = -1;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   247
            }
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   248
        }
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   249
        if (consumed < 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   250
            SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6382
diff changeset
   251
                    SDLTest_CommonUsage(state));
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   252
            quit(1);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   253
        }
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   254
        i += consumed;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   257
    /* Set OpenGL parameters */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   258
    state->window_flags |= SDL_WINDOW_OPENGL;
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   259
    state->gl_red_size = 5;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   260
    state->gl_green_size = 5;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   261
    state->gl_blue_size = 5;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   262
    state->gl_depth_size = 16;
3418
fba883490f72 Fixed compile error
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
   263
    state->gl_double_buffer = 1;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
    if (fsaa) {
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   265
        state->gl_multisamplebuffers = 1;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   266
        state->gl_multisamplesamples = fsaa;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
    }
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   268
    if (accel >= 0) {
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   269
        state->gl_accelerated = accel;
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   270
    }
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   271
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6382
diff changeset
   272
    if (!SDLTest_CommonInit(state)) {
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   273
        quit(2);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
    }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   275
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   276
    /* Create OpenGL context */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   277
    context = SDL_GL_CreateContext(state->windows[0]);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   278
    if (!context) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   279
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   280
        quit(2);
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   281
    }
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   282
    
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   283
    /* Important: call this *after* creating the context */
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   284
    if (LoadContext(&ctx) < 0) {
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   285
        SDL_Log("Could not load GL functions\n");
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   286
        quit(2);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   287
        return 0;
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   288
    }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   289
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1936
diff changeset
   290
    if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) {
6382
64d54101773a Add support for (GLX|WGL)_EXT_swap_control_tear.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   291
        /* try late-swap-tearing first. If not supported, try normal vsync. */
64d54101773a Add support for (GLX|WGL)_EXT_swap_control_tear.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   292
        if (SDL_GL_SetSwapInterval(-1) == -1) {
64d54101773a Add support for (GLX|WGL)_EXT_swap_control_tear.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   293
            SDL_GL_SetSwapInterval(1);
64d54101773a Add support for (GLX|WGL)_EXT_swap_control_tear.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   294
        }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
    } else {
6382
64d54101773a Add support for (GLX|WGL)_EXT_swap_control_tear.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   296
        SDL_GL_SetSwapInterval(0);  /* disable vsync. */
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
5244
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 3571
diff changeset
   299
    SDL_GetCurrentDisplayMode(0, &mode);
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   300
    SDL_Log("Screen BPP    : %d\n", SDL_BITSPERPIXEL(mode.format));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   301
    SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
7746
6a05d7352575 add in High DPI support (aka Retina)
Edward Rudd <urkle@outoforder.cc>
parents: 7639
diff changeset
   302
    SDL_GetWindowSize(state->windows[0], &dw, &dh);
6a05d7352575 add in High DPI support (aka Retina)
Edward Rudd <urkle@outoforder.cc>
parents: 7639
diff changeset
   303
    SDL_Log("Window Size   : %d,%d\n", dw, dh);
6a05d7352575 add in High DPI support (aka Retina)
Edward Rudd <urkle@outoforder.cc>
parents: 7639
diff changeset
   304
    SDL_GL_GetDrawableSize(state->windows[0], &dw, &dh);
6a05d7352575 add in High DPI support (aka Retina)
Edward Rudd <urkle@outoforder.cc>
parents: 7639
diff changeset
   305
    SDL_Log("Draw Size     : %d,%d\n", dw, dh);
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   306
    SDL_Log("\n");
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   307
    SDL_Log("Vendor        : %s\n", ctx.glGetString(GL_VENDOR));
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   308
    SDL_Log("Renderer      : %s\n", ctx.glGetString(GL_RENDERER));
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   309
    SDL_Log("Version       : %s\n", ctx.glGetString(GL_VERSION));
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   310
    SDL_Log("Extensions    : %s\n", ctx.glGetString(GL_EXTENSIONS));
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   311
    SDL_Log("\n");
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   313
    status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   314
    if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   315
        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   316
    } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   317
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   318
    }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   319
    status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   320
    if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   321
        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   322
    } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   323
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   324
    }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   325
    status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   326
    if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   327
        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   328
    } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   329
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   330
    }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   331
    status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   332
    if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   333
        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   334
    } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   335
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   336
    }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
    if (fsaa) {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   338
        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   339
        if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   340
            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   341
        } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   342
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   343
                   SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   344
        }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   345
        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   346
        if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   347
            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   348
                   value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   349
        } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   350
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3099
diff changeset
   351
                   SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2328
diff changeset
   352
        }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
    }
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   354
    if (accel >= 0) {
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   355
        status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   356
        if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   357
            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   358
                   value);
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   359
        } else {
9922
b066d5fd5fa7 Replaced tabs with spaces in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9619
diff changeset
   360
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   361
                   SDL_GetError());
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3570
diff changeset
   362
        }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   365
    /* Set rendering settings */
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   366
    ctx.glMatrixMode(GL_PROJECTION);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   367
    ctx.glLoadIdentity();
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   368
    ctx.glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   369
    ctx.glMatrixMode(GL_MODELVIEW);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   370
    ctx.glLoadIdentity();
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   371
    ctx.glEnable(GL_DEPTH_TEST);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   372
    ctx.glDepthFunc(GL_LESS);
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   373
    ctx.glShadeModel(GL_SMOOTH);
7746
6a05d7352575 add in High DPI support (aka Retina)
Edward Rudd <urkle@outoforder.cc>
parents: 7639
diff changeset
   374
    
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   375
    /* Main render loop */
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
    frames = 0;
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   377
    then = SDL_GetTicks();
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   378
    done = 0;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
    while (!done) {
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   380
        /* Check for events */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   381
        ++frames;
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   382
        while (SDL_PollEvent(&event)) {
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6382
diff changeset
   383
            SDLTest_CommonEvent(state, &event, &done);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   384
        }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   385
        for (i = 0; i < state->num_windows; ++i) {
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   386
            int w, h;
7787
e6f3e8fc96ea Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed
Sam Lantinga <slouken@libsdl.org>
parents: 7746
diff changeset
   387
            if (state->windows[i] == NULL)
e6f3e8fc96ea Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed
Sam Lantinga <slouken@libsdl.org>
parents: 7746
diff changeset
   388
                continue;
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   389
            SDL_GL_MakeCurrent(state->windows[i], context);
7746
6a05d7352575 add in High DPI support (aka Retina)
Edward Rudd <urkle@outoforder.cc>
parents: 7639
diff changeset
   390
            SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
8062
4fc5f66d63cc Wayland support
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7787
diff changeset
   391
            ctx.glViewport(0, 0, w, h);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   392
            Render();
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   393
            SDL_GL_SwapWindow(state->windows[i]);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   396
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   397
    /* Print out some timing information */
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   398
    now = SDL_GetTicks();
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   399
    if (now > then) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   400
        SDL_Log("%2.2f frames per second\n",
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   401
               ((double) frames * 1000) / (now - then));
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   402
    }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   403
    quit(0);
2232
Sam Lantinga <slouken@libsdl.org>
parents: 2228
diff changeset
   404
    return 0;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   405
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   406
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
#else /* HAVE_OPENGL */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
int
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
main(int argc, char *argv[])
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
{
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   412
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   413
    return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   414
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   416
#endif /* HAVE_OPENGL */