Mercurial > sdl-ios-xcode
annotate test/testdyngl.c @ 2982:b64c1d23039b
Make the current revision number available
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Jan 2009 05:08:12 +0000 |
parents | 204be4fc2726 |
children | 8d0889509afb |
rev | line source |
---|---|
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 * Small SDL example to demonstrate dynamically loading |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 * OpenGL lib and functions |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 * |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 * (FYI it was supposed to look like snow in the wind or something...) |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 * |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 * Compile with : |
847
0afe0e38e02c
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
842
diff
changeset
|
8 * gcc testdyngl.c `sdl-config --libs --cflags` -o testdyngl -DHAVE_OPENGL |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 * |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 * You can specify a different OpenGL lib on the command line, i.e. : |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 * ./testdyngl /usr/X11R6/lib/libGL.so.1.2 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 * or |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 * ./testdyngl /usr/lib/libGL.so.1.0.4496 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 * |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 */ |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 #include <stdio.h> |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 #include <stdlib.h> |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 #include "SDL.h" |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
1815
871090feb7ad
Fixed building with CodeWarrior on MacOS Classic
Sam Lantinga <slouken@libsdl.org>
parents:
1440
diff
changeset
|
22 #ifdef __MACOS__ |
871090feb7ad
Fixed building with CodeWarrior on MacOS Classic
Sam Lantinga <slouken@libsdl.org>
parents:
1440
diff
changeset
|
23 #define HAVE_OPENGL |
871090feb7ad
Fixed building with CodeWarrior on MacOS Classic
Sam Lantinga <slouken@libsdl.org>
parents:
1440
diff
changeset
|
24 #endif |
871090feb7ad
Fixed building with CodeWarrior on MacOS Classic
Sam Lantinga <slouken@libsdl.org>
parents:
1440
diff
changeset
|
25 |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #ifdef HAVE_OPENGL |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "SDL_opengl.h" |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
990
diff
changeset
|
30 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
31 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
32 quit(int rc) |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
990
diff
changeset
|
33 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
34 SDL_Quit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
35 exit(rc); |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
990
diff
changeset
|
36 } |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
990
diff
changeset
|
37 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
38 void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
39 get_funcaddr(const char *p) |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
41 void *f = SDL_GL_GetProcAddress(p); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
42 if (f) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
43 return f; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
44 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
45 printf("Unable to get function pointer for %s\n", p); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
46 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
47 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
48 return NULL; |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 } |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 typedef struct |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
53 void (APIENTRY * glBegin) (GLenum); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
54 void (APIENTRY * glEnd) (); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
55 void (APIENTRY * glVertex3f) (GLfloat, GLfloat, GLfloat); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
56 void (APIENTRY * glClearColor) (GLfloat, GLfloat, GLfloat, GLfloat); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
57 void (APIENTRY * glClear) (GLbitfield); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
58 void (APIENTRY * glDisable) (GLenum); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
59 void (APIENTRY * glEnable) (GLenum); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
60 void (APIENTRY * glColor4ub) (GLubyte, GLubyte, GLubyte, GLubyte); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
61 void (APIENTRY * glPointSize) (GLfloat); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
62 void (APIENTRY * glHint) (GLenum, GLenum); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
63 void (APIENTRY * glBlendFunc) (GLenum, GLenum); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
64 void (APIENTRY * glMatrixMode) (GLenum); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
65 void (APIENTRY * glLoadIdentity) (); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
66 void (APIENTRY * glOrtho) (GLdouble, GLdouble, GLdouble, GLdouble, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
67 GLdouble, GLdouble); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
68 void (APIENTRY * glRotatef) (GLfloat, GLfloat, GLfloat, GLfloat); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
69 void (APIENTRY * glViewport) (GLint, GLint, GLsizei, GLsizei); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
70 void (APIENTRY * glFogf) (GLenum, GLfloat); |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 } |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 glfuncs; |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
74 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
75 init_glfuncs(glfuncs * f) |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
77 f->glBegin = get_funcaddr("glBegin"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
78 f->glEnd = get_funcaddr("glEnd"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
79 f->glVertex3f = get_funcaddr("glVertex3f"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
80 f->glClearColor = get_funcaddr("glClearColor"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
81 f->glClear = get_funcaddr("glClear"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
82 f->glDisable = get_funcaddr("glDisable"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
83 f->glEnable = get_funcaddr("glEnable"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
84 f->glColor4ub = get_funcaddr("glColor4ub"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
85 f->glPointSize = get_funcaddr("glPointSize"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
86 f->glHint = get_funcaddr("glHint"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
87 f->glBlendFunc = get_funcaddr("glBlendFunc"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
88 f->glMatrixMode = get_funcaddr("glMatrixMode"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
89 f->glLoadIdentity = get_funcaddr("glLoadIdentity"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
90 f->glOrtho = get_funcaddr("glOrtho"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
91 f->glRotatef = get_funcaddr("glRotatef"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
92 f->glViewport = get_funcaddr("glViewport"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
93 f->glFogf = get_funcaddr("glFogf"); |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 } |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 #define NB_PIXELS 1000 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
98 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
99 main(int argc, char *argv[]) |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
101 glfuncs f; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
102 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
103 SDL_Event event; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
104 int done = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
105 GLfloat pixels[NB_PIXELS * 3]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
106 const char *gl_library = NULL; /* Use the default GL library */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1386
diff
changeset
|
107 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
108 if (argv[1]) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
109 gl_library = argv[1]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
110 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
111 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
112 if (SDL_Init(SDL_INIT_VIDEO) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
113 printf("Unable to init SDL : %s\n", SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
114 return (1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
115 } |
990
8e20c48a9c13
Restore everything when a function pointer is NULL
Patrice Mandin <patmandin@gmail.com>
parents:
910
diff
changeset
|
116 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
117 if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
118 printf("Unable to set GL attribute : %s\n", SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
119 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
120 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
121 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
122 if (SDL_GL_LoadLibrary(gl_library) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
123 printf("Unable to dynamically open GL lib : %s\n", SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
124 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
125 } |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
127 if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
128 printf("Unable to open video mode : %s\n", SDL_GetError()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
129 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
130 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
131 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
132 /* Set the window manager title bar */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
133 SDL_WM_SetCaption("SDL Dynamic OpenGL Loading Test", "testdyngl"); |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
135 init_glfuncs(&f); |
910
4ab6d1fd028f
Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
885
diff
changeset
|
136 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
137 for (i = 0; i < NB_PIXELS; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
138 pixels[3 * i] = rand() % 250 - 125; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
139 pixels[3 * i + 1] = rand() % 250 - 125; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
140 pixels[3 * i + 2] = rand() % 250 - 125; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
141 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
142 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
143 f.glViewport(0, 0, 640, 480); |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
145 f.glMatrixMode(GL_PROJECTION); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
146 f.glLoadIdentity(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
147 f.glOrtho(-100, 100, -100, 100, -500, 500); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
148 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
149 f.glMatrixMode(GL_MODELVIEW); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
150 f.glLoadIdentity(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
151 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
152 f.glEnable(GL_DEPTH_TEST); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
153 f.glDisable(GL_TEXTURE_2D); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
154 f.glEnable(GL_BLEND); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
155 f.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
156 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
157 f.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
158 f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
159 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
160 f.glEnable(GL_POINT_SMOOTH); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
161 f.glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
162 f.glPointSize(5.0f); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
163 f.glEnable(GL_FOG); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
164 f.glFogf(GL_FOG_START, -500); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
165 f.glFogf(GL_FOG_END, 500); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
166 f.glFogf(GL_FOG_DENSITY, 0.005); |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
168 do { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
169 f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
170 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
171 f.glRotatef(2.0, 1.0, 1.0, 1.0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
172 f.glRotatef(1.0, 0.0, 1.0, 1.0); |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
174 f.glColor4ub(255, 255, 255, 255); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
175 f.glBegin(GL_POINTS); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
176 for (i = 0; i < NB_PIXELS; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
177 f.glVertex3f(pixels[3 * i], pixels[3 * i + 1], pixels[3 * i + 2]); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
178 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
179 f.glEnd(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
180 SDL_GL_SwapBuffers(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
181 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
182 while (SDL_PollEvent(&event)) { |
2327
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
1895
diff
changeset
|
183 if (event.type == SDL_KEYDOWN) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
184 done = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
185 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
186 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
187 SDL_Delay(20); |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2327
diff
changeset
|
188 } while (!done); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
189 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
190 SDL_Quit(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
191 return 0; |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 } |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 #else /* HAVE_OPENGL */ |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
196 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
197 main(int argc, char *argv[]) |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
199 printf("No OpenGL support on this system\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1815
diff
changeset
|
200 return 1; |
839
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 } |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
7b255f0290da
Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 #endif /* HAVE_OPENGL */ |