diff --git a/android/test/app/src/main/cpp/main.cpp b/android/test/app/src/main/cpp/main.cpp index 2612ee7db..d4a1a368d 100644 --- a/android/test/app/src/main/cpp/main.cpp +++ b/android/test/app/src/main/cpp/main.cpp @@ -20,7 +20,7 @@ JNGL_MAIN_BEGIN { jngl::Sprite sprite("././/././jngl.webp"); while (jngl::running()) { jngl::updateInput(); - jngl::setBackgroundColor(jngl::Color(133, 133, 133)); + jngl::setBackgroundColor(jngl::Rgb::u8(133, 133, 133)); jngl::setFont("Arial.ttf"); jngl::setFontSize(100); if (first) { diff --git a/src/jngl/Color.hpp b/src/jngl/Color.hpp index adb3c11cd..604de3310 100644 --- a/src/jngl/Color.hpp +++ b/src/jngl/Color.hpp @@ -60,11 +60,11 @@ class Color { Color interpolate(Color a, Color b, float t); /// Sets the screen's background color which is visible when nothing is drawn -void setBackgroundColor(jngl::Color); +void setBackgroundColor(jngl::Rgb); /// Sets the screen's background color which is visible when nothing is drawn -/// \deprecated Use setBackgroundColor(jngl::Color) instead. -[[deprecated("use setBackgroundColor(jngl::Color) instead")]] +/// \deprecated Use setBackgroundColor(jngl::Rgb) instead. +[[deprecated("use setBackgroundColor(jngl::Rgb) instead")]] void setBackgroundColor(unsigned char red, unsigned char green, unsigned char blue); } // namespace jngl diff --git a/src/jngl/shapes.cpp b/src/jngl/shapes.cpp index ff0eb5f31..1f6af093b 100644 --- a/src/jngl/shapes.cpp +++ b/src/jngl/shapes.cpp @@ -96,11 +96,14 @@ void drawCircle(Mat3 modelview, const float radius) { } void drawCircle(Mat3 modelview, const float radius, const Rgba color) { + drawCircle(modelview.scale(radius), color); +} + +void drawCircle(Mat3 modelview, const Rgba color) { glBindVertexArray(opengl::vaoStream); - auto tmp = - useSimpleShaderProgram(modelview.scale(radius).scale(static_cast(getScaleFactor()), - static_cast(getScaleFactor())), - color); + auto tmp = useSimpleShaderProgram( + modelview.scale(static_cast(getScaleFactor()), static_cast(getScaleFactor())), + color); // clang-format off const static float vertexes[] = { 1.f, 0.f, 0.9951847f, 0.09801714f, 0.9807853f, 0.1950903f, 0.9569403f, 0.2902847f, diff --git a/src/jngl/shapes.hpp b/src/jngl/shapes.hpp index bbe039958..c2f5dfd57 100644 --- a/src/jngl/shapes.hpp +++ b/src/jngl/shapes.hpp @@ -42,8 +42,8 @@ void pushAlpha(unsigned char alpha); /// \deprecated Use setAlpha instead void popAlpha(); -[[deprecated("Use drawRectangle instead")]] -/// \deprecated Use drawRectangle instead +[[deprecated("Use drawRect instead")]] +/// \deprecated Use drawRect instead void setLineWidth(float width); /// Draws a line from start to end, the width can be set using setLineWidth @@ -75,6 +75,8 @@ void drawCircle(Mat3 modelview, float radius); /// Draws a circle at (0, 0) with \a radius in \a color void drawCircle(Mat3 modelview, float radius, Rgba color); +/// Draws a circle at (0, 0) with radius of 1 in \a color +void drawCircle(Mat3 modelview, Rgba color); [[deprecated("Use drawCircle instead")]] /// \deprecated Use drawCircle instead diff --git a/src/main.cpp b/src/main.cpp index 701bd1684..7bc4ba9d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,14 +54,15 @@ namespace jngl { std::string pathPrefix; optional configPath; std::vector args; -float bgRed = 1.0f, bgGreen = 1.0f, bgBlue = 1.0f; // Background Colors +Rgb backgroundColor(1, 1, 1); std::stack modelviewStack; std::unique_ptr simpleShaderProgram; int simpleModelviewUniform; int simpleColorUniform; void clearBackgroundColor() { - glClearColor(bgRed, bgGreen, bgBlue, 1); + glClearColor(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), + 1); } #if defined(GL_DEBUG_OUTPUT) && !defined(NDEBUG) @@ -337,11 +338,9 @@ void cancelQuit() { } } -void setBackgroundColor(const jngl::Color color) { +void setBackgroundColor(const jngl::Rgb color) { pWindow.ThrowIfNull(); - bgRed = static_cast(color.getRed()) / 255.f; - bgGreen = static_cast(color.getGreen()) / 255.f; - bgBlue = static_cast(color.getBlue()) / 255.f; + backgroundColor = color; clearBackgroundColor(); glClear(GL_COLOR_BUFFER_BIT); }