16 #define GL_GLEXT_PROTOTYPES 1
17 #define GL3_PROTOTYPES 1
21 #include <SDL_opengl.h>
46 int bpp = SDL_GetVideoInfo()->vfmt->BitsPerPixel;
70 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]);
71 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]);
72 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]);
73 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
74 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
81 glPushAttrib(GL_ENABLE_BIT);
82 glDisable(GL_DEPTH_TEST);
83 glDisable(GL_CULL_FACE);
84 glEnable(GL_TEXTURE_2D);
86 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
88 glViewport(-1, -1, +1, +1);
89 glMatrixMode(GL_PROJECTION);
92 glOrtho(-1.0, +1.0, -1.0, +1.0, -10.0, +10.0);
94 glMatrixMode(GL_MODELVIEW);
97 glEnable(GL_DEPTH_TEST);
99 glShadeModel(GL_SMOOTH);
106 #if !defined(USE_GL_2)
118 int memory_size = points_size *
sizeof(points[0]);
120 glEnableClientState(GL_VERTEX_ARRAY);
121 glEnableClientState(GL_COLOR_ARRAY);
123 glBindBuffer(GL_ARRAY_BUFFER, buffer_id);
124 glBufferData(GL_ARRAY_BUFFER, memory_size, points, GL_STATIC_DRAW);
126 glInterleavedArrays(GL_V2F, 0, NULL);
127 glDrawArrays(GL_POINTS, 0, points_size);
128 glBindBuffer(GL_ARRAY_BUFFER, 0);
130 glDisableClientState(GL_COLOR_ARRAY);
131 glDisableClientState(GL_VERTEX_ARRAY);
142 glMatrixMode(GL_PROJECTION);
148 glMatrixMode(GL_MODELVIEW);
152 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
166 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
167 printf(
"SDL_Init: %s\n", SDL_GetError());
181 #if defined(USE_GL_2)
182 glGenBuffers(1, &buffer_id);
201 glClearColor(0x00, 0x00, 0x00, 0xff);
202 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
211 SDL_GL_SwapBuffers();
220 glColor3f(r / 255.0, g / 255.0, b / 255.0);
238 bool is_quit =
false;
242 while (SDL_PollEvent(&event)) {
243 switch (event.type) {
250 if ((event.key.keysym.sym == SDLK_q) ||
251 (event.key.keysym.sym == SDLK_F4)) {
254 if (event.key.keysym.sym == SDLK_COMMA) {
257 if (event.key.keysym.sym == SDLK_PERIOD) {
262 case SDL_MOUSEBUTTONDOWN:
263 if (event.button.button == SDL_BUTTON_WHEELUP) {
265 }
else if (event.button.button == SDL_BUTTON_WHEELDOWN) {
273 while (magnify < 0) {
277 while (magnify > 0) {