diff options
author | Mike Erwin <significant.bit@gmail.com> | 2017-03-17 06:32:35 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2017-03-17 06:32:35 +0300 |
commit | 4452bea2f170ec7fe48c223c8c499f1eb9b5356c (patch) | |
tree | 28dcc9ac042fcce5c77f3c60b4ce8af8677fa4a8 /intern/gawain/src/primitive.c | |
parent | b4e8dc8c82dfcae60f33e39684272867745a8af2 (diff) |
move Gawain library to intern
Before now it lived in source/blender/gpu for convenience. Only a few files in the gpu module use Gawain directly.
Tested on Mac, time to push and test on Windows.
Todo: some CMake magic to make it easy to
#include "gawain/some_header.h"
from any C or H file. Main problem here is the many editors that include GPU_immediate.h which includes Gawain's immediate.h -- is there a way to avoid changing every editor's CMakeLists?
Diffstat (limited to 'intern/gawain/src/primitive.c')
-rw-r--r-- | intern/gawain/src/primitive.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/intern/gawain/src/primitive.c b/intern/gawain/src/primitive.c new file mode 100644 index 00000000000..95472c289e8 --- /dev/null +++ b/intern/gawain/src/primitive.c @@ -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); + } |