From c64c44b72db943b213d6dce03d4253528d13be92 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 4 Aug 2006 01:36:55 +0000 Subject: git-svn-id: svn://mattst88.com/svn/glpong3d/trunk@2 4dd1920e-271a-0410-bca0-81b404a81564 --- Makefile | 26 +++++++++++++++++++++++++ glpong3d.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 Makefile create mode 100644 glpong3d.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4ff56b7 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +CC=gcc +STRIP=strip +WARN=-Wall -W -ansi -pedantic +CFLAGS=-Os -pipe -std=c99 ${WARN} +LDFLAGS=-Wl,-O1,-s +INCLUDES=`sdl-config --cflags` +LIBRARIES=`sdl-config --libs` -lSDL_image -lGL -lGLU +EXT=.exe + +EXE=glpong3d${EXT} + +OBJS=glpong3d.o + +all: ${OBJS} + ${CC} ${LDFLAGS} ${OBJS} -o ${EXE} ${LIBRARIES} + +clean: + rm -f ${OBJS} + rm -f ${EXE} + +rebuild: clean all +remake: rebuild + +%.o: %.c + ${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $< + \ No newline at end of file diff --git a/glpong3d.c b/glpong3d.c new file mode 100644 index 0000000..90bab22 --- /dev/null +++ b/glpong3d.c @@ -0,0 +1,65 @@ +#include "SDL.h" +#include "SDL_opengl.h" +#include "SDL_image.h" + +#include +#include + +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; +} -- cgit v1.2.3