diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | ball.png | bin | 12689 -> 10213 bytes | |||
-rw-r--r-- | glpong3d.c | 41 | ||||
-rw-r--r-- | glpong3d.h | 2 | ||||
-rw-r--r-- | paddle-skyos.png | bin | 57023 -> 56609 bytes |
5 files changed, 24 insertions, 23 deletions
@@ -4,7 +4,7 @@ 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 -lSDL_net -lGL -lGLU -lglc32
+LIBRARIES=`sdl-config --libs` -lSDL_image -lSDL_net -lGL -lGLU -lGLC
EXT=.exe
EXE=glpong3d${EXT}
@@ -23,4 +23,4 @@ remake: rebuild %.o: %.c
${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
-
\ No newline at end of file + Binary files differ@@ -13,27 +13,28 @@ GLuint box;
int main(int argc, char * argv[]) {
- clock_t now, last = 0;
+ clock_t start;
unsigned int frames = 0;
if (argc) {
if (argv) {}
}
- GLPong_Init();
+ GLPong_Init(); + + start = SDL_GetTicks();
while ( !GLPong.done ) {
GLPong_HandleEvents();
- GLPong_Move();
- now = clock();
- frames++;
- if (now - last > CLK_TCK * 2) {
- GLPong.fps = (frames * CLK_TCK) / (now - last);
- last = now;
- frames = 0;
- }
- printf("now: %ld, last %ld, frames: %u, fps: %u\n", now, last, frames, GLPong.fps);
- GLPong_Draw();
- SDL_Delay(10);
+ GLPong_Move(); + GLPong_Draw(); + frames++; + if (frames == 10) { + GLPong.fps = (float) frames / (SDL_GetTicks() - start) * 1000; + frames = 0; + start = SDL_GetTicks(); + } + printf("frames: %u, fps: %f\n", frames, GLPong.fps); + SDL_Delay(10); }
GLPong_CleanUp();
@@ -107,12 +108,12 @@ void GLPong_Init() { SDL_WM_SetIcon(temp, NULL);
SDL_FreeSurface(temp);*/
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
GLPong.Surface = SDL_SetVideoMode(GLPong.w, GLPong.h, 32, SDL_OPENGL);
glViewport(0, 0, GLPong.w, GLPong.h);
@@ -321,7 +322,7 @@ void GLPong_Draw() { glEnd();
glDisable(GL_TEXTURE_2D);
- sprintf(buffer, "%u FPS", GLPong.fps);
+ sprintf(buffer, "%.0f FPS", GLPong.fps);
glLoadIdentity();
glTranslatef(-1.5f, 1.1f, -3.0f);
glColor3f(1.0f, 1.0f, 1.0f);
@@ -40,7 +40,7 @@ struct { GLC_t GLC;
GLfloat w;
GLfloat h;
- GLuint fps;
+ GLfloat fps;
Sint8 done;
} GLPong;
diff --git a/paddle-skyos.png b/paddle-skyos.png Binary files differindex 4af354c..eb80a8d 100644 --- a/paddle-skyos.png +++ b/paddle-skyos.png |