This commit is contained in:
parent
ff7638a245
commit
3d86c3cd1c
|
|
@ -63,9 +63,9 @@ int Window::init(float* data) {
|
||||||
|
|
||||||
|
|
||||||
int Window::init_quad(float* data) {
|
int Window::init_quad(float* data) {
|
||||||
this->current_quad = std::make_unique<Quad>(this->w, this->h);
|
this->quad = std::make_unique<Quad>(this->w, this->h);
|
||||||
this->current_quad->cuda_init(data);
|
this->quad->cuda_init(data);
|
||||||
this->current_quad->make_fbo();
|
this->quad->make_fbo();
|
||||||
|
|
||||||
this->shader = std::make_unique<Shader>("./shaders/vertshader.glsl", "./shaders/fragshader.glsl");
|
this->shader = std::make_unique<Shader>("./shaders/vertshader.glsl", "./shaders/fragshader.glsl");
|
||||||
this->shader->use();
|
this->shader->use();
|
||||||
|
|
@ -78,7 +78,7 @@ int Window::init_quad(float* data) {
|
||||||
void Window::free(float* data) {
|
void Window::free(float* data) {
|
||||||
// To preserve the proper destruction order we forcefully set the quads to null (calling their destructor in the process)
|
// To preserve the proper destruction order we forcefully set the quads to null (calling their destructor in the process)
|
||||||
// Not strictly necessary, but i saw some weird errors on exit without this so best to keep it in.
|
// Not strictly necessary, but i saw some weird errors on exit without this so best to keep it in.
|
||||||
this->current_quad = nullptr;
|
this->quad = nullptr;
|
||||||
cudaFree(data);
|
cudaFree(data);
|
||||||
|
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
|
|
@ -106,10 +106,10 @@ void Window::tick() {
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
this->current_quad->render();
|
this->quad->render();
|
||||||
this->shader->use();
|
this->shader->use();
|
||||||
glBindVertexArray(this->current_quad->VAO);
|
glBindVertexArray(this->quad->VAO);
|
||||||
glBindTexture(GL_TEXTURE_2D, this->current_quad->tex);
|
glBindTexture(GL_TEXTURE_2D, this->quad->tex);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6); // draw current frame to texture
|
glDrawArrays(GL_TRIANGLES, 0, 6); // draw current frame to texture
|
||||||
|
|
||||||
// check for events
|
// check for events
|
||||||
|
|
@ -121,5 +121,5 @@ void Window::tick() {
|
||||||
void Window::resize(unsigned int w, unsigned int h) {
|
void Window::resize(unsigned int w, unsigned int h) {
|
||||||
this->w = w;
|
this->w = w;
|
||||||
this->h = h;
|
this->h = h;
|
||||||
this->current_quad->resize(w, h);
|
this->quad->resize(w, h);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
std::unique_ptr<Quad> current_quad;
|
std::unique_ptr<Quad> quad;
|
||||||
|
|
||||||
std::chrono::steady_clock::time_point last_frame;
|
std::chrono::steady_clock::time_point last_frame;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue