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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/GPU_immediate.h')
-rw-r--r--source/blender/gpu/GPU_immediate.h112
1 files changed, 101 insertions, 11 deletions
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 2a2692e6baf..c8a4ea6a837 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -24,29 +24,113 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/* Immediate mode rendering is powered by the Gawain library.
- * This file contains any additions or modifications specific to Blender.
+/** \file blender/gpu/GPU_immediate.h
+ * \ingroup gpu
+ *
+ * GPU immediate mode work-alike
*/
#ifndef __GPU_IMMEDIATE_H__
#define __GPU_IMMEDIATE_H__
-#include "../../../intern/gawain/gawain/gwn_immediate.h"
-#include "../../../intern/gawain/gawain/gwn_imm_util.h"
+#include "GPU_vertex_format.h"
+#include "GPU_primitive.h"
+#include "GPU_shader_interface.h"
+#include "GPU_batch.h"
+#include "GPU_immediate_util.h"
+#include "GPU_shader.h"
-// TODO: CMake magic to do this:
-// #include "gawain/gwn_immediate.h"
-// #include "gawain/gwn_imm_util.h"
+GPUVertFormat *immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */
-#include "GPU_shader.h"
+void immBindProgram(uint32_t program, const GPUShaderInterface *); /* every immBegin must have a program bound first. */
+void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */
+
+void immBegin(GPUPrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */
+void immBeginAtMost(GPUPrimType, uint max_vertex_len); /* can supply fewer vertices. */
+void immEnd(void); /* finishes and draws. */
+
+/* ImmBegin a batch, then use standard immFunctions as usual. */
+/* ImmEnd will finalize the batch instead of drawing. */
+/* Then you can draw it as many times as you like! Partially replaces the need for display lists. */
+GPUBatch *immBeginBatch(GPUPrimType, uint vertex_len);
+GPUBatch *immBeginBatchAtMost(GPUPrimType, uint vertex_len);
+
+/* Provide attribute values that can change per vertex. */
+/* First vertex after immBegin must have all its attributes specified. */
+/* Skipped attributes will continue using the previous value for that attrib_id. */
+void immAttrib1f(uint attrib_id, float x);
+void immAttrib2f(uint attrib_id, float x, float y);
+void immAttrib3f(uint attrib_id, float x, float y, float z);
+void immAttrib4f(uint attrib_id, float x, float y, float z, float w);
+
+void immAttrib2i(uint attrib_id, int x, int y);
+
+void immAttrib1u(uint attrib_id, uint x);
+
+void immAttrib2s(uint attrib_id, short x, short y);
+
+void immAttrib2fv(uint attrib_id, const float data[2]);
+void immAttrib3fv(uint attrib_id, const float data[3]);
+void immAttrib4fv(uint attrib_id, const float data[4]);
+
+void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b);
+void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
+
+void immAttrib3ubv(uint attrib_id, const unsigned char data[4]);
+void immAttrib4ubv(uint attrib_id, const unsigned char data[4]);
+
+/* Explicitly skip an attribute. */
+/* This advanced option kills automatic value copying for this attrib_id. */
+void immSkipAttrib(uint attrib_id);
+
+/* Provide one last attribute value & end the current vertex. */
+/* This is most often used for 2D or 3D position (similar to glVertex). */
+void immVertex2f(uint attrib_id, float x, float y);
+void immVertex3f(uint attrib_id, float x, float y, float z);
+void immVertex4f(uint attrib_id, float x, float y, float z, float w);
+
+void immVertex2i(uint attrib_id, int x, int y);
+
+void immVertex2s(uint attrib_id, short x, short y);
+
+void immVertex2fv(uint attrib_id, const float data[2]);
+void immVertex3fv(uint attrib_id, const float data[3]);
+
+void immVertex2iv(uint attrib_id, const int data[2]);
+
+/* Provide uniform values that don't change for the entire draw call. */
+void immUniform1i(const char *name, int x);
+void immUniform4iv(const char *name, const int data[4]);
+void immUniform1f(const char *name, float x);
+void immUniform2f(const char *name, float x, float y);
+void immUniform2fv(const char *name, const float data[2]);
+void immUniform3f(const char *name, float x, float y, float z);
+void immUniform3fv(const char *name, const float data[3]);
+void immUniformArray3fv(const char *name, const float *data, int count);
+void immUniform4f(const char *name, float x, float y, float z, float w);
+void immUniform4fv(const char *name, const float data[4]);
+void immUniformArray4fv(const char *bare_name, const float *data, int count);
+void immUniformMatrix4fv(const char *name, const float data[4][4]);
+
+/* Convenience functions for setting "uniform vec4 color". */
+/* The rgb functions have implicit alpha = 1.0. */
+void immUniformColor4f(float r, float g, float b, float a);
+void immUniformColor4fv(const float rgba[4]);
+void immUniformColor3f(float r, float g, float b);
+void immUniformColor3fv(const float rgb[3]);
+void immUniformColor3fvAlpha(const float rgb[3], float a);
+
+void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b);
+void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
+void immUniformColor3ubv(const unsigned char rgb[3]);
+void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a);
+void immUniformColor4ubv(const unsigned char rgba[4]);
/* Extend immBindProgram to use Blender’s library of built-in shader programs.
* Use immUnbindProgram() when done. */
void immBindBuiltinProgram(GPUBuiltinShader shader_id);
-/*
- * Extend immUniformColor to take Blender's themes
- */
+/* Extend immUniformColor to take Blender's themes */
void immUniformThemeColor(int color_id);
void immUniformThemeColor3(int color_id);
void immUniformThemeColorShade(int color_id, int offset);
@@ -55,4 +139,10 @@ void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int
void immUniformThemeColorBlend(int color_id1, int color_id2, float fac);
void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset);
+/* These are called by the system -- not part of drawing API. */
+void immInit(void);
+void immActivate(void);
+void immDeactivate(void);
+void immDestroy(void);
+
#endif /* __GPU_IMMEDIATE_H__ */