mirror of
https://git.shylie.info/shylie/glerminal.git
synced 2024-12-22 22:50:06 +00:00
Compare commits
No commits in common. "ffcafb516076f527c2f67512d06d1fa441c239bd" and "ae2052f8a910d1ef35de58a79c2ed1d7f805119b" have entirely different histories.
ffcafb5160
...
ae2052f8a9
@ -24,9 +24,9 @@ jobs:
|
|||||||
- name: Build previous
|
- name: Build previous
|
||||||
run: cmake -S prev -B prev/build -DGLERMINAL_TEST=ON && cmake --build prev/build
|
run: cmake -S prev -B prev/build -DGLERMINAL_TEST=ON && cmake --build prev/build
|
||||||
- name: Generate PNG file for current
|
- name: Generate PNG file for current
|
||||||
run: cd curr/build/tests && ls $PWD/resources && XDG_RUNTIME_DIR=$PWD xvfb-run -a ./test-basic
|
run: cd curr/build/tests && XDG_RUNTIME_DIR=$PWD xvfb-run -a ./test-basic
|
||||||
- name: Generate PNG file for previous
|
- name: Generate PNG file for previous
|
||||||
run: cd prev/build/tests && ls $PWD/resources && XDG_RUNTIME_DIR=$PWD xvfb-run -a ./test-basic
|
run: cd prev/build/tests && XDG_RUNTIME_DIR=$PWD xvfb-run -a ./test-basic
|
||||||
- name: Upload current PNG
|
- name: Upload current PNG
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
@ -68,7 +68,7 @@ void glerminal_layer_scale(unsigned char layer, float scale);
|
|||||||
* @brief Load sprites from a png file
|
* @brief Load sprites from a png file
|
||||||
* @param filename Name of the png file
|
* @param filename Name of the png file
|
||||||
*/
|
*/
|
||||||
int glerminal_load_sprites_file(const char* filename);
|
void glerminal_load_sprites_file(const char* filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Load sprites from memory
|
* @brief Load sprites from memory
|
||||||
@ -76,7 +76,7 @@ int glerminal_load_sprites_file(const char* filename);
|
|||||||
* @param height height of the atlas in sprites
|
* @param height height of the atlas in sprites
|
||||||
* @param buffer the in-memory atlas
|
* @param buffer the in-memory atlas
|
||||||
*/
|
*/
|
||||||
int glerminal_load_sprites_buffer(unsigned char width, unsigned char height, const unsigned int* buffer);
|
void glerminal_load_sprites_buffer(unsigned char width, unsigned char height, const unsigned int* buffer);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -815,41 +815,29 @@ void glerminal_layer_scale(unsigned char layer, float scale)
|
|||||||
GLERMINAL_G->layer_scale(layer, scale);
|
GLERMINAL_G->layer_scale(layer, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
int glerminal_load_sprites_file(const char* filename)
|
void glerminal_load_sprites_file(const char* filename)
|
||||||
{
|
{
|
||||||
if (!GLERMINAL_G) { return false; }
|
if (!GLERMINAL_G) { return; }
|
||||||
|
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
stbi_uc* const buffer = stbi_load(filename, &w, &h, nullptr, 4);
|
stbi_uc* const buffer = stbi_load(filename, &w, &h, nullptr, 4);
|
||||||
|
|
||||||
// verify atlas size is a multiple of CELL_SIZE in each dimension
|
// verify atlas size is a multiple of CELL_SIZE in each dimension
|
||||||
if (buffer && w % glerminal::CELL_SIZE == 0 && h % glerminal::CELL_SIZE == 0)
|
if (w % glerminal::CELL_SIZE == 0 && h % glerminal::CELL_SIZE == 0)
|
||||||
{
|
{
|
||||||
GLERMINAL_G->load_atlas(w / glerminal::CELL_SIZE, h / glerminal::CELL_SIZE, reinterpret_cast<unsigned int*>(buffer));
|
GLERMINAL_G->load_atlas(w / glerminal::CELL_SIZE, h / glerminal::CELL_SIZE, reinterpret_cast<unsigned int*>(buffer));
|
||||||
|
|
||||||
success = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stbi_image_free(buffer);
|
stbi_image_free(buffer);
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int glerminal_load_sprites_buffer(unsigned char width, unsigned char height, const unsigned int* buffer)
|
void glerminal_load_sprites_buffer(unsigned char width, unsigned char height, const unsigned int* buffer)
|
||||||
{
|
{
|
||||||
if (!GLERMINAL_G) { return false; }
|
if (!GLERMINAL_G) { return; }
|
||||||
|
|
||||||
// verify atlas size is a multiple of CELL_SIZE in each dimension
|
// verify atlas size is a multiple of CELL_SIZE in each dimension
|
||||||
if (width % glerminal::CELL_SIZE == 0 && height % glerminal::CELL_SIZE == 0)
|
if (width % glerminal::CELL_SIZE == 0 && height % glerminal::CELL_SIZE == 0)
|
||||||
{
|
{
|
||||||
GLERMINAL_G->load_atlas(width / glerminal::CELL_SIZE, height / glerminal::CELL_SIZE, buffer);
|
GLERMINAL_G->load_atlas(width / glerminal::CELL_SIZE, height / glerminal::CELL_SIZE, buffer);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,16 +2,11 @@
|
|||||||
|
|
||||||
#include <test-common.h>
|
#include <test-common.h>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
if (!glerminal_load_sprites_file("resources/image.png"))
|
glerminal_load_sprites_file("resources/image.png");
|
||||||
{
|
|
||||||
std::cout << "Failed to load texture" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < GRID_HEIGHT; i++)
|
for (int i = 0; i < GRID_HEIGHT; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user