Skip to content

Commit bd0536f

Browse files
Merge pull request #50 from KhangPham9/bugfix-resize-memory-leak
Created resize function to avoid recreating multiple LAppSpriteShaders.
2 parents 6e77bfe + 07d79b6 commit bd0536f

4 files changed

Lines changed: 24 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77

8+
## [Unreleased]
9+
10+
## Fixed
11+
12+
* Fix unintended object recreating when resizing the window in the OpenGL Linux sample program.
13+
14+
815
## [5-r.4] - 2025-05-29
916

1017
### Added

Samples/OpenGL/Demo/proj.linux.cmake/src/LAppDelegate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void LAppDelegate::Run()
148148
glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
149149
if((_windowWidth!=width || _windowHeight!=height) && width>0 && height>0)
150150
{
151-
_view->Initialize(width, height);
151+
_view->ResizeWindow(width, height);
152152
_view->ResizeSprite();
153153

154154
_windowWidth = width;

Samples/OpenGL/Demo/proj.linux.cmake/src/LAppView.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ LAppView::LAppView() :
3030
_gear(NULL),
3131
_power(NULL),
3232
_renderSprite(NULL),
33-
_renderTarget(SelectTarget_None)
33+
_renderTarget(SelectTarget_None),
34+
_spriteShader(NULL)
3435
{
3536
_clearColor[0] = 1.0f;
3637
_clearColor[1] = 1.0f;
@@ -78,6 +79,12 @@ void LAppView::Initialize(int width, int height)
7879
_spriteShader = new LAppSpriteShader();
7980
}
8081

82+
void LAppView::ResizeWindow(int width, int height)
83+
{
84+
LAppView_Common::Initialize(width, height);
85+
}
86+
87+
8188
void LAppView::Render()
8289
{
8390
_back->Render();

Samples/OpenGL/Demo/proj.linux.cmake/src/LAppView.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ class LAppView : public LAppView_Common
5353
*/
5454
virtual void Initialize(int width, int height) override;
5555

56+
/**
57+
* @brief Resize the window view
58+
*
59+
* @param[in] width new view width
60+
* @param[in] height new view height
61+
*/
62+
void ResizeWindow(int width, int height);
63+
5664
/**
5765
* @brief 描画する。
5866
*/

0 commit comments

Comments
 (0)