diff options
author | Andy Belle-Isle <abelleisle@roadrunner.com> | 2015-09-15 22:16:34 -0400 |
---|---|---|
committer | Andy Belle-Isle <abelleisle@roadrunner.com> | 2015-09-15 22:16:34 -0400 |
commit | c5d48afdbfb7451581a8f61fe24a606b15415224 (patch) | |
tree | f7c2f12d489c9d2fa339171d16e5616c33a1d7fc /src | |
parent | ba4b5bd76ae9b1fa3e3c862d8672e35b02e1664c (diff) |
Fixed timestep, added AA and a mouse cursor
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3ae4206..1843f4a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ #include <chrono> #define TICKS_PER_SEC 20 -#define MSEC_PER_TICK 500//(1000/TICKS_PER_SEC) +#define MSEC_PER_TICK (1000/TICKS_PER_SEC) SDL_Window *window = NULL; SDL_Surface *renderSurface = NULL; @@ -32,7 +32,7 @@ void render(); unsigned int millis(void){ std::chrono::system_clock::time_point now=std::chrono::system_clock::now(); - return std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count(); + return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count(); } int main(int argc,char **argv){ @@ -46,6 +46,9 @@ int main(int argc,char **argv){ atexit(IMG_Quit); //Turn on double Buffering SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + //ANTIALIASING!!! + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16); //create the window window = SDL_CreateWindow("Independent Study v.0.2 alpha", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL #ifdef FULLSCREEN @@ -70,6 +73,7 @@ int main(int argc,char **argv){ glViewport(0,0,SCREEN_WIDTH, SCREEN_HEIGHT); glClearColor(.3,.5,.8,0); glEnable(GL_BLEND); + glEnable(GL_MULTISAMPLE); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); SDL_ShowCursor(SDL_DISABLE); @@ -185,11 +189,18 @@ void render(){ **************************/ //DRAW MOUSE HERE!!!!!W - glColor3ub(255,0,0); mx=(ui.mousex/(float)SCREEN_WIDTH)*2.0f-1.0f; my=((SCREEN_HEIGHT-ui.mousey)/(float)SCREEN_HEIGHT)*2.0f-1.0f; if(player.loc.x-1>-1)mx+=player.loc.x; - glRectf(mx,my,mx+HLINE*4,my+HLINE*4); + + glBegin(GL_TRIANGLES); + + glColor3ub(255,255,255); + glVertex2f(mx,my); + glVertex2f(mx + (HLINE*3.5),my - (HLINE*1)); + glVertex2f(mx + (HLINE*1),my - (HLINE*6)); + + glEnd(); glPopMatrix(); //take the matrix(s) off the stack to pass them to the renderer SDL_GL_SwapWindow(window); //give the stack to SDL to render it |