diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-09-13 09:18:33 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-09-13 09:18:33 +0300 |
commit | b6bd2993598712240bd354e4400d057732cda459 (patch) | |
tree | b6ebbad35ddb8513dd430b5c15eefd0cfcb3819f /source/blender/gpu/GPU_immediate.h | |
parent | 18d49a8283f2490b0751798685770533cc814d29 (diff) |
Gawain: reorganize source code
Put Gawain source code in a subfolder to make the boundary between the
library and the rest of Blender clear.
Changed Gawain’s license from Apache to Mozilla Public License. Has
more essence of copyleft — closer to GPL but not as restrictive.
Split immediate.c into several files so parts can be reused (adding
more files soon…)
Diffstat (limited to 'source/blender/gpu/GPU_immediate.h')
-rw-r--r-- | source/blender/gpu/GPU_immediate.h | 126 |
1 files changed, 30 insertions, 96 deletions
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h index ffd0a6d5afc..8b882751aca 100644 --- a/source/blender/gpu/GPU_immediate.h +++ b/source/blender/gpu/GPU_immediate.h @@ -1,99 +1,33 @@ - -// Gawain immediate mode work-alike, take 2 -// -// This code is part of the Gawain library, with modifications -// specific to integration with Blender. -// -// Copyright 2016 Mike Erwin -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Mike Erwin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/* Immediate mode rendering is powered by the Gawain library. + * This file contains any additions or modifications specific to Blender. + */ #pragma once -#include "GPU_glew.h" -#include <stdbool.h> - -#define PER_THREAD -// #define PER_THREAD __thread -// MSVC uses __declspec(thread) for C code - -#define MAX_VERTEX_ATTRIBS 16 - -#define TRUST_NO_ONE 1 - -typedef enum { - KEEP_FLOAT, - KEEP_INT, - NORMALIZE_INT_TO_FLOAT, // 127 (ubyte) -> 0.5 (and so on for other int types) - CONVERT_INT_TO_FLOAT // 127 (any int type) -> 127.0 -} VertexFetchMode; - -typedef struct { - GLenum comp_type; - unsigned comp_ct; // 1 to 4 - unsigned sz; // size in bytes, 1 to 16 - unsigned offset; // from beginning of vertex, in bytes - VertexFetchMode fetch_mode; - char* name; // TODO: shared allocation of all names within a VertexFormat -} Attrib; - -typedef struct { - unsigned attrib_ct; // 0 to 16 (MAX_VERTEX_ATTRIBS) - unsigned stride; // stride in bytes, 1 to 256 - bool packed; - Attrib attribs[MAX_VERTEX_ATTRIBS]; // TODO: variable-size attribs array -} VertexFormat; - -void clear_VertexFormat(VertexFormat*); -unsigned add_attrib(VertexFormat*, const char* name, GLenum comp_type, unsigned comp_ct, VertexFetchMode); -void pack(VertexFormat*); -// unsigned attrib_idx(const VertexFormat*, const char* name); -void bind_attrib_locations(const VertexFormat*, GLuint program); - -// --- immediate mode work-alike -------------------------------- - -void immInit(void); -void immDestroy(void); - -VertexFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib - -void immBindProgram(GLuint program); -void immUnbindProgram(void); - -void immBegin(GLenum primitive, unsigned vertex_ct); // must supply exactly vertex_ct vertices -void immBeginAtMost(GLenum primitive, unsigned max_vertex_ct); // can supply fewer vertices -void immEnd(void); - -void immAttrib1f(unsigned attrib_id, float x); -void immAttrib2f(unsigned attrib_id, float x, float y); -void immAttrib3f(unsigned attrib_id, float x, float y, float z); -void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w); - -void immAttrib3fv(unsigned attrib_id, const float data[3]); -void immAttrib4fv(unsigned attrib_id, const float data[4]); - -void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b); -void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a); - -void immAttrib3ubv(unsigned attrib_id, const unsigned char data[4]); -void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]); - -void immEndVertex(void); // and move on to the next vertex - -// provide 2D or 3D attribute value and end the current vertex, similar to glVertex: -void immVertex2f(unsigned attrib_id, float x, float y); -void immVertex3f(unsigned attrib_id, float x, float y, float z); - -void immVertex2fv(unsigned attrib_id, const float data[2]); -void immVertex3fv(unsigned attrib_id, const float data[3]); - -// provide values that don't change for the entire draw call -void immUniform4f(const char* name, float x, float y, float z, float w); - -// these set "uniform vec4 color" -// TODO: treat as sRGB? -void immUniformColor3ubv(const unsigned char data[3]); -void immUniformColor4ubv(const unsigned char data[4]); +#include "gawain/immediate.h" |