test/testdyngl.c
author Sam Lantinga <slouken@libsdl.org>
Tue, 17 Feb 2004 18:16:49 +0000
changeset 839 7b255f0290da
child 842 0eec9985767d
permissions -rw-r--r--
Added a test program for dynamically loading OpenGL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 :
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
 * gcc testdyngl.c `sdl-config --libs --cflags` -o testdyngl
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
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#ifdef HAVE_OPENGL
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#include "SDL_opengl.h"
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
void* get_funcaddr(const char* p)
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
	void* f=SDL_GL_GetProcAddress(p);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
	if (f)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
		return f;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
	else
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
		printf("Unable to get function pointer for %s\n",p);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
		exit(1);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
typedef struct
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
	void(*glBegin)(GLenum);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
	void(*glEnd)();
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
	void(*glVertex3f)(GLfloat, GLfloat, GLfloat);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
	void(*glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
	void(*glClear)(GLbitfield);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
	void(*glDisable)(GLenum);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
	void(*glEnable)(GLenum);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
	void(*glColor4ub)(GLubyte,GLubyte,GLubyte,GLubyte);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
	void(*glPointSize)(GLfloat);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
	void(*glHint)(GLenum,GLenum);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
	void(*glBlendFunc)(GLenum,GLenum);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
	void(*glMatrixMode)(GLenum);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
	void(*glLoadIdentity)();
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
	void(*glOrtho)(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
	void(*glRotatef)(GLfloat,GLfloat,GLfloat,GLfloat);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
	void(*glViewport)(GLint,GLint,GLsizei,GLsizei);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
	void(*glFogf)(GLenum,GLfloat);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
glfuncs;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
void init_glfuncs(glfuncs* f)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
	f->glBegin=get_funcaddr("glBegin");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
	f->glEnd=get_funcaddr("glEnd");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
	f->glVertex3f=get_funcaddr("glVertex3f");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
	f->glClearColor=get_funcaddr("glClearColor");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
	f->glClear=get_funcaddr("glClear");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
	f->glDisable=get_funcaddr("glDisable");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
	f->glEnable=get_funcaddr("glEnable");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
	f->glColor4ub=get_funcaddr("glColor4ub");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
	f->glPointSize=get_funcaddr("glPointSize");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
	f->glHint=get_funcaddr("glHint");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
	f->glBlendFunc=get_funcaddr("glBlendFunc");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
	f->glMatrixMode=get_funcaddr("glMatrixMode");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
	f->glLoadIdentity=get_funcaddr("glLoadIdentity");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
	f->glOrtho=get_funcaddr("glOrtho");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
	f->glRotatef=get_funcaddr("glRotatef");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
	f->glViewport=get_funcaddr("glViewport");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
	f->glFogf=get_funcaddr("glFogf");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
#define NB_PIXELS 1000
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
int main(int argc,char *argv[])
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
	glfuncs f;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
	int i;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
	SDL_Event event;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
	int done=0;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
	GLfloat pixels[NB_PIXELS*3];
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
	char default_gl_lib[]="/usr/lib/libGL.so";
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
	char* current_gl_lib=default_gl_lib;
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
	if (argc==2)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
		current_gl_lib=argv[1];
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
	if (SDL_Init(SDL_INIT_EVERYTHING)<0)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
		printf("Unable to init SDL : %s\n",SDL_GetError());
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
		exit(1);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
	if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1)<0)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
		printf("Unable to set GL attribute : %s\n",SDL_GetError());
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
		exit(1);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
	if (SDL_GL_LoadLibrary(current_gl_lib)<0)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
		printf("Unable to dynamically open GL lib : %s\n",SDL_GetError());
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
		exit(1);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
	if (SDL_SetVideoMode(640,480,0,SDL_OPENGL)==NULL)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
		printf("Unable to open video mode : %s\n",SDL_GetError());
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
		exit(1);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
	init_glfuncs(&f);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
	for(i=0;i<NB_PIXELS;i++)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
		pixels[3*i]=rand()%250-125;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
		pixels[3*i+1]=rand()%250-125;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
		pixels[3*i+2]=rand()%250-125;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
	f.glViewport(0,0,640,480);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
	f.glMatrixMode(GL_PROJECTION);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
	f.glLoadIdentity();
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
	f.glOrtho(-100,100,-100,100,-500,500);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
	f.glMatrixMode(GL_MODELVIEW);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
	f.glLoadIdentity();
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
	f.glEnable(GL_DEPTH_TEST);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
	f.glDisable(GL_TEXTURE_2D);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
	f.glEnable(GL_BLEND);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
	f.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
	f.glClearColor(0.0f,0.0f,0.0f,0.0f);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
	f.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
	f.glEnable(GL_POINT_SMOOTH);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
	f.glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
	f.glPointSize(5.0f);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
	f.glEnable(GL_FOG);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
	f.glFogf(GL_FOG_START,-500);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
	f.glFogf(GL_FOG_END,500);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
	f.glFogf(GL_FOG_DENSITY,0.005);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
	do
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
	{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
		f.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
		
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
		f.glRotatef(2.0,1.0,1.0,1.0);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
		f.glRotatef(1.0,0.0,1.0,1.0);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
		
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
		f.glColor4ub(255,255,255,255);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
		f.glBegin(GL_POINTS);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
		for(i=0;i<NB_PIXELS;i++)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
		{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
			f.glVertex3f(pixels[3*i],pixels[3*i+1],pixels[3*i+2]);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
		}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
		f.glEnd();
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
		SDL_GL_SwapBuffers();
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
		while(SDL_PollEvent(&event))
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
		{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
			if(event.type & SDL_KEYDOWN)
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
				done=1;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
		}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
		SDL_Delay(20);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
	}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
	while(!done);
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
	
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
	SDL_Quit();
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
	return 0;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
#else /* HAVE_OPENGL */
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
int main(int argc, char *argv[])
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
{
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
	printf("No OpenGL support on this system\n");
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
	return 1;
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
}
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
7b255f0290da Added a test program for dynamically loading OpenGL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
#endif /* HAVE_OPENGL */