From 44b079f8ee4a8f4a751a3a4e12b2a15a831786a4 Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Wed, 16 Jul 2008 22:30:47 -0400 Subject: [PATCH] graphics moved to folder, Make flags updated --- src/Entities/Ball.cpp | 3 +++ src/Makefile | 25 +++++++++++++++--------- src/depend.mk | 42 +++++++++++++++++++++++++++++++++++------ src/{ => graphics}/graphics.cpp | 6 +++--- src/{ => graphics}/graphics.h | 4 +++- src/main.cpp | 24 ++++++++++++++++------- 6 files changed, 78 insertions(+), 26 deletions(-) rename src/{ => graphics}/graphics.cpp (92%) rename src/{ => graphics}/graphics.h (58%) diff --git a/src/Entities/Ball.cpp b/src/Entities/Ball.cpp index 7c31364..ad24d8e 100644 --- a/src/Entities/Ball.cpp +++ b/src/Entities/Ball.cpp @@ -1,5 +1,6 @@ #include "Ball.h" #include "../Vector2.h" +#include "../graphics/graphics.h" /// ***** Public Class Methods ***** Ball::Ball(Vector2 pos, float radius) @@ -15,4 +16,6 @@ Ball::~Ball() void Ball::draw() const { // TODO + + glDrawCircle(radius, &position); } diff --git a/src/Makefile b/src/Makefile index 4a51706..1d89438 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,14 +1,18 @@ -LIBGL = -lGL -lGLU -LIBSDL = `sdl-config --libs` -LIBS = ${LIBSDL} ${LIBGL} +LIBGL := -lGL -lGLU +LIBSDL := `sdl-config --libs` +LIBS := ${LIBSDL} ${LIBGL} + +OPTFLAGS := -O2 +DBGFLAGS := -ggdb +PRFFLAGS := ${DBGFLAGS} -pg + +#CXX := g++ +CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS} -CXX = g++ -CXXFLAGS = -ggdb -Wall -pedantic SRCS := entityManager.cpp SRCS += game.cpp -SRCS += graphics.cpp SRCS += main.cpp SRCS += mathw.cpp SRCS += ticks.cpp @@ -30,10 +34,13 @@ SRCS += GameStates/Running.cpp SRCS += input/inputManager.cpp -OBJS = ${SRCS:.cpp=.o} +SRCS += graphics/graphics.cpp + +OBJS := ${SRCS:.cpp=.o} + -TARGET = ../run_physics -DEPEND = depend.mk +TARGET := ../run_physics +DEPEND := depend.mk .PHONY: all diff --git a/src/depend.mk b/src/depend.mk index 9eb1e16..445efce 100644 --- a/src/depend.mk +++ b/src/depend.mk @@ -1,9 +1,39 @@ -Vector2.o: Vector2.cpp Vector2.h mathw.h -ticks.o: ticks.cpp ticks.h -main.o: main.cpp game.h ticks.h graphics.h -game.o: game.cpp game.h entityManager.o: entityManager.cpp entityManager.h Entities/Entity.h \ Entities/../Vector2.h Entities/Particle.h Entities/Entity.h \ Entities/PhysicsEntity.h -gldraw.o: gldraw.cpp -graphics.o: graphics.cpp +game.o: game.cpp game.h GameStates/GameState.h GameStates/Running.h \ + GameStates/GameState.h GameStates/Paused.h GameStates/CreatingPolygon.h +main.o: main.cpp debug.h game.h ticks.h graphics/graphics.h \ + graphics/../Vector2.h input/inputManager.h +mathw.o: mathw.cpp mathw.h Vector2.h +ticks.o: ticks.cpp ticks.h +Vector2.o: Vector2.cpp Vector2.h mathw.h +Ball.o: Entities/Ball.cpp Entities/Ball.h Entities/PhysicsEntity.h \ + Entities/Entity.h Entities/../Vector2.h Entities/../graphics/graphics.h \ + Entities/../graphics/../Vector2.h +Entity.o: Entities/Entity.cpp Entities/Entity.h Entities/../Vector2.h +Line.o: Entities/Line.cpp Entities/Line.h Entities/Particle.h \ + Entities/Entity.h Entities/../Vector2.h +Particle.o: Entities/Particle.cpp Entities/Particle.h Entities/Entity.h \ + Entities/../Vector2.h +PhysicsEntity.o: Entities/PhysicsEntity.cpp Entities/PhysicsEntity.h \ + Entities/Entity.h Entities/../Vector2.h +Point.o: Entities/Point.cpp Entities/Point.h Entities/Particle.h \ + Entities/Entity.h Entities/../Vector2.h +Polygon.o: Entities/Polygon.cpp Entities/Polygon.h \ + Entities/PhysicsEntity.h Entities/Entity.h Entities/../Vector2.h +WindParticle.o: Entities/WindParticle.cpp Entities/WindParticle.h \ + Entities/Point.h Entities/Particle.h Entities/Entity.h \ + Entities/../Vector2.h +CreatingPolygon.o: GameStates/CreatingPolygon.cpp \ + GameStates/CreatingPolygon.h GameStates/GameState.h +GameState.o: GameStates/GameState.cpp GameStates/GameState.h +Paused.o: GameStates/Paused.cpp GameStates/Paused.h \ + GameStates/GameState.h +Running.o: GameStates/Running.cpp GameStates/Running.h \ + GameStates/GameState.h GameStates/../entityManager.h \ + GameStates/../Entities/Entity.h GameStates/../Entities/../Vector2.h +inputManager.o: input/inputManager.cpp input/inputManager.h \ + input/../debug.h +graphics.o: graphics/graphics.cpp graphics/graphics.h \ + graphics/../Vector2.h graphics/../debug.h diff --git a/src/graphics.cpp b/src/graphics/graphics.cpp similarity index 92% rename from src/graphics.cpp rename to src/graphics/graphics.cpp index 0f84d20..a719662 100644 --- a/src/graphics.cpp +++ b/src/graphics/graphics.cpp @@ -5,7 +5,7 @@ #include #include -#include "debug.h" +#include "../debug.h" static const float PI = 3.1415926535897; @@ -27,11 +27,11 @@ void graphicsCleanUp() } -void glDrawCircle(float radius, float x, float y, const float* color) +void glDrawCircle(float radius, const Vector2* vec, const float* color) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(x, y, -1); + glTranslatef(vec->x, vec->y, -1); glScalef(radius, radius, radius); if(color != NULL) diff --git a/src/graphics.h b/src/graphics/graphics.h similarity index 58% rename from src/graphics.h rename to src/graphics/graphics.h index 43505a6..df3b5c2 100644 --- a/src/graphics.h +++ b/src/graphics/graphics.h @@ -1,10 +1,12 @@ #ifndef GRAPHICS_H #define GRAPHICS_H +#include "../Vector2.h" + /// ***** Header Methods ***** void graphicsInit(); void graphicsCleanUp(); -void glDrawCircle(float radius, float x, float y, const float* color = 0); +void glDrawCircle(float radius, const Vector2*, const float* color = 0); #endif // GRAPHICS_H diff --git a/src/main.cpp b/src/main.cpp index fd14612..629ca9b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,8 @@ using std::vector; #include "game.h" #include "ticks.h" -#include "graphics.h" + +#include "graphics/graphics.h" #include "input/inputManager.h" @@ -83,6 +84,17 @@ void init() #endif } +void cleanUp() +{ +#ifdef DEBUGGING + cout << "Cleaning up" << endl; +#endif + + gameClean(); + + graphicsCleanUp(); +} + void run() { is_Running = true; @@ -97,11 +109,6 @@ void run() } } -void cleanUp() -{ - gameClean(); -} - void blockUpdate() { long int start = tickCountMicro(); @@ -142,6 +149,9 @@ void updateFPSCounters() draw_Count = 0; last_Second = tickCountMicro(); + + //cout << "ups:\t" << ups << endl; + //cout << "fps:\t" << fps << endl; } } @@ -151,7 +161,7 @@ void input() gameInput(); - if(isPressed(SDLK_ESCAPE)) + if(wasReleased(SDLK_ESCAPE)) is_Running = false; } -- 2.10.2