summaryrefslogtreecommitdiff
path: root/glpong3d.c
blob: 90bab228c49b59de7ac57b922fc5b898a6cdeebf (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
#include "SDL.h"
#include "SDL_opengl.h"
#include "SDL_image.h"

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char * argv[]) {
	SDL_Surface * Surface = NULL;
	SDL_Event Event;
	
	int width = 640;
	int height = 480;
	
	if (argc) {
		if (argv) {}
	}
	
	if (SDL_Init(SDL_INIT_VIDEO) != 0) {
		fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
		return -1;
	}
	atexit(SDL_Quit);
	
	Event.type = SDL_NOEVENT;
	
	Surface = SDL_SetVideoMode(width, height, 0, SDL_OPENGL);
	
	SDL_WM_SetCaption("glpong3d", "glpong3d");
	
	glShadeModel(GL_SMOOTH);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	glDepthFunc(GL_LEQUAL);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	
	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
	
	glViewport(0, 0, width, height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45.0f, width / (float)height, 0.1f, 50.0f);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	while (1) {
		if (!SDL_PollEvent(&Event)) {
			if (Event.type == SDL_QUIT) {
				return 0;
			} else if (Event.type == SDL_KEYDOWN) {
				if (Event.key.keysym.sym == SDLK_ESCAPE) {
					return 0;
				}
			}
		}
		
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		
		SDL_GL_SwapBuffers();
		SDL_Delay(10);
	}
	
	return 0;
}