Gawain: move PRIM types to new file, classify by geometry
PrimitiveClass will help match shaders to draw calls & detect usage errors. For example a point sprite shader only makes sense with PRIM_POINTS. Updated other files to include new primitive.h
This commit is contained in:
parent
a99495d291
commit
33758c7cb8
|
@ -81,6 +81,8 @@ set(SRC
|
|||
gawain/immediate.h
|
||||
gawain/imm_util.c
|
||||
gawain/imm_util.h
|
||||
gawain/primitive.h
|
||||
gawain/primitive.c
|
||||
gawain/vertex_buffer.c
|
||||
gawain/vertex_buffer.h
|
||||
gawain/vertex_format.c
|
||||
|
|
|
@ -39,20 +39,3 @@
|
|||
#undef glBindVertexArray
|
||||
#define glBindVertexArray glBindVertexArrayAPPLE
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PRIM_POINTS = GL_POINTS,
|
||||
PRIM_LINES = GL_LINES,
|
||||
PRIM_TRIANGLES = GL_TRIANGLES,
|
||||
|
||||
#ifdef WITH_GL_PROFILE_COMPAT
|
||||
PRIM_QUADS = GL_QUADS, // legacy GL has this, modern GL & Vulkan do not
|
||||
#endif
|
||||
|
||||
PRIM_LINE_STRIP = GL_LINE_STRIP,
|
||||
PRIM_LINE_LOOP = GL_LINE_LOOP, // GL has this, Vulkan does not
|
||||
PRIM_TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
|
||||
PRIM_TRIANGLE_FAN = GL_TRIANGLE_FAN,
|
||||
|
||||
PRIM_NONE = 0xF
|
||||
} PrimitiveType;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include "primitive.h"
|
||||
|
||||
#define TRACK_INDEX_RANGE 1
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "vertex_format.h"
|
||||
#include "primitive.h"
|
||||
|
||||
#define IMM_BATCH_COMBO 1
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
// Gawain geometric primitives
|
||||
//
|
||||
// This code is part of the Gawain library, with modifications
|
||||
// specific to integration with Blender.
|
||||
//
|
||||
// Copyright 2017 Mike Erwin
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
|
||||
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "primitive.h"
|
||||
|
||||
PrimitiveClass prim_class_of_type(PrimitiveType prim_type)
|
||||
{
|
||||
static const PrimitiveClass classes[] =
|
||||
{
|
||||
[PRIM_NONE] = PRIM_CLASS_NONE,
|
||||
[PRIM_POINTS] = PRIM_CLASS_POINT,
|
||||
[PRIM_LINES] = PRIM_CLASS_LINE,
|
||||
[PRIM_LINE_STRIP] = PRIM_CLASS_LINE,
|
||||
[PRIM_LINE_LOOP] = PRIM_CLASS_LINE,
|
||||
[PRIM_TRIANGLES] = PRIM_CLASS_SURFACE,
|
||||
[PRIM_TRIANGLE_STRIP] = PRIM_CLASS_SURFACE,
|
||||
[PRIM_TRIANGLE_FAN] = PRIM_CLASS_SURFACE,
|
||||
|
||||
#ifdef WITH_GL_PROFILE_COMPAT
|
||||
[PRIM_QUADS] = PRIM_CLASS_SURFACE,
|
||||
#endif
|
||||
};
|
||||
|
||||
return classes[prim_type];
|
||||
}
|
||||
|
||||
bool prim_type_belongs_to_class(PrimitiveType prim_type, PrimitiveClass prim_class)
|
||||
{
|
||||
if (prim_class == PRIM_CLASS_NONE && prim_type == PRIM_NONE)
|
||||
return true;
|
||||
|
||||
return prim_class & prim_class_of_type(prim_type);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
// Gawain geometric primitives
|
||||
//
|
||||
// This code is part of the Gawain library, with modifications
|
||||
// specific to integration with Blender.
|
||||
//
|
||||
// Copyright 2017 Mike Erwin
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
|
||||
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef enum {
|
||||
PRIM_POINTS = GL_POINTS,
|
||||
PRIM_LINES = GL_LINES,
|
||||
PRIM_TRIANGLES = GL_TRIANGLES,
|
||||
|
||||
#ifdef WITH_GL_PROFILE_COMPAT
|
||||
PRIM_QUADS = GL_QUADS, // legacy GL has this, modern GL & Vulkan do not
|
||||
#endif
|
||||
|
||||
PRIM_LINE_STRIP = GL_LINE_STRIP,
|
||||
PRIM_LINE_LOOP = GL_LINE_LOOP, // GL has this, Vulkan does not
|
||||
PRIM_TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
|
||||
PRIM_TRIANGLE_FAN = GL_TRIANGLE_FAN,
|
||||
|
||||
PRIM_NONE = 0xF
|
||||
} PrimitiveType;
|
||||
|
||||
// what types of primitives does each shader expect?
|
||||
typedef enum {
|
||||
PRIM_CLASS_NONE = 0,
|
||||
PRIM_CLASS_POINT = (1 << 0),
|
||||
PRIM_CLASS_LINE = (1 << 1),
|
||||
PRIM_CLASS_SURFACE = (1 << 2),
|
||||
PRIM_CLASS_ANY = PRIM_CLASS_POINT | PRIM_CLASS_LINE | PRIM_CLASS_SURFACE
|
||||
} PrimitiveClass;
|
||||
|
||||
PrimitiveClass prim_class_of_type(PrimitiveType);
|
||||
bool prim_type_belongs_to_class(PrimitiveType, PrimitiveClass);
|
Loading…
Reference in New Issue