2020-09-14 00:00:00 +00:00
|
|
|
#include "./cinescope.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "util/math/vector.h"
|
|
|
|
|
2020-10-09 00:00:00 +00:00
|
|
|
#include "./single.h"
|
2020-09-14 00:00:00 +00:00
|
|
|
#include "./uniblock.h"
|
|
|
|
|
|
|
|
/* resources */
|
2020-10-09 00:00:00 +00:00
|
|
|
#include "core/loshader/anysrc/header.shader.h"
|
|
|
|
#include "core/loshader/anysrc/cinescope.vshader.h"
|
|
|
|
#include "core/loshader/anysrc/cinescope.fshader.h"
|
2020-09-14 00:00:00 +00:00
|
|
|
|
2020-10-09 00:00:00 +00:00
|
|
|
#define PRIMITIVE_COUNT_ 12
|
2020-09-14 00:00:00 +00:00
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
typedef struct {
|
|
|
|
vec4_t color;
|
|
|
|
float size;
|
|
|
|
} loshader_cinescope_drawer_internal_param_t;
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2020-10-09 00:00:00 +00:00
|
|
|
_Static_assert(
|
|
|
|
sizeof(float)*5 ==
|
|
|
|
sizeof(loshader_cinescope_drawer_internal_param_t),
|
|
|
|
"recheck the type has no padding");
|
2020-09-14 00:00:00 +00:00
|
|
|
|
2020-10-09 00:00:00 +00:00
|
|
|
void loshader_cinescope_drawer_initialize(
|
|
|
|
loshader_cinescope_drawer_t* drawer,
|
|
|
|
const loshader_uniblock_t* uniblock) {
|
|
|
|
assert(drawer != NULL);
|
|
|
|
assert(uniblock != NULL);
|
2020-09-14 00:00:00 +00:00
|
|
|
|
2020-10-09 00:00:00 +00:00
|
|
|
const gleasy_program_t prog = gleasy_program_new(
|
|
|
|
loshader_header_shader_, sizeof(loshader_header_shader_),
|
2020-09-14 00:00:00 +00:00
|
|
|
loshader_cinescope_vshader_, sizeof(loshader_cinescope_vshader_),
|
|
|
|
loshader_cinescope_fshader_, sizeof(loshader_cinescope_fshader_));
|
|
|
|
|
2020-10-09 00:00:00 +00:00
|
|
|
loshader_single_drawer_initialize(
|
|
|
|
&drawer->super,
|
|
|
|
prog,
|
|
|
|
uniblock,
|
|
|
|
sizeof(loshader_cinescope_drawer_internal_param_t));
|
2020-09-14 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loshader_cinescope_drawer_set_param(
|
|
|
|
loshader_cinescope_drawer_t* drawer,
|
|
|
|
const loshader_cinescope_drawer_param_t* param) {
|
|
|
|
assert(drawer != NULL);
|
|
|
|
assert(param != NULL);
|
|
|
|
|
|
|
|
const loshader_cinescope_drawer_internal_param_t p = {
|
|
|
|
.size = param->size,
|
|
|
|
.color = param->color,
|
|
|
|
};
|
2020-10-09 00:00:00 +00:00
|
|
|
loshader_single_drawer_set_param(&drawer->super, &p);
|
2020-09-14 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loshader_cinescope_drawer_draw(const loshader_cinescope_drawer_t* drawer) {
|
|
|
|
assert(drawer != NULL);
|
|
|
|
|
2020-10-09 00:00:00 +00:00
|
|
|
loshader_single_drawer_draw(&drawer->super, PRIMITIVE_COUNT_);
|
2020-09-14 00:00:00 +00:00
|
|
|
}
|