]> git.localhorst.tv Git - blank.git/blobdiff - src/app.cpp
orientable blocks
[blank.git] / src / app.cpp
index 9580d33560024171ab9db84e957777b697f2c970..716fb3caa4ee7530ddddcaa47975de228efd58a6 100644 (file)
@@ -31,12 +31,6 @@ Application::Application()
 , place_id(1) {
        GLContext::EnableVSync();
 
-       GLuint VertexArrayID;
-       glGenVertexArrays(1, &VertexArrayID);
-       glBindVertexArray(VertexArrayID);
-
-       world.Generate({ -4, -4, -4 }, { 5, 5, 5});
-
        hud.Viewport(960, 600);
        hud.Display(*world.BlockTypes()[place_id]);
 
@@ -44,6 +38,34 @@ Application::Application()
 }
 
 
+void Application::RunN(size_t n) {
+       Uint32 last = SDL_GetTicks();
+       for (size_t i = 0; i < n; ++i) {
+               Uint32 now = SDL_GetTicks();
+               int delta = now - last;
+               Loop(delta);
+               last = now;
+       }
+}
+
+void Application::RunT(size_t t) {
+       Uint32 last = SDL_GetTicks();
+       Uint32 finish = last + t;
+       while (last < finish) {
+               Uint32 now = SDL_GetTicks();
+               int delta = now - last;
+               Loop(delta);
+               last = now;
+       }
+}
+
+void Application::RunS(size_t n, size_t t) {
+       for (size_t i = 0; i < n; ++i) {
+               Loop(t);
+       }
+}
+
+
 void Application::Run() {
        running = true;
        Uint32 last = SDL_GetTicks();
@@ -115,12 +137,12 @@ void Application::Update(int dt) {
        float dist;
        glm::vec3 normal;
        if (world.Intersection(aim, glm::mat4(1.0f), &chunk, &blkid, &dist, &normal)) {
-               glm::vec3 pos = Chunk::ToCoords(blkid);
                outline_visible = true;
                outline.Clear();
                chunk->Type(chunk->BlockAt(blkid)).FillOutlineModel(outline);
-               outline_transform = glm::translate(chunk->Transform(world.Player().ChunkCoords()), pos);
-               outline_transform = glm::scale(outline_transform, glm::vec3(1.0001f));
+               outline_transform = glm::scale(glm::mat4(1.0f), glm::vec3(1.0002f));
+               outline_transform = chunk->Transform(world.Player().ChunkCoords());
+               outline_transform *= chunk->ToTransform(blkid);
        } else {
                outline_visible = false;
        }