Browse Source

replace remaining 'glm::' types with using directives

remotes/bxxa/master
cinnaboot 4 years ago
parent
commit
92313472f8
  1. 5
      examples/main.cpp
  2. 10
      include/asset.h
  3. 5
      include/camera.h
  4. 6
      include/entity.h
  5. 4
      include/shader.h
  6. 16
      include/tangerine.h
  7. 10
      include/types.h
  8. 16
      src/asset.cpp
  9. 6
      src/camera.cpp
  10. 10
      src/entity.cpp
  11. 6
      src/shader.cpp
  12. 26
      src/tangerine.cpp

5
examples/main.cpp

@ -6,11 +6,6 @@
#include "tangerine.h"
using glm::vec3;
using glm::vec4;
using glm::uvec4;
using glm::mat4;
bool
loadLights(RenderState* rs)

10
include/asset.h

@ -27,12 +27,12 @@ struct Mesh
{
u32 num_vertices;
u32 num_indices;
glm::vec3* vertices;
glm::vec3* normals;
glm::vec2* uvs;
glm::vec3* colors;
vec3* vertices;
vec3* normals;
vec2* uvs;
vec3* colors;
u16* indices; // NOTE: u16 to match tinygltf library output
glm::mat4* xform;
mat4* xform;
};
#define MAX_PATH_SIZE 256

5
include/camera.h

@ -6,11 +6,6 @@
#include "types.h"
#include "shader.h"
using glm::ivec2;
using glm::vec2;
using glm::vec3;
using glm::mat4;
struct Transforms
{

6
include/entity.h

@ -12,7 +12,7 @@ struct Entity
u32 num_meshes;
GLMesh* meshes;
GLTexture* diffuse_texture; // NOTE: pointer into gl_ctx->textures array
glm::mat4* model_xform;
mat4* model_xform;
char* name;
};
@ -25,8 +25,8 @@ bool initEntity(Entity* e,
GLBufferToAttribMapping* attrib_mappings,
const char* name = "");
void setEntityPosition(Entity* e, glm::vec3 pos);
void setEntityPosition(Entity* e, vec3 pos);
void rotateEntity(Entity* e, glm::vec3 axis, float radians);
void rotateEntity(Entity* e, vec3 axis, float radians);
void scaleEntity(Entity* e, float scale);

4
include/shader.h

