Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gwn_primitive.c « src « gawain « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b206b3ae1b3ad2699e8015c566ddc5d27b724098 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

// 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 "gwn_primitive.h"
#include "gwn_primitive_private.h"

Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type)
	{
	static const Gwn_PrimClass classes[] =
		{
		[GWN_PRIM_POINTS] = GWN_PRIM_CLASS_POINT,
		[GWN_PRIM_LINES] = GWN_PRIM_CLASS_LINE,
		[GWN_PRIM_LINE_STRIP] = GWN_PRIM_CLASS_LINE,
		[GWN_PRIM_LINE_LOOP] = GWN_PRIM_CLASS_LINE,
		[GWN_PRIM_TRIS] = GWN_PRIM_CLASS_SURFACE,
		[GWN_PRIM_TRI_STRIP] = GWN_PRIM_CLASS_SURFACE,
		[GWN_PRIM_TRI_FAN] = GWN_PRIM_CLASS_SURFACE,

		[GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE,

		[GWN_PRIM_NONE] = GWN_PRIM_CLASS_NONE
		};

	return classes[prim_type];
	}

bool GWN_primtype_belongs_to_class(Gwn_PrimType prim_type, Gwn_PrimClass prim_class)
	{
	if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE)
		return true;

	return prim_class & GWN_primtype_class(prim_type);
	}

GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type)
	{
#if TRUST_NO_ONE
	assert(prim_type != GWN_PRIM_NONE);
#endif

	static const GLenum table[] =
		{
		[GWN_PRIM_POINTS] = GL_POINTS,
		[GWN_PRIM_LINES] = GL_LINES,
		[GWN_PRIM_LINE_STRIP] = GL_LINE_STRIP,
		[GWN_PRIM_LINE_LOOP] = GL_LINE_LOOP,
		[GWN_PRIM_TRIS] = GWN_PRIM_CLASS_SURFACE,
		[GWN_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP,
		[GWN_PRIM_TRI_FAN] = GL_TRIANGLE_FAN,

		[GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY,
		};

	return table[prim_type];
	}