Fix interface types and constness.

This commit is contained in:
Roz K 2023-01-02 12:14:13 +01:00
parent beca8798bf
commit afad17d517
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
5 changed files with 32 additions and 32 deletions

View File

@ -19,7 +19,7 @@ void rk_vec3_rotate(
rk_vec3 & ret, rk_vec3 & ret,
rk_vec3 const & vec3, rk_vec3 const & vec3,
rk_vec3 const & axis, rk_vec3 const & axis,
float const angle) { rk_float const angle) {
ret = glm::angleAxis(angle, axis) * vec3; ret = glm::angleAxis(angle, axis) * vec3;
} }
@ -33,7 +33,7 @@ void rk_vec3_mul_vec3(
void rk_mat3_rotation( void rk_mat3_rotation(
rk_mat3 & ret, rk_mat3 & ret,
rk_vec3 const & axis, rk_vec3 const & axis,
float const angle) { rk_float const angle) {
ret = glm::mat3_cast(glm::angleAxis(angle, axis)); ret = glm::mat3_cast(glm::angleAxis(angle, axis));
} }
@ -53,10 +53,10 @@ void rk_mat3_mul_mat3(
void rk_mat4_projection( void rk_mat4_projection(
rk_mat4 & ret, rk_mat4 & ret,
float hfov, rk_float hfov,
float ratio, rk_float ratio,
float near, rk_float near,
float far) { rk_float far) {
ret = glm::perspectiveRH(hfov, ratio, near, far); ret = glm::perspectiveRH(hfov, ratio, near, far);
} }
@ -70,9 +70,9 @@ void rk_mat4_lookat(
void rk_mat4_orbit( void rk_mat4_orbit(
rk_mat4 & ret, rk_mat4 & ret,
rk_vec3 const & origin, rk_vec3 const & origin,
float const yaw, rk_float const yaw,
float const pitch, rk_float const pitch,
float const distance) { rk_float const distance) {
ret = glm::translate( ret = glm::translate(
glm::lookAtRH(glm::vec3(0.f, -distance, 0.f), vec3_origin, vec3_up) * glm::lookAtRH(glm::vec3(0.f, -distance, 0.f), vec3_origin, vec3_up) *
glm::mat4(glm::angleAxis(pitch, vec3_right) * glm::angleAxis(yaw, vec3_up)), glm::mat4(glm::angleAxis(pitch, vec3_right) * glm::angleAxis(yaw, vec3_up)),
@ -83,7 +83,7 @@ void rk_mat4_mul_vec3(
rk_vec3 & ret, rk_vec3 & ret,
rk_mat4 const & a, rk_mat4 const & a,
rk_vec3 const & b, rk_vec3 const & b,
float const w) { rk_float const w) {
ret = glm::vec3(a * glm::vec4(b, w)); ret = glm::vec3(a * glm::vec4(b, w));
} }

View File

@ -35,7 +35,7 @@ RK_EXPORT void rk_vec3_rotate(
rk_vec3 & ret, rk_vec3 & ret,
rk_vec3 const & vec3, rk_vec3 const & vec3,
rk_vec3 const & axis, rk_vec3 const & axis,
float const angle); rk_float const angle);
RK_EXPORT void rk_vec3_mul_vec3( RK_EXPORT void rk_vec3_mul_vec3(
rk_vec3 & ret, rk_vec3 & ret,
@ -45,7 +45,7 @@ RK_EXPORT void rk_vec3_mul_vec3(
RK_EXPORT void rk_mat3_rotation( RK_EXPORT void rk_mat3_rotation(
rk_mat3 & ret, rk_mat3 & ret,
rk_vec3 const & axis, rk_vec3 const & axis,
float const angle); rk_float const angle);
RK_EXPORT void rk_mat3_mul_vec3( RK_EXPORT void rk_mat3_mul_vec3(
rk_vec3 & ret, rk_vec3 & ret,
@ -59,10 +59,10 @@ RK_EXPORT void rk_mat3_mul_mat3(
RK_EXPORT void rk_mat4_projection( RK_EXPORT void rk_mat4_projection(
rk_mat4 & ret, rk_mat4 & ret,
float hfov, rk_float hfov,
float ratio, rk_float ratio,
float near, rk_float near,
float far); rk_float far);
RK_EXPORT void rk_mat4_lookat( RK_EXPORT void rk_mat4_lookat(
rk_mat4 & ret, rk_mat4 & ret,
@ -72,15 +72,15 @@ RK_EXPORT void rk_mat4_lookat(
RK_EXPORT void rk_mat4_orbit( RK_EXPORT void rk_mat4_orbit(
rk_mat4 & ret, rk_mat4 & ret,
rk_vec3 const & origin, rk_vec3 const & origin,
float const yaw, rk_float const yaw,
float const pitch, rk_float const pitch,
float const distance); rk_float const distance);
RK_EXPORT void rk_mat4_mul_vec3( RK_EXPORT void rk_mat4_mul_vec3(
rk_vec3 & ret, rk_vec3 & ret,
rk_mat4 const & a, rk_mat4 const & a,
rk_vec3 const & b, rk_vec3 const & b,
float const w); rk_float const w);
RK_EXPORT void rk_mat4_mul_vec4( RK_EXPORT void rk_mat4_mul_vec4(
rk_vec4 & ret, rk_vec4 & ret,

View File

@ -87,17 +87,17 @@ RK_EXPORT void rk_render_terminate();
RK_EXPORT rk_shader_t rk_create_shader( RK_EXPORT rk_shader_t rk_create_shader(
rk_uint const vert_nlines, rk_uint const vert_nlines,
char const ** const vert_lines, rk_char const * const * vert_lines,
rk_uint const frag_nlines, rk_uint const frag_nlines,
char const ** const frag_lines); rk_char const * const * frag_lines);
RK_EXPORT rk_input_t rk_resolve_input( RK_EXPORT rk_input_t rk_resolve_input(
rk_shader_t shader, rk_shader_t shader,
char const * name); rk_char const * name);
RK_EXPORT rk_param_t rk_resolve_param( RK_EXPORT rk_param_t rk_resolve_param(
rk_shader_t shader, rk_shader_t shader,
char const * name); rk_char const * name);
RK_EXPORT rk_texture_t rk_create_texture( RK_EXPORT rk_texture_t rk_create_texture(
rk_texture_format format, rk_texture_format format,
@ -168,7 +168,7 @@ RK_EXPORT void rk_draw_batch(
rk_uint size, rk_uint size,
rk_instance_flags const * flags, rk_instance_flags const * flags,
rk_mesh const * meshes, rk_mesh const * meshes,
rk_ubyte const ** params); rk_ubyte const * const * params);
RK_EXPORT void rk_unselect_texture( RK_EXPORT void rk_unselect_texture(
rk_uint slot, rk_uint slot,

View File

@ -114,9 +114,9 @@ static void rk_print_program_infolog(GLuint program) {
rk_shader_t rk_create_shader( rk_shader_t rk_create_shader(
rk_uint const vert_nlines, rk_uint const vert_nlines,
char const ** const vert_lines, rk_char const * const * vert_lines,
rk_uint const frag_nlines, rk_uint const frag_nlines,
char const ** const frag_lines) { rk_char const * const * const frag_lines) {
if (!vert_nlines || !vert_lines || !frag_nlines || !frag_lines) { if (!vert_nlines || !vert_lines || !frag_nlines || !frag_lines) {
rk_printf("rk_load_shader(): invalid params."); rk_printf("rk_load_shader(): invalid params.");
return RK_INVALID_HANDLE; return RK_INVALID_HANDLE;
@ -172,7 +172,7 @@ rk_shader_t rk_create_shader(
rk_input_t rk_resolve_input( rk_input_t rk_resolve_input(
rk_shader_t _shader, rk_shader_t _shader,
char const * name) { rk_char const * name) {
rk_shader const * const shader = reinterpret_cast<rk_shader const *>(_shader); rk_shader const * const shader = reinterpret_cast<rk_shader const *>(_shader);
if (!shader || !name) { if (!shader || !name) {
rk_printf("rk_resolve_input(): invalid params."); rk_printf("rk_resolve_input(): invalid params.");
@ -187,7 +187,7 @@ rk_input_t rk_resolve_input(
rk_param_t rk_resolve_param( rk_param_t rk_resolve_param(
rk_shader_t _shader, rk_shader_t _shader,
char const * name) { rk_char const * name) {
rk_shader const * const shader = reinterpret_cast<rk_shader const *>(_shader); rk_shader const * const shader = reinterpret_cast<rk_shader const *>(_shader);
if (!shader || !name) { if (!shader || !name) {
rk_printf("rk_resolve_param(): invalid params."); rk_printf("rk_resolve_param(): invalid params.");
@ -815,7 +815,7 @@ static unsigned rk_batch_build_commands(
static void rk_batch_pack( static void rk_batch_pack(
rk_batch const & batch, rk_batch const & batch,
unsigned const ninstances, unsigned const ninstances,
rk_ubyte const ** srcs) { rk_ubyte const * const * srcs) {
rk_parameter const * const last_param = batch.params + batch.nparams; rk_parameter const * const last_param = batch.params + batch.nparams;
for (rk_parameter const * param = batch.params; param < last_param; ++param) { for (rk_parameter const * param = batch.params; param < last_param; ++param) {
rk_ubyte const * const src = *srcs++; rk_ubyte const * const src = *srcs++;
@ -836,7 +836,7 @@ void rk_draw_batch(
rk_uint count, rk_uint count,
rk_instance_flags const * flags, rk_instance_flags const * flags,
rk_mesh const * meshes, rk_mesh const * meshes,
rk_ubyte const ** params) { rk_ubyte const * const * params) {
rk_batch const * const batch = reinterpret_cast<rk_batch const *>(_batch); rk_batch const * const batch = reinterpret_cast<rk_batch const *>(_batch);
if (!batch || !count || count > batch->max_size || !flags || !meshes) { if (!batch || !count || count > batch->max_size || !flags || !meshes) {
return; return;

View File

@ -33,7 +33,7 @@ typedef int32_t rk_int;
typedef uint32_t rk_uint; typedef uint32_t rk_uint;
typedef int64_t rk_long; typedef int64_t rk_long;
typedef uint64_t rk_ulong; typedef uint64_t rk_ulong;
typedef float rk_float;
typedef void * rk_handle_t; typedef void * rk_handle_t;
#define RK_INVALID_HANDLE nullptr #define RK_INVALID_HANDLE nullptr