Skip to content

Commit

Permalink
Fix GLFW issue with texPreviousFrame not working after a lot of windo…
Browse files Browse the repository at this point in the history
…w resizing
  • Loading branch information
Nusan committed Mar 24, 2023
1 parent 06ffce6 commit 1457cda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ As you can see you're gonna need [CMAKE](https://cmake.org/) for this, but don't

### Windows
Use at least [Visual C++ 2010](https://support.microsoft.com/ru-ru/help/2977003/the-latest-supported-visual-c-downloads). For the DX9/DX11 builds, obviously you'll be needing a [DirectX SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6812), though a lot of it is already in the Windows 8.1 SDK as well.
You will need to install NDI SDK and install Visual Studio with components ATL and MFC
Then:
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ../
Expand Down
10 changes: 9 additions & 1 deletion src/platform_glfw/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ namespace Renderer
};

int textureUnit = 0;
int RGBA8_textureUnit = -1;

Texture * CreateRGBA8Texture()
{
Expand All @@ -752,12 +753,19 @@ namespace Renderer
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

if (RGBA8_textureUnit < 0)
{
// Reuse the same textureUnit instead of using a new one each time
// this solve the issue with recreating the previous frame buffer each time you resize the screen
RGBA8_textureUnit = textureUnit++;
}

GLTexture * tex = new GLTexture();
tex->width = nWidth;
tex->height = nHeight;
tex->ID = glTexId;
tex->type = TEXTURETYPE_2D;
tex->unit = textureUnit++;
tex->unit = RGBA8_textureUnit;
return tex;
}

Expand Down

0 comments on commit 1457cda

Please sign in to comment.