|
|
|
@ -46,7 +46,7 @@ void Game::init() {
@@ -46,7 +46,7 @@ void Game::init() {
|
|
|
|
|
|
|
|
|
|
SDL_GL_SetSwapInterval(conf->getValue<int>("graphics.vsync", 0)); |
|
|
|
|
|
|
|
|
|
window.setTitle("OpenGL"); |
|
|
|
|
window.setTitle("VTK"); |
|
|
|
|
window.setResolution(conf->getValue<int>("graphics.res.x", 800), |
|
|
|
|
conf->getValue<int>("graphics.res.y", 600)); |
|
|
|
|
window.setFOV(conf->getValue<float>("graphics.fov", 45.0f)); |
|
|
|
@ -68,28 +68,6 @@ void Game::init() {
@@ -68,28 +68,6 @@ void Game::init() {
|
|
|
|
|
glClearDepth(0.0f); |
|
|
|
|
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
//depth buffer stuff
|
|
|
|
|
glGenTextures(1, &mColor); |
|
|
|
|
glBindTexture(GL_TEXTURE_2D, mColor); |
|
|
|
|
glTexStorage2D(GL_TEXTURE_2D, 1, GL_SRGB8_ALPHA8, conf->getValue<int>("graphics.res.x", 800), conf->getValue<int>("graphics.res.y", 600)); |
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
|
|
|
|
|
|
|
glGenTextures(1, &mDepth); |
|
|
|
|
glBindTexture(GL_TEXTURE_2D, mDepth); |
|
|
|
|
glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT32F, conf->getValue<int>("graphics.res.x", 800), conf->getValue<int>("graphics.res.y", 600)); |
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
|
|
|
|
|
|
|
glGenFramebuffers(1, &mFBO); |
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, mFBO); |
|
|
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mColor, 0); |
|
|
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, mDepth, 0); |
|
|
|
|
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); |
|
|
|
|
if (status != GL_FRAMEBUFFER_COMPLETE) { |
|
|
|
|
fprintf(stderr, "glCheckFramebufferStatus: %x\n", status); |
|
|
|
|
} |
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
running = false; |
|
|
|
|
gls::setTracking(true); // track OpenGL state changes
|
|
|
|
@ -104,12 +82,12 @@ void Game::start() {
@@ -104,12 +82,12 @@ void Game::start() {
|
|
|
|
|
void Game::loop() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::chrono::steady_clock::time_point lastFrameTime = std::chrono::steady_clock::now(); |
|
|
|
|
std::chrono::steady_clock::time_point lastFrameTime = std::chrono::steady_clock::now(); |
|
|
|
|
|
|
|
|
|
while (running) { |
|
|
|
|
//time
|
|
|
|
|
std::chrono::steady_clock::time_point curTime = std::chrono::steady_clock::now(); |
|
|
|
|
auto timeSpan = std::chrono::duration_cast<std::chrono::duration<float>>(curTime - lastFrameTime); |
|
|
|
|
//time
|
|
|
|
|
std::chrono::steady_clock::time_point curTime = std::chrono::steady_clock::now(); |
|
|
|
|
auto timeSpan = std::chrono::duration_cast<std::chrono::duration<float>>(curTime - lastFrameTime); |
|
|
|
|
lastFrameTime = curTime; |
|
|
|
|
float dTime = timeSpan.count(); |
|
|
|
|
|
|
|
|
@ -122,18 +100,6 @@ void Game::loop() {
@@ -122,18 +100,6 @@ void Game::loop() {
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
activeScene->draw(); //draw the scene
|
|
|
|
|
|
|
|
|
|
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, mFBO); |
|
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); // default FBO
|
|
|
|
|
glBlitFramebuffer( |
|
|
|
|
0, 0, conf->getValue<int>("graphics.res.x", 800), conf->getValue<int>("graphics.res.y", 600), |
|
|
|
|
0, 0, conf->getValue<int>("graphics.res.x", 800), conf->getValue<int>("graphics.res.y", 600), |
|
|
|
|
GL_COLOR_BUFFER_BIT, GL_LINEAR); |
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
SDL_GL_SwapWindow(window.getWindow()); |
|
|
|
|
} |
|
|
|
|
cleanup(); |
|
|
|
|