8 Commits
v2.0 ... master

Author SHA1 Message Date
29cfe699cc Make for smoother zoom. 2018-10-25 23:40:22 +02:00
72e2b3dd09 Can use ESC or 'Q' to quit now.
For those who don't know the system shortcut for closing a window.
2018-10-25 23:33:55 +02:00
30c0bdb23b Removing OpenMP support.
Just realized that there are only 8 vertices, and therefore 24 variables
being updated every frame, which means that using OpenMP would (if
anything) slow it down.
2018-10-25 23:05:05 +02:00
44a71b3227 Set version string to v2.1 2018-10-25 23:01:26 +02:00
e1f7cbaa1d Optimize color changing with OpenMP. 2018-10-25 23:00:26 +02:00
766a2d597c Add FPS limiter (limits at 60 FPS). 2018-10-25 22:59:40 +02:00
5400c4a8fc New version. 2018-10-25 20:40:30 +02:00
039ae5f134 Use real fullscreen. 2018-10-25 20:40:09 +02:00
6 changed files with 15 additions and 12 deletions

View File

@ -25,7 +25,7 @@ project(TrippyCube C CXX)
# Binary filename
set(TARGET_NAME "trippy-cube")
set(TARGET_VERSION "v2.0")
set(TARGET_VERSION "v2.1")
# Use DEBUG by default
if(NOT CMAKE_BUILD_TYPE)

View File

@ -38,7 +38,7 @@ void camera::update(const input *in_sys) {
std::get<1>(pos) = dist * sin(yaw);
std::get<2>(pos) = dist * cos(yaw) * cos(angle);
dist -= in_sys->get_scroll();
if(dist < 0)
dist = 0;
dist -= static_cast<float>(in_sys->get_scroll()) / 2.5f;
if(dist < 0.0f)
dist = 0.0f;
}

View File

@ -36,7 +36,7 @@ public:
void render();
private:
const float color_shift = 0.0001;
const float color_shift = 0.005;
void shift_colors();
// OpenGL buffers

View File

@ -93,6 +93,9 @@ void input::set_key(SDL_Keysym key, bool value) {
case SDLK_d:
actions["move_right"] = value;
break;
case SDLK_ESCAPE:
case SDLK_q:
actions["quit"] = value;
default:
break;
}

View File

@ -73,11 +73,7 @@ int main(int argc, char *argv[]) {
}
if(args.fullscreen)
{
SDL_SetWindowBordered(window, SDL_FALSE);
SDL_SetWindowFullscreen(window,
SDL_WINDOW_FULLSCREEN_DESKTOP);
}
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
SDL_SetRelativeMouseMode(SDL_TRUE);
SDL_GLContext glcontext = SDL_GL_CreateContext(window);

View File

@ -39,8 +39,11 @@ void run() {
camera cam;
cube box;
unsigned int last_time = SDL_GetTicks();
while(not in_sys.get_action("quit"))
{
in_sys.sync_events();
cam.update(&in_sys);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -64,9 +67,10 @@ void run() {
glUniformMatrix4fv(matrix_id, 1, GL_FALSE, &mvp[0][0]);
box.render();
SDL_GL_SwapWindow(window);
in_sys.sync_events();
if(SDL_GetTicks() - last_time < (1000 / 60))
SDL_Delay((1000 / 60) - (SDL_GetTicks() - last_time));
last_time = SDL_GetTicks();
}
}