- mesh_load_obj: parse vertices, UVs, faces from .obj files - Auto-generate face normals - Per-face vertex expansion (simple but correct)
26 lines
587 B
C
26 lines
587 B
C
#pragma once
|
|
#include <d3d11.h>
|
|
#include <stdint.h>
|
|
|
|
typedef struct {
|
|
float pos[3];
|
|
float norm[3];
|
|
float uv[2];
|
|
float color[4];
|
|
} Vertex;
|
|
|
|
typedef struct {
|
|
ID3D11Buffer* vb;
|
|
ID3D11Buffer* ib;
|
|
uint32_t vcount;
|
|
uint32_t icount;
|
|
uint32_t stride;
|
|
} Mesh;
|
|
|
|
Mesh* mesh_create_cube(ID3D11Device* dev);
|
|
Mesh* mesh_create_plane(ID3D11Device* dev, float size);
|
|
Mesh* mesh_create_sphere(ID3D11Device* dev, float r, int seg);
|
|
Mesh* mesh_load_obj(ID3D11Device* dev, const char* path);
|
|
void mesh_destroy(Mesh* m);
|
|
void mesh_draw(Mesh* m, ID3D11DeviceContext* ctx);
|