mirror of https://github.com/kurisufriend/threedee
parent
6f4b292709
commit
7761e67c2f
@ -0,0 +1,17 @@ |
||||
#include "callbacks.h" |
||||
|
||||
void callbacks::handleCallbacks(SDL_Event* eventHandler) |
||||
{ |
||||
while (SDL_PollEvent(eventHandler)) |
||||
{ |
||||
switch (eventHandler->type) |
||||
{ |
||||
case SDL_QUIT: |
||||
global::running = false; |
||||
break; |
||||
case SDL_MOUSEMOTION: |
||||
callbacks::mouseMotion(eventHandler); |
||||
break; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
#pragma once |
||||
#include <iostream> |
||||
#include "SDL.h" |
||||
|
||||
#include "../globals/globals.h" |
||||
|
||||
namespace callbacks |
||||
{ |
||||
inline void mouseMotion(SDL_Event* eventResponse) |
||||
{ |
||||
global::mousePos = vector2(eventResponse->motion.x, eventResponse->motion.y); |
||||
} |
||||
inline void quit(SDL_Event* eventResponse) |
||||
{ |
||||
global::running = false; |
||||
} |
||||
void handleCallbacks(SDL_Event* eventHandler); |
||||
} |
@ -0,0 +1,4 @@ |
||||
#include "globals.h" |
||||
|
||||
bool global::running = true; |
||||
vector2 global::mousePos; |
@ -0,0 +1,7 @@ |
||||
#pragma once |
||||
#include "../objects/vector.h" |
||||
namespace global |
||||
{ |
||||
extern bool running; |
||||
extern vector2 mousePos; |
||||
} |
@ -0,0 +1,21 @@ |
||||
#pragma once |
||||
#include "vector2.h" |
||||
/*
|
||||
vectors extend vector2s and hold 3D cartesian coordinates |
||||
*/ |
||||
struct vector : public vector2 |
||||
{ |
||||
float z; |
||||
vector() |
||||
{ |
||||
this->x = 0.f; |
||||
this->y = 0.f; |
||||
this->z = 0.f; |
||||
} |
||||
vector(float x_, float y_, float z_) |
||||
{ |
||||
this->x = x_; |
||||
this->y = y_; |
||||
this->z = z_; |
||||
} |
||||
}; |
@ -0,0 +1,18 @@ |
||||
#pragma once |
||||
/*
|
||||
vector2s hold 2D cartesian coordinates |
||||
*/ |
||||
struct vector2 |
||||
{ |
||||
float x, y; |
||||
vector2() |
||||
{ |
||||
this->x = 0.f; |
||||
this->y = 0.f; |
||||
} |
||||
vector2(float x_, float y_) |
||||
{ |
||||
this->x = x_; |
||||
this->y = y_; |
||||
} |
||||
}; |
Loading…
Reference in new issue