format
This commit is contained in:
parent
caca15cd63
commit
dd0158bcb3
2
.clang-format
Normal file → Executable file
2
.clang-format
Normal file → Executable file
@ -10,6 +10,7 @@ AllowShortFunctionsOnASingleLine: None
|
|||||||
AllowShortIfStatementsOnASingleLine: 'false'
|
AllowShortIfStatementsOnASingleLine: 'false'
|
||||||
AllowShortLoopsOnASingleLine: 'false'
|
AllowShortLoopsOnASingleLine: 'false'
|
||||||
BreakBeforeBraces: Allman
|
BreakBeforeBraces: Allman
|
||||||
|
ColumnLimit: 0
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
|
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
|
||||||
Cpp11BracedListStyle: 'false'
|
Cpp11BracedListStyle: 'false'
|
||||||
IndentCaseLabels: 'false'
|
IndentCaseLabels: 'false'
|
||||||
@ -31,4 +32,5 @@ Standard: Auto
|
|||||||
TabWidth: '4'
|
TabWidth: '4'
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -35,5 +35,5 @@ constexpr rgba black(0, 0, 0);
|
|||||||
constexpr rgba red(255, 0, 0);
|
constexpr rgba red(255, 0, 0);
|
||||||
constexpr rgba green(0, 255, 0);
|
constexpr rgba green(0, 255, 0);
|
||||||
constexpr rgba blue(0, 0, 255);
|
constexpr rgba blue(0, 0, 255);
|
||||||
}
|
} // namespace color
|
||||||
}
|
} // namespace glez
|
@ -29,4 +29,4 @@ void shutdown();
|
|||||||
|
|
||||||
unsigned create();
|
unsigned create();
|
||||||
font &get(unsigned handle);
|
font &get(unsigned handle);
|
||||||
}
|
} // namespace glez::detail::font
|
@ -29,4 +29,4 @@ void begin();
|
|||||||
void end();
|
void end();
|
||||||
|
|
||||||
extern vertex_buffer_t *buffer;
|
extern vertex_buffer_t *buffer;
|
||||||
};
|
}; // namespace glez::detail::program
|
@ -32,11 +32,13 @@ public:
|
|||||||
~RecordedCommands();
|
~RecordedCommands();
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void store(glez::detail::render::vertex *vertices, size_t vcount, uint32_t *indices, size_t icount);
|
void store(glez::detail::render::vertex *vertices, size_t vcount,
|
||||||
|
uint32_t *indices, size_t icount);
|
||||||
void bindTexture(glez::detail::texture::texture *tx);
|
void bindTexture(glez::detail::texture::texture *tx);
|
||||||
void bindFont(ftgl::texture_font_t *font);
|
void bindFont(ftgl::texture_font_t *font);
|
||||||
void render();
|
void render();
|
||||||
void end();
|
void end();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void cutSegment();
|
void cutSegment();
|
||||||
|
|
||||||
@ -48,4 +50,4 @@ protected:
|
|||||||
extern RecordedCommands *currentRecord;
|
extern RecordedCommands *currentRecord;
|
||||||
extern bool isReplaying;
|
extern bool isReplaying;
|
||||||
|
|
||||||
}
|
} // namespace glez::detail::record
|
@ -23,4 +23,4 @@ void begin();
|
|||||||
void end();
|
void end();
|
||||||
|
|
||||||
void bind(GLuint texture);
|
void bind(GLuint texture);
|
||||||
}
|
} // namespace glez::detail::render
|
@ -33,4 +33,4 @@ void shutdown();
|
|||||||
|
|
||||||
unsigned create();
|
unsigned create();
|
||||||
texture &get(unsigned handle);
|
texture &get(unsigned handle);
|
||||||
}
|
} // namespace glez::detail::texture
|
@ -15,13 +15,16 @@ namespace glez::draw
|
|||||||
|
|
||||||
void line(float x, float y, float dx, float dy, rgba color, float thickness);
|
void line(float x, float y, float dx, float dy, rgba color, float thickness);
|
||||||
void rect(float x, float y, float w, float h, rgba color);
|
void rect(float x, float y, float w, float h, rgba color);
|
||||||
void rect_outline(float x, float y, float w, float h, rgba color, float thickness);
|
void rect_outline(float x, float y, float w, float h, rgba color,
|
||||||
void rect_textured(float x, float y, float w, float h, rgba color, texture &texture,
|
float thickness);
|
||||||
float tx, float ty, float tw, float th, float angle);
|
void rect_textured(float x, float y, float w, float h, rgba color,
|
||||||
void circle(float x, float y, float radius, rgba color, float thickness, int steps);
|
texture &texture, float tx, float ty, float tw, float th,
|
||||||
|
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, font &font, rgba color,
|
||||||
float *width, float *height);
|
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, font &font,
|
||||||
rgba color, rgba outline, float *width, float *height);
|
rgba color, rgba outline, float *width, float *height);
|
||||||
}
|
} // namespace glez::draw
|
@ -42,4 +42,4 @@ protected:
|
|||||||
|
|
||||||
unsigned handle{ std::numeric_limits<unsigned>::max() };
|
unsigned handle{ std::numeric_limits<unsigned>::max() };
|
||||||
};
|
};
|
||||||
}
|
} // namespace glez
|
@ -16,4 +16,4 @@ void resize(int width, int height);
|
|||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void end();
|
void end();
|
||||||
};
|
}; // namespace glez
|
@ -1,3 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
int decodePNG(unsigned char* &out_image, int& image_width, int& image_height, const unsigned char* in_png, size_t in_size, bool convert_to_rgba32 = true);
|
int decodePNG(unsigned char *&out_image, int &image_width, int &image_height,
|
||||||
|
const unsigned char *in_png, size_t in_size,
|
||||||
|
bool convert_to_rgba32 = true);
|
||||||
|
@ -25,4 +25,4 @@ public:
|
|||||||
detail::record::RecordedCommands *commands{ nullptr };
|
detail::record::RecordedCommands *commands{ nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace glez::record
|
@ -57,4 +57,4 @@ protected:
|
|||||||
|
|
||||||
unsigned handle{ std::numeric_limits<unsigned>::max() };
|
unsigned handle{ std::numeric_limits<unsigned>::max() };
|
||||||
};
|
};
|
||||||
}
|
} // namespace glez
|
@ -93,4 +93,4 @@ font &get(unsigned handle)
|
|||||||
{
|
{
|
||||||
return (*cache)[handle];
|
return (*cache)[handle];
|
||||||
}
|
}
|
||||||
}
|
} // namespace glez::detail::font
|
||||||
|
@ -153,4 +153,4 @@ void end()
|
|||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace glez::detail::program
|
@ -14,7 +14,7 @@ void RecordedCommands::render()
|
|||||||
{
|
{
|
||||||
isReplaying = true;
|
isReplaying = true;
|
||||||
vertex_buffer_render_setup(vertex_buffer, GL_TRIANGLES);
|
vertex_buffer_render_setup(vertex_buffer, GL_TRIANGLES);
|
||||||
for (const auto& i: segments)
|
for (const auto &i : segments)
|
||||||
{
|
{
|
||||||
if (i.texture)
|
if (i.texture)
|
||||||
{
|
{
|
||||||
@ -31,32 +31,37 @@ void RecordedCommands::render()
|
|||||||
|
|
||||||
if (i.font->atlas->dirty)
|
if (i.font->atlas->dirty)
|
||||||
{
|
{
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||||
|
GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
|
GL_NEAREST);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, i.font->atlas->width,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, i.font->atlas->width,
|
||||||
i.font->atlas->height, 0, GL_RED, GL_UNSIGNED_BYTE,
|
i.font->atlas->height, 0, GL_RED, GL_UNSIGNED_BYTE,
|
||||||
i.font->atlas->data);
|
i.font->atlas->data);
|
||||||
i.font->atlas->dirty = 0;
|
i.font->atlas->dirty = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glDrawElements(GL_TRIANGLES, i.size, GL_UNSIGNED_INT, (void *)(i.start * 4));
|
glDrawElements(GL_TRIANGLES, i.size, GL_UNSIGNED_INT,
|
||||||
|
(void *) (i.start * 4));
|
||||||
}
|
}
|
||||||
vertex_buffer_render_finish(vertex_buffer);
|
vertex_buffer_render_finish(vertex_buffer);
|
||||||
isReplaying = false;
|
isReplaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void RecordedCommands::store(glez::detail::render::vertex *vertices,
|
||||||
RecordedCommands::store(glez::detail::render::vertex *vertices, size_t vcount,
|
size_t vcount, uint32_t *indices, size_t icount)
|
||||||
uint32_t *indices, size_t icount)
|
|
||||||
{
|
{
|
||||||
vertex_buffer_push_back(vertex_buffer, vertices, vcount, indices, icount);
|
vertex_buffer_push_back(vertex_buffer, vertices, vcount, indices, icount);
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordedCommands::RecordedCommands()
|
RecordedCommands::RecordedCommands()
|
||||||
{
|
{
|
||||||
vertex_buffer = vertex_buffer_new("vertex:2f,tex_coord:2f,color:4f,drawmode:1i");
|
vertex_buffer =
|
||||||
|
vertex_buffer_new("vertex:2f,tex_coord:2f,color:4f,drawmode:1i");
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordedCommands::~RecordedCommands()
|
RecordedCommands::~RecordedCommands()
|
||||||
@ -106,7 +111,7 @@ void RecordedCommands::end()
|
|||||||
RecordedCommands *currentRecord{ nullptr };
|
RecordedCommands *currentRecord{ nullptr };
|
||||||
bool isReplaying{ false };
|
bool isReplaying{ false };
|
||||||
|
|
||||||
}
|
} // namespace glez::detail::record
|
||||||
|
|
||||||
glez::record::Record::Record()
|
glez::record::Record::Record()
|
||||||
{
|
{
|
||||||
|
@ -68,4 +68,4 @@ void bind(GLuint texture)
|
|||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace glez::detail::render
|
25
src/draw.cpp
25
src/draw.cpp
@ -110,7 +110,8 @@ void internal_draw_string(float x, float y, const std::string &string,
|
|||||||
size_y = glyph->height;
|
size_y = glyph->height;
|
||||||
|
|
||||||
if (glez::detail::record::currentRecord)
|
if (glez::detail::record::currentRecord)
|
||||||
glez::detail::record::currentRecord->store(vertices, 4, indices::rectangle, 6);
|
glez::detail::record::currentRecord->store(vertices, 4,
|
||||||
|
indices::rectangle, 6);
|
||||||
else
|
else
|
||||||
vertex_buffer_push_back(glez::detail::program::buffer, vertices, 4,
|
vertex_buffer_push_back(glez::detail::program::buffer, vertices, 4,
|
||||||
indices::rectangle, 6);
|
indices::rectangle, 6);
|
||||||
@ -169,7 +170,8 @@ void line(float x, float y, float dx, float dy, rgba color, float thickness)
|
|||||||
vertices[0].position = { ex + nx - px, ey + ny - py };
|
vertices[0].position = { ex + nx - px, ey + ny - py };
|
||||||
|
|
||||||
if (detail::record::currentRecord)
|
if (detail::record::currentRecord)
|
||||||
detail::record::currentRecord->store(vertices, 4, indices::rectangle, 6);
|
detail::record::currentRecord->store(vertices, 4, indices::rectangle,
|
||||||
|
6);
|
||||||
else
|
else
|
||||||
ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4,
|
ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4,
|
||||||
indices::rectangle, 6);
|
indices::rectangle, 6);
|
||||||
@ -191,13 +193,15 @@ void rect(float x, float y, float w, float h, rgba color)
|
|||||||
vertices[3].position = { x + w, y };
|
vertices[3].position = { x + w, y };
|
||||||
|
|
||||||
if (detail::record::currentRecord)
|
if (detail::record::currentRecord)
|
||||||
detail::record::currentRecord->store(vertices, 4, indices::rectangle, 6);
|
detail::record::currentRecord->store(vertices, 4, indices::rectangle,
|
||||||
|
6);
|
||||||
else
|
else
|
||||||
ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4,
|
ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4,
|
||||||
indices::rectangle, 6);
|
indices::rectangle, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rect_outline(float x, float y, float w, float h, rgba color, float thickness)
|
void rect_outline(float x, float y, float w, float h, rgba color,
|
||||||
|
float thickness)
|
||||||
{
|
{
|
||||||
rect(x, y, w, 1, color);
|
rect(x, y, w, 1, color);
|
||||||
rect(x, y, 1, h, color);
|
rect(x, y, 1, h, color);
|
||||||
@ -205,7 +209,8 @@ void rect_outline(float x, float y, float w, float h, rgba color, float thicknes
|
|||||||
rect(x, y + h - 1, w, 1, color);
|
rect(x, y + h - 1, w, 1, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void circle(float x, float y, float radius, rgba color, float thickness, int steps)
|
void circle(float x, float y, float radius, rgba color, float thickness,
|
||||||
|
int steps)
|
||||||
{
|
{
|
||||||
float px = 0;
|
float px = 0;
|
||||||
float py = 0;
|
float py = 0;
|
||||||
@ -249,8 +254,9 @@ void outlined_string(float x, float y, const std::string &string, font &font,
|
|||||||
internal_draw_string(x, y, string, fnt, color, width, height);
|
internal_draw_string(x, y, string, fnt, color, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rect_textured(float x, float y, float w, float h, rgba color, texture &texture,
|
void rect_textured(float x, float y, float w, float h, rgba color,
|
||||||
float tx, float ty, float tw, float th, float angle)
|
texture &texture, float tx, float ty, float tw, float th,
|
||||||
|
float angle)
|
||||||
{
|
{
|
||||||
if (!texture.isLoaded())
|
if (!texture.isLoaded())
|
||||||
texture.load();
|
texture.load();
|
||||||
@ -305,9 +311,10 @@ void rect_textured(float x, float y, float w, float h, rgba color, texture &text
|
|||||||
vertices[3].uv = { s1, t0 };
|
vertices[3].uv = { s1, t0 };
|
||||||
|
|
||||||
if (detail::record::currentRecord)
|
if (detail::record::currentRecord)
|
||||||
detail::record::currentRecord->store(vertices, 4, indices::rectangle, 6);
|
detail::record::currentRecord->store(vertices, 4, indices::rectangle,
|
||||||
|
6);
|
||||||
else
|
else
|
||||||
ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4,
|
ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4,
|
||||||
indices::rectangle, 6);
|
indices::rectangle, 6);
|
||||||
}
|
}
|
||||||
}
|
} // namespace glez::draw
|
||||||
|
@ -38,4 +38,4 @@ void font::stringSize(const std::string &string, float *width, float *height)
|
|||||||
auto &font = detail::font::get(handle);
|
auto &font = detail::font::get(handle);
|
||||||
font.stringSize(string, width, height);
|
font.stringSize(string, width, height);
|
||||||
}
|
}
|
||||||
}
|
} // namespace glez
|
@ -45,4 +45,4 @@ void preInit()
|
|||||||
detail::font::init();
|
detail::font::init();
|
||||||
detail::texture::init();
|
detail::texture::init();
|
||||||
}
|
}
|
||||||
}
|
} // namespace glez
|
Loading…
x
Reference in New Issue
Block a user