Compare commits

..

2 Commits

Author SHA1 Message Date
221db8e972
Allow constants 2022-04-22 23:27:23 -04:00
b32117e552
Working rainbow! 2022-04-07 14:58:45 -04:00
6 changed files with 35 additions and 9 deletions

View File

@ -22,8 +22,8 @@ void rect_textured(float x, float y, float w, float h, rgba color,
float angle);
void circle(float x, float y, float radius, rgba color, float thickness, int steps);
void string(float x, float y, const std::string& string, font& font, rgba color,
void string(float x, float y, const std::string& string, const font& font, rgba color,
float* width, float* height);
void outlined_string(float x, float y, const std::string& string, font& font,
void outlined_string(float x, float y, const std::string& string, const font& font,
rgba color, rgba outline, float* width, float* height);
} // namespace glez::draw

View File

@ -22,8 +22,8 @@ public:
glez::font& operator=(glez::font&&);
// void stringSize(std::string_view string, float* width, float* height);
void stringSize(const std::string& string, float* width, float* height);
inline bool isLoaded() { return this->m_font != nullptr && this->atlas != nullptr; };
void stringSize(const std::string& string, float* width, float* height) const;
inline bool isLoaded() const { return this->m_font != nullptr && this->atlas != nullptr; };
public:
texture_font_t* m_font = nullptr;

View File

@ -1,7 +1,8 @@
target_sources(glez PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/color.cpp"
"${CMAKE_CURRENT_LIST_DIR}/draw.cpp"
"${CMAKE_CURRENT_LIST_DIR}/glez.cpp"
"${CMAKE_CURRENT_LIST_DIR}/font.cpp"
"${CMAKE_CURRENT_LIST_DIR}/texture.cpp")
add_subdirectory(picopng)
add_subdirectory(picopng)

25
src/color.cpp Normal file
View File

@ -0,0 +1,25 @@
/*
* Created by Rebekah Rowe on 04.07.22. GPL3
*/
#include <cmath>
#include <chrono>
#include <iostream>
#include <glm/gtx/color_space.hpp>
#include <glez/color.hpp>
namespace glez::color {
static auto start_time = std::chrono::steady_clock::now();
rgba RainbowCurrent() {
std::chrono::duration<float, std::deca> ctime = std::chrono::steady_clock::now() - start_time;
auto ret_raw = glm::rgbColor(glm::vec3(fabs(sin(ctime.count())) * 360.0f, 0.85f, 0.9f));
rgba ret;
ret.r = ret_raw.r;
ret.g = ret_raw.g;
ret.b = ret_raw.b;
return ret;
}
} // namespace glez::color

View File

@ -21,7 +21,7 @@ static GLuint triangle[3] = { 0, 1, 2 };
} // namespace indices
void internal_draw_string(float x, float y, const std::string& string,
glez::font& font, glez::rgba color, float* width, float* height) {
const glez::font& font, glez::rgba color, float* width, float* height) {
assert(font.isLoaded());
auto* fnt = font.m_font;
float pen_x = x;
@ -202,14 +202,14 @@ void circle(float x, float y, float radius, rgba color, float thickness,
}
}
void string(float x, float y, const std::string& string, font& font, rgba color, float* width, float* height) {
void string(float x, float y, const std::string& string, const font& font, rgba color, float* width, float* height) {
auto fnt = font.m_font;
fnt->rendermode = RENDER_NORMAL;
fnt->outline_thickness = 0.0f;
internal_draw_string(x, y, string, font, color, width, height);
}
void outlined_string(float x, float y, const std::string& string, font& font, rgba color, rgba outline, float* width, float* height) {
void outlined_string(float x, float y, const std::string& string, const font& font, rgba color, rgba outline, float* width, float* height) {
auto fnt = font.m_font;
fnt->rendermode = RENDER_OUTLINE_POSITIVE;
fnt->outline_thickness = 1.0f;

View File

@ -36,7 +36,7 @@ glez::font& font::operator=(glez::font&& var) {
var.atlas = nullptr;
return *this;
}
void font::stringSize(const std::string& string, float* width, float* height) {
void font::stringSize(const std::string& string, float* width, float* height) const {
assert(this->isLoaded());
float penX = 0;