Skip to content

Commit

Permalink
Fix a bug where shader attributes where not properly disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
daid committed Apr 16, 2024
1 parent 1b410ab commit 00850e7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/graphics/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ bool Shader::bind()
LOG(Warning, "Shader:", name, "has no attribute for a_vertex, this is odd... (legacy shader with gl_Vertex?)");
}

glUseProgram(program);

if (previous_shader)
{
if (previous_shader->vertex_attribute != -1)
Expand All @@ -130,6 +128,7 @@ bool Shader::bind()
if (previous_shader->uv_attribute != -1)
glDisableVertexAttribArray(previous_shader->uv_attribute);
}
glUseProgram(program);

if (vertex_attribute != -1) glEnableVertexAttribArray(vertex_attribute);
if (normal_attribute != -1) glEnableVertexAttribArray(normal_attribute);
Expand Down Expand Up @@ -239,6 +238,15 @@ int Shader::getUniformLocation(const string& s)

void Shader::unbind()
{
if (bound_shader)
{
if (bound_shader->vertex_attribute != -1)
glDisableVertexAttribArray(bound_shader->vertex_attribute);
if (bound_shader->normal_attribute != -1)
glDisableVertexAttribArray(bound_shader->normal_attribute);
if (bound_shader->uv_attribute != -1)
glDisableVertexAttribArray(bound_shader->uv_attribute);
}
glUseProgram(0);
bound_shader = nullptr;
}
Expand Down

1 comment on commit 00850e7

@daid-tinyci
Copy link

@daid-tinyci daid-tinyci bot commented on 00850e7 Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TinyCI build failure:

[cmake ../template/ -G Ninja -DCMAKE_MODULE_PATH=../cmake/ -DCMAKE_BUILD_TYPE=Debug] returned [1]:

  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is

  not set.  The policy's OLD behavior will be used.  When using a URL

  download, the timestamps of extracted files should preferably be that of

  the time of extraction, otherwise code that depends on the extracted

  contents might not be rebuilt if the URL changes.  The OLD behavior

  preserves the timestamps from the archive instead, but this is usually not

  what you want.  Update your project to the NEW behavior or specify the

  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this

  robustness issue.

Call Stack (most recent call first):

  /data/tinyci_build/daid/SeriousProton2/SeriousProton2.include.cmake:84 (FetchContent_Declare)

  /data/tinyci_build/daid/SeriousProton2/cmake/FindSeriousProton2.cmake:30 (include)

  CMakeLists.txt:7 (find_package)

This warning is for project developers.  Use -Wno-dev to suppress it.



-- Using the single-header code from /data/tinyci_build/daid/SeriousProton2/_build_native_debug/_deps/json-src/single_include/

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success

-- Configuring done

-- Generating done

CMake Error:

  Running



   '/usr/bin/ninja' '-C' '/data/tinyci_build/daid/SeriousProton2/_build_native_debug' '-t' 'recompact'



  failed with:



   ninja: warning: bad deps log signature or version; starting over



  ninja: error: failed recompaction: No such file or directory







CMake Generate step failed.  Build files cannot be regenerated correctly.

Please sign in to comment.