Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernization #72

Open
wants to merge 3 commits into
base: Omega
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ const BYTE PixelShader[] =
};
#endif

CMyAddon::CMyAddon()
: m_asteroids(nullptr),
m_timer(nullptr)
{
}

////////////////////////////////////////////////////////////////////////////
// Kodi tells us we should get ready to start rendering. This function
// is called once when the screensaver is activated by Kodi.
Expand Down Expand Up @@ -127,11 +121,9 @@ bool CMyAddon::Start()
m_Height = Height();

srand((u32)time(nullptr));
m_asteroids = new CAsteroids(this);
if (!m_asteroids)
return false;
m_asteroids = std::make_unique<CAsteroids>(this);

m_timer = new CTimer();
m_timer = std::make_unique<CTimer>();
m_timer->Init();
if (!m_asteroids->RestoreDevice())
{
Expand Down Expand Up @@ -179,15 +171,13 @@ void CMyAddon::Stop()
#endif

m_asteroids->InvalidateDevice();
SAFE_DELETE(m_asteroids);
SAFE_DELETE(m_timer);

#ifndef WIN32
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &m_vertexVBO);
m_vertexVBO = 0;
delete m_VertBuf;

delete[] m_VertBuf;
m_VertBuf = nullptr;
#endif
}
Expand Down
8 changes: 5 additions & 3 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <d3d11.h>
#endif

#include <memory>

#include <stdio.h>
#include <stdlib.h>
#include "types.h"
Expand Down Expand Up @@ -47,7 +49,7 @@ class ATTR_DLL_LOCAL CMyAddon
#endif
{
public:
CMyAddon();
CMyAddon() = default;

bool Start() override;
void Stop() override;
Expand Down Expand Up @@ -83,8 +85,8 @@ class ATTR_DLL_LOCAL CMyAddon
ID3D11PixelShader* m_pPShader;
#endif

CAsteroids* m_asteroids;
CTimer* m_timer;
std::unique_ptr<CAsteroids> m_asteroids;
std::unique_ptr<CTimer> m_timer;
};

/***************************** I N L I N E S *******************************/