@ -147,7 +147,7 @@ struct GLMesh
GLenum draw_mode; // NOTE: GL_LINES, GL_TRIANGLES
GLenum usage; // NOTE: GL_STATIC_DRAW, GL_DYNAMIC_DRAW
glm::mat4* node_xform;
mat4* node_xform;
u32 num_vertex_attrib_buffers;
GLBuffer* vertex_attrib_buffers;
@ -198,7 +198,7 @@ GLBuffer* initGLBackingBuffer(GLContext* gl_ctx,
void updateGLBuffer(GLBuffer* gl_buf, void* data);
void renderVAO(GLMesh* glmesh,
glm::mat4* node_xform,
mat4* node_xform,
ShaderProgram* shader,
GLTexture* gl_tex);

16
include/tangerine.h

@ -84,8 +84,6 @@
#include "types.h"
#include "util.h"
using glm::uvec2;
struct SDLHandles
{
@ -157,15 +155,15 @@ struct LightsBuffer
u32* max_d_lights;
u32* active_d_lights;
glm::vec4* ambient_color;
vec4* ambient_color;
glm::vec4* pl_positions;
glm::vec4* pl_colors;
glm::uvec4* pl_intensities;
vec4* pl_positions;
vec4* pl_colors;
uvec4* pl_intensities;
glm::vec4* dl_directions;
glm::vec4* dl_colors;
glm::uvec4* dl_intensities;
vec4* dl_directions;
vec4* dl_colors;
uvec4* dl_intensities;
void* buffer;
};

10
include/types.h

@ -2,6 +2,7 @@
#pragma once
#include <cstdint>
#include <glm/glm.hpp>
typedef uint8_t u8;
@ -11,3 +12,12 @@ typedef uint64_t u64;
typedef int32_t i32;
typedef int64_t i64;
using glm::ivec2;
using glm::uvec2;
using glm::uvec4;
using glm::vec2;
using glm::vec3;
using glm::vec4;
using glm::mat4;

16
src/asset.cpp

@ -213,27 +213,27 @@ copyBuffer(uint8_t*& buffer_ref,
}
// FIXME: need to implement tree structure for blender models to work properly
glm::mat4*
mat4*
parseNodeTransform(MemoryArena* arena, const tinygltf::Node* node)
{
if (node->rotation.size() == 4
&& node->scale.size() == 3
&& node->translation.size() == 3)
{
glm::mat4* xform = ARENA_ALLOC(arena, glm::mat4, 1);
*xform = glm::mat4(1.0f);
mat4* xform = ARENA_ALLOC(arena, mat4, 1);
*xform = mat4(1.0f);
*xform = glm::rotate(*xform, (float) node->rotation[3],
glm::vec3((float) node->rotation[0],
vec3((float) node->rotation[0],
(float) node->rotation[1],
(float) node->rotation[2])
);
*xform = glm::scale(*xform,
glm::vec3((float) node->scale[0],
vec3((float) node->scale[0],
(float) node->scale[0],
(float) node->scale[0])
);
*xform = glm::translate(*xform,
glm::vec3((float) node->translation[0],
vec3((float) node->translation[0],
(float) node->translation[0],
(float) node->translation[0])
);
@ -269,8 +269,8 @@ parseMeshNode(Mesh* m,
m->num_indices = index_acc.count;
// FIXME: the node transforms from blender only work as part of a node tree
#if 1
m->xform = ARENA_ALLOC(arena, glm::mat4, 1);
*m->xform = glm::mat4(1.0f);
m->xform = ARENA_ALLOC(arena, mat4, 1);
*m->xform = mat4(1.0f);
#else
m->xform = parseNodeTransform(arena, &node);
#endif

6
src/camera.cpp

@ -7,12 +7,6 @@
#include "camera.h"
using glm::ivec2;
using glm::vec2;
using glm::vec3;
using glm::vec4;
using glm::mat4;
// TODO: add these props to scene json
#define MOVE_SPEED 5.f

10
src/entity.cpp

@ -16,8 +16,8 @@ initEntity(Entity* e,
{
e->num_meshes = mdl->num_meshes;
e->meshes = ARENA_ALLOC(arena, GLMesh, e->num_meshes);
e->model_xform = ARENA_ALLOC(arena, glm::mat4, 1);
*e->model_xform = glm::mat4(1.f);
e->model_xform = ARENA_ALLOC(arena, mat4, 1);
*e->model_xform = mat4(1.f);
e->name = arenaCopyCStr(arena, name);
if (mdl->diffuse_texture) {
@ -46,7 +46,7 @@ initEntity(Entity* e,
}
void
setEntityPosition(Entity* e, glm::vec3 pos)
setEntityPosition(Entity* e, vec3 pos)
{
(*e->model_xform)[3][0] = pos.x;
(*e->model_xform)[3][1] = pos.y;
@ -54,7 +54,7 @@ setEntityPosition(Entity* e, glm::vec3 pos)
}
void
rotateEntity(Entity* e, glm::vec3 axis, float radians)
rotateEntity(Entity* e, vec3 axis, float radians)
{
*e->model_xform = glm::rotate(*e->model_xform, radians, axis);
}
@ -63,6 +63,6 @@ void
scaleEntity(Entity* e, float scale)
{
*e->model_xform =
glm::scale(*e->model_xform, glm::vec3(scale, scale, scale));
glm::scale(*e->model_xform, vec3(scale, scale, scale));
}

6
src/shader.cpp

@ -254,7 +254,7 @@ updateGLBuffer(GLBuffer* gl_buf, void* data)
void
renderVAO(GLMesh* glmesh,
glm::mat4* node_xform,
mat4* node_xform,
ShaderProgram* shader,
GLTexture* gl_tex)
{
@ -308,8 +308,8 @@ initGLMesh(MemoryArena* arena,
glm.num_vertex_attrib_buffers = num_mappings;
glm .vertex_attrib_buffers = ARENA_ALLOC(arena, GLBuffer, num_mappings);
glm.element_buf = ARENA_ALLOC(arena, GLBuffer, 1);
glm.node_xform = ARENA_ALLOC(arena, glm::mat4, 1);
*glm.node_xform = glm::mat4(1);
glm.node_xform = ARENA_ALLOC(arena, mat4, 1);
*glm.node_xform = mat4(1);
return glm;
}

26
src/tangerine.cpp

@ -7,8 +7,6 @@
#define UTIL_IMPLEMENTATION
#include "util.h"
using glm::vec4;
// forward declarations
@ -325,7 +323,7 @@ initGraphics(SDLHandles* handles, const char* title, uvec2 dims)
LightsBuffer*
initLights(RenderState* rs,
u32 max_lights,
glm::vec4 ambient_color)
vec4 ambient_color)
{
// FIXME: revisit for 'Scene' abstraction
// FIXME: see if we can simplify this with the use of offsetof()
@ -333,8 +331,8 @@ initLights(RenderState* rs,
LightsBuffer* lb = ARENA_ALLOC(rs->assets.arena, LightsBuffer, 1);
lb->buf_size = 8 * sizeof(u32) // NOTE: 'header'
+ sizeof(glm::vec4) // NOTE: ambient color
+ 6 * max_lights * sizeof(glm::vec4); // NOTE: vector arrays
+ sizeof(vec4) // NOTE: ambient color
+ 6 * max_lights * sizeof(vec4); // NOTE: vector arrays
LOGF(Debug, "buf_size: %d\n", lb->buf_size);
lb->buffer = ARENA_ALLOC(rs->assets.arena, u8, lb->buf_size);
@ -355,23 +353,23 @@ initLights(RenderState* rs,
void* arr_start = arenaGetAddressOffset(lb->buffer, 8 * sizeof(u32));
// NOTE: ambient color
lb->ambient_color = (glm::vec4*) arr_start;
lb->ambient_color = (vec4*) arr_start;
*lb->ambient_color = ambient_color;
// NOTE: set offsets for array pointers
u32 arr_size = max_lights * sizeof(glm::vec4);
lb->pl_positions = //(glm::vec4*) arr_start;
(glm::vec4*) arenaGetAddressOffset(arr_start, sizeof(glm::vec4));
u32 arr_size = max_lights * sizeof(vec4);
lb->pl_positions = //(vec4*) arr_start;
(vec4*) arenaGetAddressOffset(arr_start, sizeof(vec4));
lb->pl_colors =
(glm::vec4*) arenaGetAddressOffset(lb->pl_positions, arr_size);
(vec4*) arenaGetAddressOffset(lb->pl_positions, arr_size);
lb->pl_intensities =
(glm::uvec4*) arenaGetAddressOffset(lb->pl_colors, arr_size);
(uvec4*) arenaGetAddressOffset(lb->pl_colors, arr_size);
lb->dl_directions =
(glm::vec4*) arenaGetAddressOffset(lb->pl_intensities, arr_size);
(vec4*) arenaGetAddressOffset(lb->pl_intensities, arr_size);
lb->dl_colors =
(glm::vec4*) arenaGetAddressOffset(lb->dl_directions, arr_size);
(vec4*) arenaGetAddressOffset(lb->dl_directions, arr_size);
lb->dl_intensities =
(glm::uvec4*) arenaGetAddressOffset(lb->dl_colors, arr_size);
(uvec4*) arenaGetAddressOffset(lb->dl_colors, arr_size);
initGLBackingBuffer(rs->gl_ctx,
rs->assets.arena,

Loading…
Cancel
Save