stuff-from-scratch/src/graphics/DrawingSurface.cpp

52 lines
859 B
C++
Raw Normal View History

2021-04-17 12:57:14 +00:00
#include "DrawingSurface.h"
2022-05-15 15:14:04 +00:00
#include "Image.h"
2022-11-16 15:06:08 +00:00
#include "Scene.h"
#include "RootNode.h"
DrawingSurface::DrawingSurface()
{
}
2021-04-17 12:57:14 +00:00
std::unique_ptr<DrawingSurface> DrawingSurface::Create()
{
return std::make_unique<DrawingSurface>();
}
2022-11-14 11:19:51 +00:00
void DrawingSurface::setSize(unsigned width, unsigned height)
2021-04-17 12:57:14 +00:00
{
mWidth = width;
mHeight = height;
}
2022-11-14 11:19:51 +00:00
unsigned DrawingSurface::getWidth() const
2021-04-17 12:57:14 +00:00
{
return mWidth;
}
2022-11-14 11:19:51 +00:00
unsigned DrawingSurface::getHeight() const
2021-04-17 12:57:14 +00:00
{
return mHeight;
}
2022-05-15 13:58:31 +00:00
2022-11-16 15:06:08 +00:00
Scene* DrawingSurface::getScene()
{
if (!mScene)
{
mScene = std::make_unique<Scene>();
}
return mScene.get();
}
2022-11-14 11:19:51 +00:00
Image<unsigned char>* DrawingSurface::getImage()
2022-05-15 13:58:31 +00:00
{
2022-11-14 11:19:51 +00:00
if (!mBackingImage)
{
mBackingImage = std::make_unique<Image<unsigned char> >(mWidth, mHeight);
mBackingImage->initialize();
}
return mBackingImage.get();
2022-05-15 13:58:31 +00:00
}