Skip to content

Commit

Permalink
some lib changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SeriousSamV committed Jan 25, 2017
1 parent 52daa92 commit 884137b
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 4 deletions.
30 changes: 26 additions & 4 deletions lib/mylib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,44 @@ class App
}
App() = delete;

void run(App& app)
static void run(App& app)
{
window.init();
app.window.init();
app.startup();

while (!glfwWindowShouldClose(window.getWindow())) {
while (!glfwWindowShouldClose(app.window.getWindow())) {
app.update(glfwGetTime());
app.render();

glfwSwapBuffers(window.getWindow());
glfwSwapBuffers(app.window.getWindow());
glfwPollEvents();
}

app.shutdown();
}

static void threaded_run(void* app_addr = nullptr)
{
if (app_addr == nullptr) {
std::cerr << "add_addr = nullptr" << std::endl;
std::exit(EXIT_FAILURE);
}

mylib::App *app = reinterpret_cast<mylib::App*>(app_addr);
app->window.init();
app->startup();

while (!glfwWindowShouldClose(app->window.getWindow())) {
app->update(glfwGetTime());
app->render();

glfwSwapBuffers(app->window.getWindow());
glfwPollEvents();
}

app->shutdown();
}

virtual void startup() {}
virtual void update(double) {}
virtual void render() {}
Expand Down
61 changes: 61 additions & 0 deletions template_code/template01.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#undef _NDEBUG

#include "../lib/mylib.hpp"

#include <epoxy/gl.h>
#include <epoxy/glx.h>

#include <SOIL/SOIL.h>

#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/string_cast.hpp>

#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>

/*
*
*/

class myApp: public mylib::App
{
public:
myApp(mylib::Window&& window):
mylib::App(std::move(window)) {}

void startup() override
{

}

~myApp()
{

}

void update(double time) override
{

}

void render() override
{

}

protected:

private:

};

int main(const int argc, const char* const argv[])
{

std::exit(EXIT_SUCCESS);
}

0 comments on commit 884137b

Please sign in to comment.