rev: 3827f53bae88e48a594610914ba74b9512ead6dd tukan/testing/test_glinit.sc -rw-r--r-- 1.4 KiB View raw Log this file
3827f53bae88 — Leonard Ritter * more work on module system 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#assert (operating-system == 'windows) "this test is windows only"

using import ..tukan.sdl
using import ..tukan.gl

SDL_Init
    | SDL_INIT_AUDIO
        SDL_INIT_VIDEO
        SDL_INIT_GAMECONTROLLER
        #SDL_INIT_JOYSTICK

SDL_GL_SetAttribute SDL_GL_DOUBLEBUFFER 1

SDL_GL_SetAttribute SDL_GL_STENCIL_SIZE 8
SDL_GL_SetAttribute SDL_GL_DEPTH_SIZE 24

SDL_GL_SetAttribute SDL_GL_CONTEXT_MAJOR_VERSION 4
SDL_GL_SetAttribute SDL_GL_CONTEXT_MINOR_VERSION 5
#if IS_OSX
    SDL_GL_SetAttribute
        SDL_GL_CONTEXT_PROFILE_MASK
        SDL_GL_CONTEXT_PROFILE_CORE

let window =
    SDL_CreateWindow "OpenGL Test"
        SDL_WINDOWPOS_UNDEFINED
        SDL_WINDOWPOS_UNDEFINED
        640
        480
        | SDL_WINDOW_OPENGL
            SDL_WINDOW_SHOWN
            SDL_WINDOW_RESIZABLE

let context = (SDL_GL_CreateContext window)
SDL_GL_SetSwapInterval 1
SDL_GL_MakeCurrent window context

#do
    let LoadLibrary = (extern 'LoadLibraryA (function voidstar rawstring))
    let GetProcAddress = (extern 'GetProcAddress (function voidstar voidstar rawstring))

    let libGL = (LoadLibrary "opengl32.dll")
    assert (libGL != null)
    print "GL lib handle:" libGL
    let func =
        GetProcAddress libGL "wglGetProcAddress"
    print "wglGetProcAddress handle:" func

let result = (gladLoadGL)
assert (result != 0) "failed to load GL core functions"

print result