Skip to content

Commit

Permalink
Merge branch 'texture-refactoring' into scene-refactor-base
Browse files Browse the repository at this point in the history
  • Loading branch information
hjanetzek committed Nov 30, 2018
2 parents 2c76931 + f7eb842 commit 1639f03
Show file tree
Hide file tree
Showing 19 changed files with 1,640 additions and 950 deletions.
1 change: 1 addition & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ add_library(tangram-core
src/util/json.cpp
src/util/mapProjection.cpp
src/util/rasterize.cpp
src/util/stbImage.cpp
src/util/url.cpp
src/util/yamlPath.cpp
src/util/yamlUtil.cpp
Expand Down
2,113 changes: 1,410 additions & 703 deletions core/deps/stb/stb_image.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core/src/gl/framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ void FrameBuffer::init(RenderState& _rs) {

m_texture = std::make_unique<Texture>(options);
m_texture->resize(m_width, m_height);
m_texture->update(_rs, 0);
m_texture->bind(_rs, 0);

GL::framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, m_texture->getGlHandle(), 0);
GL_TEXTURE_2D, m_texture->glHandle(), 0);
}

{
Expand Down
4 changes: 2 additions & 2 deletions core/src/gl/primitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ void drawTexture(RenderState& rs, Texture& _tex, glm::vec2 _pos, glm::vec2 _dim)
rs.vertexBuffer(0);
rs.depthTest(GL_FALSE);

float w = _tex.getWidth();
float h = _tex.getHeight();
float w = _tex.width();
float h = _tex.height();

if (_dim != glm::vec2(0)) {
w = _dim.x;
Expand Down
17 changes: 5 additions & 12 deletions core/src/gl/renderState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,24 +333,17 @@ bool RenderState::shaderProgram(GLuint program) {
return true;
}

bool RenderState::texture(GLenum target, GLuint handle) {
if (!m_texture.set || m_texture.target != target || m_texture.handle != handle) {
m_texture = { target, handle, true };
GL::bindTexture(target, handle);
return false;
}
return true;
}

bool RenderState::textureUnit(GLuint unit) {
void RenderState::texture(GLuint handle, GLuint unit, GLenum target) {
if (!m_textureUnit.set || m_textureUnit.unit != unit) {
m_textureUnit = { unit, true };
// Our cached texture handle is irrelevant on the new unit, so unset it.
m_texture.set = false;
GL::activeTexture(getTextureUnit(unit));
return false;
}
return true;
if (!m_texture.set || m_texture.target != target || m_texture.handle != handle) {
m_texture = { target, handle, true };
GL::bindTexture(target, handle);
}
}

bool RenderState::vertexBuffer(GLuint handle) {
Expand Down
4 changes: 1 addition & 3 deletions core/src/gl/renderState.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ class RenderState {

bool shaderProgram(GLuint program);

bool texture(GLenum target, GLuint handle);

bool textureUnit(GLuint unit);
void texture(GLuint handle, GLuint unit, GLenum target);

bool vertexBuffer(GLuint handle);

Expand Down
Loading

0 comments on commit 1639f03

Please sign in to comment.