|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
olcPixelGameEngine.h |
|
|
|
|
|
|
|
|
|
+-------------------------------------------------------------+ |
|
|
|
|
| OneLoneCoder Pixel Game Engine v2.06 | |
|
|
|
|
| OneLoneCoder Pixel Game Engine v2.07 | |
|
|
|
|
| "What do you need? Pixels... Lots of Pixels..." - javidx9 | |
|
|
|
|
+-------------------------------------------------------------+ |
|
|
|
|
|
|
|
|
@ -109,9 +109,9 @@ |
|
|
|
|
~~~~~~ |
|
|
|
|
I'd like to extend thanks to Eremiell, slavka, gurkanctn, Phantim, IProgramInCPP |
|
|
|
|
JackOJC, KrossX, Huhlig, Dragoneye, Appa, JustinRichardsMusic, SliceNDice, dandistine |
|
|
|
|
Ralakus, Gorbit99, raoul, joshinils, benedani, Moros1138, SaladinAkara & MagetzUb
|
|
|
|
|
Ralakus, Gorbit99, raoul, joshinils, benedani, Moros1138, Alexio, SaladinAkara & MagetzUb |
|
|
|
|
for advice, ideas and testing, and I'd like to extend my appreciation to the |
|
|
|
|
164K YouTube followers, 70+ Patreons and 8K Discord server members who give me
|
|
|
|
|
174K YouTube followers, 70+ Patreons and 8K Discord server members who give me |
|
|
|
|
the motivation to keep going with all this :D |
|
|
|
|
|
|
|
|
|
Significant Contributors: @Moros1138, @SaladinAkara, @MaGetzUb, @slavka, @Dragoneye & @Gorbit99 |
|
|
|
@ -135,17 +135,26 @@ |
|
|
|
|
2.02: Added Decal destructor, optimised Pixel constructor |
|
|
|
|
2.03: Added FreeBSD flags, Added DrawStringDecal() |
|
|
|
|
2.04: Windows Full-Screen bug fixed |
|
|
|
|
2.05: Added DrawPartialWarpedDecal(), Added DrawPartialRotatedDecal() |
|
|
|
|
2.05: +DrawPartialWarpedDecal() - draws a warped decal from a subset image |
|
|
|
|
+DrawPartialRotatedDecal() - draws a rotated decal from a subset image |
|
|
|
|
2.06: +GetTextSize() - returns area occupied by multiline string |
|
|
|
|
+GetWindowSize() - returns actual window size |
|
|
|
|
+GetElapsedTime() - returns last calculated fElapsedTime |
|
|
|
|
+GetWindowMouse() - returns actual mouse location in window |
|
|
|
|
+DrawExplicitDecal() - bow-chikka-bow-bow |
|
|
|
|
+DrawPartialDecal(pos, size) - draws a partial decal to dpecified area |
|
|
|
|
+DrawPartialDecal(pos, size) - draws a partial decal to specified area |
|
|
|
|
+FillRectDecal() - draws a flat shaded rectangle as a decal |
|
|
|
|
+GradientFillRectDecal() - draws a rectangle, with unique colour corners |
|
|
|
|
+Modified DrawCircle() & FillCircle() - Thanks IanM-Matrix1 (#PR121) |
|
|
|
|
+Gone someway to appeasing pedants |
|
|
|
|
2.07: +GetPixelSize() - returns user specified pixel size |
|
|
|
|
+GetScreenPixelSize() - returns actual size in monitor pixels |
|
|
|
|
+Pixel Cohesion Mode (flag in Construct()) - disallows arbitrary window scaling |
|
|
|
|
+Working VSYNC in Windows windowed application - now much smoother |
|
|
|
|
+Added string conversion for olc::vectors |
|
|
|
|
+Added comparator operators for olc::vectors |
|
|
|
|
+Added DestroyWindow() on windows platforms for serial PGE launches |
|
|
|
|
+Added GetMousePos() to stop TarriestPython whinging |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
@ -340,7 +349,7 @@ namespace olc |
|
|
|
|
v2d_generic() : x(0), y(0) { } |
|
|
|
|
v2d_generic(T _x, T _y) : x(_x), y(_y) { } |
|
|
|
|
v2d_generic(const v2d_generic& v) : x(v.x), y(v.y) { } |
|
|
|
|
T mag() { return std::sqrt(x * x + y * y); } |
|
|
|
|
T mag() { return T(std::sqrt(x * x + y * y)); } |
|
|
|
|
T mag2() { return x * x + y * y; } |
|
|
|
|
v2d_generic norm() { T r = 1 / mag(); return v2d_generic(x * r, y * r); } |
|
|
|
|
v2d_generic perp() { return v2d_generic(-y, x); } |
|
|
|
@ -356,6 +365,10 @@ namespace olc |
|
|
|
|
v2d_generic& operator -= (const v2d_generic& rhs) { this->x -= rhs.x; this->y -= rhs.y; return *this; } |
|
|
|
|
v2d_generic& operator *= (const T& rhs) { this->x *= rhs; this->y *= rhs; return *this; } |
|
|
|
|
v2d_generic& operator /= (const T& rhs) { this->x /= rhs; this->y /= rhs; return *this; } |
|
|
|
|
bool operator == (const v2d_generic& rhs) const { return (this->x == rhs.x && this->y == rhs.y); } |
|
|
|
|
bool operator != (const v2d_generic& rhs) const { return (this->x != rhs.x || this->y != rhs.y); } |
|
|
|
|
const std::string str() const { return std::string("(") + std::to_string(this->x) + "," + std::to_string(this->y) + ")"; } |
|
|
|
|
friend std::ostream& operator << (std::ostream& os, const v2d_generic& rhs) { os << rhs.str(); return os; } |
|
|
|
|
operator v2d_generic<int32_t>() const { return { static_cast<int32_t>(this->x), static_cast<int32_t>(this->y) }; } |
|
|
|
|
operator v2d_generic<float>() const { return { static_cast<float>(this->x), static_cast<float>(this->y) }; } |
|
|
|
|
operator v2d_generic<double>() const { return { static_cast<double>(this->x), static_cast<double>(this->y) }; } |
|
|
|
@ -364,17 +377,29 @@ namespace olc |
|
|
|
|
// Note: joshinils has some good suggestions here, but they are complicated to implement at this moment,
|
|
|
|
|
// however they will appear in a future version of PGE
|
|
|
|
|
template<class T> inline v2d_generic<T> operator * (const float& lhs, const v2d_generic<T>& rhs) |
|
|
|
|
{ return v2d_generic<T>((T)(lhs * (float)rhs.x), (T)(lhs * (float)rhs.y)); } |
|
|
|
|
{ |
|
|
|
|
return v2d_generic<T>((T)(lhs * (float)rhs.x), (T)(lhs * (float)rhs.y)); |
|
|
|
|
} |
|
|
|
|
template<class T> inline v2d_generic<T> operator * (const double& lhs, const v2d_generic<T>& rhs) |
|
|
|
|
{ return v2d_generic<T>((T)(lhs * (double)rhs.x), (T)(lhs * (double)rhs.y)); } |
|
|
|
|
{ |
|
|
|
|
return v2d_generic<T>((T)(lhs * (double)rhs.x), (T)(lhs * (double)rhs.y)); |
|
|
|
|
} |
|
|
|
|
template<class T> inline v2d_generic<T> operator * (const int& lhs, const v2d_generic<T>& rhs) |
|
|
|
|
{ return v2d_generic<T>((T)(lhs * (int)rhs.x), (T)(lhs * (int)rhs.y)); } |
|
|
|
|
{ |
|
|
|
|
return v2d_generic<T>((T)(lhs * (int)rhs.x), (T)(lhs * (int)rhs.y)); |
|
|
|
|
} |
|
|
|
|
template<class T> inline v2d_generic<T> operator / (const float& lhs, const v2d_generic<T>& rhs) |
|
|
|
|
{ return v2d_generic<T>((T)(lhs / (float)rhs.x), (T)(lhs / (float)rhs.y)); } |
|
|
|
|
{ |
|
|
|
|
return v2d_generic<T>((T)(lhs / (float)rhs.x), (T)(lhs / (float)rhs.y)); |
|
|
|
|
} |
|
|
|
|
template<class T> inline v2d_generic<T> operator / (const double& lhs, const v2d_generic<T>& rhs) |
|
|
|
|
{ return v2d_generic<T>((T)(lhs / (double)rhs.x), (T)(lhs / (double)rhs.y)); } |
|
|
|
|
{ |
|
|
|
|
return v2d_generic<T>((T)(lhs / (double)rhs.x), (T)(lhs / (double)rhs.y)); |
|
|
|
|
} |
|
|
|
|
template<class T> inline v2d_generic<T> operator / (const int& lhs, const v2d_generic<T>& rhs) |
|
|
|
|
{ return v2d_generic<T>((T)(lhs / (int)rhs.x), (T)(lhs / (int)rhs.y)); } |
|
|
|
|
{ |
|
|
|
|
return v2d_generic<T>((T)(lhs / (int)rhs.x), (T)(lhs / (int)rhs.y)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
typedef v2d_generic<int32_t> vi2d; |
|
|
|
|
typedef v2d_generic<uint32_t> vu2d; |
|
|
|
@ -576,7 +601,7 @@ namespace olc |
|
|
|
|
virtual ~PixelGameEngine(); |
|
|
|
|
public: |
|
|
|
|
olc::rcode Construct(int32_t screen_w, int32_t screen_h, int32_t pixel_w, int32_t pixel_h, |
|
|
|
|
bool full_screen = false, bool vsync = false); |
|
|
|
|
bool full_screen = false, bool vsync = false, bool cohesion = false); |
|
|
|
|
olc::rcode Start(); |
|
|
|
|
|
|
|
|
|
public: // User Override Interfaces
|
|
|
|
@ -595,13 +620,15 @@ namespace olc |
|
|
|
|
// Get the state of a specific mouse button
|
|
|
|
|
HWButton GetMouse(uint32_t b); |
|
|
|
|
// Get Mouse X coordinate in "pixel" space
|
|
|
|
|
int32_t GetMouseX(); |
|
|
|
|
int32_t GetMouseX() const; |
|
|
|
|
// Get Mouse Y coordinate in "pixel" space
|
|
|
|
|
int32_t GetMouseY(); |
|
|
|
|
int32_t GetMouseY() const; |
|
|
|
|
// Get Mouse Wheel Delta
|
|
|
|
|
int32_t GetMouseWheel(); |
|
|
|
|
// Get the ouse in window space
|
|
|
|
|
// Get the mouse in window space
|
|
|
|
|
const olc::vi2d& GetWindowMouse() const; |
|
|
|
|
// Gets the mouse as a vector to keep Tarriest happy
|
|
|
|
|
const olc::vi2d& GetMousePos() const; |
|
|
|
|
|
|
|
|
|
public: // Utility
|
|
|
|
|
// Returns the width of the screen in "pixels"
|
|
|
|
@ -625,6 +652,10 @@ namespace olc |
|
|
|
|
const float GetElapsedTime() const; |
|
|
|
|
// Gets Actual Window size
|
|
|
|
|
const olc::vi2d& GetWindowSize() const; |
|
|
|
|
// Gets pixel scale
|
|
|
|
|
const olc::vi2d& GetPixelSize() const; |
|
|
|
|
// Gets actual pixel scale
|
|
|
|
|
const olc::vi2d& GetScreenPixelSize() const; |
|
|
|
|
|
|
|
|
|
public: // CONFIGURATION ROUTINES
|
|
|
|
|
// Layer targeting functions
|
|
|
|
@ -737,6 +768,7 @@ namespace olc |
|
|
|
|
olc::vi2d vScreenSize = { 256, 240 }; |
|
|
|
|
olc::vf2d vInvScreenSize = { 1.0f / 256.0f, 1.0f / 240.0f }; |
|
|
|
|
olc::vi2d vPixelSize = { 4, 4 }; |
|
|
|
|
olc::vi2d vScreenPixelSize = { 4, 4 }; |
|
|
|
|
olc::vi2d vMousePos = { 0, 0 }; |
|
|
|
|
int32_t nMouseWheelDelta = 0; |
|
|
|
|
olc::vi2d vMousePosCache = { 0, 0 }; |
|
|
|
@ -759,6 +791,7 @@ namespace olc |
|
|
|
|
std::vector<LayerDesc> vLayers; |
|
|
|
|
uint8_t nTargetLayer = 0; |
|
|
|
|
uint32_t nLastFPS = 0; |
|
|
|
|
bool bPixelCohesion = false; |
|
|
|
|
std::function<olc::Pixel(const int x, const int y, const olc::Pixel&, const olc::Pixel&)> funcPixelMode; |
|
|
|
|
std::chrono::time_point<std::chrono::system_clock> m_tp1, m_tp2; |
|
|
|
|
|
|
|
|
@ -858,20 +891,30 @@ namespace olc |
|
|
|
|
// | olc::Pixel IMPLEMENTATION |
|
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
|
|
Pixel::Pixel() |
|
|
|
|
{ r = 0; g = 0; b = 0; a = nDefaultAlpha; } |
|
|
|
|
{ |
|
|
|
|
r = 0; g = 0; b = 0; a = nDefaultAlpha; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pixel::Pixel(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) |
|
|
|
|
{ n = red | (green << 8) | (blue << 16) | (alpha << 24); } // Thanks jarekpelczar
|
|
|
|
|
{ |
|
|
|
|
n = red | (green << 8) | (blue << 16) | (alpha << 24); |
|
|
|
|
} // Thanks jarekpelczar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pixel::Pixel(uint32_t p) |
|
|
|
|
{ n = p; } |
|
|
|
|
{ |
|
|
|
|
n = p; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Pixel::operator==(const Pixel& p) const |
|
|
|
|
{ return n == p.n; } |
|
|
|
|
{ |
|
|
|
|
return n == p.n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Pixel::operator!=(const Pixel& p) const |
|
|
|
|
{ return n != p.n; } |
|
|
|
|
{ |
|
|
|
|
return n != p.n; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pixel PixelF(float red, float green, float blue, float alpha) |
|
|
|
|
{ |
|
|
|
@ -882,10 +925,14 @@ namespace olc |
|
|
|
|
// | olc::Sprite IMPLEMENTATION |
|
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
|
|
Sprite::Sprite() |
|
|
|
|
{ pColData = nullptr; width = 0; height = 0; } |
|
|
|
|
{ |
|
|
|
|
pColData = nullptr; width = 0; height = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Sprite::Sprite(const std::string& sImageFile, olc::ResourcePack* pack) |
|
|
|
|
{ LoadFromFile(sImageFile, pack); } |
|
|
|
|
{ |
|
|
|
|
LoadFromFile(sImageFile, pack); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Sprite::Sprite(int32_t w, int32_t h) |
|
|
|
|
{ |
|
|
|
@ -897,7 +944,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Sprite::~Sprite() |
|
|
|
|
{ if (pColData) delete[] pColData; } |
|
|
|
|
{ |
|
|
|
|
if (pColData) delete[] pColData; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
olc::rcode Sprite::LoadFromPGESprFile(const std::string& sImageFile, olc::ResourcePack* pack) |
|
|
|
@ -954,13 +1003,19 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Sprite::SetSampleMode(olc::Sprite::Mode mode) |
|
|
|
|
{ modeSample = mode; } |
|
|
|
|
{ |
|
|
|
|
modeSample = mode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pixel Sprite::GetPixel(const olc::vi2d& a) const |
|
|
|
|
{ return GetPixel(a.x, a.y); } |
|
|
|
|
{ |
|
|
|
|
return GetPixel(a.x, a.y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Sprite::SetPixel(const olc::vi2d& a, Pixel p) |
|
|
|
|
{ return SetPixel(a.x, a.y, p); } |
|
|
|
|
{ |
|
|
|
|
return SetPixel(a.x, a.y, p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pixel Sprite::GetPixel(int32_t x, int32_t y) const |
|
|
|
|
{ |
|
|
|
@ -1018,7 +1073,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pixel* Sprite::GetData() |
|
|
|
|
{ return pColData; } |
|
|
|
|
{ |
|
|
|
|
return pColData; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
|
@ -1073,10 +1130,14 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
olc::Decal* Renderable::Decal() const |
|
|
|
|
{ return pDecal.get(); } |
|
|
|
|
{ |
|
|
|
|
return pDecal.get(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
olc::Sprite* Renderable::Sprite() const |
|
|
|
|
{ return pSprite.get(); } |
|
|
|
|
{ |
|
|
|
|
return pSprite.get(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// O------------------------------------------------------------------------------O
|
|
|
|
|
// | olc::ResourcePack IMPLEMENTATION |
|
|
|
|
@ -1236,10 +1297,14 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ResourceBuffer ResourcePack::GetFileBuffer(const std::string& sFile) |
|
|
|
|
{ return ResourceBuffer(baseFile, mapFiles[sFile].nOffset, mapFiles[sFile].nSize); } |
|
|
|
|
{ |
|
|
|
|
return ResourceBuffer(baseFile, mapFiles[sFile].nOffset, mapFiles[sFile].nSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool ResourcePack::Loaded() |
|
|
|
|
{ return baseFile.is_open(); } |
|
|
|
|
{ |
|
|
|
|
return baseFile.is_open(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector<char> ResourcePack::scramble(const std::vector<char>& data, const std::string& key) |
|
|
|
|
{ |
|
|
|
@ -1274,8 +1339,9 @@ namespace olc |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
olc::rcode PixelGameEngine::Construct(int32_t screen_w, int32_t screen_h, int32_t pixel_w, int32_t pixel_h, bool full_screen, bool vsync) |
|
|
|
|
olc::rcode PixelGameEngine::Construct(int32_t screen_w, int32_t screen_h, int32_t pixel_w, int32_t pixel_h, bool full_screen, bool vsync, bool cohesion) |
|
|
|
|
{ |
|
|
|
|
bPixelCohesion = cohesion; |
|
|
|
|
vScreenSize = { screen_w, screen_h }; |
|
|
|
|
vInvScreenSize = { 1.0f / float(screen_w), 1.0f / float(screen_h) }; |
|
|
|
|
vPixelSize = { pixel_w, pixel_h }; |
|
|
|
@ -1358,28 +1424,44 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::EnableLayer(uint8_t layer, bool b) |
|
|
|
|
{ if(layer < vLayers.size()) vLayers[layer].bShow = b; } |
|
|
|
|
{ |
|
|
|
|
if (layer < vLayers.size()) vLayers[layer].bShow = b; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetLayerOffset(uint8_t layer, const olc::vf2d& offset) |
|
|
|
|
{ SetLayerOffset(layer, offset.x, offset.y); } |
|
|
|
|
{ |
|
|
|
|
SetLayerOffset(layer, offset.x, offset.y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetLayerOffset(uint8_t layer, float x, float y) |
|
|
|
|
{ if (layer < vLayers.size()) vLayers[layer].vOffset = { x, y }; } |
|
|
|
|
{ |
|
|
|
|
if (layer < vLayers.size()) vLayers[layer].vOffset = { x, y }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetLayerScale(uint8_t layer, const olc::vf2d& scale) |
|
|
|
|
{ SetLayerScale(layer, scale.x, scale.y); } |
|
|
|
|
{ |
|
|
|
|
SetLayerScale(layer, scale.x, scale.y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetLayerScale(uint8_t layer, float x, float y) |
|
|
|
|
{ if (layer < vLayers.size()) vLayers[layer].vScale = { x, y }; } |
|
|
|
|
{ |
|
|
|
|
if (layer < vLayers.size()) vLayers[layer].vScale = { x, y }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetLayerTint(uint8_t layer, const olc::Pixel& tint) |
|
|
|
|
{ if (layer < vLayers.size()) vLayers[layer].tint = tint; } |
|
|
|
|
{ |
|
|
|
|
if (layer < vLayers.size()) vLayers[layer].tint = tint; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetLayerCustomRenderFunction(uint8_t layer, std::function<void()> f) |
|
|
|
|
{ if (layer < vLayers.size()) vLayers[layer].funcHook = f; } |
|
|
|
|
{ |
|
|
|
|
if (layer < vLayers.size()) vLayers[layer].funcHook = f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector<LayerDesc>& PixelGameEngine::GetLayers() |
|
|
|
|
{ return vLayers; } |
|
|
|
|
{ |
|
|
|
|
return vLayers; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t PixelGameEngine::CreateLayer() |
|
|
|
|
{ |
|
|
|
@ -1392,7 +1474,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Sprite* PixelGameEngine::GetDrawTarget() |
|
|
|
|
{ return pDrawTarget; } |
|
|
|
|
{ |
|
|
|
|
return pDrawTarget; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int32_t PixelGameEngine::GetDrawTargetWidth() |
|
|
|
|
{ |
|
|
|
@ -1411,40 +1495,79 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t PixelGameEngine::GetFPS() |
|
|
|
|
{ return nLastFPS; } |
|
|
|
|
{ |
|
|
|
|
return nLastFPS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool PixelGameEngine::IsFocused() |
|
|
|
|
{ return bHasInputFocus; } |
|
|
|
|
{ |
|
|
|
|
return bHasInputFocus; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HWButton PixelGameEngine::GetKey(Key k) |
|
|
|
|
{ return pKeyboardState[k]; } |
|
|
|
|
{ |
|
|
|
|
return pKeyboardState[k]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HWButton PixelGameEngine::GetMouse(uint32_t b) |
|
|
|
|
{ return pMouseState[b]; } |
|
|
|
|
{ |
|
|
|
|
return pMouseState[b]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int32_t PixelGameEngine::GetMouseX() |
|
|
|
|
{ return vMousePos.x; } |
|
|
|
|
int32_t PixelGameEngine::GetMouseX() const |
|
|
|
|
{ |
|
|
|
|
return vMousePos.x; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int32_t PixelGameEngine::GetMouseY() |
|
|
|
|
{ return vMousePos.y; } |
|
|
|
|
int32_t PixelGameEngine::GetMouseY() const |
|
|
|
|
{ |
|
|
|
|
return vMousePos.y; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const olc::vi2d& PixelGameEngine::GetMousePos() const |
|
|
|
|
{ |
|
|
|
|
return vMousePos; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int32_t PixelGameEngine::GetMouseWheel() |
|
|
|
|
{ return nMouseWheelDelta; } |
|
|
|
|
{ |
|
|
|
|
return nMouseWheelDelta; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int32_t PixelGameEngine::ScreenWidth() |
|
|
|
|
{ return vScreenSize.x; } |
|
|
|
|
{ |
|
|
|
|
return vScreenSize.x; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int32_t PixelGameEngine::ScreenHeight() |
|
|
|
|
{ return vScreenSize.y; } |
|
|
|
|
{ |
|
|
|
|
return vScreenSize.y; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const float PixelGameEngine::GetElapsedTime() const |
|
|
|
|
{ return fLastElapsed; } |
|
|
|
|
{ |
|
|
|
|
return fLastElapsed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const olc::vi2d& PixelGameEngine::GetWindowSize() const |
|
|
|
|
{ return vWindowSize; } |
|
|
|
|
{ |
|
|
|
|
return vWindowSize; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const olc::vi2d& PixelGameEngine::GetPixelSize() const |
|
|
|
|
{ |
|
|
|
|
return vPixelSize; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const olc::vi2d& PixelGameEngine::GetScreenPixelSize() const |
|
|
|
|
{ |
|
|
|
|
return vScreenPixelSize; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const olc::vi2d& PixelGameEngine::GetWindowMouse() const |
|
|
|
|
{ return vMouseWindowPos; } |
|
|
|
|
{ |
|
|
|
|
return vMouseWindowPos; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1458,7 +1581,9 @@ namespace olc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool PixelGameEngine::Draw(const olc::vi2d& pos, Pixel p) |
|
|
|
|
{ return Draw(pos.x, pos.y, p); } |
|
|
|
|
{ |
|
|
|
|
return Draw(pos.x, pos.y, p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// This is it, the critical function that plots a pixel
|
|
|
|
|
bool PixelGameEngine::Draw(int32_t x, int32_t y, Pixel p) |
|
|
|
@ -1502,7 +1627,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawLine(const olc::vi2d& pos1, const olc::vi2d& pos2, Pixel p, uint32_t pattern) |
|
|
|
|
{ DrawLine(pos1.x, pos1.y, pos2.x, pos2.y, p, pattern); } |
|
|
|
|
{ |
|
|
|
|
DrawLine(pos1.x, pos1.y, pos2.x, pos2.y, p, pattern); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, Pixel p, uint32_t pattern) |
|
|
|
|
{ |
|
|
|
@ -1532,9 +1659,13 @@ namespace olc |
|
|
|
|
if (dy1 <= dx1) |
|
|
|
|
{ |
|
|
|
|
if (dx >= 0) |
|
|
|
|
{ x = x1; y = y1; xe = x2; } |
|
|
|
|
{ |
|
|
|
|
x = x1; y = y1; xe = x2; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ x = x2; y = y2; xe = x1; } |
|
|
|
|
{ |
|
|
|
|
x = x2; y = y2; xe = x1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (rol()) Draw(x, y, p); |
|
|
|
|
|
|
|
|
@ -1554,9 +1685,13 @@ namespace olc |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (dy >= 0) |
|
|
|
|
{ x = x1; y = y1; ye = y2; } |
|
|
|
|
{ |
|
|
|
|
x = x1; y = y1; ye = y2; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ x = x2; y = y2; ye = y1; } |
|
|
|
|
{ |
|
|
|
|
x = x2; y = y2; ye = y1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (rol()) Draw(x, y, p); |
|
|
|
|
|
|
|
|
@ -1576,7 +1711,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawCircle(const olc::vi2d& pos, int32_t radius, Pixel p, uint8_t mask) |
|
|
|
|
{ DrawCircle(pos.x, pos.y, radius, p, mask);} |
|
|
|
|
{ |
|
|
|
|
DrawCircle(pos.x, pos.y, radius, p, mask); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawCircle(int32_t x, int32_t y, int32_t radius, Pixel p, uint8_t mask) |
|
|
|
|
{ // Thanks to IanM-Matrix1 #PR121
|
|
|
|
@ -1615,7 +1752,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::FillCircle(const olc::vi2d& pos, int32_t radius, Pixel p) |
|
|
|
|
{ FillCircle(pos.x, pos.y, radius, p); } |
|
|
|
|
{ |
|
|
|
|
FillCircle(pos.x, pos.y, radius, p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::FillCircle(int32_t x, int32_t y, int32_t radius, Pixel p) |
|
|
|
|
{ // Thanks to IanM-Matrix1 #PR121
|
|
|
|
@ -1657,7 +1796,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawRect(const olc::vi2d& pos, const olc::vi2d& size, Pixel p) |
|
|
|
|
{ DrawRect(pos.x, pos.y, size.x, size.y, p); } |
|
|
|
|
{ |
|
|
|
|
DrawRect(pos.x, pos.y, size.x, size.y, p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawRect(int32_t x, int32_t y, int32_t w, int32_t h, Pixel p) |
|
|
|
|
{ |
|
|
|
@ -1680,7 +1821,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::FillRect(const olc::vi2d& pos, const olc::vi2d& size, Pixel p) |
|
|
|
|
{ FillRect(pos.x, pos.y, size.x, size.y, p); } |
|
|
|
|
{ |
|
|
|
|
FillRect(pos.x, pos.y, size.x, size.y, p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::FillRect(int32_t x, int32_t y, int32_t w, int32_t h, Pixel p) |
|
|
|
|
{ |
|
|
|
@ -1703,7 +1846,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawTriangle(const olc::vi2d& pos1, const olc::vi2d& pos2, const olc::vi2d& pos3, Pixel p) |
|
|
|
|
{ DrawTriangle(pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, p); } |
|
|
|
|
{ |
|
|
|
|
DrawTriangle(pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, Pixel p) |
|
|
|
|
{ |
|
|
|
@ -1713,7 +1858,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::FillTriangle(const olc::vi2d& pos1, const olc::vi2d& pos2, const olc::vi2d& pos3, Pixel p) |
|
|
|
|
{ FillTriangle(pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, p); } |
|
|
|
|
{ |
|
|
|
|
FillTriangle(pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// https://www.avrfreaks.net/sites/default/files/triangles.c
|
|
|
|
|
void PixelGameEngine::FillTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, Pixel p) |
|
|
|
@ -1732,11 +1879,13 @@ namespace olc |
|
|
|
|
|
|
|
|
|
t1x = t2x = x1; y = y1; // Starting points
|
|
|
|
|
dx1 = (int)(x2 - x1); |
|
|
|
|
if (dx1<0) { dx1 = -dx1; signx1 = -1; } else signx1 = 1; |
|
|
|
|
if (dx1 < 0) { dx1 = -dx1; signx1 = -1; } |
|
|
|
|
else signx1 = 1; |
|
|
|
|
dy1 = (int)(y2 - y1); |
|
|
|
|
|
|
|
|
|
dx2 = (int)(x3 - x1); |
|
|
|
|
if (dx2<0) { dx2 = -dx2; signx2 = -1; } else signx2 = 1; |
|
|
|
|
if (dx2 < 0) { dx2 = -dx2; signx2 = -1; } |
|
|
|
|
else signx2 = 1; |
|
|
|
|
dy2 = (int)(y3 - y1); |
|
|
|
|
|
|
|
|
|
if (dy1 > dx1) { std::swap(dx1, dy1); changed1 = true; } |
|
|
|
@ -1851,7 +2000,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawSprite(const olc::vi2d& pos, Sprite* sprite, uint32_t scale, uint8_t flip) |
|
|
|
|
{ DrawSprite(pos.x, pos.y, sprite, scale, flip); } |
|
|
|
|
{ |
|
|
|
|
DrawSprite(pos.x, pos.y, sprite, scale, flip); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawSprite(int32_t x, int32_t y, Sprite* sprite, uint32_t scale, uint8_t flip) |
|
|
|
|
{ |
|
|
|
@ -1888,7 +2039,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawPartialSprite(const olc::vi2d& pos, Sprite* sprite, const olc::vi2d& sourcepos, const olc::vi2d& size, uint32_t scale, uint8_t flip) |
|
|
|
|
{ DrawPartialSprite(pos.x, pos.y, sprite, sourcepos.x, sourcepos.y, size.x, size.y, scale, flip); } |
|
|
|
|
{ |
|
|
|
|
DrawPartialSprite(pos.x, pos.y, sprite, sourcepos.x, sourcepos.y, size.x, size.y, scale, flip); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawPartialSprite(int32_t x, int32_t y, Sprite* sprite, int32_t ox, int32_t oy, int32_t w, int32_t h, uint32_t scale, uint8_t flip) |
|
|
|
|
{ |
|
|
|
@ -2134,16 +2287,24 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawWarpedDecal(olc::Decal* decal, const std::array<olc::vf2d, 4>& pos, const olc::Pixel& tint) |
|
|
|
|
{ DrawWarpedDecal(decal, pos.data(), tint); } |
|
|
|
|
{ |
|
|
|
|
DrawWarpedDecal(decal, pos.data(), tint); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::Pixel& tint) |
|
|
|
|
{ DrawWarpedDecal(decal, &pos[0], tint); } |
|
|
|
|
{ |
|
|
|
|
DrawWarpedDecal(decal, &pos[0], tint); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawPartialWarpedDecal(olc::Decal* decal, const std::array<olc::vf2d, 4>& pos, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint) |
|
|
|
|
{ DrawPartialWarpedDecal(decal, pos.data(), source_pos, source_size, tint); } |
|
|
|
|
{ |
|
|
|
|
DrawPartialWarpedDecal(decal, pos.data(), source_pos, source_size, tint); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawPartialWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint) |
|
|
|
|
{ DrawPartialWarpedDecal(decal, &pos[0], source_pos, source_size, tint); } |
|
|
|
|
{ |
|
|
|
|
DrawPartialWarpedDecal(decal, &pos[0], source_pos, source_size, tint); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const olc::vf2d& scale) |
|
|
|
|
{ |
|
|
|
@ -2179,7 +2340,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawString(const olc::vi2d& pos, const std::string& sText, Pixel col, uint32_t scale) |
|
|
|
|
{ DrawString(pos.x, pos.y, sText, col, scale); } |
|
|
|
|
{ |
|
|
|
|
DrawString(pos.x, pos.y, sText, col, scale); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawString(int32_t x, int32_t y, const std::string& sText, Pixel col, uint32_t scale) |
|
|
|
|
{ |
|
|
|
@ -2223,10 +2386,14 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetPixelMode(Pixel::Mode m) |
|
|
|
|
{ nPixelMode = m; } |
|
|
|
|
{ |
|
|
|
|
nPixelMode = m; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pixel::Mode PixelGameEngine::GetPixelMode() |
|
|
|
|
{ return nPixelMode; } |
|
|
|
|
{ |
|
|
|
|
return nPixelMode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::SetPixelMode(std::function<olc::Pixel(const int x, const int y, const olc::Pixel&, const olc::Pixel&)> pixelMode) |
|
|
|
|
{ |
|
|
|
@ -2246,13 +2413,19 @@ namespace olc |
|
|
|
|
// they are not overwritten
|
|
|
|
|
|
|
|
|
|
bool PixelGameEngine::OnUserCreate() |
|
|
|
|
{ return false; } |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool PixelGameEngine::OnUserUpdate(float fElapsedTime) |
|
|
|
|
{ UNUSED(fElapsedTime); return false; } |
|
|
|
|
{ |
|
|
|
|
UNUSED(fElapsedTime); return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool PixelGameEngine::OnUserDestroy() |
|
|
|
|
{ return true; } |
|
|
|
|
{ |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void PixelGameEngine::olc_UpdateViewport() |
|
|
|
@ -2261,6 +2434,13 @@ namespace olc |
|
|
|
|
int32_t wh = vScreenSize.y * vPixelSize.y; |
|
|
|
|
float wasp = (float)ww / (float)wh; |
|
|
|
|
|
|
|
|
|
if (bPixelCohesion) |
|
|
|
|
{ |
|
|
|
|
vScreenPixelSize = (vWindowSize / vScreenSize); |
|
|
|
|
vViewSize = (vWindowSize / vScreenSize) * vScreenSize; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
vViewSize.x = (int32_t)vWindowSize.x; |
|
|
|
|
vViewSize.y = (int32_t)((float)vViewSize.x / wasp); |
|
|
|
|
|
|
|
|
@ -2269,6 +2449,7 @@ namespace olc |
|
|
|
|
vViewSize.y = vWindowSize.y; |
|
|
|
|
vViewSize.x = (int32_t)((float)vViewSize.y * wasp); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vViewPos = (vWindowSize - vViewSize) / 2; |
|
|
|
|
} |
|
|
|
@ -2280,7 +2461,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::olc_UpdateMouseWheel(int32_t delta) |
|
|
|
|
{ nMouseWheelDeltaCache += delta; } |
|
|
|
|
{ |
|
|
|
|
nMouseWheelDeltaCache += delta; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::olc_UpdateMouse(int32_t x, int32_t y) |
|
|
|
|
{ |
|
|
|
@ -2300,19 +2483,29 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::olc_UpdateMouseState(int32_t button, bool state) |
|
|
|
|
{ pMouseNewState[button] = state; } |
|
|
|
|
{ |
|
|
|
|
pMouseNewState[button] = state; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::olc_UpdateKeyState(int32_t key, bool state) |
|
|
|
|
{ pKeyNewState[key] = state; } |
|
|
|
|
{ |
|
|
|
|
pKeyNewState[key] = state; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::olc_UpdateMouseFocus(bool state) |
|
|
|
|
{ bHasMouseFocus = state; } |
|
|
|
|
{ |
|
|
|
|
bHasMouseFocus = state; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::olc_UpdateKeyFocus(bool state) |
|
|
|
|
{ bHasInputFocus = state; } |
|
|
|
|
{ |
|
|
|
|
bHasInputFocus = state; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::olc_Terminate() |
|
|
|
|
{ bAtomActive = false; } |
|
|
|
|
{ |
|
|
|
|
bAtomActive = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::EngineThread() |
|
|
|
|
{ |
|
|
|
@ -2407,7 +2600,7 @@ namespace olc |
|
|
|
|
nMouseWheelDelta = nMouseWheelDeltaCache; |
|
|
|
|
nMouseWheelDeltaCache = 0; |
|
|
|
|
|
|
|
|
|
renderer->ClearBuffer(olc::BLACK, true); |
|
|
|
|
// renderer->ClearBuffer(olc::BLACK, true);
|
|
|
|
|
|
|
|
|
|
// Handle Frame Update
|
|
|
|
|
if (!OnUserUpdate(fElapsedTime)) |
|
|
|
@ -2527,6 +2720,7 @@ namespace olc |
|
|
|
|
#if defined(OLC_GFX_OPENGL10) |
|
|
|
|
#if defined(_WIN32) |
|
|
|
|
#include <windows.h> |
|
|
|
|
#include <dwmapi.h> |
|
|
|
|
#include <GL/gl.h> |
|
|
|
|
typedef BOOL(WINAPI wglSwapInterval_t) (int interval); |
|
|
|
|
static wglSwapInterval_t* wglSwapInterval = nullptr; |
|
|
|
@ -2556,6 +2750,7 @@ namespace olc |
|
|
|
|
private: |
|
|
|
|
glDeviceContext_t glDeviceContext = 0; |
|
|
|
|
glRenderContext_t glRenderContext = 0; |
|
|
|
|
bool bSync = false; |
|
|
|
|
|
|
|
|
|
#if defined(__linux__) || defined(__FreeBSD__) |
|
|
|
|
X11::Display* olc_Display = nullptr; |
|
|
|
@ -2590,6 +2785,7 @@ namespace olc |
|
|
|
|
// Remove Frame cap
|
|
|
|
|
wglSwapInterval = (wglSwapInterval_t*)wglGetProcAddress("wglSwapIntervalEXT"); |
|
|
|
|
if (wglSwapInterval && !bVSYNC) wglSwapInterval(0); |
|
|
|
|
bSync = bVSYNC; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if defined(__linux__) || defined(__FreeBSD__) |
|
|
|
@ -2643,6 +2839,7 @@ namespace olc |
|
|
|
|
{ |
|
|
|
|
#if defined(_WIN32) |
|
|
|
|
SwapBuffers(glDeviceContext); |
|
|
|
|
if (bSync) DwmFlush(); // Woooohooooooo!!!! SMOOOOOOOTH!
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if defined(__linux__) || defined(__FreeBSD__) |
|
|
|
@ -2707,6 +2904,8 @@ namespace olc |
|
|
|
|
glBindTexture(GL_TEXTURE_2D, id); |
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); |
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); |
|
|
|
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
|
|
return id; |
|
|
|
|
} |
|
|
|
@ -2756,6 +2955,7 @@ namespace olc |
|
|
|
|
#pragma comment(lib, "opengl32.lib") // these libs to your linker input
|
|
|
|
|
#pragma comment(lib, "gdiplus.lib") |
|
|
|
|
#pragma comment(lib, "Shlwapi.lib") |
|
|
|
|
#pragma comment(lib, "Dwmapi.lib") |
|
|
|
|
#else |
|
|
|
|
// In Code::Blocks
|
|
|
|
|
#if !defined(_WIN32_WINNT) |
|
|
|
@ -2776,6 +2976,7 @@ namespace olc |
|
|
|
|
#include <windows.h> |
|
|
|
|
#include <gdiplus.h> |
|
|
|
|
#include <Shlwapi.h> |
|
|
|
|
#include <dwmapi.h> |
|
|
|
|
|
|
|
|
|
namespace olc |
|
|
|
|
{ |
|
|
|
@ -2965,7 +3166,7 @@ namespace olc |
|
|
|
|
case WM_MBUTTONDOWN:ptrPGE->olc_UpdateMouseState(2, true); return 0; |
|
|
|
|
case WM_MBUTTONUP: ptrPGE->olc_UpdateMouseState(2, false); return 0; |
|
|
|
|
case WM_CLOSE: ptrPGE->olc_Terminate(); return 0; |
|
|
|
|
case WM_DESTROY: PostQuitMessage(0); return 0; |
|
|
|
|
case WM_DESTROY: PostQuitMessage(0); DestroyWindow(hWnd); return 0; |
|
|
|
|
} |
|
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam); |
|
|
|
|
} |
|
|
|
@ -3031,13 +3232,19 @@ namespace olc |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
virtual olc::rcode ApplicationStartUp() override |
|
|
|
|
{ return olc::rcode::OK; } |
|
|
|
|
{ |
|
|
|
|
return olc::rcode::OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual olc::rcode ApplicationCleanUp() override |
|
|
|
|
{ return olc::rcode::OK; } |
|
|
|
|
{ |
|
|
|
|
return olc::rcode::OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual olc::rcode ThreadStartUp() override |
|
|
|
|
{ return olc::rcode::OK; } |
|
|
|
|
{ |
|
|
|
|
return olc::rcode::OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual olc::rcode ThreadCleanUp() override |
|
|
|
|
{ |
|
|
|
@ -3151,7 +3358,9 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual olc::rcode StartSystemEventLoop() override |
|
|
|
|
{ return olc::OK; } |
|
|
|
|
{ |
|
|
|
|
return olc::OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual olc::rcode HandleSystemEvent() override |
|
|
|
|
{ |
|
|
|
|