|
|
|
@ -2,6 +2,7 @@
@@ -2,6 +2,7 @@
|
|
|
|
|
//Using SDL, SDL OpenGL, standard IO, and, strings
|
|
|
|
|
|
|
|
|
|
#include <SDL2/SDL_mouse.h> |
|
|
|
|
#include <cstdint> |
|
|
|
|
#include <glm/glm.hpp> |
|
|
|
|
#include <glm/gtc/matrix_transform.hpp> |
|
|
|
|
#include <glm/gtc/type_ptr.hpp> |
|
|
|
@ -33,9 +34,9 @@
@@ -33,9 +34,9 @@
|
|
|
|
|
#include "drawing.h" |
|
|
|
|
#include "level.h" |
|
|
|
|
#include "player.h" |
|
|
|
|
#include "frametime.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float framestep = 0.0; |
|
|
|
|
|
|
|
|
|
class SDLGLGLWindow { |
|
|
|
|
|
|
|
|
@ -120,7 +121,7 @@ class SDLGLGLWindow {
@@ -120,7 +121,7 @@ class SDLGLGLWindow {
|
|
|
|
|
SDL_GL_CONTEXT_PROFILE_CORE ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gWindow = SDL_CreateWindow( "Tutorial", SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
|
gWindow = SDL_CreateWindow( "ponder orb", SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
|
SDL_WINDOWPOS_UNDEFINED, screen_width, screen_height,
|
|
|
|
|
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); |
|
|
|
|
|
|
|
|
@ -222,6 +223,7 @@ class SDLGLGLWindow {
@@ -222,6 +223,7 @@ class SDLGLGLWindow {
|
|
|
|
|
int initGL() { |
|
|
|
|
bool success = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float cubeVertices[] = { |
|
|
|
|
// vertices normals textures tangent
|
|
|
|
|
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, |
|
|
|
@ -478,10 +480,13 @@ int main(int argc, char **argv) {
@@ -478,10 +480,13 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
|
|
std::cout << "Rendering now\n"; |
|
|
|
|
|
|
|
|
|
float last_frametime = SDL_GetTicks(); |
|
|
|
|
|
|
|
|
|
//While application is running
|
|
|
|
|
while( !quit ) |
|
|
|
|
{ |
|
|
|
|
bool shademode = true; |
|
|
|
|
const float camera_speed = 5.4f; |
|
|
|
|
//Handle events on queue
|
|
|
|
|
while( SDL_PollEvent( &e ) != 0 ) |
|
|
|
|
{ |
|
|
|
@ -490,9 +495,24 @@ int main(int argc, char **argv) {
@@ -490,9 +495,24 @@ int main(int argc, char **argv) {
|
|
|
|
|
{ |
|
|
|
|
quit = true; |
|
|
|
|
} |
|
|
|
|
if (e.type == SDL_KEYUP) { |
|
|
|
|
switch (e.key.keysym.scancode) { |
|
|
|
|
case SDL_SCANCODE_W: |
|
|
|
|
cont.player_data->move(0, glm::vec3(0,0,1)); |
|
|
|
|
break; |
|
|
|
|
case SDL_SCANCODE_S: |
|
|
|
|
cont.player_data->move(0, glm::vec3(0,0,-1)); |
|
|
|
|
break; |
|
|
|
|
case SDL_SCANCODE_A: |
|
|
|
|
cont.player_data->move(0, glm::vec3(-1,0,0)); |
|
|
|
|
break; |
|
|
|
|
case SDL_SCANCODE_D: |
|
|
|
|
cont.player_data->move(0, glm::vec3(1,0,0)); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (e.type == SDL_KEYDOWN) { |
|
|
|
|
bool shademode = true; |
|
|
|
|
const float camera_speed = 0.4f; |
|
|
|
|
switch (e.key.keysym.scancode) { |
|
|
|
|
case SDL_SCANCODE_X: |
|
|
|
|
if ((shademode = !shademode)) { |
|
|
|
@ -544,8 +564,12 @@ int main(int argc, char **argv) {
@@ -544,8 +564,12 @@ int main(int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
cont.update_camera(); |
|
|
|
|
float this_frametime = SDL_GetTicks() / 1000.0; |
|
|
|
|
framestep = this_frametime - last_frametime; |
|
|
|
|
last_frametime = this_frametime; |
|
|
|
|
|
|
|
|
|
cont.player_data->update(); |
|
|
|
|
cont.update_camera(); |
|
|
|
|
|
|
|
|
|
cont.render(); |
|
|
|
|
cont.swap_window(); |
|
|
|
|