Skip to content

Commit

Permalink
Added preliminary support to Render-To-Texture via setRenderTarget() …
Browse files Browse the repository at this point in the history
…functions for both Texture and Window
  • Loading branch information
harrand committed Mar 21, 2017
1 parent 39e7865 commit c5ed6f9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion res/runtime/resources.data
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ speed: 2.5



played: 117303


played: 117352
1 change: 1 addition & 0 deletions src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ int main()
std::cout << "Camera Position = [" << cam.getPosR().getX() << ", " << cam.getPosR().getY() << ", " << cam.getPosR().getZ() << "].\n";
std::cout << "Lifetime Spent: " << secondsLifetime << " seconds.\n";
}
wnd.setRenderTarget();
fpscounter.update();
deltaTotal += fpscounter.getRange();
deltas.push_back(fpscounter.getRange());
Expand Down
5 changes: 5 additions & 0 deletions src/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ void Texture::bind(GLuint shaderProgram, unsigned int id)
glUniform1i(this->textureID, id);
}

void Texture::setRenderTarget() const
{

}

std::string Texture::getFileName() const
{
return this->filename;
Expand Down
1 change: 1 addition & 0 deletions src/texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Texture
Texture(std::string filename = "./res/textures/undefined.jpg");
~Texture();
void bind(GLuint shaderProgram, unsigned int id);
void setRenderTarget() const;
std::string getFileName() const;
static std::shared_ptr<Texture> getFromLink(std::string textureLink, std::vector<std::shared_ptr<Texture>> allTextures);
protected:
Expand Down
6 changes: 6 additions & 0 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ void Window::setTitle(std::string newTitle)
SDL_SetWindowTitle(this->wnd, newTitle.c_str());
}

void Window::setRenderTarget() const
{
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glViewport(0, 0, this->w, this->h);
}

void Window::clear(float r, float g, float b, float a) const
{
glClearColor(r, g, b, a);
Expand Down
1 change: 1 addition & 0 deletions src/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Window
bool isCloseRequested() const;
void requestClose();
void setTitle(std::string newTitle);
void setRenderTarget() const;

void clear(float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f) const;
void update();
Expand Down

0 comments on commit c5ed6f9

Please sign in to comment.