texture support
This commit is contained in:
parent
d4a5fea127
commit
b17759b34a
6 changed files with 8087 additions and 14 deletions
42
glonkers.c
42
glonkers.c
|
|
@ -11,16 +11,28 @@
|
|||
#include "wayland.h"
|
||||
#include <string.h>
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
void print_help(FILE *channel, char *bin_path) {
|
||||
fprintf(channel, "Usage: %s [OPTION]... [PATH]\n", bin_path);
|
||||
}
|
||||
|
||||
/// What is the argument parser currently reading?
|
||||
enum list_state {
|
||||
list_none,
|
||||
list_ouptut,
|
||||
list_texture,
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *shader_path = NULL;
|
||||
int output_type = OUTPUT_WINDOW;
|
||||
bool currently_reading_output = false;
|
||||
enum list_state list_state = list_none;
|
||||
char **output_list = NULL;
|
||||
int output_count;
|
||||
char **texture_list = NULL;
|
||||
int output_count = 0;
|
||||
int texture_count = 0;
|
||||
// syntax: --window for a normal window or --layer for a wallpaper
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp("--help", argv[i]) == 0) {
|
||||
|
|
@ -29,24 +41,36 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
else if (strcmp("--window", argv[i]) == 0) {
|
||||
output_type = OUTPUT_WINDOW;
|
||||
currently_reading_output = false;
|
||||
list_state = list_none;
|
||||
}
|
||||
else if (strcmp("--layer", argv[i]) == 0) {
|
||||
output_type = OUTPUT_LAYER;
|
||||
currently_reading_output = false;
|
||||
list_state = list_none;
|
||||
}
|
||||
else if (strcmp("--output", argv[i]) == 0) {
|
||||
output_count = 0;
|
||||
output_list = &argv[i + 1];
|
||||
currently_reading_output = true;
|
||||
list_state = list_ouptut;
|
||||
}
|
||||
else if (strcmp("--texture", argv[i]) == 0) {
|
||||
texture_count = 0;
|
||||
texture_list = &argv[i + 1];
|
||||
list_state = list_texture;
|
||||
}
|
||||
else if (strcmp("--", argv[i]) == 0) {
|
||||
currently_reading_output = false;
|
||||
list_state = list_none;
|
||||
}
|
||||
else if (currently_reading_output) {
|
||||
else if (list_state == list_ouptut) {
|
||||
output_count++;
|
||||
}
|
||||
else if (!currently_reading_output) {
|
||||
else if (list_state == list_texture) {
|
||||
texture_count++;
|
||||
if (texture_count > 4) {
|
||||
fprintf(stderr, "maximum number of textures is 4\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (list_state == list_none) {
|
||||
// path to fragment shader
|
||||
if (shader_path != NULL) {
|
||||
fprintf(stderr, "Tried supplying '%s' as a shader file while one has already been selected.\n", argv[i]);
|
||||
|
|
@ -74,7 +98,7 @@ int main(int argc, char *argv[]) {
|
|||
int height = event.data.draw.height;
|
||||
double time = event.data.draw.time / 1000.0;
|
||||
if (!renderer_initialized) {
|
||||
renderer = new_renderer();
|
||||
renderer = new_renderer(texture_list, texture_count);
|
||||
renderer_initialized = true;
|
||||
}
|
||||
render(&renderer, width, height, time, shader_path, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue