Basic window opening

This commit is contained in:
Robert 2020-08-29 17:51:22 +02:00
parent 26a3775406
commit f7107f5885
7 changed files with 163 additions and 5 deletions

View file

@ -1,7 +1,7 @@
add_executable(example
"main.cpp"
)
"MyWindow.hpp")
target_include_directories(example PRIVATE
${CMAKE_SOURCE_DIR}/GLFramework/include

22
example/MyWindow.hpp Normal file
View file

@ -0,0 +1,22 @@
#include "glf.hpp"
using namespace glf;
class MyWindow :
public IWindow
{
public:
MyWindow() :
IWindow()
{
Create(800, 600, "Example Window");
glfwSetFramebufferSizeCallback(window, FramebufferSizeCallback);
}
private:
static void FramebufferSizeCallback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
};

View file

@ -1,8 +1,27 @@
#include "glf.hpp"
#include "MyWindow.hpp"
int main(int argc, char** argv)
{
glfwInit();
MyWindow* window = nullptr;
try {
glfInit();
window = new MyWindow;
}
catch (std::exception e)
{
std::cout << e.what() << std::endl;
return 1;
}
while (!window->ShouldClose())
{
glfwPollEvents();
window->Display();
}
window->Close();
glfwTerminate();
return 0;
}