Refactored Math::IntPoint in CInput and CImage
parent
0ef4579da8
commit
60deb0328a
|
@ -201,7 +201,7 @@ void CInput::EventProcess(Event& event)
|
|||
event.cameraInput = Math::Clamp(m_joyMotionCam + m_cameraKeyMotion, Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector(1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
void CInput::MouseMove(Math::IntPoint pos)
|
||||
void CInput::MouseMove(const glm::ivec2& pos)
|
||||
{
|
||||
m_mousePos = Gfx::CEngine::GetInstancePointer()->WindowToInterfaceCoords(pos);
|
||||
}
|
||||
|
|
|
@ -27,10 +27,11 @@
|
|||
#include "common/key.h"
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "math/intpoint.h"
|
||||
#include "math/point.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
struct Event;
|
||||
|
@ -78,7 +79,7 @@ public:
|
|||
void EventProcess(Event &event);
|
||||
|
||||
//! Called by CApplication on SDL MOUSE_MOTION event
|
||||
void MouseMove(Math::IntPoint pos);
|
||||
void MouseMove(const glm::ivec2& pos);
|
||||
|
||||
|
||||
//! Returns whether the key is pressed
|
||||
|
|
|
@ -169,7 +169,7 @@ CImage::CImage()
|
|||
m_data = nullptr;
|
||||
}
|
||||
|
||||
CImage::CImage(Math::IntPoint size)
|
||||
CImage::CImage(const glm::ivec2& size)
|
||||
{
|
||||
m_data = MakeUnique<ImageData>();
|
||||
m_data->surface = SDL_CreateRGBSurface(0, size.x, size.y, 32,
|
||||
|
@ -204,12 +204,12 @@ ImageData* CImage::GetData()
|
|||
return m_data.get();
|
||||
}
|
||||
|
||||
Math::IntPoint CImage::GetSize() const
|
||||
glm::ivec2 CImage::GetSize() const
|
||||
{
|
||||
if (m_data == nullptr)
|
||||
return Math::IntPoint();
|
||||
return { 0, 0 };
|
||||
|
||||
return Math::IntPoint(m_data->surface->w, m_data->surface->h);
|
||||
return { m_data->surface->w, m_data->surface->h };
|
||||
}
|
||||
|
||||
/** Image must be valid. */
|
||||
|
@ -268,7 +268,7 @@ void CImage::BlitToNewRGBASurface(int width, int height)
|
|||
* \param pixel pixel coords (range x: 0..width-1 y: 0..height-1)
|
||||
* \returns color
|
||||
*/
|
||||
Gfx::IntColor CImage::GetPixelInt(Math::IntPoint pixel)
|
||||
Gfx::IntColor CImage::GetPixelInt(const glm::ivec2& pixel)
|
||||
{
|
||||
assert(m_data != nullptr);
|
||||
assert(pixel.x >= 0 && pixel.x < m_data->surface->w);
|
||||
|
@ -316,7 +316,7 @@ Gfx::IntColor CImage::GetPixelInt(Math::IntPoint pixel)
|
|||
* \param pixel pixel coords (range x: 0..width-1 y: 0..height-1)
|
||||
* \returns color
|
||||
*/
|
||||
Gfx::Color CImage::GetPixel(Math::IntPoint pixel)
|
||||
Gfx::Color CImage::GetPixel(const glm::ivec2& pixel)
|
||||
{
|
||||
return Gfx::IntColorToColor(GetPixelInt(pixel));
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ Gfx::Color CImage::GetPixel(Math::IntPoint pixel)
|
|||
* \param pixel pixel coords (range x: 0..width-1 y: 0..height-1)
|
||||
* \param color color
|
||||
*/
|
||||
void CImage::SetPixelInt(Math::IntPoint pixel, Gfx::IntColor color)
|
||||
void CImage::SetPixelInt(const glm::ivec2& pixel, Gfx::IntColor color)
|
||||
{
|
||||
assert(m_data != nullptr);
|
||||
assert(pixel.x >= 0 && pixel.x < m_data->surface->w);
|
||||
|
@ -380,7 +380,7 @@ void CImage::SetPixelInt(Math::IntPoint pixel, Gfx::IntColor color)
|
|||
* \param pixel pixel coords (range x: 0..width-1 y: 0..height-1)
|
||||
* \param color color
|
||||
*/
|
||||
void CImage::SetPixel(Math::IntPoint pixel, Gfx::Color color)
|
||||
void CImage::SetPixel(const glm::ivec2& pixel, Gfx::Color color)
|
||||
{
|
||||
SetPixelInt(pixel, Gfx::ColorToIntColor(color));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "graphics/core/color.h"
|
||||
|
||||
#include "math/intpoint.h"
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
//! Constructs empty image (with nullptr data)
|
||||
CImage();
|
||||
//! Constructs a RGBA image of given size
|
||||
CImage(Math::IntPoint size);
|
||||
CImage(const glm::ivec2& size);
|
||||
//! Destroys image, calling Free()
|
||||
virtual ~CImage();
|
||||
|
||||
|
@ -74,22 +74,22 @@ public:
|
|||
ImageData* GetData();
|
||||
|
||||
//! Returns the image size
|
||||
Math::IntPoint GetSize() const;
|
||||
glm::ivec2 GetSize() const;
|
||||
|
||||
//! Fills the whole image with given color
|
||||
void Fill(Gfx::IntColor color);
|
||||
|
||||
//! Sets the color at given pixel
|
||||
void SetPixel(Math::IntPoint pixel, Gfx::Color color);
|
||||
void SetPixel(const glm::ivec2& pixel, Gfx::Color color);
|
||||
|
||||
//! Sets the precise color at given pixel
|
||||
void SetPixelInt(Math::IntPoint pixel, Gfx::IntColor color);
|
||||
void SetPixelInt(const glm::ivec2& pixel, Gfx::IntColor color);
|
||||
|
||||
//! Returns the color at given pixel
|
||||
Gfx::Color GetPixel(Math::IntPoint pixel);
|
||||
Gfx::Color GetPixel(const glm::ivec2& pixel);
|
||||
|
||||
//! Returns the precise color at given pixel
|
||||
Gfx::IntColor GetPixelInt(Math::IntPoint pixel);
|
||||
Gfx::IntColor GetPixelInt(const glm::ivec2& pixel);
|
||||
|
||||
//! Pads the image to nearest power of 2 dimensions
|
||||
void PadToNearestPowerOfTwo();
|
||||
|
|
Loading…
Reference in New Issue