summaryrefslogtreecommitdiff
path: root/gfx/src/core/geometry.h
blob: c37a76f07b5539420c306e4f2abf5373dca134fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

#include <gfx/core.h>

#include "gl_util.h"

#include <stdbool.h>

/// A piece of renderable geometry.
///
/// The Geometry does not own its buffers, since buffers are typically shared
/// to reduce the memory footprint and the number of draw calls. More generally,
/// the renderer assumes ownership of all rendering resources, which simplifies
/// their management.
typedef struct Geometry {
  GLuint       vao;
  GLenum       mode;
  GeometryDesc desc;
  size_t num_verts; // May differ from the initial value in the descriptor if
                    // the geometry is updated.
  GfxCore* gfxcore;
} Geometry;

/// Create new geometry.
bool gfx_init_geometry(Geometry*, GfxCore*, const GeometryDesc*);

/// Destroy the geometry.
void gfx_del_geometry(Geometry*);