-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-opengl.cpp
37 lines (30 loc) · 1.01 KB
/
example-opengl.cpp
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
/// uselibrary GL
/// usepackage sdl
#include <GL/gl.h>
#include <SDL.h>
int main()
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
exit(1);
}
const SDL_VideoInfo *vidinfo = SDL_GetVideoInfo();
printf("Screen resolution: %d x %d\n", vidinfo->current_w, vidinfo->current_h);
int flags = SDL_OPENGL | SDL_DOUBLEBUF | SDL_HWSURFACE;
SDL_Surface *surface;
surface = SDL_SetVideoMode(800, 600, 0, flags);
if (surface == NULL)
{
fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
SDL_Quit();
exit(-1);
}
printf("Vendor: %s\n", glGetString(GL_VENDOR));
printf("Renderer: %s\n", glGetString(GL_RENDERER));
printf("Version: %s\n", glGetString(GL_VERSION));
printf("GLSL version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
printf("Extensions: %s\n", glGetString(GL_EXTENSIONS));
SDL_Quit();
return 0;
}