40 RayWindow(int32_t screenWidth, int32_t screenHeight, std::string title) : _quitRequested(false) {
41 raylib::InitWindow(screenWidth, screenHeight, title.c_str());
49 raylib::CloseWindow();
54 return raylib::IsWindowReady() && !raylib::WindowShouldClose() && !_quitRequested;
58 _quitRequested =
true;
62 const raylib::Vector2 position = raylib::GetWindowPosition();
63 return {
static_cast<double>(position.x),
static_cast<double>(position.y)};
67 raylib::SetWindowPosition(
static_cast<int>(position.
x),
static_cast<int>(position.
y));
71 return {
static_cast<double>(raylib::GetScreenWidth()),
72 static_cast<double>(raylib::GetScreenHeight())};
76 raylib::SetWindowSize(
static_cast<int>(size.
x),
static_cast<int>(size.
y));
80 raylib::SetTargetFPS(limit);
91 return static_cast<int32_t
>(raylib::GetFrameTime() * 1000);
116 raylib::BeginDrawing();
117 raylib::ClearBackground({0, 0, 0, 255});
121 raylib::EndDrawing();
136 raylib::Camera *_activeCamera =
nullptr;
145 const std::vector<Triangle<double>> &triangles = rayPolygon->_triangles;
147 for (
size_t i = 0; i < triangles.size(); i++) {
149 raylib::DrawTriangle(
150 {
static_cast<float>(triangles[i].p3.x + rayPolygon->
getPosition().x),
static_cast<float>(triangles[i].p3.y + rayPolygon->
getPosition().y)},
151 {
static_cast<float>(triangles[i].p2.x + rayPolygon->
getPosition().x),
static_cast<float>(triangles[i].p2.y + rayPolygon->
getPosition().y)},
152 {
static_cast<float>(triangles[i].p1.x + rayPolygon->
getPosition().x),
static_cast<float>(triangles[i].p1.y + rayPolygon->
getPosition().y)},
162 raylib::DrawTexturePro(raySprite->_texture.
handle(), raySprite->_crop, posSize, {0, 0}, raySprite->_rotation,
163 {255, 255, 255, 255});
169 raylib::DrawTextPro(rayText->_font->
handle(), rayText->_data.c_str(), rayText->_position, {0, 0},
170 rayText->_rotation, rayText->_size, rayText->_spacing, rayText->_color);
178 raylib::UpdateCamera(&rayCamera->_camera, rayCamera->_mode);
179 _activeCamera = &rayCamera->_camera;
181 raylib::BeginMode3D(rayCamera->_camera);
187 raylib::DrawModelEx(rayModel->_mesh.
handle(), rayModel->_position, {0, 1, 0}, 0, rayModel->_scale, raylib::WHITE);
197 if (!_activeCamera)
return;
199 raylib::Vector3 worldPos = {float(position.
x), float(position.
y), float(position.
z)};
200 raylib::Vector2 screenPos = raylib::GetWorldToScreen(worldPos, *_activeCamera);
203 raylib::DrawTextPro(rayText->_font->
handle(), rayText->_data.c_str(), screenPos, {0, 0}, rayText->_rotation,
204 rayText->_size, rayText->_spacing, rayText->_color);
205 raylib::BeginMode3D(*_activeCamera);
210 _activeCamera =
nullptr;
Raylib Camera class.
Definition RayCamera.hpp:23
raylib::Font handle() const
Definition RayFont.hpp:39
raylib::Model & handle()
Definition RayMesh.hpp:42
Raylib Model class - references a RayMesh, does not own it.
Definition RayModel.hpp:47
Definition RayPolygon.hpp:25
Vector2f getPosition() const override
Get the Position object.
Definition RayPolygon.hpp:45
Raylib Sprite class - references a RayTexture, does not own it. Deleting the sprite never touches the...
Definition RaySprite.hpp:27
Vector2f getSize() const override
Get the Sprite size.
Definition RaySprite.hpp:67
Vector2f getPosition() const override
Get the Position object.
Definition RaySprite.hpp:52
Raylib Text class - references a RayFont, does not own it. Deleting the text never touches the font.
Definition RayText.hpp:30
raylib::Texture2D handle() const
Definition RayTexture.hpp:45
~RayWindow()
Definition RayWindow.hpp:44
void setPosition(Vector2f position) override
Move the window on the desktop.
Definition RayWindow.hpp:66
RayWindow(int32_t screenWidth, int32_t screenHeight, std::string title)
Definition RayWindow.hpp:40
void endDraw() override
end the 2D drawing
Definition RayWindow.hpp:120
void setSize(Vector2f size) override
Resize the drawable area.
Definition RayWindow.hpp:75
void eventClose() override
notice the window that a close was requested
Definition RayWindow.hpp:110
Vector2f getSize() override
The drawable area, in pixels - NOT the desktop size. A hit-test built on IMouse::getPosition() compar...
Definition RayWindow.hpp:70
void beginDraw() override
allowing to draw 2D on the window
Definition RayWindow.hpp:115
void setFrameLimit(int32_t limit) override
Set the Frame Limit object.
Definition RayWindow.hpp:79
int32_t getDelta() override
Get the Delta object.
Definition RayWindow.hpp:90
bool isOpen() override
notice if the window is open
Definition RayWindow.hpp:53
void close() override
close the window
Definition RayWindow.hpp:57
void setMouseVisibility(bool visible) override
Show or hide the system cursor over THIS window.
Definition RayWindow.hpp:83
Vector2f getPosition() override
Where the window sits on the desktop, in pixels, origin top-left of the primary screen.
Definition RayWindow.hpp:61
bool pollEvent() override
raylib has NO event queue : only state queries, refreshed once per frame by PollInputEvents() inside ...
Definition RayWindow.hpp:106
Camera interface.
Definition ICamera.hpp:23
Model interface.
Definition IModel.hpp:27
Polygon interface.
Definition IPolygon.hpp:34
Sprite interface.
Definition ISprite.hpp:22
Text interface.
Definition IText.hpp:26
A window that can also draw 3D. Extends IWindow2, so anything that only needs 2D can keep using it as...
Definition IWindow3.hpp:25
void drawPoly(graphic::IPolygon *polygon) override
draw a polygon
Definition RayWindow.hpp:141
void beginMode3(graphic::ICamera *camera) override
allowing to draw 3D on the window
Definition RayWindow.hpp:175
void drawModel(graphic::IModel *model) override
draw a model
Definition RayWindow.hpp:184
void endMode3() override
end the 3D drawing
Definition RayWindow.hpp:208
void drawSprite(graphic::ISprite *sprite) override
draw a sprite
Definition RayWindow.hpp:157
void drawText3D(graphic::IText *text, Vector3f position) override
draw text at a 3D world position - the same IText used by drawText(), just projected through the acti...
Definition RayWindow.hpp:190
void drawText(graphic::IText *text) override
draw a text
Definition RayWindow.hpp:166
Vector2< double > Vector2f
Definition Vector2.hpp:112
Vector3< double > Vector3f
Definition Vector3.hpp:121
T y
Definition Vector2.hpp:21
T x
Definition Vector2.hpp:21
T x
Definition Vector3.hpp:21
T y
Definition Vector3.hpp:21
T z
Definition Vector3.hpp:21