Fix interface types and constness.
This commit is contained in:
parent
beca8798bf
commit
afad17d517
20
cpp/math.cpp
20
cpp/math.cpp
@ -19,7 +19,7 @@ void rk_vec3_rotate(
|
||||
rk_vec3 & ret,
|
||||
rk_vec3 const & vec3,
|
||||
rk_vec3 const & axis,
|
||||
float const angle) {
|
||||
rk_float const angle) {
|
||||
ret = glm::angleAxis(angle, axis) * vec3;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ void rk_vec3_mul_vec3(
|
||||
void rk_mat3_rotation(
|
||||
rk_mat3 & ret,
|
||||
rk_vec3 const & axis,
|
||||
float const angle) {
|
||||
rk_float const angle) {
|
||||
ret = glm::mat3_cast(glm::angleAxis(angle, axis));
|
||||
}
|
||||
|
||||
@ -53,10 +53,10 @@ void rk_mat3_mul_mat3(
|
||||
|
||||
void rk_mat4_projection(
|
||||
rk_mat4 & ret,
|
||||
float hfov,
|
||||
float ratio,
|
||||
float near,
|
||||
float far) {
|
||||
rk_float hfov,
|
||||
rk_float ratio,
|
||||
rk_float near,
|
||||
rk_float far) {
|
||||
ret = glm::perspectiveRH(hfov, ratio, near, far);
|
||||
}
|
||||
|
||||
@ -70,9 +70,9 @@ void rk_mat4_lookat(
|
||||
void rk_mat4_orbit(
|
||||
rk_mat4 & ret,
|
||||
rk_vec3 const & origin,
|
||||
float const yaw,
|
||||
float const pitch,
|
||||
float const distance) {
|
||||
rk_float const yaw,
|
||||
rk_float const pitch,
|
||||
rk_float const distance) {
|
||||
ret = glm::translate(
|
||||
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)),
|
||||
@ -83,7 +83,7 @@ void rk_mat4_mul_vec3(
|
||||
rk_vec3 & ret,
|
||||
rk_mat4 const & a,
|
||||
rk_vec3 const & b,
|
||||
float const w) {
|
||||
rk_float const w) {
|
||||
ret = glm::vec3(a * glm::vec4(b, w));
|
||||
}
|
||||
|
||||
|
20
cpp/math.hpp
20
cpp/math.hpp
@ -35,7 +35,7 @@ RK_EXPORT void rk_vec3_rotate(
|
||||
rk_vec3 & ret,
|
||||
rk_vec3 const & vec3,
|
||||
rk_vec3 const & axis,
|
||||
float const angle);
|
||||
rk_float const angle);
|
||||
|
||||
RK_EXPORT void rk_vec3_mul_vec3(
|
||||
rk_vec3 & ret,
|
||||
@ -45,7 +45,7 @@ RK_EXPORT void rk_vec3_mul_vec3(
|
||||
RK_EXPORT void rk_mat3_rotation(
|
||||
rk_mat3 & ret,
|
||||
rk_vec3 const & axis,
|
||||
float const angle);
|
||||
rk_float const angle);
|
||||
|
||||
RK_EXPORT void rk_mat3_mul_vec3(
|
||||
rk_vec3 & ret,
|
||||
@ -59,10 +59,10 @@ RK_EXPORT void rk_mat3_mul_mat3(
|
||||
|
||||
RK_EXPORT void rk_mat4_projection(
|
||||
rk_mat4 & ret,
|
||||
float hfov,
|
||||
float ratio,
|
||||
float near,
|
||||
float far);
|
||||
rk_float hfov,
|
||||
rk_float ratio,
|
||||
rk_float near,
|
||||
rk_float far);
|
||||
|
||||
RK_EXPORT void rk_mat4_lookat(
|
||||
rk_mat4 & ret,
|
||||
@ -72,15 +72,15 @@ RK_EXPORT void rk_mat4_lookat(
|
||||
RK_EXPORT void rk_mat4_orbit(
|
||||
rk_mat4 & ret,
|
||||
rk_vec3 const & origin,
|
||||
float const yaw,
|
||||
float const pitch,
|
||||
float const distance);
|
||||
rk_float const yaw,
|
||||
rk_float const pitch,
|
||||
rk_float const distance);
|
||||
|
||||
RK_EXPORT void rk_mat4_mul_vec3(
|
||||
rk_vec3 & ret,
|
||||
rk_mat4 const & a,
|
||||
rk_vec3 const & b,
|
||||
float const w);
|
||||
rk_float const w);
|
||||
|
||||
RK_EXPORT void rk_mat4_mul_vec4(
|
||||
rk_vec4 & ret,
|
||||
|
@ -87,17 +87,17 @@ RK_EXPORT void rk_render_terminate();
|
||||
|
||||
RK_EXPORT rk_shader_t rk_create_shader(
|
||||
rk_uint const vert_nlines,
|
||||
char const ** const vert_lines,
|
||||
rk_char const * const * vert_lines,
|
||||
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_shader_t shader,
|
||||
char const * name);
|
||||
rk_char const * name);
|
||||
|
||||
RK_EXPORT rk_param_t rk_resolve_param(
|
||||
rk_shader_t shader,
|
||||
char const * name);
|
||||
rk_char const * name);
|
||||
|
||||
RK_EXPORT rk_texture_t rk_create_texture(
|
||||
rk_texture_format format,
|
||||
@ -168,7 +168,7 @@ RK_EXPORT void rk_draw_batch(
|
||||
rk_uint size,
|
||||
rk_instance_flags const * flags,
|
||||
rk_mesh const * meshes,
|
||||
rk_ubyte const ** params);
|
||||
rk_ubyte const * const * params);
|
||||
|
||||
RK_EXPORT void rk_unselect_texture(
|
||||
rk_uint slot,
|
||||
|
@ -114,9 +114,9 @@ static void rk_print_program_infolog(GLuint program) {
|
||||
|
||||
rk_shader_t rk_create_shader(
|
||||
rk_uint const vert_nlines,
|
||||
char const ** const vert_lines,
|
||||
rk_char const * const * vert_lines,
|
||||
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) {
|
||||
rk_printf("rk_load_shader(): invalid params.");
|
||||
return RK_INVALID_HANDLE;
|
||||
@ -172,7 +172,7 @@ rk_shader_t rk_create_shader(
|
||||
|
||||
rk_input_t rk_resolve_input(
|
||||
rk_shader_t _shader,
|
||||
char const * name) {
|
||||
rk_char const * name) {
|
||||
rk_shader const * const shader = reinterpret_cast<rk_shader const *>(_shader);
|
||||
if (!shader || !name) {
|
||||
rk_printf("rk_resolve_input(): invalid params.");
|
||||
@ -187,7 +187,7 @@ rk_input_t rk_resolve_input(
|
||||
|
||||
rk_param_t rk_resolve_param(
|
||||
rk_shader_t _shader,
|
||||
char const * name) {
|
||||
rk_char const * name) {
|
||||
rk_shader const * const shader = reinterpret_cast<rk_shader const *>(_shader);
|
||||
if (!shader || !name) {
|
||||
rk_printf("rk_resolve_param(): invalid params.");
|
||||
@ -815,7 +815,7 @@ static unsigned rk_batch_build_commands(
|
||||
static void rk_batch_pack(
|
||||
rk_batch const & batch,
|
||||
unsigned const ninstances,
|
||||
rk_ubyte const ** srcs) {
|
||||
rk_ubyte const * const * srcs) {
|
||||
rk_parameter const * const last_param = batch.params + batch.nparams;
|
||||
for (rk_parameter const * param = batch.params; param < last_param; ++param) {
|
||||
rk_ubyte const * const src = *srcs++;
|
||||
@ -836,7 +836,7 @@ void rk_draw_batch(
|
||||
rk_uint count,
|
||||
rk_instance_flags const * flags,
|
||||
rk_mesh const * meshes,
|
||||
rk_ubyte const ** params) {
|
||||
rk_ubyte const * const * params) {
|
||||
rk_batch const * const batch = reinterpret_cast<rk_batch const *>(_batch);
|
||||
if (!batch || !count || count > batch->max_size || !flags || !meshes) {
|
||||
return;
|
||||
|
@ -33,7 +33,7 @@ typedef int32_t rk_int;
|
||||
typedef uint32_t rk_uint;
|
||||
typedef int64_t rk_long;
|
||||
typedef uint64_t rk_ulong;
|
||||
|
||||
typedef float rk_float;
|
||||
typedef void * rk_handle_t;
|
||||
|
||||
#define RK_INVALID_HANDLE nullptr
|
||||
|
Loading…
Reference in New Issue
Block a user