Gawain API naming refactor
Use consistent prefix for gawain API names as well as some abbreviations to avoid over-long names, see: D2678
This commit is contained in:
@@ -16,4 +16,4 @@
|
||||
typedef struct {
|
||||
uint64_t loc_bits; // store 4 bits for each of the 16 attribs
|
||||
uint16_t enabled_bits; // 1 bit for each attrib
|
||||
} AttribBinding;
|
||||
} Gwn_AttrBinding;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "vertex_format.h"
|
||||
#include "shader_interface.h"
|
||||
|
||||
void AttribBinding_clear(AttribBinding*);
|
||||
void AttribBinding_clear(Gwn_AttrBinding*);
|
||||
|
||||
void get_attrib_locations(const VertexFormat*, AttribBinding*, const ShaderInterface*);
|
||||
unsigned read_attrib_location(const AttribBinding*, unsigned a_idx);
|
||||
void get_attrib_locations(const Gwn_VertFormat*, Gwn_AttrBinding*, const Gwn_ShaderInterface*);
|
||||
unsigned read_attrib_location(const Gwn_AttrBinding*, unsigned a_idx);
|
||||
|
||||
@@ -16,64 +16,64 @@
|
||||
#include "shader_interface.h"
|
||||
|
||||
typedef enum {
|
||||
READY_TO_FORMAT,
|
||||
READY_TO_BUILD,
|
||||
BUILDING,
|
||||
READY_TO_DRAW
|
||||
} BatchPhase;
|
||||
GWN_BATCH_READY_TO_FORMAT,
|
||||
GWN_BATCH_READY_TO_BUILD,
|
||||
GWN_BATCH_BUILDING,
|
||||
GWN_BATCH_READY_TO_DRAW
|
||||
} Gwn_BatchPhase;
|
||||
|
||||
#define BATCH_MAX_VBO_CT 3
|
||||
#define GWN_BATCH_VBO_MAX_LEN 3
|
||||
|
||||
typedef struct Batch {
|
||||
typedef struct Gwn_Batch {
|
||||
// geometry
|
||||
VertexBuffer* verts[BATCH_MAX_VBO_CT]; // verts[0] is required, others can be NULL
|
||||
ElementList* elem; // NULL if element list not needed
|
||||
PrimitiveType prim_type;
|
||||
Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; // verts[0] is required, others can be NULL
|
||||
Gwn_IndexBuf* elem; // NULL if element list not needed
|
||||
Gwn_PrimType prim_type;
|
||||
GLenum gl_prim_type;
|
||||
|
||||
// book-keeping
|
||||
GLuint vao_id; // remembers all geometry state (vertex attrib bindings & element buffer)
|
||||
BatchPhase phase;
|
||||
Gwn_BatchPhase phase;
|
||||
bool program_dirty;
|
||||
bool program_in_use;
|
||||
|
||||
// state
|
||||
GLuint program;
|
||||
const ShaderInterface* interface;
|
||||
} Batch;
|
||||
const Gwn_ShaderInterface* interface;
|
||||
} Gwn_Batch;
|
||||
|
||||
Batch* Batch_create(PrimitiveType, VertexBuffer*, ElementList*);
|
||||
void Batch_init(Batch*, PrimitiveType, VertexBuffer*, ElementList*);
|
||||
Gwn_Batch* GWN_batch_create(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*);
|
||||
void GWN_batch_init(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*);
|
||||
|
||||
void Batch_discard(Batch*); // verts & elem are not discarded
|
||||
void Batch_discard_all(Batch*); // including verts & elem
|
||||
void GWN_batch_discard(Gwn_Batch*); // verts & elem are not discarded
|
||||
void GWN_batch_discard_all(Gwn_Batch*); // including verts & elem
|
||||
|
||||
int Batch_add_VertexBuffer(Batch*, VertexBuffer*);
|
||||
int GWN_batch_vertbuf_add(Gwn_Batch*, Gwn_VertBuf*);
|
||||
|
||||
void Batch_set_program(Batch*, GLuint program, const ShaderInterface*);
|
||||
void GWN_batch_program_set(Gwn_Batch*, GLuint program, const Gwn_ShaderInterface*);
|
||||
// Entire batch draws with one shader program, but can be redrawn later with another program.
|
||||
// Vertex shader's inputs must be compatible with the batch's vertex format.
|
||||
|
||||
void Batch_use_program(Batch*); // call before Batch_Uniform (temp hack?)
|
||||
void Batch_done_using_program(Batch*);
|
||||
void GWN_batch_program_use_begin(Gwn_Batch*); // call before Batch_Uniform (temp hack?)
|
||||
void GWN_batch_program_use_end(Gwn_Batch*);
|
||||
|
||||
void Batch_Uniform1i(Batch*, const char* name, int value);
|
||||
void Batch_Uniform1b(Batch*, const char* name, bool value);
|
||||
void Batch_Uniform1f(Batch*, const char* name, float value);
|
||||
void Batch_Uniform2f(Batch*, const char* name, float x, float y);
|
||||
void Batch_Uniform3f(Batch*, const char* name, float x, float y, float z);
|
||||
void Batch_Uniform4f(Batch*, const char* name, float x, float y, float z, float w);
|
||||
void Batch_Uniform3fv(Batch*, const char* name, const float data[3]);
|
||||
void Batch_Uniform4fv(Batch*, const char* name, const float data[4]);
|
||||
void GWN_batch_uniform_1i(Gwn_Batch*, const char* name, int value);
|
||||
void GWN_batch_uniform_1b(Gwn_Batch*, const char* name, bool value);
|
||||
void GWN_batch_uniform_1f(Gwn_Batch*, const char* name, float value);
|
||||
void GWN_batch_uniform_2f(Gwn_Batch*, const char* name, float x, float y);
|
||||
void GWN_batch_uniform_3f(Gwn_Batch*, const char* name, float x, float y, float z);
|
||||
void GWN_batch_uniform_4f(Gwn_Batch*, const char* name, float x, float y, float z, float w);
|
||||
void GWN_batch_uniform_3fv(Gwn_Batch*, const char* name, const float data[3]);
|
||||
void GWN_batch_uniform_4fv(Gwn_Batch*, const char* name, const float data[4]);
|
||||
|
||||
void Batch_draw(Batch*);
|
||||
void GWN_batch_draw(Gwn_Batch*);
|
||||
|
||||
|
||||
// clement : temp stuff
|
||||
void Batch_draw_stupid(Batch*);
|
||||
void Batch_draw_stupid_instanced(Batch*, unsigned int instance_vbo, int instance_count,
|
||||
void GWN_batch_draw_stupid(Gwn_Batch*);
|
||||
void GWN_batch_draw_stupid_instanced(Gwn_Batch*, unsigned int instance_vbo, int instance_count,
|
||||
int attrib_nbr, int attrib_stride, int attrib_loc[16], int attrib_size[16]);
|
||||
void Batch_draw_stupid_instanced_with_batch(Batch*, Batch*);
|
||||
void GWN_batch_draw_stupid_instanced_with_batch(Gwn_Batch*, Gwn_Batch*);
|
||||
|
||||
|
||||
|
||||
@@ -81,49 +81,49 @@ void Batch_draw_stupid_instanced_with_batch(Batch*, Batch*);
|
||||
|
||||
#if 0 // future plans
|
||||
|
||||
// Can multiple batches share a VertexBuffer? Use ref count?
|
||||
// Can multiple batches share a Gwn_VertBuf? Use ref count?
|
||||
|
||||
|
||||
// We often need a batch with its own data, to be created and discarded together.
|
||||
// WithOwn variants reduce number of system allocations.
|
||||
|
||||
typedef struct {
|
||||
Batch batch;
|
||||
VertexBuffer verts; // link batch.verts to this
|
||||
Gwn_Batch batch;
|
||||
Gwn_VertBuf verts; // link batch.verts to this
|
||||
} BatchWithOwnVertexBuffer;
|
||||
|
||||
typedef struct {
|
||||
Batch batch;
|
||||
ElementList elem; // link batch.elem to this
|
||||
Gwn_Batch batch;
|
||||
Gwn_IndexBuf elem; // link batch.elem to this
|
||||
} BatchWithOwnElementList;
|
||||
|
||||
typedef struct {
|
||||
Batch batch;
|
||||
ElementList elem; // link batch.elem to this
|
||||
VertexBuffer verts; // link batch.verts to this
|
||||
Gwn_Batch batch;
|
||||
Gwn_IndexBuf elem; // link batch.elem to this
|
||||
Gwn_VertBuf verts; // link batch.verts to this
|
||||
} BatchWithOwnVertexBufferAndElementList;
|
||||
|
||||
Batch* create_BatchWithOwnVertexBuffer(PrimitiveType, VertexFormat*, unsigned v_ct, ElementList*);
|
||||
Batch* create_BatchWithOwnElementList(PrimitiveType, VertexBuffer*, unsigned prim_ct);
|
||||
Batch* create_BatchWithOwnVertexBufferAndElementList(PrimitiveType, VertexFormat*, unsigned v_ct, unsigned prim_ct);
|
||||
Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, unsigned v_ct, Gwn_IndexBuf*);
|
||||
Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, unsigned prim_ct);
|
||||
Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, unsigned v_ct, unsigned prim_ct);
|
||||
// verts: shared, own
|
||||
// elem: none, shared, own
|
||||
Batch* create_BatchInGeneral(PrimitiveType, VertexBufferStuff, ElementListStuff);
|
||||
Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff);
|
||||
|
||||
#endif // future plans
|
||||
|
||||
|
||||
/* Macros */
|
||||
|
||||
#define BATCH_DISCARD_SAFE(batch) do { \
|
||||
#define GWN_BATCH_DISCARD_SAFE(batch) do { \
|
||||
if (batch != NULL) { \
|
||||
Batch_discard(batch); \
|
||||
GWN_batch_discard(batch); \
|
||||
batch = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
#define BATCH_DISCARD_ALL_SAFE(batch) do { \
|
||||
if (batch != NULL) { \
|
||||
Batch_discard_all(batch); \
|
||||
GWN_batch_discard_all(batch); \
|
||||
batch = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -22,11 +22,11 @@ extern "C" {
|
||||
|
||||
#include "common.h"
|
||||
|
||||
GLuint buffer_id_alloc(void);
|
||||
void buffer_id_free(GLuint buffer_id);
|
||||
GLuint GWN_buf_id_alloc(void);
|
||||
void GWN_buf_id_free(GLuint buffer_id);
|
||||
|
||||
GLuint vao_id_alloc(void);
|
||||
void vao_id_free(GLuint vao_id);
|
||||
GLuint GWN_vao_alloc(void);
|
||||
void GWN_vao_free(GLuint vao_id);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -13,18 +13,18 @@
|
||||
|
||||
#include "primitive.h"
|
||||
|
||||
#define TRACK_INDEX_RANGE 1
|
||||
#define GWN_TRACK_INDEX_RANGE 1
|
||||
|
||||
typedef enum {
|
||||
INDEX_U8, // GL has this, Vulkan does not
|
||||
INDEX_U16,
|
||||
INDEX_U32
|
||||
} IndexType;
|
||||
GWN_INDEX_U8, // GL has this, Vulkan does not
|
||||
GWN_INDEX_U16,
|
||||
GWN_INDEX_U32
|
||||
} Gwn_IndexBufType;
|
||||
|
||||
typedef struct {
|
||||
unsigned index_ct;
|
||||
#if TRACK_INDEX_RANGE
|
||||
IndexType index_type;
|
||||
#if GWN_TRACK_INDEX_RANGE
|
||||
Gwn_IndexBufType index_type;
|
||||
GLenum gl_index_type;
|
||||
unsigned min_index;
|
||||
unsigned max_index;
|
||||
@@ -32,44 +32,44 @@ typedef struct {
|
||||
#endif
|
||||
void* data; // NULL indicates data in VRAM (unmapped) or not yet allocated
|
||||
GLuint vbo_id; // 0 indicates not yet sent to VRAM
|
||||
} ElementList;
|
||||
} Gwn_IndexBuf;
|
||||
|
||||
void ElementList_use(ElementList*);
|
||||
unsigned ElementList_size(const ElementList*);
|
||||
void GWN_indexbuf_use(Gwn_IndexBuf*);
|
||||
unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf*);
|
||||
|
||||
typedef struct {
|
||||
unsigned max_allowed_index;
|
||||
unsigned max_index_ct;
|
||||
unsigned index_ct;
|
||||
PrimitiveType prim_type;
|
||||
Gwn_PrimType prim_type;
|
||||
unsigned* data;
|
||||
} ElementListBuilder;
|
||||
} Gwn_IndexBufBuilder;
|
||||
|
||||
// supported primitives:
|
||||
// PRIM_POINTS
|
||||
// PRIM_LINES
|
||||
// PRIM_TRIANGLES
|
||||
// GWN_PRIM_POINTS
|
||||
// GWN_PRIM_LINES
|
||||
// GWN_PRIM_TRIS
|
||||
|
||||
void ElementListBuilder_init(ElementListBuilder*, PrimitiveType, unsigned prim_ct, unsigned vertex_ct);
|
||||
//void ElementListBuilder_init_custom(ElementListBuilder*, PrimitiveType, unsigned index_ct, unsigned vertex_ct);
|
||||
void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned prim_ct, unsigned vertex_ct);
|
||||
//void GWN_indexbuf_init_custom(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned index_ct, unsigned vertex_ct);
|
||||
|
||||
void add_generic_vertex(ElementListBuilder*, unsigned v);
|
||||
void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, unsigned v);
|
||||
|
||||
void add_point_vertex(ElementListBuilder*, unsigned v);
|
||||
void add_line_vertices(ElementListBuilder*, unsigned v1, unsigned v2);
|
||||
void add_triangle_vertices(ElementListBuilder*, unsigned v1, unsigned v2, unsigned v3);
|
||||
void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, unsigned v);
|
||||
void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2);
|
||||
void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, unsigned v1, unsigned v2, unsigned v3);
|
||||
|
||||
ElementList* ElementList_build(ElementListBuilder*);
|
||||
void ElementList_build_in_place(ElementListBuilder*, ElementList*);
|
||||
Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*);
|
||||
void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*);
|
||||
|
||||
void ElementList_discard(ElementList*);
|
||||
void GWN_indexbuf_discard(Gwn_IndexBuf*);
|
||||
|
||||
|
||||
/* Macros */
|
||||
|
||||
#define ELEMENTLIST_DISCARD_SAFE(elem) do { \
|
||||
#define GWN_INDEXBUF_DISCARD_SAFE(elem) do { \
|
||||
if (elem != NULL) { \
|
||||
ElementList_discard(elem); \
|
||||
GWN_indexbuf_discard(elem); \
|
||||
elem = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
#define IMM_BATCH_COMBO 1
|
||||
|
||||
|
||||
VertexFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib
|
||||
Gwn_VertFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib
|
||||
|
||||
void immBindProgram(GLuint program, const ShaderInterface*); // every immBegin must have a program bound first
|
||||
void immBindProgram(GLuint program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first
|
||||
void immUnbindProgram(void); // call after your last immEnd, or before binding another program
|
||||
|
||||
void immBegin(PrimitiveType, unsigned vertex_ct); // must supply exactly vertex_ct vertices
|
||||
void immBeginAtMost(PrimitiveType, unsigned max_vertex_ct); // can supply fewer vertices
|
||||
void immBegin(Gwn_PrimType, unsigned vertex_ct); // must supply exactly vertex_ct vertices
|
||||
void immBeginAtMost(Gwn_PrimType, unsigned max_vertex_ct); // can supply fewer vertices
|
||||
void immEnd(void); // finishes and draws
|
||||
|
||||
#if IMM_BATCH_COMBO
|
||||
@@ -32,8 +32,8 @@ 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.
|
||||
Batch* immBeginBatch(PrimitiveType, unsigned vertex_ct);
|
||||
Batch* immBeginBatchAtMost(PrimitiveType, unsigned vertex_ct);
|
||||
Gwn_Batch* immBeginBatch(Gwn_PrimType, unsigned vertex_ct);
|
||||
Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, unsigned vertex_ct);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -14,27 +14,27 @@
|
||||
#include "common.h"
|
||||
|
||||
typedef enum {
|
||||
PRIM_POINTS,
|
||||
PRIM_LINES,
|
||||
PRIM_TRIANGLES,
|
||||
PRIM_LINE_STRIP,
|
||||
PRIM_LINE_LOOP, // GL has this, Vulkan does not
|
||||
PRIM_TRIANGLE_STRIP,
|
||||
PRIM_TRIANGLE_FAN,
|
||||
GWN_PRIM_POINTS,
|
||||
GWN_PRIM_LINES,
|
||||
GWN_PRIM_TRIS,
|
||||
GWN_PRIM_LINE_STRIP,
|
||||
GWN_PRIM_LINE_LOOP, // GL has this, Vulkan does not
|
||||
GWN_PRIM_TRI_STRIP,
|
||||
GWN_PRIM_TRI_FAN,
|
||||
|
||||
PRIM_LINE_STRIP_ADJACENCY,
|
||||
GWN_PRIM_LINE_STRIP_ADJ,
|
||||
|
||||
PRIM_NONE
|
||||
} PrimitiveType;
|
||||
GWN_PRIM_NONE
|
||||
} Gwn_PrimType;
|
||||
|
||||
// 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;
|
||||
GWN_PRIM_CLASS_NONE = 0,
|
||||
GWN_PRIM_CLASS_POINT = (1 << 0),
|
||||
GWN_PRIM_CLASS_LINE = (1 << 1),
|
||||
GWN_PRIM_CLASS_SURFACE = (1 << 2),
|
||||
GWN_PRIM_CLASS_ANY = GWN_PRIM_CLASS_POINT | GWN_PRIM_CLASS_LINE | GWN_PRIM_CLASS_SURFACE
|
||||
} Gwn_PrimClass;
|
||||
|
||||
PrimitiveClass prim_class_of_type(PrimitiveType);
|
||||
bool prim_type_belongs_to_class(PrimitiveType, PrimitiveClass);
|
||||
Gwn_PrimClass GWN_primtype_class(Gwn_PrimType);
|
||||
bool GWN_primtype_belongs_to_class(Gwn_PrimType, Gwn_PrimClass);
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
GLenum convert_prim_type_to_gl(PrimitiveType);
|
||||
GLenum convert_prim_type_to_gl(Gwn_PrimType);
|
||||
|
||||
@@ -14,40 +14,40 @@
|
||||
#include "common.h"
|
||||
|
||||
typedef enum {
|
||||
UNIFORM_NONE, // uninitialized/unknown
|
||||
GWN_UNIFORM_NONE, // uninitialized/unknown
|
||||
|
||||
UNIFORM_MODELVIEW, // mat4 ModelViewMatrix
|
||||
UNIFORM_PROJECTION, // mat4 ProjectionMatrix
|
||||
UNIFORM_MVP, // mat4 ModelViewProjectionMatrix
|
||||
GWN_UNIFORM_MODELVIEW, // mat4 ModelViewMatrix
|
||||
GWN_UNIFORM_PROJECTION, // mat4 ProjectionMatrix
|
||||
GWN_UNIFORM_MVP, // mat4 ModelViewProjectionMatrix
|
||||
|
||||
UNIFORM_MODELVIEW_INV, // mat4 ModelViewInverseMatrix
|
||||
UNIFORM_PROJECTION_INV, // mat4 ProjectionInverseMatrix
|
||||
GWN_UNIFORM_MODELVIEW_INV, // mat4 ModelViewInverseMatrix
|
||||
GWN_UNIFORM_PROJECTION_INV, // mat4 ProjectionInverseMatrix
|
||||
|
||||
UNIFORM_NORMAL, // mat3 NormalMatrix
|
||||
GWN_UNIFORM_NORMAL, // mat3 NormalMatrix
|
||||
|
||||
UNIFORM_COLOR, // vec4 color
|
||||
GWN_UNIFORM_COLOR, // vec4 color
|
||||
|
||||
UNIFORM_CUSTOM // custom uniform, not one of the above built-ins
|
||||
} BuiltinUniform;
|
||||
GWN_UNIFORM_CUSTOM // custom uniform, not one of the above built-ins
|
||||
} Gwn_UniformBuiltin;
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
unsigned name_hash;
|
||||
GLenum gl_type;
|
||||
BuiltinUniform builtin_type; // only for uniform inputs
|
||||
Gwn_UniformBuiltin builtin_type; // only for uniform inputs
|
||||
GLint size;
|
||||
GLint location;
|
||||
} ShaderInput;
|
||||
} Gwn_ShaderInput;
|
||||
|
||||
typedef struct {
|
||||
uint16_t uniform_ct;
|
||||
uint16_t attrib_ct;
|
||||
ShaderInput inputs[0]; // dynamic size, uniforms followed by attribs
|
||||
} ShaderInterface;
|
||||
Gwn_ShaderInput inputs[0]; // dynamic size, uniforms followed by attribs
|
||||
} Gwn_ShaderInterface;
|
||||
|
||||
ShaderInterface* ShaderInterface_create(GLint program_id);
|
||||
void ShaderInterface_discard(ShaderInterface*);
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program_id);
|
||||
void GWN_shaderinterface_discard(Gwn_ShaderInterface*);
|
||||
|
||||
const ShaderInput* ShaderInterface_uniform(const ShaderInterface*, const char* name);
|
||||
const ShaderInput* ShaderInterface_builtin_uniform(const ShaderInterface*, BuiltinUniform);
|
||||
const ShaderInput* ShaderInterface_attrib(const ShaderInterface*, const char* name);
|
||||
const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name);
|
||||
const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin);
|
||||
const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name);
|
||||
|
||||
@@ -13,41 +13,41 @@
|
||||
|
||||
#include "vertex_format.h"
|
||||
|
||||
// How to create a VertexBuffer:
|
||||
// 1) verts = VertexBuffer_create() or VertexBuffer_init(verts)
|
||||
// 2) VertexFormat_add_attrib(verts->format, ...)
|
||||
// 3) VertexBuffer_allocate_data(verts, vertex_ct) <-- finalizes/packs vertex format
|
||||
// 4) VertexBuffer_fill_attrib(verts, pos, application_pos_buffer)
|
||||
// How to create a Gwn_VertBuf:
|
||||
// 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts)
|
||||
// 2) GWN_vertformat_attr_add(verts->format, ...)
|
||||
// 3) GWN_vertbuf_data_alloc(verts, vertex_ct) <-- finalizes/packs vertex format
|
||||
// 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer)
|
||||
|
||||
// Is VertexBuffer always used as part of a Batch?
|
||||
// Is Gwn_VertBuf always used as part of a Gwn_Batch?
|
||||
|
||||
typedef struct {
|
||||
VertexFormat format;
|
||||
Gwn_VertFormat format;
|
||||
unsigned vertex_ct;
|
||||
GLubyte* data; // NULL indicates data in VRAM (unmapped) or not yet allocated
|
||||
GLuint vbo_id; // 0 indicates not yet sent to VRAM
|
||||
} VertexBuffer;
|
||||
} Gwn_VertBuf;
|
||||
|
||||
VertexBuffer* VertexBuffer_create(void);
|
||||
VertexBuffer* VertexBuffer_create_with_format(const VertexFormat*);
|
||||
Gwn_VertBuf* GWN_vertbuf_create(void);
|
||||
Gwn_VertBuf* GWN_vertbuf_create_with_format(const Gwn_VertFormat*);
|
||||
|
||||
void VertexBuffer_discard(VertexBuffer*);
|
||||
void GWN_vertbuf_discard(Gwn_VertBuf*);
|
||||
|
||||
void VertexBuffer_init(VertexBuffer*);
|
||||
void VertexBuffer_init_with_format(VertexBuffer*, const VertexFormat*);
|
||||
void GWN_vertbuf_init(Gwn_VertBuf*);
|
||||
void GWN_vertbuf_init_with_format(Gwn_VertBuf*, const Gwn_VertFormat*);
|
||||
|
||||
unsigned VertexBuffer_size(const VertexBuffer*);
|
||||
void VertexBuffer_allocate_data(VertexBuffer*, unsigned v_ct);
|
||||
void VertexBuffer_resize_data(VertexBuffer*, unsigned v_ct);
|
||||
unsigned GWN_vertbuf_size_get(const Gwn_VertBuf*);
|
||||
void GWN_vertbuf_data_alloc(Gwn_VertBuf*, unsigned v_ct);
|
||||
void GWN_vertbuf_data_resize(Gwn_VertBuf*, unsigned v_ct);
|
||||
|
||||
// The most important set_attrib variant is the untyped one. Get it right first.
|
||||
// It takes a void* so the app developer is responsible for matching their app data types
|
||||
// to the vertex attribute's type and component count. They're in control of both, so this
|
||||
// should not be a problem.
|
||||
|
||||
void VertexBuffer_set_attrib(VertexBuffer*, unsigned a_idx, unsigned v_idx, const void* data);
|
||||
void VertexBuffer_fill_attrib(VertexBuffer*, unsigned a_idx, const void* data); // tightly packed, non interleaved input data
|
||||
void VertexBuffer_fill_attrib_stride(VertexBuffer*, unsigned a_idx, unsigned stride, const void* data);
|
||||
void GWN_vertbuf_attr_set(Gwn_VertBuf*, unsigned a_idx, unsigned v_idx, const void* data);
|
||||
void GWN_vertbuf_attr_fill(Gwn_VertBuf*, unsigned a_idx, const void* data); // tightly packed, non interleaved input data
|
||||
void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, unsigned a_idx, unsigned stride, const void* data);
|
||||
|
||||
// TODO: decide whether to keep the functions below
|
||||
// doesn't immediate mode satisfy these needs?
|
||||
@@ -60,19 +60,19 @@ void VertexBuffer_fill_attrib_stride(VertexBuffer*, unsigned a_idx, unsigned str
|
||||
// void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b);
|
||||
// void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
|
||||
void VertexBuffer_use(VertexBuffer*);
|
||||
void GWN_vertbuf_use(Gwn_VertBuf*);
|
||||
|
||||
|
||||
// Metrics
|
||||
|
||||
unsigned VertexBuffer_get_memory_usage(void);
|
||||
unsigned GWN_vertbuf_get_memory_usage(void);
|
||||
|
||||
|
||||
// Macros
|
||||
|
||||
#define VERTEXBUFFER_DISCARD_SAFE(verts) do { \
|
||||
#define GWN_VERTBUF_DISCARD_SAFE(verts) do { \
|
||||
if (verts != NULL) { \
|
||||
VertexBuffer_discard(verts); \
|
||||
GWN_vertbuf_discard(verts); \
|
||||
verts = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -13,57 +13,57 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define MAX_VERTEX_ATTRIBS 16
|
||||
#define GWN_VERT_ATTR_MAX_LEN 16
|
||||
#define MAX_ATTRIB_NAMES 3
|
||||
#define AVG_VERTEX_ATTRIB_NAME_LEN 11
|
||||
#define VERTEX_ATTRIB_NAMES_BUFFER_LEN ((AVG_VERTEX_ATTRIB_NAME_LEN + 1) * MAX_VERTEX_ATTRIBS)
|
||||
#define GWN_VERT_ATTR_NAME_AVERAGE_LEN 11
|
||||
#define GWN_VERT_ATTR_NAMES_BUF_LEN ((GWN_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GWN_VERT_ATTR_MAX_LEN)
|
||||
|
||||
typedef enum {
|
||||
COMP_I8,
|
||||
COMP_U8,
|
||||
COMP_I16,
|
||||
COMP_U16,
|
||||
COMP_I32,
|
||||
COMP_U32,
|
||||
GWN_COMP_I8,
|
||||
GWN_COMP_U8,
|
||||
GWN_COMP_I16,
|
||||
GWN_COMP_U16,
|
||||
GWN_COMP_I32,
|
||||
GWN_COMP_U32,
|
||||
|
||||
COMP_F32,
|
||||
GWN_COMP_F32,
|
||||
|
||||
COMP_I10
|
||||
} VertexCompType;
|
||||
GWN_COMP_I10
|
||||
} Gwn_VertCompType;
|
||||
|
||||
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;
|
||||
GWN_FETCH_FLOAT,
|
||||
GWN_FETCH_INT,
|
||||
GWN_FETCH_INT_TO_FLOAT_UNIT, // 127 (ubyte) -> 0.5 (and so on for other int types)
|
||||
GWN_FETCH_INT_TO_FLOAT // 127 (any int type) -> 127.0
|
||||
} Gwn_VertFetchMode;
|
||||
|
||||
typedef struct {
|
||||
VertexCompType comp_type;
|
||||
Gwn_VertCompType comp_type;
|
||||
unsigned gl_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;
|
||||
Gwn_VertFetchMode fetch_mode;
|
||||
const char* name[MAX_ATTRIB_NAMES];
|
||||
unsigned name_ct;
|
||||
} Attrib;
|
||||
} Gwn_VertAttr;
|
||||
|
||||
typedef struct {
|
||||
unsigned attrib_ct; // 0 to 16 (MAX_VERTEX_ATTRIBS)
|
||||
unsigned attrib_ct; // 0 to 16 (GWN_VERT_ATTR_MAX_LEN)
|
||||
unsigned name_ct; // total count of active vertex attrib
|
||||
unsigned stride; // stride in bytes, 1 to 256
|
||||
bool packed;
|
||||
Attrib attribs[MAX_VERTEX_ATTRIBS]; // TODO: variable-size attribs array
|
||||
char names[VERTEX_ATTRIB_NAMES_BUFFER_LEN];
|
||||
Gwn_VertAttr attribs[GWN_VERT_ATTR_MAX_LEN]; // TODO: variable-size attribs array
|
||||
char names[GWN_VERT_ATTR_NAMES_BUF_LEN];
|
||||
unsigned name_offset;
|
||||
} VertexFormat;
|
||||
} Gwn_VertFormat;
|
||||
|
||||
void VertexFormat_clear(VertexFormat*);
|
||||
void VertexFormat_copy(VertexFormat* dest, const VertexFormat* src);
|
||||
void GWN_vertformat_clear(Gwn_VertFormat*);
|
||||
void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src);
|
||||
|
||||
unsigned VertexFormat_add_attrib(VertexFormat*, const char* name, VertexCompType, unsigned comp_ct, VertexFetchMode);
|
||||
void VertexFormat_add_alias(VertexFormat*, const char* alias);
|
||||
unsigned GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, unsigned comp_ct, Gwn_VertFetchMode);
|
||||
void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias);
|
||||
|
||||
// format conversion
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
void VertexFormat_pack(VertexFormat*);
|
||||
void VertexFormat_pack(Gwn_VertFormat*);
|
||||
unsigned padding(unsigned offset, unsigned alignment);
|
||||
unsigned vertex_buffer_size(const VertexFormat*, unsigned vertex_ct);
|
||||
unsigned vertex_buffer_size(const Gwn_VertFormat*, unsigned vertex_ct);
|
||||
|
||||
@@ -13,31 +13,31 @@
|
||||
#include "attrib_binding_private.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#if MAX_VERTEX_ATTRIBS != 16
|
||||
#error "attrib binding code assumes MAX_VERTEX_ATTRIBS = 16"
|
||||
#if GWN_VERT_ATTR_MAX_LEN != 16
|
||||
#error "attrib binding code assumes GWN_VERT_ATTR_MAX_LEN = 16"
|
||||
#endif
|
||||
|
||||
void AttribBinding_clear(AttribBinding* binding)
|
||||
void AttribBinding_clear(Gwn_AttrBinding* binding)
|
||||
{
|
||||
binding->loc_bits = 0;
|
||||
binding->enabled_bits = 0;
|
||||
}
|
||||
|
||||
unsigned read_attrib_location(const AttribBinding* binding, unsigned a_idx)
|
||||
unsigned read_attrib_location(const Gwn_AttrBinding* binding, unsigned a_idx)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(a_idx < MAX_VERTEX_ATTRIBS);
|
||||
assert(a_idx < GWN_VERT_ATTR_MAX_LEN);
|
||||
assert(binding->enabled_bits & (1 << a_idx));
|
||||
#endif
|
||||
|
||||
return (binding->loc_bits >> (4 * a_idx)) & 0xF;
|
||||
}
|
||||
|
||||
static void write_attrib_location(AttribBinding* binding, unsigned a_idx, unsigned location)
|
||||
static void write_attrib_location(Gwn_AttrBinding* binding, unsigned a_idx, unsigned location)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(a_idx < MAX_VERTEX_ATTRIBS);
|
||||
assert(location < MAX_VERTEX_ATTRIBS);
|
||||
assert(a_idx < GWN_VERT_ATTR_MAX_LEN);
|
||||
assert(location < GWN_VERT_ATTR_MAX_LEN);
|
||||
#endif
|
||||
|
||||
const unsigned shift = 4 * a_idx;
|
||||
@@ -48,16 +48,16 @@ static void write_attrib_location(AttribBinding* binding, unsigned a_idx, unsign
|
||||
binding->enabled_bits |= 1 << a_idx;
|
||||
}
|
||||
|
||||
void get_attrib_locations(const VertexFormat* format, AttribBinding* binding, const ShaderInterface* shaderface)
|
||||
void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding, const Gwn_ShaderInterface* shaderface)
|
||||
{
|
||||
AttribBinding_clear(binding);
|
||||
|
||||
for (unsigned a_idx = 0; a_idx < format->attrib_ct; ++a_idx)
|
||||
{
|
||||
const Attrib* a = format->attribs + a_idx;
|
||||
const Gwn_VertAttr* a = format->attribs + a_idx;
|
||||
for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx)
|
||||
{
|
||||
const ShaderInput* input = ShaderInterface_attrib(shaderface, a->name[n_idx]);
|
||||
const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]);
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(input != NULL);
|
||||
|
||||
@@ -15,59 +15,59 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
// necessary functions from matrix API
|
||||
extern void gpuBindMatrices(const ShaderInterface* shaderface);
|
||||
extern void gpuBindMatrices(const Gwn_ShaderInterface* shaderface);
|
||||
extern bool gpuMatricesDirty(void); // how best to use this here?
|
||||
|
||||
Batch* Batch_create(PrimitiveType prim_type, VertexBuffer* verts, ElementList* elem)
|
||||
Gwn_Batch* GWN_batch_create(Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem)
|
||||
{
|
||||
Batch* batch = calloc(1, sizeof(Batch));
|
||||
Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch));
|
||||
|
||||
Batch_init(batch, prim_type, verts, elem);
|
||||
GWN_batch_init(batch, prim_type, verts, elem);
|
||||
|
||||
return batch;
|
||||
}
|
||||
|
||||
void Batch_init(Batch* batch, PrimitiveType prim_type, VertexBuffer* verts, ElementList* elem)
|
||||
void GWN_batch_init(Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(verts != NULL);
|
||||
#endif
|
||||
|
||||
batch->verts[0] = verts;
|
||||
for (int v = 1; v < BATCH_MAX_VBO_CT; ++v)
|
||||
for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v)
|
||||
batch->verts[v] = NULL;
|
||||
batch->elem = elem;
|
||||
batch->prim_type = prim_type;
|
||||
batch->gl_prim_type = convert_prim_type_to_gl(prim_type);
|
||||
batch->phase = READY_TO_DRAW;
|
||||
batch->phase = GWN_BATCH_READY_TO_DRAW;
|
||||
}
|
||||
|
||||
void Batch_discard(Batch* batch)
|
||||
void GWN_batch_discard(Gwn_Batch* batch)
|
||||
{
|
||||
if (batch->vao_id)
|
||||
vao_id_free(batch->vao_id);
|
||||
GWN_vao_free(batch->vao_id);
|
||||
|
||||
free(batch);
|
||||
}
|
||||
|
||||
void Batch_discard_all(Batch* batch)
|
||||
void GWN_batch_discard_all(Gwn_Batch* batch)
|
||||
{
|
||||
for (int v = 0; v < BATCH_MAX_VBO_CT; ++v)
|
||||
for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
|
||||
{
|
||||
if (batch->verts[v] == NULL)
|
||||
break;
|
||||
VertexBuffer_discard(batch->verts[v]);
|
||||
GWN_vertbuf_discard(batch->verts[v]);
|
||||
}
|
||||
|
||||
if (batch->elem)
|
||||
ElementList_discard(batch->elem);
|
||||
GWN_indexbuf_discard(batch->elem);
|
||||
|
||||
Batch_discard(batch);
|
||||
GWN_batch_discard(batch);
|
||||
}
|
||||
|
||||
int Batch_add_VertexBuffer(Batch* batch, VertexBuffer* verts)
|
||||
int GWN_batch_vertbuf_add(Gwn_Batch* batch, Gwn_VertBuf* verts)
|
||||
{
|
||||
for (unsigned v = 0; v < BATCH_MAX_VBO_CT; ++v)
|
||||
for (unsigned v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
|
||||
{
|
||||
if (batch->verts[v] == NULL)
|
||||
{
|
||||
@@ -82,14 +82,14 @@ int Batch_add_VertexBuffer(Batch* batch, VertexBuffer* verts)
|
||||
}
|
||||
}
|
||||
|
||||
// we only make it this far if there is no room for another VertexBuffer
|
||||
// we only make it this far if there is no room for another Gwn_VertBuf
|
||||
#if TRUST_NO_ONE
|
||||
assert(false);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Batch_set_program(Batch* batch, GLuint program, const ShaderInterface* shaderface)
|
||||
void GWN_batch_program_set(Gwn_Batch* batch, GLuint program, const Gwn_ShaderInterface* shaderface)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(glIsProgram(program));
|
||||
@@ -99,38 +99,38 @@ void Batch_set_program(Batch* batch, GLuint program, const ShaderInterface* shad
|
||||
batch->interface = shaderface;
|
||||
batch->program_dirty = true;
|
||||
|
||||
Batch_use_program(batch); // hack! to make Batch_Uniform* simpler
|
||||
GWN_batch_program_use_begin(batch); // hack! to make Batch_Uniform* simpler
|
||||
}
|
||||
|
||||
static void Batch_update_program_bindings(Batch* batch)
|
||||
static void Batch_update_program_bindings(Gwn_Batch* batch)
|
||||
{
|
||||
// disable all as a precaution
|
||||
// why are we not using prev_attrib_enabled_bits?? see immediate.c
|
||||
for (unsigned a_idx = 0; a_idx < MAX_VERTEX_ATTRIBS; ++a_idx)
|
||||
for (unsigned a_idx = 0; a_idx < GWN_VERT_ATTR_MAX_LEN; ++a_idx)
|
||||
glDisableVertexAttribArray(a_idx);
|
||||
|
||||
for (int v = 0; v < BATCH_MAX_VBO_CT; ++v)
|
||||
for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
|
||||
{
|
||||
VertexBuffer* verts = batch->verts[v];
|
||||
Gwn_VertBuf* verts = batch->verts[v];
|
||||
if (verts == NULL)
|
||||
break;
|
||||
|
||||
const VertexFormat* format = &verts->format;
|
||||
const Gwn_VertFormat* format = &verts->format;
|
||||
|
||||
const unsigned attrib_ct = format->attrib_ct;
|
||||
const unsigned stride = format->stride;
|
||||
|
||||
VertexBuffer_use(verts);
|
||||
GWN_vertbuf_use(verts);
|
||||
|
||||
for (unsigned a_idx = 0; a_idx < attrib_ct; ++a_idx)
|
||||
{
|
||||
const Attrib* a = format->attribs + a_idx;
|
||||
const Gwn_VertAttr* a = format->attribs + a_idx;
|
||||
|
||||
const GLvoid* pointer = (const GLubyte*)0 + a->offset;
|
||||
|
||||
for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx)
|
||||
{
|
||||
const ShaderInput* input = ShaderInterface_attrib(batch->interface, a->name[n_idx]);
|
||||
const Gwn_ShaderInput* input = GWN_shaderinterface_attr(batch->interface, a->name[n_idx]);
|
||||
|
||||
if (input == NULL) continue;
|
||||
|
||||
@@ -138,14 +138,14 @@ static void Batch_update_program_bindings(Batch* batch)
|
||||
|
||||
switch (a->fetch_mode)
|
||||
{
|
||||
case KEEP_FLOAT:
|
||||
case CONVERT_INT_TO_FLOAT:
|
||||
case GWN_FETCH_FLOAT:
|
||||
case GWN_FETCH_INT_TO_FLOAT:
|
||||
glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer);
|
||||
break;
|
||||
case NORMALIZE_INT_TO_FLOAT:
|
||||
case GWN_FETCH_INT_TO_FLOAT_UNIT:
|
||||
glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer);
|
||||
break;
|
||||
case KEEP_INT:
|
||||
case GWN_FETCH_INT:
|
||||
glVertexAttribIPointer(input->location, a->comp_ct, a->gl_comp_type, stride, pointer);
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ static void Batch_update_program_bindings(Batch* batch)
|
||||
batch->program_dirty = false;
|
||||
}
|
||||
|
||||
void Batch_use_program(Batch* batch)
|
||||
void GWN_batch_program_use_begin(Gwn_Batch* batch)
|
||||
{
|
||||
// NOTE: use_program & done_using_program are fragile, depend on staying in sync with
|
||||
// the GL context's active program. use_program doesn't mark other programs as "not used".
|
||||
@@ -168,7 +168,7 @@ void Batch_use_program(Batch* batch)
|
||||
}
|
||||
}
|
||||
|
||||
void Batch_done_using_program(Batch* batch)
|
||||
void GWN_batch_program_use_end(Gwn_Batch* batch)
|
||||
{
|
||||
if (batch->program_in_use)
|
||||
{
|
||||
@@ -178,81 +178,81 @@ void Batch_done_using_program(Batch* batch)
|
||||
}
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(batch->interface, name); assert(uniform);
|
||||
#define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); assert(uniform);
|
||||
#else
|
||||
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(batch->interface, name);
|
||||
#define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name);
|
||||
#endif
|
||||
|
||||
void Batch_Uniform1i(Batch* batch, const char* name, int value)
|
||||
void GWN_batch_uniform_1i(Gwn_Batch* batch, const char* name, int value)
|
||||
{
|
||||
GET_UNIFORM
|
||||
glUniform1i(uniform->location, value);
|
||||
}
|
||||
|
||||
void Batch_Uniform1b(Batch* batch, const char* name, bool value)
|
||||
void GWN_batch_uniform_1b(Gwn_Batch* batch, const char* name, bool value)
|
||||
{
|
||||
GET_UNIFORM
|
||||
glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE);
|
||||
}
|
||||
|
||||
void Batch_Uniform2f(Batch* batch, const char* name, float x, float y)
|
||||
void GWN_batch_uniform_2f(Gwn_Batch* batch, const char* name, float x, float y)
|
||||
{
|
||||
GET_UNIFORM
|
||||
glUniform2f(uniform->location, x, y);
|
||||
}
|
||||
|
||||
void Batch_Uniform3f(Batch* batch, const char* name, float x, float y, float z)
|
||||
void GWN_batch_uniform_3f(Gwn_Batch* batch, const char* name, float x, float y, float z)
|
||||
{
|
||||
GET_UNIFORM
|
||||
glUniform3f(uniform->location, x, y, z);
|
||||
}
|
||||
|
||||
void Batch_Uniform4f(Batch* batch, const char* name, float x, float y, float z, float w)
|
||||
void GWN_batch_uniform_4f(Gwn_Batch* batch, const char* name, float x, float y, float z, float w)
|
||||
{
|
||||
GET_UNIFORM
|
||||
glUniform4f(uniform->location, x, y, z, w);
|
||||
}
|
||||
|
||||
void Batch_Uniform1f(Batch* batch, const char* name, float x)
|
||||
void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x)
|
||||
{
|
||||
GET_UNIFORM
|
||||
glUniform1f(uniform->location, x);
|
||||
}
|
||||
|
||||
void Batch_Uniform3fv(Batch* batch, const char* name, const float data[3])
|
||||
void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3])
|
||||
{
|
||||
GET_UNIFORM
|
||||
glUniform3fv(uniform->location, 1, data);
|
||||
}
|
||||
|
||||
void Batch_Uniform4fv(Batch* batch, const char* name, const float data[4])
|
||||
void GWN_batch_uniform_4fv(Gwn_Batch* batch, const char* name, const float data[4])
|
||||
{
|
||||
GET_UNIFORM
|
||||
glUniform4fv(uniform->location, 1, data);
|
||||
}
|
||||
|
||||
static void Batch_prime(Batch* batch)
|
||||
static void Batch_prime(Gwn_Batch* batch)
|
||||
{
|
||||
batch->vao_id = vao_id_alloc();
|
||||
batch->vao_id = GWN_vao_alloc();
|
||||
glBindVertexArray(batch->vao_id);
|
||||
|
||||
for (int v = 0; v < BATCH_MAX_VBO_CT; ++v)
|
||||
for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
|
||||
{
|
||||
if (batch->verts[v] == NULL)
|
||||
break;
|
||||
VertexBuffer_use(batch->verts[v]);
|
||||
GWN_vertbuf_use(batch->verts[v]);
|
||||
}
|
||||
|
||||
if (batch->elem)
|
||||
ElementList_use(batch->elem);
|
||||
GWN_indexbuf_use(batch->elem);
|
||||
|
||||
// vertex attribs and element list remain bound to this VAO
|
||||
}
|
||||
|
||||
void Batch_draw(Batch* batch)
|
||||
void GWN_batch_draw(Gwn_Batch* batch)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(batch->phase == READY_TO_DRAW);
|
||||
assert(batch->phase == GWN_BATCH_READY_TO_DRAW);
|
||||
assert(glIsProgram(batch->program));
|
||||
#endif
|
||||
|
||||
@@ -264,15 +264,15 @@ void Batch_draw(Batch* batch)
|
||||
if (batch->program_dirty)
|
||||
Batch_update_program_bindings(batch);
|
||||
|
||||
Batch_use_program(batch);
|
||||
GWN_batch_program_use_begin(batch);
|
||||
|
||||
gpuBindMatrices(batch->interface);
|
||||
|
||||
if (batch->elem)
|
||||
{
|
||||
const ElementList* el = batch->elem;
|
||||
const Gwn_IndexBuf* el = batch->elem;
|
||||
|
||||
#if TRACK_INDEX_RANGE
|
||||
#if GWN_TRACK_INDEX_RANGE
|
||||
if (el->base_index)
|
||||
glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->gl_index_type, 0, el->base_index);
|
||||
else
|
||||
@@ -284,14 +284,14 @@ void Batch_draw(Batch* batch)
|
||||
else
|
||||
glDrawArrays(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct);
|
||||
|
||||
Batch_done_using_program(batch);
|
||||
GWN_batch_program_use_end(batch);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// clement : temp stuff
|
||||
void Batch_draw_stupid(Batch* batch)
|
||||
void GWN_batch_draw_stupid(Gwn_Batch* batch)
|
||||
{
|
||||
if (batch->vao_id)
|
||||
glBindVertexArray(batch->vao_id);
|
||||
@@ -301,15 +301,15 @@ void Batch_draw_stupid(Batch* batch)
|
||||
if (batch->program_dirty)
|
||||
Batch_update_program_bindings(batch);
|
||||
|
||||
// Batch_use_program(batch);
|
||||
// GWN_batch_program_use_begin(batch);
|
||||
|
||||
//gpuBindMatrices(batch->program);
|
||||
|
||||
if (batch->elem)
|
||||
{
|
||||
const ElementList* el = batch->elem;
|
||||
const Gwn_IndexBuf* el = batch->elem;
|
||||
|
||||
#if TRACK_INDEX_RANGE
|
||||
#if GWN_TRACK_INDEX_RANGE
|
||||
if (el->base_index)
|
||||
glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, el->max_index, el->index_ct, el->gl_index_type, 0, el->base_index);
|
||||
else
|
||||
@@ -321,12 +321,12 @@ void Batch_draw_stupid(Batch* batch)
|
||||
else
|
||||
glDrawArrays(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct);
|
||||
|
||||
// Batch_done_using_program(batch);
|
||||
// GWN_batch_program_use_end(batch);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
// clement : temp stuff
|
||||
void Batch_draw_stupid_instanced(Batch* batch, unsigned int instance_vbo, int instance_count,
|
||||
void GWN_batch_draw_stupid_instanced(Gwn_Batch* batch, unsigned int instance_vbo, int instance_count,
|
||||
int attrib_nbr, int attrib_stride, int attrib_size[16], int attrib_loc[16])
|
||||
{
|
||||
if (batch->vao_id)
|
||||
@@ -358,24 +358,24 @@ void Batch_draw_stupid_instanced(Batch* batch, unsigned int instance_vbo, int in
|
||||
}
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
// Batch_use_program(batch);
|
||||
// GWN_batch_program_use_begin(batch);
|
||||
|
||||
//gpuBindMatrices(batch->program);
|
||||
|
||||
if (batch->elem)
|
||||
{
|
||||
const ElementList* el = batch->elem;
|
||||
const Gwn_IndexBuf* el = batch->elem;
|
||||
|
||||
glDrawElementsInstanced(batch->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0, instance_count);
|
||||
}
|
||||
else
|
||||
glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct, instance_count);
|
||||
|
||||
// Batch_done_using_program(batch);
|
||||
// GWN_batch_program_use_end(batch);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void Batch_draw_stupid_instanced_with_batch(Batch* batch_instanced, Batch* batch_instancing)
|
||||
void GWN_batch_draw_stupid_instanced_with_batch(Gwn_Batch* batch_instanced, Gwn_Batch* batch_instancing)
|
||||
{
|
||||
if (batch_instanced->vao_id)
|
||||
glBindVertexArray(batch_instanced->vao_id);
|
||||
@@ -385,24 +385,24 @@ void Batch_draw_stupid_instanced_with_batch(Batch* batch_instanced, Batch* batch
|
||||
if (batch_instanced->program_dirty)
|
||||
Batch_update_program_bindings(batch_instanced);
|
||||
|
||||
VertexBuffer* verts = batch_instancing->verts[0];
|
||||
Gwn_VertBuf* verts = batch_instancing->verts[0];
|
||||
|
||||
const VertexFormat* format = &verts->format;
|
||||
const Gwn_VertFormat* format = &verts->format;
|
||||
|
||||
const unsigned attrib_ct = format->attrib_ct;
|
||||
const unsigned stride = format->stride;
|
||||
|
||||
VertexBuffer_use(verts);
|
||||
GWN_vertbuf_use(verts);
|
||||
|
||||
for (unsigned a_idx = 0; a_idx < attrib_ct; ++a_idx)
|
||||
{
|
||||
const Attrib* a = format->attribs + a_idx;
|
||||
const Gwn_VertAttr* a = format->attribs + a_idx;
|
||||
|
||||
const GLvoid* pointer = (const GLubyte*)0 + a->offset;
|
||||
|
||||
for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx)
|
||||
{
|
||||
const ShaderInput* input = ShaderInterface_attrib(batch_instanced->interface, a->name[n_idx]);
|
||||
const Gwn_ShaderInput* input = GWN_shaderinterface_attr(batch_instanced->interface, a->name[n_idx]);
|
||||
|
||||
if (input == NULL) continue;
|
||||
|
||||
@@ -411,32 +411,32 @@ void Batch_draw_stupid_instanced_with_batch(Batch* batch_instanced, Batch* batch
|
||||
|
||||
switch (a->fetch_mode)
|
||||
{
|
||||
case KEEP_FLOAT:
|
||||
case CONVERT_INT_TO_FLOAT:
|
||||
case GWN_FETCH_FLOAT:
|
||||
case GWN_FETCH_INT_TO_FLOAT:
|
||||
glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer);
|
||||
break;
|
||||
case NORMALIZE_INT_TO_FLOAT:
|
||||
case GWN_FETCH_INT_TO_FLOAT_UNIT:
|
||||
glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer);
|
||||
break;
|
||||
case KEEP_INT:
|
||||
case GWN_FETCH_INT:
|
||||
glVertexAttribIPointer(input->location, a->comp_ct, a->gl_comp_type, stride, pointer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Batch_use_program(batch);
|
||||
// GWN_batch_program_use_begin(batch);
|
||||
|
||||
//gpuBindMatrices(batch->program);
|
||||
|
||||
if (batch_instanced->elem)
|
||||
{
|
||||
const ElementList* el = batch_instanced->elem;
|
||||
const Gwn_IndexBuf* el = batch_instanced->elem;
|
||||
|
||||
glDrawElementsInstanced(batch_instanced->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0, verts->vertex_ct);
|
||||
}
|
||||
else
|
||||
glDrawArraysInstanced(batch_instanced->gl_prim_type, 0, batch_instanced->verts[0]->vertex_ct, verts->vertex_ct);
|
||||
|
||||
// Batch_done_using_program(batch);
|
||||
// GWN_batch_program_use_end(batch);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ static bool thread_is_main()
|
||||
return BLI_thread_is_main();
|
||||
}
|
||||
|
||||
GLuint buffer_id_alloc()
|
||||
GLuint GWN_buf_id_alloc()
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(thread_is_main());
|
||||
@@ -58,7 +58,7 @@ GLuint buffer_id_alloc()
|
||||
return new_buffer_id;
|
||||
}
|
||||
|
||||
void buffer_id_free(GLuint buffer_id)
|
||||
void GWN_buf_id_free(GLuint buffer_id)
|
||||
{
|
||||
if (thread_is_main())
|
||||
glDeleteBuffers(1, &buffer_id);
|
||||
@@ -74,7 +74,7 @@ void buffer_id_free(GLuint buffer_id)
|
||||
}
|
||||
}
|
||||
|
||||
GLuint vao_id_alloc()
|
||||
GLuint GWN_vao_alloc()
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(thread_is_main());
|
||||
@@ -98,7 +98,7 @@ GLuint vao_id_alloc()
|
||||
return new_vao_id;
|
||||
}
|
||||
|
||||
void vao_id_free(GLuint vao_id)
|
||||
void GWN_vao_free(GLuint vao_id)
|
||||
{
|
||||
if (thread_is_main())
|
||||
glDeleteVertexArrays(1, &vao_id);
|
||||
|
||||
@@ -15,23 +15,23 @@
|
||||
|
||||
#define KEEP_SINGLE_COPY 1
|
||||
|
||||
static GLenum convert_index_type_to_gl(IndexType type)
|
||||
static GLenum convert_index_type_to_gl(Gwn_IndexBufType type)
|
||||
{
|
||||
static const GLenum table[] = {
|
||||
[INDEX_U8] = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not
|
||||
[INDEX_U16] = GL_UNSIGNED_SHORT,
|
||||
[INDEX_U32] = GL_UNSIGNED_INT
|
||||
[GWN_INDEX_U8] = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not
|
||||
[GWN_INDEX_U16] = GL_UNSIGNED_SHORT,
|
||||
[GWN_INDEX_U32] = GL_UNSIGNED_INT
|
||||
};
|
||||
return table[type];
|
||||
}
|
||||
|
||||
unsigned ElementList_size(const ElementList* elem)
|
||||
unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf* elem)
|
||||
{
|
||||
#if TRACK_INDEX_RANGE
|
||||
#if GWN_TRACK_INDEX_RANGE
|
||||
static const unsigned table[] = {
|
||||
[INDEX_U8] = sizeof(GLubyte), // GL has this, Vulkan does not
|
||||
[INDEX_U16] = sizeof(GLushort),
|
||||
[INDEX_U32] = sizeof(GLuint)
|
||||
[GWN_INDEX_U8] = sizeof(GLubyte), // GL has this, Vulkan does not
|
||||
[GWN_INDEX_U16] = sizeof(GLushort),
|
||||
[GWN_INDEX_U32] = sizeof(GLuint)
|
||||
};
|
||||
return elem->index_ct * table[elem->index_type];
|
||||
#else
|
||||
@@ -39,12 +39,12 @@ unsigned ElementList_size(const ElementList* elem)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ElementList_prime(ElementList* elem)
|
||||
static void ElementList_prime(Gwn_IndexBuf* elem)
|
||||
{
|
||||
elem->vbo_id = buffer_id_alloc();
|
||||
elem->vbo_id = GWN_buf_id_alloc();
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id);
|
||||
// fill with delicious data & send to GPU the first time only
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ElementList_size(elem), elem->data, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, GWN_indexbuf_size_get(elem), elem->data, GL_STATIC_DRAW);
|
||||
|
||||
#if KEEP_SINGLE_COPY
|
||||
// now that GL has a copy, discard original
|
||||
@@ -53,7 +53,7 @@ static void ElementList_prime(ElementList* elem)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ElementList_use(ElementList* elem)
|
||||
void GWN_indexbuf_use(Gwn_IndexBuf* elem)
|
||||
{
|
||||
if (elem->vbo_id)
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id);
|
||||
@@ -61,18 +61,18 @@ void ElementList_use(ElementList* elem)
|
||||
ElementList_prime(elem);
|
||||
}
|
||||
|
||||
void ElementListBuilder_init(ElementListBuilder* builder, PrimitiveType prim_type, unsigned prim_ct, unsigned vertex_ct)
|
||||
void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned prim_ct, unsigned vertex_ct)
|
||||
{
|
||||
unsigned verts_per_prim = 0;
|
||||
switch (prim_type)
|
||||
{
|
||||
case PRIM_POINTS:
|
||||
case GWN_PRIM_POINTS:
|
||||
verts_per_prim = 1;
|
||||
break;
|
||||
case PRIM_LINES:
|
||||
case GWN_PRIM_LINES:
|
||||
verts_per_prim = 2;
|
||||
break;
|
||||
case PRIM_TRIANGLES:
|
||||
case GWN_PRIM_TRIS:
|
||||
verts_per_prim = 3;
|
||||
break;
|
||||
default:
|
||||
@@ -89,7 +89,7 @@ void ElementListBuilder_init(ElementListBuilder* builder, PrimitiveType prim_typ
|
||||
builder->data = calloc(builder->max_index_ct, sizeof(unsigned));
|
||||
}
|
||||
|
||||
void add_generic_vertex(ElementListBuilder* builder, unsigned v)
|
||||
void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, unsigned v)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(builder->data != NULL);
|
||||
@@ -100,39 +100,39 @@ void add_generic_vertex(ElementListBuilder* builder, unsigned v)
|
||||
builder->data[builder->index_ct++] = v;
|
||||
}
|
||||
|
||||
void add_point_vertex(ElementListBuilder* builder, unsigned v)
|
||||
void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, unsigned v)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(builder->prim_type == PRIM_POINTS);
|
||||
assert(builder->prim_type == GWN_PRIM_POINTS);
|
||||
#endif
|
||||
|
||||
add_generic_vertex(builder, v);
|
||||
GWN_indexbuf_add_generic_vert(builder, v);
|
||||
}
|
||||
|
||||
void add_line_vertices(ElementListBuilder* builder, unsigned v1, unsigned v2)
|
||||
void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(builder->prim_type == PRIM_LINES);
|
||||
assert(builder->prim_type == GWN_PRIM_LINES);
|
||||
assert(v1 != v2);
|
||||
#endif
|
||||
|
||||
add_generic_vertex(builder, v1);
|
||||
add_generic_vertex(builder, v2);
|
||||
GWN_indexbuf_add_generic_vert(builder, v1);
|
||||
GWN_indexbuf_add_generic_vert(builder, v2);
|
||||
}
|
||||
|
||||
void add_triangle_vertices(ElementListBuilder* builder, unsigned v1, unsigned v2, unsigned v3)
|
||||
void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, unsigned v1, unsigned v2, unsigned v3)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(builder->prim_type == PRIM_TRIANGLES);
|
||||
assert(builder->prim_type == GWN_PRIM_TRIS);
|
||||
assert(v1 != v2 && v2 != v3 && v3 != v1);
|
||||
#endif
|
||||
|
||||
add_generic_vertex(builder, v1);
|
||||
add_generic_vertex(builder, v2);
|
||||
add_generic_vertex(builder, v3);
|
||||
GWN_indexbuf_add_generic_vert(builder, v1);
|
||||
GWN_indexbuf_add_generic_vert(builder, v2);
|
||||
GWN_indexbuf_add_generic_vert(builder, v3);
|
||||
}
|
||||
|
||||
#if TRACK_INDEX_RANGE
|
||||
#if GWN_TRACK_INDEX_RANGE
|
||||
// Everything remains 32 bit while building to keep things simple.
|
||||
// Find min/max after, then convert to smallest index type possible.
|
||||
|
||||
@@ -159,7 +159,7 @@ static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned
|
||||
return max_value - min_value;
|
||||
}
|
||||
|
||||
static void squeeze_indices_byte(const unsigned values[], ElementList* elem)
|
||||
static void squeeze_indices_byte(const unsigned values[], Gwn_IndexBuf* elem)
|
||||
{
|
||||
const unsigned index_ct = elem->index_ct;
|
||||
GLubyte* data = malloc(index_ct * sizeof(GLubyte));
|
||||
@@ -186,7 +186,7 @@ static void squeeze_indices_byte(const unsigned values[], ElementList* elem)
|
||||
elem->data = data;
|
||||
}
|
||||
|
||||
static void squeeze_indices_short(const unsigned values[], ElementList* elem)
|
||||
static void squeeze_indices_short(const unsigned values[], Gwn_IndexBuf* elem)
|
||||
{
|
||||
const unsigned index_ct = elem->index_ct;
|
||||
GLushort* data = malloc(index_ct * sizeof(GLushort));
|
||||
@@ -213,16 +213,16 @@ static void squeeze_indices_short(const unsigned values[], ElementList* elem)
|
||||
elem->data = data;
|
||||
}
|
||||
|
||||
#endif // TRACK_INDEX_RANGE
|
||||
#endif // GWN_TRACK_INDEX_RANGE
|
||||
|
||||
ElementList* ElementList_build(ElementListBuilder* builder)
|
||||
Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder* builder)
|
||||
{
|
||||
ElementList* elem = calloc(1, sizeof(ElementList));
|
||||
ElementList_build_in_place(builder, elem);
|
||||
Gwn_IndexBuf* elem = calloc(1, sizeof(Gwn_IndexBuf));
|
||||
GWN_indexbuf_build_in_place(builder, elem);
|
||||
return elem;
|
||||
}
|
||||
|
||||
void ElementList_build_in_place(ElementListBuilder* builder, ElementList* elem)
|
||||
void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* elem)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(builder->data != NULL);
|
||||
@@ -230,22 +230,22 @@ void ElementList_build_in_place(ElementListBuilder* builder, ElementList* elem)
|
||||
|
||||
elem->index_ct = builder->index_ct;
|
||||
|
||||
#if TRACK_INDEX_RANGE
|
||||
#if GWN_TRACK_INDEX_RANGE
|
||||
const unsigned range = index_range(builder->data, builder->index_ct, &elem->min_index, &elem->max_index);
|
||||
|
||||
if (range <= 0xFF)
|
||||
{
|
||||
elem->index_type = INDEX_U8;
|
||||
elem->index_type = GWN_INDEX_U8;
|
||||
squeeze_indices_byte(builder->data, elem);
|
||||
}
|
||||
else if (range <= 0xFFFF)
|
||||
{
|
||||
elem->index_type = INDEX_U16;
|
||||
elem->index_type = GWN_INDEX_U16;
|
||||
squeeze_indices_short(builder->data, elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
elem->index_type = INDEX_U32;
|
||||
elem->index_type = GWN_INDEX_U32;
|
||||
elem->base_index = 0;
|
||||
|
||||
if (builder->index_ct < builder->max_index_ct)
|
||||
@@ -281,10 +281,10 @@ void ElementList_build_in_place(ElementListBuilder* builder, ElementList* elem)
|
||||
// other fields are safe to leave
|
||||
}
|
||||
|
||||
void ElementList_discard(ElementList* elem)
|
||||
void GWN_indexbuf_discard(Gwn_IndexBuf* elem)
|
||||
{
|
||||
if (elem->vbo_id)
|
||||
buffer_id_free(elem->vbo_id);
|
||||
GWN_buf_id_free(elem->vbo_id);
|
||||
#if KEEP_SINGLE_COPY
|
||||
else
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
void immRectf(unsigned pos, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 4);
|
||||
immVertex2f(pos, x1, y1);
|
||||
immVertex2f(pos, x2, y1);
|
||||
immVertex2f(pos, x2, y2);
|
||||
@@ -25,7 +25,7 @@ void immRectf(unsigned pos, float x1, float y1, float x2, float y2)
|
||||
|
||||
void immRecti(unsigned pos, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 4);
|
||||
immVertex2i(pos, x1, y1);
|
||||
immVertex2i(pos, x2, y1);
|
||||
immVertex2i(pos, x2, y2);
|
||||
@@ -36,8 +36,8 @@ void immRecti(unsigned pos, int x1, int y1, int x2, int y2)
|
||||
#if 0 // more complete version in case we want that
|
||||
void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned pos = add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned pos = add_attrib(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4fv(color);
|
||||
immRecti(pos, x1, y1, x2, y2);
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
#include <string.h>
|
||||
|
||||
// necessary functions from matrix API
|
||||
extern void gpuBindMatrices(const ShaderInterface*);
|
||||
extern void gpuBindMatrices(const Gwn_ShaderInterface*);
|
||||
extern bool gpuMatricesDirty(void);
|
||||
|
||||
typedef struct {
|
||||
// TODO: organize this struct by frequency of change (run-time)
|
||||
|
||||
#if IMM_BATCH_COMBO
|
||||
Batch* batch;
|
||||
Gwn_Batch* batch;
|
||||
#endif
|
||||
|
||||
// current draw call
|
||||
@@ -34,9 +34,9 @@ typedef struct {
|
||||
unsigned buffer_bytes_mapped;
|
||||
unsigned vertex_ct;
|
||||
bool strict_vertex_ct;
|
||||
PrimitiveType prim_type;
|
||||
Gwn_PrimType prim_type;
|
||||
|
||||
VertexFormat vertex_format;
|
||||
Gwn_VertFormat vertex_format;
|
||||
|
||||
// current vertex
|
||||
unsigned vertex_idx;
|
||||
@@ -47,8 +47,8 @@ typedef struct {
|
||||
GLuint vao_id;
|
||||
|
||||
GLuint bound_program;
|
||||
const ShaderInterface* shader_interface;
|
||||
AttribBinding attrib_binding;
|
||||
const Gwn_ShaderInterface* shader_interface;
|
||||
Gwn_AttrBinding attrib_binding;
|
||||
uint16_t prev_enabled_attrib_bits; // <-- only affects this VAO, so we're ok
|
||||
} Immediate;
|
||||
|
||||
@@ -66,11 +66,11 @@ void immInit(void)
|
||||
|
||||
memset(&imm, 0, sizeof(Immediate));
|
||||
|
||||
imm.vbo_id = buffer_id_alloc();
|
||||
imm.vbo_id = GWN_buf_id_alloc();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id);
|
||||
glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
|
||||
|
||||
imm.prim_type = PRIM_NONE;
|
||||
imm.prim_type = GWN_PRIM_NONE;
|
||||
imm.strict_vertex_ct = true;
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
@@ -83,22 +83,22 @@ void immActivate(void)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(initialized);
|
||||
assert(imm.prim_type == PRIM_NONE); // make sure we're not between a Begin/End pair
|
||||
assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair
|
||||
assert(imm.vao_id == 0);
|
||||
#endif
|
||||
|
||||
imm.vao_id = vao_id_alloc();
|
||||
imm.vao_id = GWN_vao_alloc();
|
||||
}
|
||||
|
||||
void immDeactivate(void)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(initialized);
|
||||
assert(imm.prim_type == PRIM_NONE); // make sure we're not between a Begin/End pair
|
||||
assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair
|
||||
assert(imm.vao_id != 0);
|
||||
#endif
|
||||
|
||||
vao_id_free(imm.vao_id);
|
||||
GWN_vao_free(imm.vao_id);
|
||||
imm.vao_id = 0;
|
||||
imm.prev_enabled_attrib_bits = 0;
|
||||
}
|
||||
@@ -106,17 +106,17 @@ void immDeactivate(void)
|
||||
void immDestroy(void)
|
||||
{
|
||||
immDeactivate();
|
||||
buffer_id_free(imm.vbo_id);
|
||||
GWN_buf_id_free(imm.vbo_id);
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
VertexFormat* immVertexFormat(void)
|
||||
Gwn_VertFormat* immVertexFormat(void)
|
||||
{
|
||||
VertexFormat_clear(&imm.vertex_format);
|
||||
GWN_vertformat_clear(&imm.vertex_format);
|
||||
return &imm.vertex_format;
|
||||
}
|
||||
|
||||
void immBindProgram(GLuint program, const ShaderInterface* shaderface)
|
||||
void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(imm.bound_program == 0);
|
||||
@@ -145,7 +145,7 @@ void immUnbindProgram(void)
|
||||
}
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, PrimitiveType prim_type)
|
||||
static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, Gwn_PrimType prim_type)
|
||||
{
|
||||
// does vertex_ct make sense for this primitive type?
|
||||
if (vertex_ct == 0)
|
||||
@@ -153,19 +153,19 @@ static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, Primitive
|
||||
|
||||
switch (prim_type)
|
||||
{
|
||||
case PRIM_POINTS:
|
||||
case GWN_PRIM_POINTS:
|
||||
return true;
|
||||
case PRIM_LINES:
|
||||
case GWN_PRIM_LINES:
|
||||
return vertex_ct % 2 == 0;
|
||||
case PRIM_LINE_STRIP:
|
||||
case PRIM_LINE_LOOP:
|
||||
case GWN_PRIM_LINE_STRIP:
|
||||
case GWN_PRIM_LINE_LOOP:
|
||||
return vertex_ct >= 2;
|
||||
case PRIM_LINE_STRIP_ADJACENCY:
|
||||
case GWN_PRIM_LINE_STRIP_ADJ:
|
||||
return vertex_ct >= 4;
|
||||
case PRIM_TRIANGLES:
|
||||
case GWN_PRIM_TRIS:
|
||||
return vertex_ct % 3 == 0;
|
||||
case PRIM_TRIANGLE_STRIP:
|
||||
case PRIM_TRIANGLE_FAN:
|
||||
case GWN_PRIM_TRI_STRIP:
|
||||
case GWN_PRIM_TRI_FAN:
|
||||
return vertex_ct >= 3;
|
||||
default:
|
||||
return false;
|
||||
@@ -173,11 +173,11 @@ static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, Primitive
|
||||
}
|
||||
#endif
|
||||
|
||||
void immBegin(PrimitiveType prim_type, unsigned vertex_ct)
|
||||
void immBegin(Gwn_PrimType prim_type, unsigned vertex_ct)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(initialized);
|
||||
assert(imm.prim_type == PRIM_NONE); // make sure we haven't already begun
|
||||
assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun
|
||||
assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type));
|
||||
#endif
|
||||
|
||||
@@ -242,7 +242,7 @@ void immBegin(PrimitiveType prim_type, unsigned vertex_ct)
|
||||
imm.vertex_data = imm.buffer_data;
|
||||
}
|
||||
|
||||
void immBeginAtMost(PrimitiveType prim_type, unsigned vertex_ct)
|
||||
void immBeginAtMost(Gwn_PrimType prim_type, unsigned vertex_ct)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(vertex_ct > 0);
|
||||
@@ -254,11 +254,11 @@ void immBeginAtMost(PrimitiveType prim_type, unsigned vertex_ct)
|
||||
|
||||
#if IMM_BATCH_COMBO
|
||||
|
||||
Batch* immBeginBatch(PrimitiveType prim_type, unsigned vertex_ct)
|
||||
Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_ct)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(initialized);
|
||||
assert(imm.prim_type == PRIM_NONE); // make sure we haven't already begun
|
||||
assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun
|
||||
assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type));
|
||||
#endif
|
||||
|
||||
@@ -267,21 +267,21 @@ Batch* immBeginBatch(PrimitiveType prim_type, unsigned vertex_ct)
|
||||
imm.vertex_idx = 0;
|
||||
imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits;
|
||||
|
||||
VertexBuffer* verts = VertexBuffer_create_with_format(&imm.vertex_format);
|
||||
VertexBuffer_allocate_data(verts, vertex_ct);
|
||||
Gwn_VertBuf* verts = GWN_vertbuf_create_with_format(&imm.vertex_format);
|
||||
GWN_vertbuf_data_alloc(verts, vertex_ct);
|
||||
|
||||
imm.buffer_bytes_mapped = VertexBuffer_size(verts);
|
||||
imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts);
|
||||
imm.vertex_data = verts->data;
|
||||
|
||||
imm.batch = Batch_create(prim_type, verts, NULL);
|
||||
imm.batch->phase = BUILDING;
|
||||
imm.batch = GWN_batch_create(prim_type, verts, NULL);
|
||||
imm.batch->phase = GWN_BATCH_BUILDING;
|
||||
|
||||
Batch_set_program(imm.batch, imm.bound_program, imm.shader_interface);
|
||||
GWN_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface);
|
||||
|
||||
return imm.batch;
|
||||
}
|
||||
|
||||
Batch* immBeginBatchAtMost(PrimitiveType prim_type, unsigned vertex_ct)
|
||||
Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, unsigned vertex_ct)
|
||||
{
|
||||
imm.strict_vertex_ct = false;
|
||||
return immBeginBatch(prim_type, vertex_ct);
|
||||
@@ -297,7 +297,7 @@ static void immDrawSetup(void)
|
||||
// enable/disable vertex attribs as needed
|
||||
if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits)
|
||||
{
|
||||
for (unsigned loc = 0; loc < MAX_VERTEX_ATTRIBS; ++loc)
|
||||
for (unsigned loc = 0; loc < GWN_VERT_ATTR_MAX_LEN; ++loc)
|
||||
{
|
||||
bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc);
|
||||
bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc);
|
||||
@@ -321,7 +321,7 @@ static void immDrawSetup(void)
|
||||
|
||||
for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx)
|
||||
{
|
||||
const Attrib* a = imm.vertex_format.attribs + a_idx;
|
||||
const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx;
|
||||
|
||||
const unsigned offset = imm.buffer_offset + a->offset;
|
||||
const GLvoid* pointer = (const GLubyte*)0 + offset;
|
||||
@@ -332,14 +332,14 @@ static void immDrawSetup(void)
|
||||
|
||||
switch (a->fetch_mode)
|
||||
{
|
||||
case KEEP_FLOAT:
|
||||
case CONVERT_INT_TO_FLOAT:
|
||||
case GWN_FETCH_FLOAT:
|
||||
case GWN_FETCH_INT_TO_FLOAT:
|
||||
glVertexAttribPointer(loc, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer);
|
||||
break;
|
||||
case NORMALIZE_INT_TO_FLOAT:
|
||||
case GWN_FETCH_INT_TO_FLOAT_UNIT:
|
||||
glVertexAttribPointer(loc, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer);
|
||||
break;
|
||||
case KEEP_INT:
|
||||
case GWN_FETCH_INT:
|
||||
glVertexAttribIPointer(loc, a->comp_ct, a->gl_comp_type, stride, pointer);
|
||||
}
|
||||
}
|
||||
@@ -351,7 +351,7 @@ static void immDrawSetup(void)
|
||||
void immEnd(void)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
unsigned buffer_bytes_used;
|
||||
@@ -393,11 +393,11 @@ void immEnd(void)
|
||||
{
|
||||
if (buffer_bytes_used != imm.buffer_bytes_mapped)
|
||||
{
|
||||
VertexBuffer_resize_data(imm.batch->verts[0], imm.vertex_ct);
|
||||
GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_ct);
|
||||
// TODO: resize only if vertex count is much smaller
|
||||
}
|
||||
|
||||
imm.batch->phase = READY_TO_DRAW;
|
||||
imm.batch->phase = GWN_BATCH_READY_TO_DRAW;
|
||||
imm.batch = NULL; // don't free, batch belongs to caller
|
||||
}
|
||||
else
|
||||
@@ -419,7 +419,7 @@ void immEnd(void)
|
||||
}
|
||||
|
||||
// prep for next immBegin
|
||||
imm.prim_type = PRIM_NONE;
|
||||
imm.prim_type = GWN_PRIM_NONE;
|
||||
imm.strict_vertex_ct = true;
|
||||
}
|
||||
|
||||
@@ -439,14 +439,14 @@ static void setAttribValueBit(unsigned attrib_id)
|
||||
|
||||
void immAttrib1f(unsigned attrib_id, float x)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_F32);
|
||||
assert(attrib->comp_type == GWN_COMP_F32);
|
||||
assert(attrib->comp_ct == 1);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -459,14 +459,14 @@ void immAttrib1f(unsigned attrib_id, float x)
|
||||
|
||||
void immAttrib2f(unsigned attrib_id, float x, float y)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_F32);
|
||||
assert(attrib->comp_type == GWN_COMP_F32);
|
||||
assert(attrib->comp_ct == 2);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -480,14 +480,14 @@ void immAttrib2f(unsigned attrib_id, float x, float y)
|
||||
|
||||
void immAttrib3f(unsigned attrib_id, float x, float y, float z)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_F32);
|
||||
assert(attrib->comp_type == GWN_COMP_F32);
|
||||
assert(attrib->comp_ct == 3);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -502,14 +502,14 @@ void immAttrib3f(unsigned attrib_id, float x, float y, float z)
|
||||
|
||||
void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_F32);
|
||||
assert(attrib->comp_type == GWN_COMP_F32);
|
||||
assert(attrib->comp_ct == 4);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -525,14 +525,14 @@ void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w)
|
||||
|
||||
void immAttrib1u(unsigned attrib_id, unsigned x)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_U32);
|
||||
assert(attrib->comp_type == GWN_COMP_U32);
|
||||
assert(attrib->comp_ct == 1);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -544,14 +544,14 @@ void immAttrib1u(unsigned attrib_id, unsigned x)
|
||||
|
||||
void immAttrib2i(unsigned attrib_id, int x, int y)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_I32);
|
||||
assert(attrib->comp_type == GWN_COMP_I32);
|
||||
assert(attrib->comp_ct == 2);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -564,14 +564,14 @@ void immAttrib2i(unsigned attrib_id, int x, int y)
|
||||
|
||||
void immAttrib2s(unsigned attrib_id, short x, short y)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_I16);
|
||||
assert(attrib->comp_type == GWN_COMP_I16);
|
||||
assert(attrib->comp_ct == 2);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -599,14 +599,14 @@ void immAttrib4fv(unsigned attrib_id, const float data[4])
|
||||
|
||||
void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_U8);
|
||||
assert(attrib->comp_type == GWN_COMP_U8);
|
||||
assert(attrib->comp_ct == 3);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -621,14 +621,14 @@ void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned
|
||||
|
||||
void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
|
||||
{
|
||||
Attrib* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(attrib->comp_type == COMP_U8);
|
||||
assert(attrib->comp_type == GWN_COMP_U8);
|
||||
assert(attrib->comp_ct == 4);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -657,7 +657,7 @@ void immSkipAttrib(unsigned attrib_id)
|
||||
#if TRUST_NO_ONE
|
||||
assert(attrib_id < imm.vertex_format.attrib_ct);
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
#endif
|
||||
|
||||
setAttribValueBit(attrib_id);
|
||||
@@ -666,7 +666,7 @@ void immSkipAttrib(unsigned attrib_id)
|
||||
static void immEndVertex(void) // and move on to the next vertex
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(imm.prim_type != PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair
|
||||
assert(imm.vertex_idx < imm.vertex_ct);
|
||||
#endif
|
||||
|
||||
@@ -682,7 +682,7 @@ static void immEndVertex(void) // and move on to the next vertex
|
||||
{
|
||||
if ((imm.unassigned_attrib_bits >> a_idx) & 1)
|
||||
{
|
||||
const Attrib* a = imm.vertex_format.attribs + a_idx;
|
||||
const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx;
|
||||
|
||||
// printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx);
|
||||
|
||||
@@ -745,16 +745,16 @@ void immVertex2iv(unsigned attrib_id, const int data[2])
|
||||
|
||||
#if 0
|
||||
#if TRUST_NO_ONE
|
||||
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name); assert(uniform);
|
||||
#define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); assert(uniform);
|
||||
#else
|
||||
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name);
|
||||
#define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name);
|
||||
#endif
|
||||
#else
|
||||
// NOTE: It is possible to have uniform fully optimized out from the shader.
|
||||
// In this case we can't assert failure or allow NULL-pointer dereference.
|
||||
// TODO(sergey): How can we detect existing-but-optimized-out uniform but still
|
||||
// catch typos in uniform names passed to immUniform*() functions?
|
||||
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
|
||||
#define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
|
||||
#endif
|
||||
|
||||
void immUniform1f(const char* name, float x)
|
||||
@@ -860,7 +860,7 @@ void immUniform4iv(const char* name, const int data[4])
|
||||
|
||||
void immUniformColor4f(float r, float g, float b, float a)
|
||||
{
|
||||
const ShaderInput* uniform = ShaderInterface_builtin_uniform(imm.shader_interface, UNIFORM_COLOR);
|
||||
const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform_builtin(imm.shader_interface, GWN_UNIFORM_COLOR);
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(uniform != NULL);
|
||||
|
||||
@@ -12,51 +12,51 @@
|
||||
#include "primitive.h"
|
||||
#include "primitive_private.h"
|
||||
|
||||
PrimitiveClass prim_class_of_type(PrimitiveType prim_type)
|
||||
Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type)
|
||||
{
|
||||
static const PrimitiveClass classes[] =
|
||||
static const Gwn_PrimClass classes[] =
|
||||
{
|
||||
[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,
|
||||
[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,
|
||||
|
||||
[PRIM_LINE_STRIP_ADJACENCY] = PRIM_CLASS_LINE,
|
||||
[GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE,
|
||||
|
||||
[PRIM_NONE] = PRIM_CLASS_NONE
|
||||
[GWN_PRIM_NONE] = GWN_PRIM_CLASS_NONE
|
||||
};
|
||||
|
||||
return classes[prim_type];
|
||||
}
|
||||
|
||||
bool prim_type_belongs_to_class(PrimitiveType prim_type, PrimitiveClass prim_class)
|
||||
bool GWN_primtype_belongs_to_class(Gwn_PrimType prim_type, Gwn_PrimClass prim_class)
|
||||
{
|
||||
if (prim_class == PRIM_CLASS_NONE && prim_type == PRIM_NONE)
|
||||
if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE)
|
||||
return true;
|
||||
|
||||
return prim_class & prim_class_of_type(prim_type);
|
||||
return prim_class & GWN_primtype_class(prim_type);
|
||||
}
|
||||
|
||||
GLenum convert_prim_type_to_gl(PrimitiveType prim_type)
|
||||
GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(prim_type != PRIM_NONE);
|
||||
assert(prim_type != GWN_PRIM_NONE);
|
||||
#endif
|
||||
|
||||
static const GLenum table[] =
|
||||
{
|
||||
[PRIM_POINTS] = GL_POINTS,
|
||||
[PRIM_LINES] = GL_LINES,
|
||||
[PRIM_LINE_STRIP] = GL_LINE_STRIP,
|
||||
[PRIM_LINE_LOOP] = GL_LINE_LOOP,
|
||||
[PRIM_TRIANGLES] = PRIM_CLASS_SURFACE,
|
||||
[PRIM_TRIANGLE_STRIP] = GL_TRIANGLE_STRIP,
|
||||
[PRIM_TRIANGLE_FAN] = GL_TRIANGLE_FAN,
|
||||
[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,
|
||||
|
||||
[PRIM_LINE_STRIP_ADJACENCY] = GL_LINE_STRIP_ADJACENCY,
|
||||
[GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY,
|
||||
};
|
||||
|
||||
return table[prim_type];
|
||||
|
||||
@@ -21,24 +21,24 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
static const char* BuiltinUniform_name(BuiltinUniform u)
|
||||
static const char* BuiltinUniform_name(Gwn_UniformBuiltin u)
|
||||
{
|
||||
static const char* names[] =
|
||||
{
|
||||
[UNIFORM_NONE] = NULL,
|
||||
[GWN_UNIFORM_NONE] = NULL,
|
||||
|
||||
[UNIFORM_MODELVIEW] = "ModelViewMatrix",
|
||||
[UNIFORM_PROJECTION] = "ProjectionMatrix",
|
||||
[UNIFORM_MVP] = "ModelViewProjectionMatrix",
|
||||
[GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix",
|
||||
[GWN_UNIFORM_PROJECTION] = "ProjectionMatrix",
|
||||
[GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix",
|
||||
|
||||
[UNIFORM_MODELVIEW_INV] = "ModelViewInverseMatrix",
|
||||
[UNIFORM_PROJECTION_INV] = "ProjectionInverseMatrix",
|
||||
[GWN_UNIFORM_MODELVIEW_INV] = "ModelViewInverseMatrix",
|
||||
[GWN_UNIFORM_PROJECTION_INV] = "ProjectionInverseMatrix",
|
||||
|
||||
[UNIFORM_NORMAL] = "NormalMatrix",
|
||||
[GWN_UNIFORM_NORMAL] = "NormalMatrix",
|
||||
|
||||
[UNIFORM_COLOR] = "color",
|
||||
[GWN_UNIFORM_COLOR] = "color",
|
||||
|
||||
[UNIFORM_CUSTOM] = NULL
|
||||
[GWN_UNIFORM_CUSTOM] = NULL
|
||||
};
|
||||
|
||||
return names[u];
|
||||
@@ -61,17 +61,17 @@ static unsigned hash_string(const char *str)
|
||||
return i;
|
||||
}
|
||||
|
||||
static void set_input_name(ShaderInput* input, const char* name)
|
||||
static void set_input_name(Gwn_ShaderInput* input, const char* name)
|
||||
{
|
||||
input->name = name;
|
||||
input->name_hash = hash_string(name);
|
||||
}
|
||||
|
||||
// keep these in sync with BuiltinUniform order
|
||||
#define FIRST_MAT4_UNIFORM UNIFORM_MODELVIEW
|
||||
#define LAST_MAT4_UNIFORM UNIFORM_PROJECTION_INV
|
||||
// keep these in sync with Gwn_UniformBuiltin order
|
||||
#define FIRST_MAT4_UNIFORM GWN_UNIFORM_MODELVIEW
|
||||
#define LAST_MAT4_UNIFORM GWN_UNIFORM_PROJECTION_INV
|
||||
|
||||
static bool setup_builtin_uniform(ShaderInput* input, const char* name)
|
||||
static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name)
|
||||
{
|
||||
// TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types
|
||||
|
||||
@@ -80,7 +80,7 @@ static bool setup_builtin_uniform(ShaderInput* input, const char* name)
|
||||
switch (input->gl_type)
|
||||
{
|
||||
case GL_FLOAT_MAT4:
|
||||
for (BuiltinUniform u = FIRST_MAT4_UNIFORM; u <= LAST_MAT4_UNIFORM; ++u)
|
||||
for (Gwn_UniformBuiltin u = FIRST_MAT4_UNIFORM; u <= LAST_MAT4_UNIFORM; ++u)
|
||||
{
|
||||
const char* builtin_name = BuiltinUniform_name(u);
|
||||
if (match(name, builtin_name))
|
||||
@@ -93,22 +93,22 @@ static bool setup_builtin_uniform(ShaderInput* input, const char* name)
|
||||
break;
|
||||
case GL_FLOAT_MAT3:
|
||||
{
|
||||
const char* builtin_name = BuiltinUniform_name(UNIFORM_NORMAL);
|
||||
const char* builtin_name = BuiltinUniform_name(GWN_UNIFORM_NORMAL);
|
||||
if (match(name, builtin_name))
|
||||
{
|
||||
set_input_name(input, builtin_name);
|
||||
input->builtin_type = UNIFORM_NORMAL;
|
||||
input->builtin_type = GWN_UNIFORM_NORMAL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_FLOAT_VEC4:
|
||||
{
|
||||
const char* builtin_name = BuiltinUniform_name(UNIFORM_COLOR);
|
||||
const char* builtin_name = BuiltinUniform_name(GWN_UNIFORM_COLOR);
|
||||
if (match(name, builtin_name))
|
||||
{
|
||||
set_input_name(input, builtin_name);
|
||||
input->builtin_type = UNIFORM_COLOR;
|
||||
input->builtin_type = GWN_UNIFORM_COLOR;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -117,11 +117,11 @@ static bool setup_builtin_uniform(ShaderInput* input, const char* name)
|
||||
;
|
||||
}
|
||||
|
||||
input->builtin_type = UNIFORM_CUSTOM;
|
||||
input->builtin_type = GWN_UNIFORM_CUSTOM;
|
||||
return false;
|
||||
}
|
||||
|
||||
ShaderInterface* ShaderInterface_create(GLint program)
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program)
|
||||
{
|
||||
#if DEBUG_SHADER_INTERFACE
|
||||
printf("%s {\n", __func__); // enter function
|
||||
@@ -138,16 +138,16 @@ ShaderInterface* ShaderInterface_create(GLint program)
|
||||
const uint32_t name_buffer_len = uniform_ct * max_uniform_name_len + attrib_ct * max_attrib_name_len;
|
||||
|
||||
// allocate enough space for input counts, details for each input, and a buffer for name strings
|
||||
ShaderInterface* shaderface = calloc(1, offsetof(ShaderInterface, inputs) + input_ct * sizeof(ShaderInput) + name_buffer_len);
|
||||
Gwn_ShaderInterface* shaderface = calloc(1, offsetof(Gwn_ShaderInterface, inputs) + input_ct * sizeof(Gwn_ShaderInput) + name_buffer_len);
|
||||
shaderface->uniform_ct = uniform_ct;
|
||||
shaderface->attrib_ct = attrib_ct;
|
||||
|
||||
char* name_buffer = (char*)shaderface + offsetof(ShaderInterface, inputs) + input_ct * sizeof(ShaderInput);
|
||||
char* name_buffer = (char*)shaderface + offsetof(Gwn_ShaderInterface, inputs) + input_ct * sizeof(Gwn_ShaderInput);
|
||||
uint32_t name_buffer_offset = 0;
|
||||
|
||||
for (uint32_t i = 0; i < uniform_ct; ++i)
|
||||
{
|
||||
ShaderInput* input = shaderface->inputs + i;
|
||||
Gwn_ShaderInput* input = shaderface->inputs + i;
|
||||
GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
|
||||
char* name = name_buffer + name_buffer_offset;
|
||||
GLsizei name_len = 0;
|
||||
@@ -181,7 +181,7 @@ ShaderInterface* ShaderInterface_create(GLint program)
|
||||
|
||||
for (uint32_t i = 0; i < attrib_ct; ++i)
|
||||
{
|
||||
ShaderInput* input = shaderface->inputs + uniform_ct + i;
|
||||
Gwn_ShaderInput* input = shaderface->inputs + uniform_ct + i;
|
||||
GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
|
||||
char* name = name_buffer + name_buffer_offset;
|
||||
GLsizei name_len = 0;
|
||||
@@ -221,7 +221,7 @@ ShaderInterface* ShaderInterface_create(GLint program)
|
||||
{
|
||||
// realloc shaderface to shrink name buffer
|
||||
const size_t shaderface_alloc =
|
||||
offsetof(ShaderInterface, inputs) + (input_ct * sizeof(ShaderInput)) + name_buffer_used;
|
||||
offsetof(Gwn_ShaderInterface, inputs) + (input_ct * sizeof(Gwn_ShaderInput)) + name_buffer_used;
|
||||
const char* shaderface_orig_start = (const char*)shaderface;
|
||||
const char* shaderface_orig_end = &shaderface_orig_start[shaderface_alloc];
|
||||
shaderface = realloc(shaderface, shaderface_alloc);
|
||||
@@ -232,7 +232,7 @@ ShaderInterface* ShaderInterface_create(GLint program)
|
||||
// each input->name will need adjustment (except static built-in names)
|
||||
for (uint32_t i = 0; i < input_ct; ++i)
|
||||
{
|
||||
ShaderInput* input = shaderface->inputs + i;
|
||||
Gwn_ShaderInput* input = shaderface->inputs + i;
|
||||
|
||||
if (input->name >= shaderface_orig_start && input->name < shaderface_orig_end)
|
||||
input->name += delta;
|
||||
@@ -243,18 +243,18 @@ ShaderInterface* ShaderInterface_create(GLint program)
|
||||
return shaderface;
|
||||
}
|
||||
|
||||
void ShaderInterface_discard(ShaderInterface* shaderface)
|
||||
void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface)
|
||||
{
|
||||
// allocated as one chunk, so discard is simple
|
||||
free(shaderface);
|
||||
}
|
||||
|
||||
const ShaderInput* ShaderInterface_uniform(const ShaderInterface* shaderface, const char* name)
|
||||
const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name)
|
||||
{
|
||||
const unsigned name_hash = hash_string(name);
|
||||
for (uint32_t i = 0; i < shaderface->uniform_ct; ++i)
|
||||
{
|
||||
const ShaderInput* uniform = shaderface->inputs + i;
|
||||
const Gwn_ShaderInput* uniform = shaderface->inputs + i;
|
||||
|
||||
#if SUPPORT_LEGACY_GLSL
|
||||
if (uniform->name == NULL) continue;
|
||||
@@ -271,17 +271,17 @@ const ShaderInput* ShaderInterface_uniform(const ShaderInterface* shaderface, co
|
||||
return NULL; // not found
|
||||
}
|
||||
|
||||
const ShaderInput* ShaderInterface_builtin_uniform(const ShaderInterface* shaderface, BuiltinUniform builtin)
|
||||
const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(builtin != UNIFORM_NONE);
|
||||
assert(builtin != UNIFORM_CUSTOM);
|
||||
assert(builtin != GWN_UNIFORM_NONE);
|
||||
assert(builtin != GWN_UNIFORM_CUSTOM);
|
||||
#endif
|
||||
|
||||
// look up by enum, not name
|
||||
for (uint32_t i = 0; i < shaderface->uniform_ct; ++i)
|
||||
{
|
||||
const ShaderInput* uniform = shaderface->inputs + i;
|
||||
const Gwn_ShaderInput* uniform = shaderface->inputs + i;
|
||||
|
||||
if (uniform->builtin_type == builtin)
|
||||
return uniform;
|
||||
@@ -289,14 +289,14 @@ const ShaderInput* ShaderInterface_builtin_uniform(const ShaderInterface* shader
|
||||
return NULL; // not found
|
||||
}
|
||||
|
||||
const ShaderInput* ShaderInterface_attrib(const ShaderInterface* shaderface, const char* name)
|
||||
const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name)
|
||||
{
|
||||
// attribs are stored after uniforms
|
||||
const uint32_t input_ct = shaderface->uniform_ct + shaderface->attrib_ct;
|
||||
const unsigned name_hash = hash_string(name);
|
||||
for (uint32_t i = shaderface->uniform_ct; i < input_ct; ++i)
|
||||
{
|
||||
const ShaderInput* attrib = shaderface->inputs + i;
|
||||
const Gwn_ShaderInput* attrib = shaderface->inputs + i;
|
||||
|
||||
#if SUPPORT_LEGACY_GLSL
|
||||
if (attrib->name == NULL) continue;
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
|
||||
static unsigned vbo_memory_usage;
|
||||
|
||||
VertexBuffer* VertexBuffer_create(void)
|
||||
Gwn_VertBuf* GWN_vertbuf_create(void)
|
||||
{
|
||||
VertexBuffer* verts = malloc(sizeof(VertexBuffer));
|
||||
VertexBuffer_init(verts);
|
||||
Gwn_VertBuf* verts = malloc(sizeof(Gwn_VertBuf));
|
||||
GWN_vertbuf_init(verts);
|
||||
return verts;
|
||||
}
|
||||
|
||||
VertexBuffer* VertexBuffer_create_with_format(const VertexFormat* format)
|
||||
Gwn_VertBuf* GWN_vertbuf_create_with_format(const Gwn_VertFormat* format)
|
||||
{
|
||||
VertexBuffer* verts = VertexBuffer_create();
|
||||
VertexFormat_copy(&verts->format, format);
|
||||
Gwn_VertBuf* verts = GWN_vertbuf_create();
|
||||
GWN_vertformat_copy(&verts->format, format);
|
||||
if (!format->packed)
|
||||
VertexFormat_pack(&verts->format);
|
||||
return verts;
|
||||
@@ -38,24 +38,24 @@ VertexBuffer* VertexBuffer_create_with_format(const VertexFormat* format)
|
||||
// TODO: implement those memory savings
|
||||
}
|
||||
|
||||
void VertexBuffer_init(VertexBuffer* verts)
|
||||
void GWN_vertbuf_init(Gwn_VertBuf* verts)
|
||||
{
|
||||
memset(verts, 0, sizeof(VertexBuffer));
|
||||
memset(verts, 0, sizeof(Gwn_VertBuf));
|
||||
}
|
||||
|
||||
void VertexBuffer_init_with_format(VertexBuffer* verts, const VertexFormat* format)
|
||||
void GWN_vertbuf_init_with_format(Gwn_VertBuf* verts, const Gwn_VertFormat* format)
|
||||
{
|
||||
VertexBuffer_init(verts);
|
||||
VertexFormat_copy(&verts->format, format);
|
||||
GWN_vertbuf_init(verts);
|
||||
GWN_vertformat_copy(&verts->format, format);
|
||||
if (!format->packed)
|
||||
VertexFormat_pack(&verts->format);
|
||||
}
|
||||
|
||||
void VertexBuffer_discard(VertexBuffer* verts)
|
||||
void GWN_vertbuf_discard(Gwn_VertBuf* verts)
|
||||
{
|
||||
if (verts->vbo_id) {
|
||||
buffer_id_free(verts->vbo_id);
|
||||
vbo_memory_usage -= VertexBuffer_size(verts);
|
||||
GWN_buf_id_free(verts->vbo_id);
|
||||
vbo_memory_usage -= GWN_vertbuf_size_get(verts);
|
||||
}
|
||||
#if KEEP_SINGLE_COPY
|
||||
else
|
||||
@@ -67,24 +67,24 @@ void VertexBuffer_discard(VertexBuffer* verts)
|
||||
free(verts);
|
||||
}
|
||||
|
||||
unsigned VertexBuffer_size(const VertexBuffer* verts)
|
||||
unsigned GWN_vertbuf_size_get(const Gwn_VertBuf* verts)
|
||||
{
|
||||
return vertex_buffer_size(&verts->format, verts->vertex_ct);
|
||||
}
|
||||
|
||||
void VertexBuffer_allocate_data(VertexBuffer* verts, unsigned v_ct)
|
||||
void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_ct)
|
||||
{
|
||||
VertexFormat* format = &verts->format;
|
||||
Gwn_VertFormat* format = &verts->format;
|
||||
if (!format->packed)
|
||||
VertexFormat_pack(format);
|
||||
|
||||
verts->vertex_ct = v_ct;
|
||||
|
||||
// Data initially lives in main memory. Will be transferred to VRAM when we "prime" it.
|
||||
verts->data = malloc(VertexBuffer_size(verts));
|
||||
verts->data = malloc(GWN_vertbuf_size_get(verts));
|
||||
}
|
||||
|
||||
void VertexBuffer_resize_data(VertexBuffer* verts, unsigned v_ct)
|
||||
void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, unsigned v_ct)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(verts->vertex_ct != v_ct); // allow this?
|
||||
@@ -93,15 +93,15 @@ void VertexBuffer_resize_data(VertexBuffer* verts, unsigned v_ct)
|
||||
#endif
|
||||
|
||||
verts->vertex_ct = v_ct;
|
||||
verts->data = realloc(verts->data, VertexBuffer_size(verts));
|
||||
verts->data = realloc(verts->data, GWN_vertbuf_size_get(verts));
|
||||
// TODO: skip realloc if v_ct < existing vertex count
|
||||
// extra space will be reclaimed, and never sent to VRAM (see VertexBuffer_prime)
|
||||
}
|
||||
|
||||
void VertexBuffer_set_attrib(VertexBuffer* verts, unsigned a_idx, unsigned v_idx, const void* data)
|
||||
void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, unsigned a_idx, unsigned v_idx, const void* data)
|
||||
{
|
||||
const VertexFormat* format = &verts->format;
|
||||
const Attrib* a = format->attribs + a_idx;
|
||||
const Gwn_VertFormat* format = &verts->format;
|
||||
const Gwn_VertAttr* a = format->attribs + a_idx;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(a_idx < format->attrib_ct);
|
||||
@@ -112,10 +112,10 @@ void VertexBuffer_set_attrib(VertexBuffer* verts, unsigned a_idx, unsigned v_idx
|
||||
memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz);
|
||||
}
|
||||
|
||||
void VertexBuffer_fill_attrib(VertexBuffer* verts, unsigned a_idx, const void* data)
|
||||
void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, unsigned a_idx, const void* data)
|
||||
{
|
||||
const VertexFormat* format = &verts->format;
|
||||
const Attrib* a = format->attribs + a_idx;
|
||||
const Gwn_VertFormat* format = &verts->format;
|
||||
const Gwn_VertAttr* a = format->attribs + a_idx;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(a_idx < format->attrib_ct);
|
||||
@@ -123,13 +123,13 @@ void VertexBuffer_fill_attrib(VertexBuffer* verts, unsigned a_idx, const void* d
|
||||
|
||||
const unsigned stride = a->sz; // tightly packed input data
|
||||
|
||||
VertexBuffer_fill_attrib_stride(verts, a_idx, stride, data);
|
||||
GWN_vertbuf_attr_fill_stride(verts, a_idx, stride, data);
|
||||
}
|
||||
|
||||
void VertexBuffer_fill_attrib_stride(VertexBuffer* verts, unsigned a_idx, unsigned stride, const void* data)
|
||||
void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, unsigned a_idx, unsigned stride, const void* data)
|
||||
{
|
||||
const VertexFormat* format = &verts->format;
|
||||
const Attrib* a = format->attribs + a_idx;
|
||||
const Gwn_VertFormat* format = &verts->format;
|
||||
const Gwn_VertAttr* a = format->attribs + a_idx;
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(a_idx < format->attrib_ct);
|
||||
@@ -151,11 +151,11 @@ void VertexBuffer_fill_attrib_stride(VertexBuffer* verts, unsigned a_idx, unsign
|
||||
}
|
||||
}
|
||||
|
||||
static void VertexBuffer_prime(VertexBuffer* verts)
|
||||
static void VertexBuffer_prime(Gwn_VertBuf* verts)
|
||||
{
|
||||
const unsigned buffer_sz = VertexBuffer_size(verts);
|
||||
const unsigned buffer_sz = GWN_vertbuf_size_get(verts);
|
||||
|
||||
verts->vbo_id = buffer_id_alloc();
|
||||
verts->vbo_id = GWN_buf_id_alloc();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id);
|
||||
// fill with delicious data & send to GPU the first time only
|
||||
glBufferData(GL_ARRAY_BUFFER, buffer_sz, verts->data, GL_STATIC_DRAW);
|
||||
@@ -169,7 +169,7 @@ static void VertexBuffer_prime(VertexBuffer* verts)
|
||||
#endif
|
||||
}
|
||||
|
||||
void VertexBuffer_use(VertexBuffer* verts)
|
||||
void GWN_vertbuf_use(Gwn_VertBuf* verts)
|
||||
{
|
||||
if (verts->vbo_id)
|
||||
glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id);
|
||||
@@ -177,7 +177,7 @@ void VertexBuffer_use(VertexBuffer* verts)
|
||||
VertexBuffer_prime(verts);
|
||||
}
|
||||
|
||||
unsigned VertexBuffer_get_memory_usage(void)
|
||||
unsigned GWN_vertbuf_get_memory_usage(void)
|
||||
{
|
||||
return vbo_memory_usage;
|
||||
}
|
||||
|
||||
@@ -20,27 +20,27 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
void VertexFormat_clear(VertexFormat* format)
|
||||
void GWN_vertformat_clear(Gwn_VertFormat* format)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
memset(format, 0, sizeof(VertexFormat));
|
||||
memset(format, 0, sizeof(Gwn_VertFormat));
|
||||
#else
|
||||
format->attrib_ct = 0;
|
||||
format->packed = false;
|
||||
format->name_offset = 0;
|
||||
format->name_ct = 0;
|
||||
|
||||
for (unsigned i = 0; i < MAX_VERTEX_ATTRIBS; i++)
|
||||
for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++)
|
||||
{
|
||||
format->attribs[i].name_ct = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void VertexFormat_copy(VertexFormat* dest, const VertexFormat* src)
|
||||
void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src)
|
||||
{
|
||||
// copy regular struct fields
|
||||
memcpy(dest, src, sizeof(VertexFormat));
|
||||
memcpy(dest, src, sizeof(Gwn_VertFormat));
|
||||
|
||||
for (unsigned i = 0; i < dest->attrib_ct; i++)
|
||||
{
|
||||
@@ -52,44 +52,44 @@ void VertexFormat_copy(VertexFormat* dest, const VertexFormat* src)
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum convert_comp_type_to_gl(VertexCompType type)
|
||||
static GLenum convert_comp_type_to_gl(Gwn_VertCompType type)
|
||||
{
|
||||
static const GLenum table[] = {
|
||||
[COMP_I8] = GL_BYTE,
|
||||
[COMP_U8] = GL_UNSIGNED_BYTE,
|
||||
[COMP_I16] = GL_SHORT,
|
||||
[COMP_U16] = GL_UNSIGNED_SHORT,
|
||||
[COMP_I32] = GL_INT,
|
||||
[COMP_U32] = GL_UNSIGNED_INT,
|
||||
[GWN_COMP_I8] = GL_BYTE,
|
||||
[GWN_COMP_U8] = GL_UNSIGNED_BYTE,
|
||||
[GWN_COMP_I16] = GL_SHORT,
|
||||
[GWN_COMP_U16] = GL_UNSIGNED_SHORT,
|
||||
[GWN_COMP_I32] = GL_INT,
|
||||
[GWN_COMP_U32] = GL_UNSIGNED_INT,
|
||||
|
||||
[COMP_F32] = GL_FLOAT,
|
||||
[GWN_COMP_F32] = GL_FLOAT,
|
||||
|
||||
[COMP_I10] = GL_INT_2_10_10_10_REV
|
||||
[GWN_COMP_I10] = GL_INT_2_10_10_10_REV
|
||||
};
|
||||
return table[type];
|
||||
}
|
||||
|
||||
static unsigned comp_sz(VertexCompType type)
|
||||
static unsigned comp_sz(Gwn_VertCompType type)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(type <= COMP_F32); // other types have irregular sizes (not bytes)
|
||||
assert(type <= GWN_COMP_F32); // other types have irregular sizes (not bytes)
|
||||
#endif
|
||||
|
||||
const GLubyte sizes[] = {1,1,2,2,4,4,4};
|
||||
return sizes[type];
|
||||
}
|
||||
|
||||
static unsigned attrib_sz(const Attrib *a)
|
||||
static unsigned attrib_sz(const Gwn_VertAttr *a)
|
||||
{
|
||||
if (a->comp_type == COMP_I10)
|
||||
if (a->comp_type == GWN_COMP_I10)
|
||||
return 4; // always packed as 10_10_10_2
|
||||
|
||||
return a->comp_ct * comp_sz(a->comp_type);
|
||||
}
|
||||
|
||||
static unsigned attrib_align(const Attrib *a)
|
||||
static unsigned attrib_align(const Gwn_VertAttr *a)
|
||||
{
|
||||
if (a->comp_type == COMP_I10)
|
||||
if (a->comp_type == GWN_COMP_I10)
|
||||
return 4; // always packed as 10_10_10_2
|
||||
|
||||
unsigned c = comp_sz(a->comp_type);
|
||||
@@ -99,7 +99,7 @@ static unsigned attrib_align(const Attrib *a)
|
||||
return c; // most fetches are ok if components are naturally aligned
|
||||
}
|
||||
|
||||
unsigned vertex_buffer_size(const VertexFormat* format, unsigned vertex_ct)
|
||||
unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_ct)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(format->packed && format->stride > 0);
|
||||
@@ -108,11 +108,11 @@ unsigned vertex_buffer_size(const VertexFormat* format, unsigned vertex_ct)
|
||||
return format->stride * vertex_ct;
|
||||
}
|
||||
|
||||
static const char* copy_attrib_name(VertexFormat* format, const char* name)
|
||||
static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name)
|
||||
{
|
||||
// strncpy does 110% of what we need; let's do exactly 100%
|
||||
char* name_copy = format->names + format->name_offset;
|
||||
unsigned available = VERTEX_ATTRIB_NAMES_BUFFER_LEN - format->name_offset;
|
||||
unsigned available = GWN_VERT_ATTR_NAMES_BUF_LEN - format->name_offset;
|
||||
bool terminated = false;
|
||||
|
||||
for (unsigned i = 0; i < available; ++i)
|
||||
@@ -129,7 +129,7 @@ static const char* copy_attrib_name(VertexFormat* format, const char* name)
|
||||
|
||||
#if TRUST_NO_ONE
|
||||
assert(terminated);
|
||||
assert(format->name_offset <= VERTEX_ATTRIB_NAMES_BUFFER_LEN);
|
||||
assert(format->name_offset <= GWN_VERT_ATTR_NAMES_BUF_LEN);
|
||||
#else
|
||||
(void)terminated;
|
||||
#endif
|
||||
@@ -137,39 +137,39 @@ static const char* copy_attrib_name(VertexFormat* format, const char* name)
|
||||
return name_copy;
|
||||
}
|
||||
|
||||
unsigned VertexFormat_add_attrib(VertexFormat* format, const char* name, VertexCompType comp_type, unsigned comp_ct, VertexFetchMode fetch_mode)
|
||||
unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_ct, Gwn_VertFetchMode fetch_mode)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(format->name_ct < MAX_VERTEX_ATTRIBS); // there's room for more
|
||||
assert(format->attrib_ct < MAX_VERTEX_ATTRIBS); // there's room for more
|
||||
assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more
|
||||
assert(format->attrib_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more
|
||||
assert(!format->packed); // packed means frozen/locked
|
||||
assert(comp_ct >= 1 && comp_ct <= 4);
|
||||
switch (comp_type)
|
||||
{
|
||||
case COMP_F32:
|
||||
case GWN_COMP_F32:
|
||||
// float type can only kept as float
|
||||
assert(fetch_mode == KEEP_FLOAT);
|
||||
assert(fetch_mode == GWN_FETCH_FLOAT);
|
||||
break;
|
||||
case COMP_I10:
|
||||
case GWN_COMP_I10:
|
||||
// 10_10_10 format intended for normals (xyz) or colors (rgb)
|
||||
// extra component packed.w can be manually set to { -2, -1, 0, 1 }
|
||||
assert(comp_ct == 3 || comp_ct == 4);
|
||||
assert(fetch_mode == NORMALIZE_INT_TO_FLOAT); // not strictly required, may relax later
|
||||
assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); // not strictly required, may relax later
|
||||
break;
|
||||
default:
|
||||
// integer types can be kept as int or converted/normalized to float
|
||||
assert(fetch_mode != KEEP_FLOAT);
|
||||
assert(fetch_mode != GWN_FETCH_FLOAT);
|
||||
}
|
||||
#endif
|
||||
format->name_ct++; // multiname support
|
||||
|
||||
const unsigned attrib_id = format->attrib_ct++;
|
||||
Attrib* attrib = format->attribs + attrib_id;
|
||||
Gwn_VertAttr* attrib = format->attribs + attrib_id;
|
||||
|
||||
attrib->name[attrib->name_ct++] = copy_attrib_name(format, name);
|
||||
attrib->comp_type = comp_type;
|
||||
attrib->gl_comp_type = convert_comp_type_to_gl(comp_type);
|
||||
attrib->comp_ct = (comp_type == COMP_I10) ? 4 : comp_ct; // system needs 10_10_10_2 to be 4 or BGRA
|
||||
attrib->comp_ct = (comp_type == GWN_COMP_I10) ? 4 : comp_ct; // system needs 10_10_10_2 to be 4 or BGRA
|
||||
attrib->sz = attrib_sz(attrib);
|
||||
attrib->offset = 0; // offsets & stride are calculated later (during pack)
|
||||
attrib->fetch_mode = fetch_mode;
|
||||
@@ -177,11 +177,11 @@ unsigned VertexFormat_add_attrib(VertexFormat* format, const char* name, VertexC
|
||||
return attrib_id;
|
||||
}
|
||||
|
||||
void VertexFormat_add_alias(VertexFormat* format, const char* alias)
|
||||
void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias)
|
||||
{
|
||||
Attrib* attrib = format->attribs + (format->attrib_ct - 1);
|
||||
Gwn_VertAttr* attrib = format->attribs + (format->attrib_ct - 1);
|
||||
#if TRUST_NO_ONE
|
||||
assert(format->name_ct < MAX_VERTEX_ATTRIBS); // there's room for more
|
||||
assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more
|
||||
assert(attrib->name_ct < MAX_ATTRIB_NAMES);
|
||||
#endif
|
||||
format->name_ct++; // multiname support
|
||||
@@ -205,7 +205,7 @@ static void show_pack(unsigned a_idx, unsigned sz, unsigned pad)
|
||||
}
|
||||
#endif
|
||||
|
||||
void VertexFormat_pack(VertexFormat* format)
|
||||
void VertexFormat_pack(Gwn_VertFormat* format)
|
||||
{
|
||||
// for now, attributes are packed in the order they were added,
|
||||
// making sure each attrib is naturally aligned (add padding where necessary)
|
||||
@@ -217,7 +217,7 @@ void VertexFormat_pack(VertexFormat* format)
|
||||
// realloc just enough to hold the final combo string. And just enough to
|
||||
// hold used attribs, not all 16.
|
||||
|
||||
Attrib* a0 = format->attribs + 0;
|
||||
Gwn_VertAttr* a0 = format->attribs + 0;
|
||||
a0->offset = 0;
|
||||
unsigned offset = a0->sz;
|
||||
|
||||
@@ -227,7 +227,7 @@ void VertexFormat_pack(VertexFormat* format)
|
||||
|
||||
for (unsigned a_idx = 1; a_idx < format->attrib_ct; ++a_idx)
|
||||
{
|
||||
Attrib* a = format->attribs + a_idx;
|
||||
Gwn_VertAttr* a = format->attribs + a_idx;
|
||||
unsigned mid_padding = padding(offset, attrib_align(a));
|
||||
offset += mid_padding;
|
||||
a->offset = offset;
|
||||
|
||||
@@ -566,10 +566,10 @@ static void blf_draw_gl__start(FontBLF *font)
|
||||
gpuRotate2D(RAD2DEG(font->angle));
|
||||
|
||||
#ifndef BLF_STANDALONE
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int texCoord = VertexFormat_add_attrib(format, "texCoord", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
BLI_assert(pos == BLF_POS_ID);
|
||||
BLI_assert(texCoord == BLF_COORD_ID);
|
||||
|
||||
@@ -206,7 +206,7 @@ static void blf_font_draw_ex(
|
||||
|
||||
blf_font_ensure_ascii_table(font);
|
||||
|
||||
immBeginAtMost(PRIM_TRIANGLES, verts_needed(font, str, len));
|
||||
immBeginAtMost(GWN_PRIM_TRIS, verts_needed(font, str, len));
|
||||
/* at most because some glyphs might be clipped & not drawn */
|
||||
|
||||
while ((i < len) && str[i]) {
|
||||
@@ -253,7 +253,7 @@ static void blf_font_draw_ascii_ex(
|
||||
|
||||
blf_font_ensure_ascii_table(font);
|
||||
|
||||
immBeginAtMost(PRIM_TRIANGLES, verts_needed(font, str, len));
|
||||
immBeginAtMost(GWN_PRIM_TRIS, verts_needed(font, str, len));
|
||||
|
||||
while ((c = *(str++)) && len--) {
|
||||
BLI_assert(c < 128);
|
||||
@@ -293,7 +293,7 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
|
||||
|
||||
blf_font_ensure_ascii_table(font);
|
||||
|
||||
immBeginAtMost(PRIM_TRIANGLES, verts_needed(font, str, len));
|
||||
immBeginAtMost(GWN_PRIM_TRIS, verts_needed(font, str, len));
|
||||
|
||||
while ((i < len) && str[i]) {
|
||||
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
|
||||
|
||||
@@ -147,7 +147,7 @@ char *BKE_animdata_driver_path_hack(struct bContext *C, struct PointerRNA *ptr,
|
||||
char *base_path);
|
||||
|
||||
/* ************************************* */
|
||||
/* Batch AnimData API */
|
||||
/* Gwn_Batch AnimData API */
|
||||
|
||||
/* Define for callback looper used in BKE_animdata_main_cb */
|
||||
typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
struct Batch;
|
||||
struct Gwn_Batch;
|
||||
struct CCGElem;
|
||||
struct CCGKey;
|
||||
struct CustomData;
|
||||
@@ -121,7 +121,7 @@ void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
|
||||
int (*setMaterial)(int matnr, void *attribs), bool wireframe, bool fast);
|
||||
void BKE_pbvh_draw_cb(
|
||||
PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast,
|
||||
void (*draw_fn)(void *user_data, struct Batch *batch), void *user_data);
|
||||
void (*draw_fn)(void *user_data, struct Gwn_Batch *batch), void *user_data);
|
||||
|
||||
/* PBVH Access */
|
||||
typedef enum {
|
||||
|
||||
@@ -3520,14 +3520,14 @@ static void navmesh_drawColored(DerivedMesh *dm)
|
||||
dm->drawEdges(dm, 0, 1);
|
||||
#endif
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
|
||||
|
||||
/* Note: batch drawing API would let us share vertices */
|
||||
immBeginAtMost(PRIM_TRIANGLES, dm->numTessFaceData * 6);
|
||||
immBeginAtMost(GWN_PRIM_TRIS, dm->numTessFaceData * 6);
|
||||
for (int a = 0; a < dm->numTessFaceData; a++, mface++) {
|
||||
int pi = polygonIdx[a];
|
||||
if (pi <= 0) {
|
||||
|
||||
@@ -388,8 +388,8 @@ static void cdDM_drawEdges(DerivedMesh *dm, bool UNUSED(drawLooseEdges), bool UN
|
||||
MVert *vert = cddm->mvert;
|
||||
MEdge *edge = cddm->medge;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
/* NOTE: This is active object color, which is not really perfect.
|
||||
* But we can't query color set by glColor() :(
|
||||
@@ -406,7 +406,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, bool UNUSED(drawLooseEdges), bool UN
|
||||
const int num_current_edges = (chunk < num_chunks - 1)
|
||||
? chunk_size
|
||||
: dm->numEdgeData - chunk_size * (num_chunks - 1);
|
||||
immBeginAtMost(PRIM_LINES, num_current_edges * 2);
|
||||
immBeginAtMost(GWN_PRIM_LINES, num_current_edges * 2);
|
||||
for (int i = 0; i < num_current_edges; i++, edge++) {
|
||||
immVertex3fv(pos, vert[edge->v1].co);
|
||||
immVertex3fv(pos, vert[edge->v2].co);
|
||||
@@ -461,9 +461,9 @@ static void cdDM_drawFacesSolid(
|
||||
const float (*nors)[3] = dm->getPolyDataArray(dm, CD_NORMAL);
|
||||
const float (*lnors)[3] = dm->getLoopDataArray(dm, CD_NORMAL);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int nor = VertexFormat_add_attrib(format, "nor", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
unsigned int nor = GWN_vertformat_attr_add(format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
float color[4] = {0.8f, 0.8f, 0.8f, 1.0f};
|
||||
const float light_vec[3] = {0.0f, 0.0f, 1.0f};
|
||||
@@ -480,7 +480,7 @@ static void cdDM_drawFacesSolid(
|
||||
? chunk_size
|
||||
: num_looptris - chunk_size * (num_chunks - 1);
|
||||
|
||||
immBeginAtMost(PRIM_TRIANGLES, num_current_looptris * 3);
|
||||
immBeginAtMost(GWN_PRIM_TRIS, num_current_looptris * 3);
|
||||
|
||||
for (a = 0; a < num_current_looptris; a++, looptri++) {
|
||||
const MPoly *mp = &mpoly[looptri->poly];
|
||||
|
||||
@@ -922,7 +922,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
* SPRING NETWORK BUILDING IMPLEMENTATION BEGIN
|
||||
* SPRING NETWORK GWN_BATCH_BUILDING IMPLEMENTATION BEGIN
|
||||
***************************************************************************************/
|
||||
|
||||
BLI_INLINE void spring_verts_ordered_set(ClothSpring *spring, int v0, int v1)
|
||||
@@ -1504,6 +1504,6 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
|
||||
} /* cloth_build_springs */
|
||||
/***************************************************************************************
|
||||
* SPRING NETWORK BUILDING IMPLEMENTATION END
|
||||
* SPRING NETWORK GWN_BATCH_BUILDING IMPLEMENTATION END
|
||||
***************************************************************************************/
|
||||
|
||||
|
||||
@@ -1159,7 +1159,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
|
||||
|
||||
static void pbvh_draw_BB(PBVH *bvh)
|
||||
{
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
for (int a = 0; a < bvh->totnode; a++) {
|
||||
@@ -1849,7 +1849,7 @@ void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*fnors)[3],
|
||||
|
||||
struct PBVHNodeDrawCallbackData {
|
||||
|
||||
void (*draw_fn)(void *user_data, Batch *batch);
|
||||
void (*draw_fn)(void *user_data, Gwn_Batch *batch);
|
||||
void *user_data;
|
||||
bool fast;
|
||||
};
|
||||
@@ -1859,7 +1859,7 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v)
|
||||
struct PBVHNodeDrawCallbackData *data = data_v;
|
||||
|
||||
if (!(node->flag & PBVH_FullyHidden)) {
|
||||
Batch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast);
|
||||
Gwn_Batch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast);
|
||||
if (triangles != NULL) {
|
||||
data->draw_fn(data->user_data, triangles);
|
||||
}
|
||||
@@ -1871,7 +1871,7 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v)
|
||||
*/
|
||||
void BKE_pbvh_draw_cb(
|
||||
PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast,
|
||||
void (*draw_fn)(void *user_data, Batch *batch), void *user_data)
|
||||
void (*draw_fn)(void *user_data, Gwn_Batch *batch), void *user_data)
|
||||
{
|
||||
struct PBVHNodeDrawCallbackData draw_data = {
|
||||
.fast = fast,
|
||||
|
||||
@@ -67,7 +67,7 @@ static const std::string bc_get_dae_name(T *node)
|
||||
return node->getName().size() ? node->getName(): node->getOriginalId();
|
||||
}
|
||||
|
||||
static const char *bc_primTypeToStr(COLLADAFW::MeshPrimitive::PrimitiveType type)
|
||||
static const char *bc_primTypeToStr(COLLADAFW::MeshPrimitive::Gwn_PrimType type)
|
||||
{
|
||||
switch (type) {
|
||||
case COLLADAFW::MeshPrimitive::LINES:
|
||||
@@ -274,7 +274,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has su
|
||||
for (unsigned i = 0; i < prim_arr.getCount(); i++) {
|
||||
|
||||
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
|
||||
COLLADAFW::MeshPrimitive::PrimitiveType type = mp->getPrimitiveType();
|
||||
COLLADAFW::MeshPrimitive::Gwn_PrimType type = mp->getPrimitiveType();
|
||||
|
||||
const char *type_str = bc_primTypeToStr(type);
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ static void BASIC_cache_populate(void *vedata, Object *ob)
|
||||
if (!DRW_object_is_renderable(ob))
|
||||
return;
|
||||
|
||||
struct Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
bool do_cull = false; /* TODO (we probably wan't to take this from the viewport?) */
|
||||
#ifdef USE_DEPTH
|
||||
|
||||
@@ -776,7 +776,7 @@ static void CLAY_cache_populate(void *vedata, Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
struct Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
|
||||
const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
|
||||
|
||||
@@ -382,7 +382,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
|
||||
|
||||
static DRWShadingGroup *eevee_create_bloom_pass(const char *name, EEVEE_EffectsInfo *effects, struct GPUShader *sh, DRWPass **pass, bool upsample)
|
||||
{
|
||||
struct Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
|
||||
*pass = DRW_pass_create(name, DRW_STATE_WRITE_COLOR);
|
||||
|
||||
@@ -406,7 +406,7 @@ void EEVEE_effects_cache_init(EEVEE_Data *vedata)
|
||||
EEVEE_EffectsInfo *effects = stl->effects;
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
||||
struct Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
|
||||
{
|
||||
psl->motion_blur = DRW_pass_create("Motion Blur", DRW_STATE_WRITE_COLOR);
|
||||
|
||||
@@ -91,7 +91,7 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
struct Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
EEVEE_materials_cache_populate(vedata, sldata, ob, geom);
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
|
||||
{
|
||||
psl->probe_background = DRW_pass_create("World Probe Pass", DRW_STATE_WRITE_COLOR);
|
||||
|
||||
struct Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRWShadingGroup *grp = NULL;
|
||||
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
@@ -326,7 +326,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
|
||||
{
|
||||
psl->probe_glossy_compute = DRW_pass_create("LightProbe Glossy Compute", DRW_STATE_WRITE_COLOR);
|
||||
|
||||
struct Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.probe_filter_glossy_sh, psl->probe_glossy_compute, geom);
|
||||
DRW_shgroup_uniform_float(grp, "sampleCount", &sldata->probes->samples_ct, 1);
|
||||
@@ -359,7 +359,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
|
||||
#endif
|
||||
DRW_shgroup_uniform_texture(grp, "probeHdr", sldata->probe_rt);
|
||||
|
||||
struct Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call_add(grp, geom, NULL);
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK;
|
||||
psl->probe_display = DRW_pass_create("LightProbe Display", state);
|
||||
|
||||
struct Batch *geom = DRW_cache_sphere_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_sphere_get();
|
||||
DRWShadingGroup *grp = stl->g_data->cube_display_shgrp = DRW_shgroup_instance_create(e_data.probe_cube_display_sh, psl->probe_display, geom);
|
||||
DRW_shgroup_attrib_float(grp, "probe_id", 1); /* XXX this works because we are still uploading 4bytes and using the right stride */
|
||||
DRW_shgroup_attrib_float(grp, "probe_location", 3);
|
||||
@@ -535,7 +535,7 @@ static void EEVEE_planar_reflections_updates(EEVEE_SceneLayerData *sldata, EEVEE
|
||||
DRW_shgroup_uniform_buffer(grp, "probePlanars", &txl->planar_pool);
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
|
||||
struct Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call_add(grp, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
@@ -640,7 +640,7 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
|
||||
|
||||
/* Debug Display */
|
||||
if ((probe->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0) {
|
||||
struct Batch *geom = DRW_cache_sphere_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_sphere_get();
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.probe_grid_display_sh, psl->probe_display, geom);
|
||||
DRW_shgroup_set_instance_count(grp, ped->num_cell);
|
||||
DRW_shgroup_uniform_int(grp, "offset", &egrid->offset, 1);
|
||||
|
||||
@@ -179,7 +179,7 @@ void EEVEE_lights_cache_add(EEVEE_SceneLayerData *sldata, Object *ob)
|
||||
}
|
||||
|
||||
/* Add a shadow caster to the shadowpasses */
|
||||
void EEVEE_lights_cache_shcaster_add(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, struct Batch *geom, float (*obmat)[4])
|
||||
void EEVEE_lights_cache_shcaster_add(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, struct Gwn_Batch *geom, float (*obmat)[4])
|
||||
{
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.shadow_sh, psl->shadow_cube_pass, geom);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo);
|
||||
|
||||
@@ -133,7 +133,7 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
|
||||
DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
|
||||
DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter);
|
||||
|
||||
struct Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call_add(grp, geom, NULL);
|
||||
|
||||
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
|
||||
@@ -342,7 +342,7 @@ void EEVEE_materials_cache_init(EEVEE_Data *vedata)
|
||||
{
|
||||
psl->background_pass = DRW_pass_create("Background Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR);
|
||||
|
||||
struct Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRWShadingGroup *grp = NULL;
|
||||
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
@@ -425,7 +425,7 @@ void EEVEE_materials_cache_init(EEVEE_Data *vedata)
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob, struct Batch *geom)
|
||||
void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob, struct Gwn_Batch *geom)
|
||||
{
|
||||
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
|
||||
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
|
||||
@@ -445,7 +445,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sl
|
||||
ADD_SHGROUP_CALL(depth_clip_shgrp, ob, geom);
|
||||
|
||||
/* Get per-material split surface */
|
||||
struct Batch **mat_geom = DRW_cache_object_surface_material_get(ob);
|
||||
struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(ob);
|
||||
if (mat_geom) {
|
||||
struct GPUShader *default_shader = e_data.default_lit;
|
||||
struct DRWPass *default_pass = psl->default_pass;
|
||||
@@ -522,7 +522,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sl
|
||||
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
|
||||
|
||||
if (draw_as == PART_DRAW_PATH && (psys->pathcache || psys->childcache)) {
|
||||
struct Batch *hair_geom = DRW_cache_particles_get_hair(psys);
|
||||
struct Gwn_Batch *hair_geom = DRW_cache_particles_get_hair(psys);
|
||||
DRWShadingGroup *shgrp = NULL;
|
||||
Material *ma = give_current_material(ob, part->omat);
|
||||
static float mat[4][4];
|
||||
|
||||
@@ -383,7 +383,7 @@ EEVEE_LampEngineData *EEVEE_lamp_data_get(Object *ob);
|
||||
/* eevee_materials.c */
|
||||
void EEVEE_materials_init(void);
|
||||
void EEVEE_materials_cache_init(EEVEE_Data *vedata);
|
||||
void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob, struct Batch *geom);
|
||||
void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sldata, Object *ob, struct Gwn_Batch *geom);
|
||||
void EEVEE_materials_cache_finish(EEVEE_Data *vedata);
|
||||
struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, struct World *wo);
|
||||
struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, struct World *wo);
|
||||
@@ -396,7 +396,7 @@ void EEVEE_materials_free(void);
|
||||
void EEVEE_lights_init(EEVEE_SceneLayerData *sldata);
|
||||
void EEVEE_lights_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl);
|
||||
void EEVEE_lights_cache_add(EEVEE_SceneLayerData *sldata, struct Object *ob);
|
||||
void EEVEE_lights_cache_shcaster_add(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, struct Batch *geom, float (*obmat)[4]);
|
||||
void EEVEE_lights_cache_shcaster_add(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl, struct Gwn_Batch *geom, float (*obmat)[4]);
|
||||
void EEVEE_lights_cache_finish(EEVEE_SceneLayerData *sldata);
|
||||
void EEVEE_lights_update(EEVEE_SceneLayerData *sldata);
|
||||
void EEVEE_draw_shadows(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl);
|
||||
|
||||
@@ -128,7 +128,7 @@ static void EXTERNAL_cache_populate(void *vedata, Object *ob)
|
||||
if (!DRW_object_is_renderable(ob))
|
||||
return;
|
||||
|
||||
struct Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
/* Depth Prepass */
|
||||
DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
|
||||
|
||||
@@ -60,7 +60,7 @@ struct GPUMaterial;
|
||||
struct GPUTexture;
|
||||
struct GPUUniformBuffer;
|
||||
struct Object;
|
||||
struct Batch;
|
||||
struct Gwn_Batch;
|
||||
struct DefaultFramebufferList;
|
||||
struct DefaultTextureList;
|
||||
struct DRWTextStore;
|
||||
@@ -262,22 +262,22 @@ typedef enum {
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, struct Batch *geom);
|
||||
DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, struct Batch *geom);
|
||||
DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, struct Gwn_Batch *geom);
|
||||
DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, struct Gwn_Batch *geom);
|
||||
DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DRWPass *pass, int size);
|
||||
|
||||
typedef void (DRWCallGenerateFn)(
|
||||
DRWShadingGroup *shgroup,
|
||||
void (*draw_fn)(DRWShadingGroup *shgroup, struct Batch *geom),
|
||||
void (*draw_fn)(DRWShadingGroup *shgroup, struct Gwn_Batch *geom),
|
||||
void *user_data);
|
||||
|
||||
void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Batch *instances);
|
||||
void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *instances);
|
||||
|
||||
void DRW_shgroup_free(struct DRWShadingGroup *shgroup);
|
||||
void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Batch *geom, float (*obmat)[4]);
|
||||
void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, struct Batch *geom, struct Object *ob);
|
||||
void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]);
|
||||
void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob);
|
||||
void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shgroup, struct Object *ob, float (*obmat)[4]);
|
||||
void DRW_shgroup_call_generate_add(
|
||||
DRWShadingGroup *shgroup, DRWCallGenerateFn *geometry_fn, void *user_data, float (*obmat)[4]);
|
||||
|
||||
@@ -101,7 +101,7 @@ static struct {
|
||||
static void DRW_shgroup_bone_octahedral_solid(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_octahedral_solid == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_octahedral_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_octahedral_get();
|
||||
g_data.bone_octahedral_solid = shgroup_instance_objspace_solid(g_data.pass_bone_solid, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ static void DRW_shgroup_bone_octahedral_solid(const float (*bone_mat)[4], const
|
||||
static void DRW_shgroup_bone_octahedral_wire(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_octahedral_wire == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_octahedral_wire_outline_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_octahedral_wire_outline_get();
|
||||
g_data.bone_octahedral_wire = shgroup_instance_objspace_wire(g_data.pass_bone_wire, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ static void DRW_shgroup_bone_octahedral_wire(const float (*bone_mat)[4], const f
|
||||
static void DRW_shgroup_bone_box_solid(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_box_solid == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_box_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_box_get();
|
||||
g_data.bone_box_solid = shgroup_instance_objspace_solid(g_data.pass_bone_solid, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ static void DRW_shgroup_bone_box_solid(const float (*bone_mat)[4], const float c
|
||||
static void DRW_shgroup_bone_box_wire(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_box_wire == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_box_wire_outline_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_box_wire_outline_get();
|
||||
g_data.bone_box_wire = shgroup_instance_objspace_wire(g_data.pass_bone_wire, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ static void DRW_shgroup_bone_box_wire(const float (*bone_mat)[4], const float co
|
||||
static void DRW_shgroup_bone_wire_wire(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_wire_wire == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_wire_wire_outline_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_wire_wire_outline_get();
|
||||
g_data.bone_wire_wire = shgroup_instance_objspace_wire(g_data.pass_bone_wire, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ static void DRW_shgroup_bone_envelope_distance(
|
||||
{
|
||||
if (g_data.pass_bone_envelope != NULL) {
|
||||
if (g_data.bone_envelope_distance == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_envelope_distance_outline_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_envelope_distance_outline_get();
|
||||
/* Note: bone_wire draw pass is not really working, think we need another one here? */
|
||||
g_data.bone_envelope_distance = shgroup_instance_bone_envelope_wire(g_data.pass_bone_envelope, geom, g_data.ob->obmat);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ static void DRW_shgroup_bone_envelope_solid(
|
||||
const float *radius_head, const float *radius_tail)
|
||||
{
|
||||
if (g_data.bone_envelope_solid == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_envelope_solid_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_envelope_solid_get();
|
||||
g_data.bone_envelope_solid = shgroup_instance_bone_envelope_solid(g_data.pass_bone_solid, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ static void DRW_shgroup_bone_envelope_wire(
|
||||
const float *radius_head, const float *radius_tail, const float *distance)
|
||||
{
|
||||
if (g_data.bone_envelope_wire == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_envelope_wire_outline_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_envelope_wire_outline_get();
|
||||
g_data.bone_envelope_wire = shgroup_instance_bone_envelope_wire(g_data.pass_bone_wire, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ static void DRW_shgroup_bone_envelope_head_wire(
|
||||
const float *radius_head, const float *radius_tail, const float *distance)
|
||||
{
|
||||
if (g_data.bone_envelope_head_wire == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_envelope_head_wire_outline_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_envelope_head_wire_outline_get();
|
||||
g_data.bone_envelope_head_wire = shgroup_instance_bone_envelope_wire(g_data.pass_bone_wire, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ static void DRW_shgroup_bone_envelope_head_wire(
|
||||
static void DRW_shgroup_bone_custom_solid(const float (*bone_mat)[4], const float color[4], Object *custom)
|
||||
{
|
||||
/* grr, not re-using instances! */
|
||||
struct Batch *geom = DRW_cache_object_surface_get(custom);
|
||||
struct Gwn_Batch *geom = DRW_cache_object_surface_get(custom);
|
||||
if (geom) {
|
||||
DRWShadingGroup *shgrp_geom_solid = shgroup_instance_objspace_solid(g_data.pass_bone_solid, geom, g_data.ob->obmat);
|
||||
DRW_shgroup_call_dynamic_add(shgrp_geom_solid, bone_mat, color);
|
||||
@@ -217,7 +217,7 @@ static void DRW_shgroup_bone_custom_solid(const float (*bone_mat)[4], const floa
|
||||
static void DRW_shgroup_bone_custom_wire(const float (*bone_mat)[4], const float color[4], Object *custom)
|
||||
{
|
||||
/* grr, not re-using instances! */
|
||||
struct Batch *geom = DRW_cache_object_wire_outline_get(custom);
|
||||
struct Gwn_Batch *geom = DRW_cache_object_wire_outline_get(custom);
|
||||
if (geom) {
|
||||
DRWShadingGroup *shgrp_geom_wire = shgroup_instance_objspace_wire(g_data.pass_bone_wire, geom, g_data.ob->obmat);
|
||||
DRW_shgroup_call_dynamic_add(shgrp_geom_wire, bone_mat, color);
|
||||
@@ -228,7 +228,7 @@ static void DRW_shgroup_bone_custom_wire(const float (*bone_mat)[4], const float
|
||||
static void DRW_shgroup_bone_point_solid(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_point_solid == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_point_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_point_get();
|
||||
g_data.bone_point_solid = shgroup_instance_objspace_solid(g_data.pass_bone_solid, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ static void DRW_shgroup_bone_point_solid(const float (*bone_mat)[4], const float
|
||||
static void DRW_shgroup_bone_point_wire(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_point_wire == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_point_wire_outline_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_point_wire_outline_get();
|
||||
g_data.bone_point_wire = shgroup_instance_objspace_wire(g_data.pass_bone_wire, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ static void DRW_shgroup_bone_point_wire(const float (*bone_mat)[4], const float
|
||||
static void DRW_shgroup_bone_axes(const float (*bone_mat)[4], const float color[4])
|
||||
{
|
||||
if (g_data.bone_axes == NULL) {
|
||||
struct Batch *geom = DRW_cache_bone_arrows_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_bone_arrows_get();
|
||||
g_data.bone_axes = shgroup_instance_objspace_wire(g_data.pass_bone_wire, geom, g_data.ob->obmat);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,126 +26,126 @@
|
||||
#ifndef __DRAW_CACHE_H__
|
||||
#define __DRAW_CACHE_H__
|
||||
|
||||
struct Batch;
|
||||
struct Gwn_Batch;
|
||||
struct Object;
|
||||
|
||||
void DRW_shape_cache_free(void);
|
||||
|
||||
/* Common Shapes */
|
||||
struct Batch *DRW_cache_fullscreen_quad_get(void);
|
||||
struct Batch *DRW_cache_sphere_get(void);
|
||||
struct Batch *DRW_cache_single_vert_get(void);
|
||||
struct Batch *DRW_cache_single_line_get(void);
|
||||
struct Batch *DRW_cache_single_line_endpoints_get(void);
|
||||
struct Batch *DRW_cache_screenspace_circle_get(void);
|
||||
struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void);
|
||||
struct Gwn_Batch *DRW_cache_sphere_get(void);
|
||||
struct Gwn_Batch *DRW_cache_single_vert_get(void);
|
||||
struct Gwn_Batch *DRW_cache_single_line_get(void);
|
||||
struct Gwn_Batch *DRW_cache_single_line_endpoints_get(void);
|
||||
struct Gwn_Batch *DRW_cache_screenspace_circle_get(void);
|
||||
|
||||
/* Common Object */
|
||||
struct Batch *DRW_cache_object_wire_outline_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_object_surface_get(struct Object *ob);
|
||||
struct Batch **DRW_cache_object_surface_material_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_object_wire_outline_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_object_surface_get(struct Object *ob);
|
||||
struct Gwn_Batch **DRW_cache_object_surface_material_get(struct Object *ob);
|
||||
|
||||
/* Empties */
|
||||
struct Batch *DRW_cache_plain_axes_get(void);
|
||||
struct Batch *DRW_cache_single_arrow_get(void);
|
||||
struct Batch *DRW_cache_cube_get(void);
|
||||
struct Batch *DRW_cache_circle_get(void);
|
||||
struct Batch *DRW_cache_square_get(void);
|
||||
struct Batch *DRW_cache_empty_sphere_get(void);
|
||||
struct Batch *DRW_cache_empty_cone_get(void);
|
||||
struct Batch *DRW_cache_arrows_get(void);
|
||||
struct Batch *DRW_cache_axis_names_get(void);
|
||||
struct Batch *DRW_cache_image_plane_get(void);
|
||||
struct Batch *DRW_cache_image_plane_wire_get(void);
|
||||
struct Gwn_Batch *DRW_cache_plain_axes_get(void);
|
||||
struct Gwn_Batch *DRW_cache_single_arrow_get(void);
|
||||
struct Gwn_Batch *DRW_cache_cube_get(void);
|
||||
struct Gwn_Batch *DRW_cache_circle_get(void);
|
||||
struct Gwn_Batch *DRW_cache_square_get(void);
|
||||
struct Gwn_Batch *DRW_cache_empty_sphere_get(void);
|
||||
struct Gwn_Batch *DRW_cache_empty_cone_get(void);
|
||||
struct Gwn_Batch *DRW_cache_arrows_get(void);
|
||||
struct Gwn_Batch *DRW_cache_axis_names_get(void);
|
||||
struct Gwn_Batch *DRW_cache_image_plane_get(void);
|
||||
struct Gwn_Batch *DRW_cache_image_plane_wire_get(void);
|
||||
|
||||
/* Force Field */
|
||||
struct Batch *DRW_cache_field_wind_get(void);
|
||||
struct Batch *DRW_cache_field_force_get(void);
|
||||
struct Batch *DRW_cache_field_vortex_get(void);
|
||||
struct Batch *DRW_cache_field_tube_limit_get(void);
|
||||
struct Batch *DRW_cache_field_cone_limit_get(void);
|
||||
struct Gwn_Batch *DRW_cache_field_wind_get(void);
|
||||
struct Gwn_Batch *DRW_cache_field_force_get(void);
|
||||
struct Gwn_Batch *DRW_cache_field_vortex_get(void);
|
||||
struct Gwn_Batch *DRW_cache_field_tube_limit_get(void);
|
||||
struct Gwn_Batch *DRW_cache_field_cone_limit_get(void);
|
||||
|
||||
/* Lamps */
|
||||
struct Batch *DRW_cache_lamp_get(void);
|
||||
struct Batch *DRW_cache_lamp_sunrays_get(void);
|
||||
struct Batch *DRW_cache_lamp_area_get(void);
|
||||
struct Batch *DRW_cache_lamp_hemi_get(void);
|
||||
struct Batch *DRW_cache_lamp_spot_get(void);
|
||||
struct Batch *DRW_cache_lamp_spot_square_get(void);
|
||||
struct Gwn_Batch *DRW_cache_lamp_get(void);
|
||||
struct Gwn_Batch *DRW_cache_lamp_sunrays_get(void);
|
||||
struct Gwn_Batch *DRW_cache_lamp_area_get(void);
|
||||
struct Gwn_Batch *DRW_cache_lamp_hemi_get(void);
|
||||
struct Gwn_Batch *DRW_cache_lamp_spot_get(void);
|
||||
struct Gwn_Batch *DRW_cache_lamp_spot_square_get(void);
|
||||
|
||||
/* Camera */
|
||||
struct Batch *DRW_cache_camera_get(void);
|
||||
struct Batch *DRW_cache_camera_tria_get(void);
|
||||
struct Gwn_Batch *DRW_cache_camera_get(void);
|
||||
struct Gwn_Batch *DRW_cache_camera_tria_get(void);
|
||||
|
||||
/* Speaker */
|
||||
struct Batch *DRW_cache_speaker_get(void);
|
||||
struct Gwn_Batch *DRW_cache_speaker_get(void);
|
||||
|
||||
/* Probe */
|
||||
struct Batch *DRW_cache_lightprobe_get(void);
|
||||
struct Gwn_Batch *DRW_cache_lightprobe_get(void);
|
||||
|
||||
/* Bones */
|
||||
struct Batch *DRW_cache_bone_octahedral_get(void);
|
||||
struct Batch *DRW_cache_bone_octahedral_wire_outline_get(void);
|
||||
struct Batch *DRW_cache_bone_box_get(void);
|
||||
struct Batch *DRW_cache_bone_box_wire_outline_get(void);
|
||||
struct Batch *DRW_cache_bone_wire_wire_outline_get(void);
|
||||
struct Batch *DRW_cache_bone_envelope_solid_get(void);
|
||||
struct Batch *DRW_cache_bone_envelope_distance_outline_get(void);
|
||||
struct Batch *DRW_cache_bone_envelope_wire_outline_get(void);
|
||||
struct Batch *DRW_cache_bone_envelope_head_wire_outline_get(void);
|
||||
struct Batch *DRW_cache_bone_point_get(void);
|
||||
struct Batch *DRW_cache_bone_point_wire_outline_get(void);
|
||||
struct Batch *DRW_cache_bone_arrows_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_octahedral_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_octahedral_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_box_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_box_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_wire_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_envelope_solid_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_envelope_distance_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_envelope_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_envelope_head_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_point_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void);
|
||||
struct Gwn_Batch *DRW_cache_bone_arrows_get(void);
|
||||
|
||||
/* Meshes */
|
||||
struct Batch *DRW_cache_mesh_surface_overlay_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_surface_overlay_get(struct Object *ob);
|
||||
void DRW_cache_mesh_wire_overlay_get(
|
||||
struct Object *ob,
|
||||
struct Batch **r_tris, struct Batch **r_ledges, struct Batch **r_lverts);
|
||||
struct Gwn_Batch **r_tris, struct Gwn_Batch **r_ledges, struct Gwn_Batch **r_lverts);
|
||||
void DRW_cache_mesh_normals_overlay_get(
|
||||
struct Object *ob,
|
||||
struct Batch **r_tris, struct Batch **r_ledges, struct Batch **r_lverts);
|
||||
struct Batch *DRW_cache_face_centers_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_surface_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_edges_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_verts_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel);
|
||||
struct Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
|
||||
struct Batch **DRW_cache_mesh_surface_shaded_get(struct Object *ob);
|
||||
struct Batch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
|
||||
struct Gwn_Batch **r_tris, struct Gwn_Batch **r_ledges, struct Gwn_Batch **r_lverts);
|
||||
struct Gwn_Batch *DRW_cache_face_centers_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_surface_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_edges_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_verts_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel);
|
||||
struct Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
|
||||
struct Gwn_Batch **DRW_cache_mesh_surface_shaded_get(struct Object *ob);
|
||||
struct Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
|
||||
|
||||
/* Curve */
|
||||
struct Batch *DRW_cache_curve_surface_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_curve_surface_verts_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_curve_edge_wire_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_curve_surface_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_curve_surface_verts_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_curve_edge_wire_get(struct Object *ob);
|
||||
/* edit-mode */
|
||||
struct Batch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size);
|
||||
struct Batch *DRW_cache_curve_edge_overlay_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_curve_vert_overlay_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size);
|
||||
struct Gwn_Batch *DRW_cache_curve_edge_overlay_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_curve_vert_overlay_get(struct Object *ob);
|
||||
|
||||
/* Font */
|
||||
struct Batch *DRW_cache_text_edge_wire_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_text_surface_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_text_edge_wire_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_text_surface_get(struct Object *ob);
|
||||
/* edit-mode */
|
||||
struct Batch *DRW_cache_text_cursor_overlay_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_text_select_overlay_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_text_cursor_overlay_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_text_select_overlay_get(struct Object *ob);
|
||||
|
||||
/* Surface */
|
||||
struct Batch *DRW_cache_surf_surface_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_surf_surface_get(struct Object *ob);
|
||||
|
||||
/* Lattice */
|
||||
struct Batch *DRW_cache_lattice_verts_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_lattice_wire_get(struct Object *ob);
|
||||
struct Batch *DRW_cache_lattice_vert_overlay_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_lattice_verts_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_lattice_wire_get(struct Object *ob);
|
||||
struct Gwn_Batch *DRW_cache_lattice_vert_overlay_get(struct Object *ob);
|
||||
|
||||
/* Particles */
|
||||
struct Batch *DRW_cache_particles_get_hair(struct ParticleSystem *psys);
|
||||
struct Batch *DRW_cache_particles_get_dots(struct ParticleSystem *psys);
|
||||
struct Batch *DRW_cache_particles_get_prim(int type);
|
||||
struct Gwn_Batch *DRW_cache_particles_get_hair(struct ParticleSystem *psys);
|
||||
struct Gwn_Batch *DRW_cache_particles_get_dots(struct ParticleSystem *psys);
|
||||
struct Gwn_Batch *DRW_cache_particles_get_prim(int type);
|
||||
|
||||
#endif /* __DRAW_CACHE_H__ */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#ifndef __DRAW_CACHE_IMPL_H__
|
||||
#define __DRAW_CACHE_IMPL_H__
|
||||
|
||||
struct Batch;
|
||||
struct Gwn_Batch;
|
||||
struct ListBase;
|
||||
struct CurveCache;
|
||||
struct ParticleSystem;
|
||||
@@ -49,52 +49,52 @@ void DRW_particle_batch_cache_dirty(struct ParticleSystem *psys, int mode);
|
||||
void DRW_particle_batch_cache_free(struct ParticleSystem *psys);
|
||||
|
||||
/* Curve */
|
||||
struct Batch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu, struct CurveCache *ob_curve_cache);
|
||||
struct Batch *DRW_curve_batch_cache_get_normal_edge(
|
||||
struct Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu, struct CurveCache *ob_curve_cache);
|
||||
struct Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(
|
||||
struct Curve *cu, struct CurveCache *ob_curve_cache, float normal_size);
|
||||
struct Batch *DRW_curve_batch_cache_get_overlay_edges(struct Curve *cu);
|
||||
struct Batch *DRW_curve_batch_cache_get_overlay_verts(struct Curve *cu);
|
||||
struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(struct Curve *cu);
|
||||
struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(struct Curve *cu);
|
||||
|
||||
struct Batch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu, struct CurveCache *ob_curve_cache);
|
||||
struct Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu, struct CurveCache *ob_curve_cache);
|
||||
|
||||
/* Curve (Font) */
|
||||
struct Batch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu);
|
||||
struct Batch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu);
|
||||
struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu);
|
||||
struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu);
|
||||
|
||||
/* DispList */
|
||||
struct Batch *BLI_displist_batch_calc_surface(struct ListBase *lb);
|
||||
struct Gwn_Batch *BLI_displist_batch_calc_surface(struct ListBase *lb);
|
||||
|
||||
/* Lattice */
|
||||
struct Batch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt);
|
||||
struct Batch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt);
|
||||
struct Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
|
||||
struct Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt);
|
||||
struct Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt);
|
||||
struct Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
|
||||
|
||||
/* Mesh */
|
||||
|
||||
struct Batch **DRW_mesh_batch_cache_get_surface_shaded(struct Mesh *me);
|
||||
struct Batch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel);
|
||||
struct Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup);
|
||||
struct Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide);
|
||||
struct Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me);
|
||||
struct Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
|
||||
struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded(struct Mesh *me);
|
||||
struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me);
|
||||
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
|
||||
|
||||
/* Particles */
|
||||
struct Batch *DRW_particles_batch_cache_get_hair(struct ParticleSystem *psys);
|
||||
struct Batch *DRW_particles_batch_cache_get_dots(struct ParticleSystem *psys);
|
||||
struct Gwn_Batch *DRW_particles_batch_cache_get_hair(struct ParticleSystem *psys);
|
||||
struct Gwn_Batch *DRW_particles_batch_cache_get_dots(struct ParticleSystem *psys);
|
||||
|
||||
#endif /* __DRAW_CACHE_IMPL_H__ */
|
||||
|
||||
@@ -284,39 +284,39 @@ enum {
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Curve Batch Cache */
|
||||
/* Curve Gwn_Batch Cache */
|
||||
|
||||
typedef struct CurveBatchCache {
|
||||
/* center-line */
|
||||
struct {
|
||||
VertexBuffer *verts;
|
||||
VertexBuffer *edges;
|
||||
Batch *batch;
|
||||
ElementList *elem;
|
||||
Gwn_VertBuf *verts;
|
||||
Gwn_VertBuf *edges;
|
||||
Gwn_Batch *batch;
|
||||
Gwn_IndexBuf *elem;
|
||||
} wire;
|
||||
|
||||
/* normals */
|
||||
struct {
|
||||
VertexBuffer *verts;
|
||||
VertexBuffer *edges;
|
||||
Batch *batch;
|
||||
ElementList *elem;
|
||||
Gwn_VertBuf *verts;
|
||||
Gwn_VertBuf *edges;
|
||||
Gwn_Batch *batch;
|
||||
Gwn_IndexBuf *elem;
|
||||
} normal;
|
||||
|
||||
/* control handles and vertices */
|
||||
struct {
|
||||
Batch *edges;
|
||||
Batch *verts;
|
||||
Gwn_Batch *edges;
|
||||
Gwn_Batch *verts;
|
||||
} overlay;
|
||||
|
||||
struct {
|
||||
Batch *batch;
|
||||
Gwn_Batch *batch;
|
||||
} surface;
|
||||
|
||||
/* 3d text */
|
||||
struct {
|
||||
Batch *select;
|
||||
Batch *cursor;
|
||||
Gwn_Batch *select;
|
||||
Gwn_Batch *cursor;
|
||||
} text;
|
||||
|
||||
/* settings to determine if cache is invalid */
|
||||
@@ -330,7 +330,7 @@ typedef struct CurveBatchCache {
|
||||
bool is_editmode;
|
||||
} CurveBatchCache;
|
||||
|
||||
/* Batch cache management. */
|
||||
/* Gwn_Batch cache management. */
|
||||
|
||||
static bool curve_batch_cache_valid(Curve *cu)
|
||||
{
|
||||
@@ -453,9 +453,9 @@ static void curve_batch_cache_clear(Curve *cu)
|
||||
cache->wire.elem = NULL;
|
||||
}
|
||||
else {
|
||||
VERTEXBUFFER_DISCARD_SAFE(cache->wire.verts);
|
||||
VERTEXBUFFER_DISCARD_SAFE(cache->wire.edges);
|
||||
ELEMENTLIST_DISCARD_SAFE(cache->wire.elem);
|
||||
GWN_VERTBUF_DISCARD_SAFE(cache->wire.verts);
|
||||
GWN_VERTBUF_DISCARD_SAFE(cache->wire.edges);
|
||||
GWN_INDEXBUF_DISCARD_SAFE(cache->wire.elem);
|
||||
}
|
||||
|
||||
if (cache->normal.batch) {
|
||||
@@ -465,9 +465,9 @@ static void curve_batch_cache_clear(Curve *cu)
|
||||
cache->normal.elem = NULL;
|
||||
}
|
||||
else {
|
||||
VERTEXBUFFER_DISCARD_SAFE(cache->normal.verts);
|
||||
VERTEXBUFFER_DISCARD_SAFE(cache->normal.edges);
|
||||
ELEMENTLIST_DISCARD_SAFE(cache->normal.elem);
|
||||
GWN_VERTBUF_DISCARD_SAFE(cache->normal.verts);
|
||||
GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges);
|
||||
GWN_INDEXBUF_DISCARD_SAFE(cache->normal.elem);
|
||||
}
|
||||
|
||||
/* 3d text */
|
||||
@@ -486,30 +486,30 @@ void DRW_curve_batch_cache_free(Curve *cu)
|
||||
/** \name Private Curve Cache API
|
||||
* \{ */
|
||||
|
||||
/* Batch cache usage. */
|
||||
static VertexBuffer *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
/* Gwn_Batch cache usage. */
|
||||
static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & CU_DATATYPE_WIRE);
|
||||
BLI_assert(rdata->ob_curve_cache != NULL);
|
||||
|
||||
if (cache->wire.verts == NULL) {
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
const int vert_len = curve_render_data_wire_verts_len_get(rdata);
|
||||
|
||||
VertexBuffer *vbo = cache->wire.verts = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(vbo, vert_len);
|
||||
Gwn_VertBuf *vbo = cache->wire.verts = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, vert_len);
|
||||
int vbo_len_used = 0;
|
||||
for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) {
|
||||
if (bl->nr > 0) {
|
||||
const int i_end = vbo_len_used + bl->nr;
|
||||
for (const BevPoint *bevp = bl->bevpoints; vbo_len_used < i_end; vbo_len_used++, bevp++) {
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bevp->vec);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bevp->vec);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,7 +519,7 @@ static VertexBuffer *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, Cu
|
||||
return cache->wire.verts;
|
||||
}
|
||||
|
||||
static ElementList *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & CU_DATATYPE_WIRE);
|
||||
BLI_assert(rdata->ob_curve_cache != NULL);
|
||||
@@ -529,8 +529,8 @@ static ElementList *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cur
|
||||
const int edge_len = curve_render_data_wire_edges_len_get(rdata);
|
||||
int edge_len_used = 0;
|
||||
|
||||
ElementListBuilder elb;
|
||||
ElementListBuilder_init(&elb, PRIM_LINES, edge_len, vert_len);
|
||||
Gwn_IndexBufBuilder elb;
|
||||
GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
|
||||
|
||||
int i = 0;
|
||||
for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) {
|
||||
@@ -546,7 +546,7 @@ static ElementList *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cur
|
||||
i += 1;
|
||||
}
|
||||
for (; i < i_end; i_prev = i++) {
|
||||
add_line_vertices(&elb, i_prev, i);
|
||||
GWN_indexbuf_add_line_verts(&elb, i_prev, i);
|
||||
edge_len_used += 1;
|
||||
}
|
||||
}
|
||||
@@ -559,30 +559,30 @@ static ElementList *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cur
|
||||
BLI_assert(edge_len_used == edge_len);
|
||||
}
|
||||
|
||||
cache->wire.elem = ElementList_build(&elb);
|
||||
cache->wire.elem = GWN_indexbuf_build(&elb);
|
||||
}
|
||||
|
||||
return cache->wire.elem;
|
||||
}
|
||||
|
||||
static VertexBuffer *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & CU_DATATYPE_NORMAL);
|
||||
BLI_assert(rdata->ob_curve_cache != NULL);
|
||||
|
||||
if (cache->normal.verts == NULL) {
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
const int normal_len = curve_render_data_normal_len_get(rdata);
|
||||
const int vert_len = normal_len * 3;
|
||||
|
||||
VertexBuffer *vbo = cache->normal.verts = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(vbo, vert_len);
|
||||
Gwn_VertBuf *vbo = cache->normal.verts = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, vert_len);
|
||||
int vbo_len_used = 0;
|
||||
|
||||
const BevList *bl;
|
||||
@@ -614,9 +614,9 @@ static VertexBuffer *curve_batch_cache_get_normal_verts(CurveRenderData *rdata,
|
||||
add_v3_v3(vec_a, bevp->vec);
|
||||
add_v3_v3(vec_b, bevp->vec);
|
||||
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, vec_a);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, bevp->vec);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, vec_b);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_a);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, bevp->vec);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_b);
|
||||
|
||||
bevp += skip + 1;
|
||||
nr -= skip;
|
||||
@@ -628,7 +628,7 @@ static VertexBuffer *curve_batch_cache_get_normal_verts(CurveRenderData *rdata,
|
||||
return cache->normal.verts;
|
||||
}
|
||||
|
||||
static ElementList *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
static Gwn_IndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & CU_DATATYPE_NORMAL);
|
||||
BLI_assert(rdata->ob_curve_cache != NULL);
|
||||
@@ -638,19 +638,19 @@ static ElementList *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, C
|
||||
const int vert_len = normal_len * 3;
|
||||
const int edge_len = normal_len * 2;
|
||||
|
||||
ElementListBuilder elb;
|
||||
ElementListBuilder_init(&elb, PRIM_LINES, edge_len, vert_len);
|
||||
Gwn_IndexBufBuilder elb;
|
||||
GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
|
||||
|
||||
int vbo_len_used = 0;
|
||||
for (int i = 0; i < normal_len; i++) {
|
||||
add_line_vertices(&elb, vbo_len_used + 0, vbo_len_used + 1);
|
||||
add_line_vertices(&elb, vbo_len_used + 1, vbo_len_used + 2);
|
||||
GWN_indexbuf_add_line_verts(&elb, vbo_len_used + 0, vbo_len_used + 1);
|
||||
GWN_indexbuf_add_line_verts(&elb, vbo_len_used + 1, vbo_len_used + 2);
|
||||
vbo_len_used += 3;
|
||||
}
|
||||
|
||||
BLI_assert(vbo_len_used == vert_len);
|
||||
|
||||
cache->normal.elem = ElementList_build(&elb);
|
||||
cache->normal.elem = GWN_indexbuf_build(&elb);
|
||||
}
|
||||
|
||||
return cache->normal.elem;
|
||||
@@ -665,18 +665,18 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
|
||||
CurveRenderData *rdata = curve_render_data_create(cu, NULL, options);
|
||||
|
||||
if (cache->overlay.verts == NULL) {
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, data; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.data = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT);
|
||||
}
|
||||
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
const int vbo_len_capacity = curve_render_data_overlay_verts_len_get(rdata);
|
||||
int vbo_len_used = 0;
|
||||
VertexBuffer_allocate_data(vbo, vbo_len_capacity);
|
||||
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
|
||||
int i = 0;
|
||||
for (Nurb *nu = rdata->nurbs->first; nu; nu = nu->next) {
|
||||
if (nu->bezt) {
|
||||
@@ -689,16 +689,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
|
||||
if (rdata->hide_handles) {
|
||||
vflag = (bezt->f2 & SELECT) ?
|
||||
(is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
vbo_len_used += 1;
|
||||
}
|
||||
else {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
vflag = ((&bezt->f1)[j] & SELECT) ?
|
||||
(is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
vbo_len_used += 1;
|
||||
}
|
||||
}
|
||||
@@ -713,8 +713,8 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
|
||||
const bool is_active = (i == rdata->actvert);
|
||||
char vflag;
|
||||
vflag = (bp->f1 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bp->vec);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp->vec);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
vbo_len_used += 1;
|
||||
}
|
||||
i += 1;
|
||||
@@ -723,29 +723,29 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
|
||||
i += nu->pntsu;
|
||||
}
|
||||
if (vbo_len_capacity != vbo_len_used) {
|
||||
VertexBuffer_resize_data(vbo, vbo_len_used);
|
||||
GWN_vertbuf_data_resize(vbo, vbo_len_used);
|
||||
}
|
||||
|
||||
cache->overlay.verts = Batch_create(PRIM_POINTS, vbo, NULL);
|
||||
cache->overlay.verts = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
|
||||
}
|
||||
|
||||
|
||||
if ((cache->overlay.edges == NULL) && (rdata->hide_handles == false)) {
|
||||
/* Note: we could reference indices to vertices (above) */
|
||||
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, data; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.data = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT);
|
||||
}
|
||||
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
const int edge_len = curve_render_data_overlay_edges_len_get(rdata);
|
||||
const int vbo_len_capacity = edge_len * 2;
|
||||
int vbo_len_used = 0;
|
||||
VertexBuffer_allocate_data(vbo, vbo_len_capacity);
|
||||
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
|
||||
int i = 0;
|
||||
for (Nurb *nu = rdata->nurbs->first; nu; nu = nu->next) {
|
||||
if (nu->bezt) {
|
||||
@@ -756,22 +756,22 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
|
||||
char vflag;
|
||||
|
||||
vflag = (bezt->f1 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[0]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[0]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
vbo_len_used += 1;
|
||||
|
||||
/* same vertex twice, only check different selection */
|
||||
for (int j = 0; j < 2; j++) {
|
||||
vflag = ((j ? bezt->f3 : bezt->f1) & SELECT) ?
|
||||
(is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
vbo_len_used += 1;
|
||||
}
|
||||
|
||||
vflag = (bezt->f3 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0;
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bezt->vec[2]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[2]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
vbo_len_used += 1;
|
||||
}
|
||||
i += 1;
|
||||
@@ -783,11 +783,11 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
|
||||
if ((bp_prev->hide == false) && (bp_curr->hide == false)) {
|
||||
char vflag;
|
||||
vflag = ((bp_prev->f1 & SELECT) && (bp_curr->f1 & SELECT)) ? VFLAG_VERTEX_SELECTED : 0;
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bp_prev->vec);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_prev->vec);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
vbo_len_used += 1;
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, bp_curr->vec);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_curr->vec);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag);
|
||||
vbo_len_used += 1;
|
||||
|
||||
}
|
||||
@@ -795,16 +795,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu)
|
||||
}
|
||||
}
|
||||
if (vbo_len_capacity != vbo_len_used) {
|
||||
VertexBuffer_resize_data(vbo, vbo_len_used);
|
||||
GWN_vertbuf_data_resize(vbo, vbo_len_used);
|
||||
}
|
||||
|
||||
cache->overlay.edges = Batch_create(PRIM_LINES, vbo, NULL);
|
||||
cache->overlay.edges = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL);
|
||||
}
|
||||
|
||||
curve_render_data_free(rdata);
|
||||
}
|
||||
|
||||
static Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & CU_DATATYPE_SURFACE);
|
||||
if (cache->surface.batch == NULL) {
|
||||
@@ -822,21 +822,21 @@ static Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, Curv
|
||||
* \{ */
|
||||
|
||||
|
||||
static Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT);
|
||||
if (cache->text.select == NULL) {
|
||||
EditFont *ef = rdata->text.edit_font;
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
const int vbo_len_capacity = ef->selboxes_len * 6;
|
||||
int vbo_len_used = 0;
|
||||
VertexBuffer_allocate_data(vbo, vbo_len_capacity);
|
||||
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
|
||||
|
||||
float box[4][3];
|
||||
|
||||
@@ -883,37 +883,37 @@ static Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, Curve
|
||||
add_v2_v2(box[3], &sb->x);
|
||||
}
|
||||
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[0]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[1]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[2]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[1]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]);
|
||||
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[0]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[2]);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used++, box[3]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]);
|
||||
}
|
||||
BLI_assert(vbo_len_used == vbo_len_capacity);
|
||||
cache->text.select = Batch_create(PRIM_TRIANGLES, vbo, NULL);
|
||||
cache->text.select = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL);
|
||||
}
|
||||
return cache->text.select;
|
||||
}
|
||||
|
||||
static Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, CurveBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT);
|
||||
if (cache->text.cursor == NULL) {
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
const int vbo_len_capacity = 4;
|
||||
VertexBuffer_allocate_data(vbo, vbo_len_capacity);
|
||||
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]);
|
||||
}
|
||||
cache->text.cursor = Batch_create(PRIM_TRIANGLE_FAN, vbo, NULL);
|
||||
cache->text.cursor = GWN_batch_create(GWN_PRIM_TRI_FAN, vbo, NULL);
|
||||
}
|
||||
return cache->text.cursor;
|
||||
}
|
||||
@@ -925,7 +925,7 @@ static Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, Curve
|
||||
/** \name Public Object/Curve API
|
||||
* \{ */
|
||||
|
||||
Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache)
|
||||
Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache)
|
||||
{
|
||||
CurveBatchCache *cache = curve_batch_cache_get(cu);
|
||||
|
||||
@@ -933,8 +933,8 @@ Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache
|
||||
/* create batch from Curve */
|
||||
CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_WIRE);
|
||||
|
||||
cache->wire.batch = Batch_create(
|
||||
PRIM_LINES,
|
||||
cache->wire.batch = GWN_batch_create(
|
||||
GWN_PRIM_LINES,
|
||||
curve_batch_cache_get_wire_verts(rdata, cache),
|
||||
curve_batch_cache_get_wire_edges(rdata, cache));
|
||||
|
||||
@@ -943,7 +943,7 @@ Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache
|
||||
return cache->wire.batch;
|
||||
}
|
||||
|
||||
Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cache, float normal_size)
|
||||
Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cache, float normal_size)
|
||||
{
|
||||
CurveBatchCache *cache = curve_batch_cache_get(cu);
|
||||
|
||||
@@ -959,8 +959,8 @@ Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cac
|
||||
/* create batch from Curve */
|
||||
CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_NORMAL);
|
||||
|
||||
cache->normal.batch = Batch_create(
|
||||
PRIM_LINES,
|
||||
cache->normal.batch = GWN_batch_create(
|
||||
GWN_PRIM_LINES,
|
||||
curve_batch_cache_get_normal_verts(rdata, cache),
|
||||
curve_batch_cache_get_normal_edges(rdata, cache));
|
||||
|
||||
@@ -970,7 +970,7 @@ Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cac
|
||||
return cache->normal.batch;
|
||||
}
|
||||
|
||||
Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu)
|
||||
Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu)
|
||||
{
|
||||
CurveBatchCache *cache = curve_batch_cache_get(cu);
|
||||
|
||||
@@ -981,7 +981,7 @@ Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu)
|
||||
return cache->overlay.edges;
|
||||
}
|
||||
|
||||
Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu)
|
||||
Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu)
|
||||
{
|
||||
CurveBatchCache *cache = curve_batch_cache_get(cu);
|
||||
|
||||
@@ -992,7 +992,7 @@ Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu)
|
||||
return cache->overlay.verts;
|
||||
}
|
||||
|
||||
Batch *DRW_curve_batch_cache_get_triangles_with_normals(
|
||||
Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals(
|
||||
struct Curve *cu, struct CurveCache *ob_curve_cache)
|
||||
{
|
||||
CurveBatchCache *cache = curve_batch_cache_get(cu);
|
||||
@@ -1014,7 +1014,7 @@ Batch *DRW_curve_batch_cache_get_triangles_with_normals(
|
||||
/** \name Public Object/Font API
|
||||
* \{ */
|
||||
|
||||
Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu)
|
||||
Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu)
|
||||
{
|
||||
CurveBatchCache *cache = curve_batch_cache_get(cu);
|
||||
|
||||
@@ -1029,7 +1029,7 @@ Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu)
|
||||
return cache->text.select;
|
||||
}
|
||||
|
||||
Batch *DRW_curve_batch_cache_get_overlay_cursor(Curve *cu)
|
||||
Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(Curve *cu)
|
||||
{
|
||||
CurveBatchCache *cache = curve_batch_cache_get(cu);
|
||||
|
||||
|
||||
@@ -86,27 +86,27 @@ static int curve_render_surface_tri_len_get(const ListBase *lb)
|
||||
return tri_len;
|
||||
}
|
||||
|
||||
Batch *BLI_displist_batch_calc_surface(ListBase *lb)
|
||||
Gwn_Batch *BLI_displist_batch_calc_surface(ListBase *lb)
|
||||
{
|
||||
const int tri_len = curve_render_surface_tri_len_get(lb);
|
||||
if (tri_len == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, nor; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.nor = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
const int vert_len = curve_render_surface_vert_len_get(lb);
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
{
|
||||
const int vbo_len_capacity = vert_len;
|
||||
int vbo_len_used = 0;
|
||||
VertexBuffer_allocate_data(vbo, vbo_len_capacity);
|
||||
GWN_vertbuf_data_alloc(vbo, vbo_len_capacity);
|
||||
|
||||
BKE_displist_normals_add(lb);
|
||||
|
||||
@@ -117,9 +117,9 @@ Batch *BLI_displist_batch_calc_surface(ListBase *lb)
|
||||
const float *fp_no = dl->nors;
|
||||
const int vbo_end = vbo_len_used + dl_vert_len(dl);
|
||||
while (vbo_len_used < vbo_end) {
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, vbo_len_used, fp_co);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co);
|
||||
if (fp_no) {
|
||||
VertexBuffer_set_attrib(vbo, attr_id.nor, vbo_len_used, fp_no);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, fp_no);
|
||||
if (ndata_is_single == false) {
|
||||
fp_no += 3;
|
||||
}
|
||||
@@ -132,8 +132,8 @@ Batch *BLI_displist_batch_calc_surface(ListBase *lb)
|
||||
}
|
||||
|
||||
{
|
||||
ElementListBuilder elb;
|
||||
ElementListBuilder_init(&elb, PRIM_TRIANGLES, tri_len, vert_len);
|
||||
Gwn_IndexBufBuilder elb;
|
||||
GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len);
|
||||
|
||||
int ofs = 0;
|
||||
int tri_len_used = 0;
|
||||
@@ -143,7 +143,7 @@ Batch *BLI_displist_batch_calc_surface(ListBase *lb)
|
||||
const int *idx = dl->index;
|
||||
const int i_end = dl->parts;
|
||||
for (int i = 0; i < i_end; i++) {
|
||||
add_triangle_vertices(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs);
|
||||
GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs);
|
||||
tri_len_used += 1;
|
||||
idx += 3;
|
||||
}
|
||||
@@ -152,9 +152,9 @@ Batch *BLI_displist_batch_calc_surface(ListBase *lb)
|
||||
const int *idx = dl->index;
|
||||
const int i_end = dl->totindex;
|
||||
for (int i = 0; i < i_end; i++) {
|
||||
add_triangle_vertices(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs);
|
||||
GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs);
|
||||
tri_len_used += 1;
|
||||
add_triangle_vertices(&elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs);
|
||||
GWN_indexbuf_add_tri_verts(&elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs);
|
||||
tri_len_used += 1;
|
||||
idx += 4;
|
||||
}
|
||||
@@ -163,6 +163,6 @@ Batch *BLI_displist_batch_calc_surface(ListBase *lb)
|
||||
}
|
||||
}
|
||||
|
||||
return Batch_create(PRIM_TRIANGLES, vbo, ElementList_build(&elb));
|
||||
return GWN_batch_create(GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,16 +215,16 @@ enum {
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Lattice Batch Cache */
|
||||
/* Lattice Gwn_Batch Cache */
|
||||
|
||||
typedef struct LatticeBatchCache {
|
||||
VertexBuffer *pos;
|
||||
ElementList *edges;
|
||||
Gwn_VertBuf *pos;
|
||||
Gwn_IndexBuf *edges;
|
||||
|
||||
Batch *all_verts;
|
||||
Batch *all_edges;
|
||||
Gwn_Batch *all_verts;
|
||||
Gwn_Batch *all_edges;
|
||||
|
||||
Batch *overlay_verts;
|
||||
Gwn_Batch *overlay_verts;
|
||||
|
||||
/* settings to determine if cache is invalid */
|
||||
bool is_dirty;
|
||||
@@ -237,7 +237,7 @@ typedef struct LatticeBatchCache {
|
||||
bool is_editmode;
|
||||
} LatticeBatchCache;
|
||||
|
||||
/* Batch cache management. */
|
||||
/* Gwn_Batch cache management. */
|
||||
|
||||
static bool lattice_batch_cache_valid(Lattice *lt)
|
||||
{
|
||||
@@ -326,12 +326,12 @@ static void lattice_batch_cache_clear(Lattice *lt)
|
||||
return;
|
||||
}
|
||||
|
||||
BATCH_DISCARD_SAFE(cache->all_verts);
|
||||
BATCH_DISCARD_SAFE(cache->all_edges);
|
||||
GWN_BATCH_DISCARD_SAFE(cache->all_verts);
|
||||
GWN_BATCH_DISCARD_SAFE(cache->all_edges);
|
||||
BATCH_DISCARD_ALL_SAFE(cache->overlay_verts);
|
||||
|
||||
VERTEXBUFFER_DISCARD_SAFE(cache->pos);
|
||||
ELEMENTLIST_DISCARD_SAFE(cache->edges);
|
||||
GWN_VERTBUF_DISCARD_SAFE(cache->pos);
|
||||
GWN_INDEXBUF_DISCARD_SAFE(cache->edges);
|
||||
}
|
||||
|
||||
void DRW_lattice_batch_cache_free(Lattice *lt)
|
||||
@@ -340,33 +340,33 @@ void DRW_lattice_batch_cache_free(Lattice *lt)
|
||||
MEM_SAFE_FREE(lt->batch_cache);
|
||||
}
|
||||
|
||||
/* Batch cache usage. */
|
||||
static VertexBuffer *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache)
|
||||
/* Gwn_Batch cache usage. */
|
||||
static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & LR_DATATYPE_VERT);
|
||||
|
||||
if (cache->pos == NULL) {
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
const int vert_len = lattice_render_data_verts_len_get(rdata);
|
||||
|
||||
cache->pos = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(cache->pos, vert_len);
|
||||
cache->pos = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(cache->pos, vert_len);
|
||||
for (int i = 0; i < vert_len; ++i) {
|
||||
const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.pos, i, bp->vec);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec);
|
||||
}
|
||||
}
|
||||
|
||||
return cache->pos;
|
||||
}
|
||||
|
||||
static ElementList *lattice_batch_cache_get_edges(LatticeRenderData *rdata, LatticeBatchCache *cache)
|
||||
static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, LatticeBatchCache *cache)
|
||||
{
|
||||
BLI_assert(rdata->types & (LR_DATATYPE_VERT | LR_DATATYPE_EDGE));
|
||||
|
||||
@@ -375,8 +375,8 @@ static ElementList *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Latt
|
||||
const int edge_len = lattice_render_data_edges_len_get(rdata);
|
||||
int edge_len_real = 0;
|
||||
|
||||
ElementListBuilder elb;
|
||||
ElementListBuilder_init(&elb, PRIM_LINES, edge_len, vert_len);
|
||||
Gwn_IndexBufBuilder elb;
|
||||
GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
|
||||
|
||||
#define LATT_INDEX(u, v, w) \
|
||||
((((w) * rdata->dims.v_len + (v)) * rdata->dims.u_len) + (u))
|
||||
@@ -389,17 +389,17 @@ static ElementList *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Latt
|
||||
int uxt = (u == 0 || u == rdata->dims.u_len - 1);
|
||||
|
||||
if (w && ((uxt || vxt) || !rdata->show_only_outside)) {
|
||||
add_line_vertices(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w));
|
||||
GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w));
|
||||
BLI_assert(edge_len_real <= edge_len);
|
||||
edge_len_real++;
|
||||
}
|
||||
if (v && ((uxt || wxt) || !rdata->show_only_outside)) {
|
||||
add_line_vertices(&elb, LATT_INDEX(u, v - 1, w), LATT_INDEX(u, v, w));
|
||||
GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v - 1, w), LATT_INDEX(u, v, w));
|
||||
BLI_assert(edge_len_real <= edge_len);
|
||||
edge_len_real++;
|
||||
}
|
||||
if (u && ((vxt || wxt) || !rdata->show_only_outside)) {
|
||||
add_line_vertices(&elb, LATT_INDEX(u - 1, v, w), LATT_INDEX(u, v, w));
|
||||
GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u - 1, v, w), LATT_INDEX(u, v, w));
|
||||
BLI_assert(edge_len_real <= edge_len);
|
||||
edge_len_real++;
|
||||
}
|
||||
@@ -416,7 +416,7 @@ static ElementList *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Latt
|
||||
BLI_assert(edge_len_real == edge_len);
|
||||
}
|
||||
|
||||
cache->edges = ElementList_build(&elb);
|
||||
cache->edges = GWN_indexbuf_build(&elb);
|
||||
}
|
||||
|
||||
return cache->edges;
|
||||
@@ -431,18 +431,18 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt)
|
||||
LatticeRenderData *rdata = lattice_render_data_create(lt, options);
|
||||
|
||||
if (cache->overlay_verts == NULL) {
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, data; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.data = VertexFormat_add_attrib(&format, "data", COMP_U8, 1, KEEP_INT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT);
|
||||
}
|
||||
|
||||
const int vert_len = lattice_render_data_verts_len_get(rdata);
|
||||
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(vbo, vert_len);
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, vert_len);
|
||||
for (int i = 0; i < vert_len; ++i) {
|
||||
const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i);
|
||||
|
||||
@@ -456,17 +456,17 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt)
|
||||
}
|
||||
}
|
||||
|
||||
VertexBuffer_set_attrib(vbo, attr_id.pos, i, bp->vec);
|
||||
VertexBuffer_set_attrib(vbo, attr_id.data, i, &vflag);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, i, bp->vec);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.data, i, &vflag);
|
||||
}
|
||||
|
||||
cache->overlay_verts = Batch_create(PRIM_POINTS, vbo, NULL);
|
||||
cache->overlay_verts = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
|
||||
}
|
||||
|
||||
lattice_render_data_free(rdata);
|
||||
}
|
||||
|
||||
Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt)
|
||||
Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt)
|
||||
{
|
||||
LatticeBatchCache *cache = lattice_batch_cache_get(lt);
|
||||
|
||||
@@ -474,7 +474,7 @@ Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt)
|
||||
/* create batch from Lattice */
|
||||
LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT | LR_DATATYPE_EDGE);
|
||||
|
||||
cache->all_edges = Batch_create(PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache),
|
||||
cache->all_edges = GWN_batch_create(GWN_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache),
|
||||
lattice_batch_cache_get_edges(rdata, cache));
|
||||
|
||||
lattice_render_data_free(rdata);
|
||||
@@ -483,14 +483,14 @@ Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt)
|
||||
return cache->all_edges;
|
||||
}
|
||||
|
||||
Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt)
|
||||
Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt)
|
||||
{
|
||||
LatticeBatchCache *cache = lattice_batch_cache_get(lt);
|
||||
|
||||
if (cache->all_verts == NULL) {
|
||||
LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT);
|
||||
|
||||
cache->all_verts = Batch_create(PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache), NULL);
|
||||
cache->all_verts = GWN_batch_create(GWN_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache), NULL);
|
||||
|
||||
lattice_render_data_free(rdata);
|
||||
}
|
||||
@@ -498,7 +498,7 @@ Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt)
|
||||
return cache->all_verts;
|
||||
}
|
||||
|
||||
Batch *DRW_lattice_batch_cache_get_overlay_verts(Lattice *lt)
|
||||
Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(Lattice *lt)
|
||||
{
|
||||
LatticeBatchCache *cache = lattice_batch_cache_get(lt);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -45,13 +45,13 @@
|
||||
static void particle_batch_cache_clear(ParticleSystem *psys);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Particle Batch Cache */
|
||||
/* Particle Gwn_Batch Cache */
|
||||
|
||||
typedef struct ParticleBatchCache {
|
||||
VertexBuffer *pos;
|
||||
ElementList *segments;
|
||||
Gwn_VertBuf *pos;
|
||||
Gwn_IndexBuf *segments;
|
||||
|
||||
Batch *hairs;
|
||||
Gwn_Batch *hairs;
|
||||
|
||||
int segment_count;
|
||||
int point_count;
|
||||
@@ -60,7 +60,7 @@ typedef struct ParticleBatchCache {
|
||||
bool is_dirty;
|
||||
} ParticleBatchCache;
|
||||
|
||||
/* Batch cache management. */
|
||||
/* Gwn_Batch cache management. */
|
||||
|
||||
static bool particle_batch_cache_valid(ParticleSystem *psys)
|
||||
{
|
||||
@@ -125,10 +125,10 @@ static void particle_batch_cache_clear(ParticleSystem *psys)
|
||||
return;
|
||||
}
|
||||
|
||||
BATCH_DISCARD_SAFE(cache->hairs);
|
||||
GWN_BATCH_DISCARD_SAFE(cache->hairs);
|
||||
|
||||
VERTEXBUFFER_DISCARD_SAFE(cache->pos);
|
||||
ELEMENTLIST_DISCARD_SAFE(cache->segments);
|
||||
GWN_VERTBUF_DISCARD_SAFE(cache->pos);
|
||||
GWN_INDEXBUF_DISCARD_SAFE(cache->segments);
|
||||
}
|
||||
|
||||
void DRW_particle_batch_cache_free(ParticleSystem *psys)
|
||||
@@ -169,29 +169,29 @@ static void ensure_seg_pt_count(ParticleSystem *psys, ParticleBatchCache *cache)
|
||||
}
|
||||
}
|
||||
|
||||
/* Batch cache usage. */
|
||||
/* Gwn_Batch cache usage. */
|
||||
static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, ParticleBatchCache *cache)
|
||||
{
|
||||
if (cache->pos == NULL || cache->segments == NULL) {
|
||||
int curr_point = 0;
|
||||
|
||||
VERTEXBUFFER_DISCARD_SAFE(cache->pos);
|
||||
ELEMENTLIST_DISCARD_SAFE(cache->segments);
|
||||
GWN_VERTBUF_DISCARD_SAFE(cache->pos);
|
||||
GWN_INDEXBUF_DISCARD_SAFE(cache->segments);
|
||||
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, tan, ind; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
attr_id.pos = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.tan = VertexFormat_add_attrib(&format, "nor", COMP_F32, 3, KEEP_FLOAT);
|
||||
attr_id.ind = VertexFormat_add_attrib(&format, "ind", COMP_I32, 1, KEEP_INT);
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.tan = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
attr_id.ind = GWN_vertformat_attr_add(&format, "ind", GWN_COMP_I32, 1, GWN_FETCH_INT);
|
||||
}
|
||||
|
||||
cache->pos = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(cache->pos, cache->point_count);
|
||||
cache->pos = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(cache->pos, cache->point_count);
|
||||
|
||||
ElementListBuilder elb;
|
||||
ElementListBuilder_init(&elb, PRIM_LINES, cache->segment_count, cache->point_count);
|
||||
Gwn_IndexBufBuilder elb;
|
||||
GWN_indexbuf_init(&elb, GWN_PRIM_LINES, cache->segment_count, cache->point_count);
|
||||
|
||||
if (psys->pathcache && (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) {
|
||||
for (int i = 0; i < psys->totpart; i++) {
|
||||
@@ -208,20 +208,20 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
|
||||
sub_v3_v3v3(tangent, path[j + 1].co, path[j - 1].co);
|
||||
}
|
||||
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.pos, curr_point, path[j].co);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.tan, curr_point, tangent);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.ind, curr_point, &i);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.pos, curr_point, path[j].co);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.tan, curr_point, tangent);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.ind, curr_point, &i);
|
||||
|
||||
add_line_vertices(&elb, curr_point, curr_point + 1);
|
||||
GWN_indexbuf_add_line_verts(&elb, curr_point, curr_point + 1);
|
||||
|
||||
curr_point++;
|
||||
}
|
||||
|
||||
sub_v3_v3v3(tangent, path[path->segments].co, path[path->segments - 1].co);
|
||||
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.pos, curr_point, path[path->segments].co);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.tan, curr_point, tangent);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.ind, curr_point, &i);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.pos, curr_point, path[path->segments].co);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.tan, curr_point, tangent);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.ind, curr_point, &i);
|
||||
|
||||
curr_point++;
|
||||
}
|
||||
@@ -244,50 +244,50 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Partic
|
||||
sub_v3_v3v3(tangent, path[j + 1].co, path[j - 1].co);
|
||||
}
|
||||
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.pos, curr_point, path[j].co);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.tan, curr_point, tangent);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.ind, curr_point, &x);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.pos, curr_point, path[j].co);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.tan, curr_point, tangent);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.ind, curr_point, &x);
|
||||
|
||||
add_line_vertices(&elb, curr_point, curr_point + 1);
|
||||
GWN_indexbuf_add_line_verts(&elb, curr_point, curr_point + 1);
|
||||
|
||||
curr_point++;
|
||||
}
|
||||
|
||||
sub_v3_v3v3(tangent, path[path->segments].co, path[path->segments - 1].co);
|
||||
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.pos, curr_point, path[path->segments].co);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.tan, curr_point, tangent);
|
||||
VertexBuffer_set_attrib(cache->pos, attr_id.ind, curr_point, &x);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.pos, curr_point, path[path->segments].co);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.tan, curr_point, tangent);
|
||||
GWN_vertbuf_attr_set(cache->pos, attr_id.ind, curr_point, &x);
|
||||
|
||||
curr_point++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cache->segments = ElementList_build(&elb);
|
||||
cache->segments = GWN_indexbuf_build(&elb);
|
||||
}
|
||||
}
|
||||
|
||||
static void particle_batch_cache_ensure_pos(ParticleSystem *psys, ParticleBatchCache *cache)
|
||||
{
|
||||
if (cache->pos == NULL) {
|
||||
static VertexFormat format = { 0 };
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static unsigned pos_id, rot_id, val_id;
|
||||
int i, curr_point;
|
||||
ParticleData *pa;
|
||||
|
||||
VERTEXBUFFER_DISCARD_SAFE(cache->pos);
|
||||
ELEMENTLIST_DISCARD_SAFE(cache->segments);
|
||||
GWN_VERTBUF_DISCARD_SAFE(cache->pos);
|
||||
GWN_INDEXBUF_DISCARD_SAFE(cache->segments);
|
||||
|
||||
if (format.attrib_ct == 0) {
|
||||
/* initialize vertex format */
|
||||
pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
rot_id = VertexFormat_add_attrib(&format, "rot", COMP_F32, 4, KEEP_FLOAT);
|
||||
val_id = VertexFormat_add_attrib(&format, "val", COMP_F32, 1, KEEP_FLOAT);
|
||||
pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
rot_id = GWN_vertformat_attr_add(&format, "rot", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
|
||||
val_id = GWN_vertformat_attr_add(&format, "val", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
cache->pos = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(cache->pos, psys->totpart);
|
||||
cache->pos = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(cache->pos, psys->totpart);
|
||||
|
||||
for (curr_point = 0, i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) {
|
||||
if (pa->state.time >= pa->time && pa->state.time < pa->dietime &&
|
||||
@@ -295,8 +295,8 @@ static void particle_batch_cache_ensure_pos(ParticleSystem *psys, ParticleBatchC
|
||||
{
|
||||
float val;
|
||||
|
||||
VertexBuffer_set_attrib(cache->pos, pos_id, curr_point, pa->state.co);
|
||||
VertexBuffer_set_attrib(cache->pos, rot_id, curr_point, pa->state.rot);
|
||||
GWN_vertbuf_attr_set(cache->pos, pos_id, curr_point, pa->state.co);
|
||||
GWN_vertbuf_attr_set(cache->pos, rot_id, curr_point, pa->state.rot);
|
||||
|
||||
switch (psys->part->draw_col) {
|
||||
case PART_DRAW_COL_VEL:
|
||||
@@ -310,38 +310,38 @@ static void particle_batch_cache_ensure_pos(ParticleSystem *psys, ParticleBatchC
|
||||
break;
|
||||
}
|
||||
|
||||
VertexBuffer_set_attrib(cache->pos, val_id, curr_point, &val);
|
||||
GWN_vertbuf_attr_set(cache->pos, val_id, curr_point, &val);
|
||||
|
||||
curr_point++;
|
||||
}
|
||||
}
|
||||
|
||||
if (curr_point != psys->totpart) {
|
||||
VertexBuffer_resize_data(cache->pos, curr_point);
|
||||
GWN_vertbuf_data_resize(cache->pos, curr_point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Batch *DRW_particles_batch_cache_get_hair(ParticleSystem *psys)
|
||||
Gwn_Batch *DRW_particles_batch_cache_get_hair(ParticleSystem *psys)
|
||||
{
|
||||
ParticleBatchCache *cache = particle_batch_cache_get(psys);
|
||||
|
||||
if (cache->hairs == NULL) {
|
||||
ensure_seg_pt_count(psys, cache);
|
||||
particle_batch_cache_ensure_pos_and_seg(psys, cache);
|
||||
cache->hairs = Batch_create(PRIM_LINES, cache->pos, cache->segments);
|
||||
cache->hairs = GWN_batch_create(GWN_PRIM_LINES, cache->pos, cache->segments);
|
||||
}
|
||||
|
||||
return cache->hairs;
|
||||
}
|
||||
|
||||
Batch *DRW_particles_batch_cache_get_dots(ParticleSystem *psys)
|
||||
Gwn_Batch *DRW_particles_batch_cache_get_dots(ParticleSystem *psys)
|
||||
{
|
||||
ParticleBatchCache *cache = particle_batch_cache_get(psys);
|
||||
|
||||
if (cache->hairs == NULL) {
|
||||
particle_batch_cache_ensure_pos(psys, cache);
|
||||
cache->hairs = Batch_create(PRIM_POINTS, cache->pos, NULL);
|
||||
cache->hairs = GWN_batch_create(GWN_PRIM_POINTS, cache->pos, NULL);
|
||||
}
|
||||
|
||||
return cache->hairs;
|
||||
|
||||
@@ -184,7 +184,7 @@ DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float color[4
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Batch *geom, float *size)
|
||||
DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *geom, float *size)
|
||||
{
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR);
|
||||
|
||||
@@ -199,7 +199,7 @@ DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Batch *geom,
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_objspace_solid(DRWPass *pass, struct Batch *geom, float (*obmat)[4])
|
||||
DRWShadingGroup *shgroup_instance_objspace_solid(DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4])
|
||||
{
|
||||
static float light[3] = {0.0f, 0.0f, 1.0f};
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR);
|
||||
@@ -213,7 +213,7 @@ DRWShadingGroup *shgroup_instance_objspace_solid(DRWPass *pass, struct Batch *ge
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_objspace_wire(DRWPass *pass, struct Batch *geom, float (*obmat)[4])
|
||||
DRWShadingGroup *shgroup_instance_objspace_wire(DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4])
|
||||
{
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR);
|
||||
|
||||
@@ -225,7 +225,7 @@ DRWShadingGroup *shgroup_instance_objspace_wire(DRWPass *pass, struct Batch *geo
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Batch *geom)
|
||||
DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch *geom)
|
||||
{
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED);
|
||||
|
||||
@@ -238,7 +238,7 @@ DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Batch *ge
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Batch *geom)
|
||||
DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *geom)
|
||||
{
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS);
|
||||
|
||||
@@ -251,7 +251,7 @@ DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Batch *geom)
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Batch *geom)
|
||||
DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom)
|
||||
{
|
||||
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE);
|
||||
|
||||
@@ -263,7 +263,7 @@ DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Batch *geom)
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Batch *geom)
|
||||
DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom)
|
||||
{
|
||||
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE);
|
||||
|
||||
@@ -275,7 +275,7 @@ DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Batch *geom)
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Batch *geom)
|
||||
DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom)
|
||||
{
|
||||
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_CAMERA);
|
||||
|
||||
@@ -289,7 +289,7 @@ DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Batch *geom)
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Batch *geom)
|
||||
DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch *geom)
|
||||
{
|
||||
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_DISTANCE_LINES);
|
||||
static float point_size = 4.0f;
|
||||
@@ -304,7 +304,7 @@ DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Batch *ge
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Batch *geom)
|
||||
DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Gwn_Batch *geom)
|
||||
{
|
||||
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR);
|
||||
static bool True = true;
|
||||
@@ -320,7 +320,7 @@ DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Batch *geom)
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_bone_envelope_wire(DRWPass *pass, struct Batch *geom, float (*obmat)[4])
|
||||
DRWShadingGroup *shgroup_instance_bone_envelope_wire(DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4])
|
||||
{
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE);
|
||||
|
||||
@@ -335,7 +335,7 @@ DRWShadingGroup *shgroup_instance_bone_envelope_wire(DRWPass *pass, struct Batch
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, struct Batch *geom, float (*obmat)[4])
|
||||
DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4])
|
||||
{
|
||||
static float light[3] = {0.0f, 0.0f, 1.0f};
|
||||
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
struct DRWPass;
|
||||
struct DRWShadingGroup;
|
||||
struct Batch;
|
||||
struct Gwn_Batch;
|
||||
struct Object;
|
||||
struct SceneLayer;
|
||||
|
||||
@@ -91,19 +91,19 @@ struct DRWShadingGroup *shgroup_dynlines_uniform_color(struct DRWPass *pass, flo
|
||||
struct DRWShadingGroup *shgroup_dynpoints_uniform_color(struct DRWPass *pass, float color[4], float *size);
|
||||
struct DRWShadingGroup *shgroup_groundlines_uniform_color(struct DRWPass *pass, float color[4]);
|
||||
struct DRWShadingGroup *shgroup_groundpoints_uniform_color(struct DRWPass *pass, float color[4]);
|
||||
struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct Batch *geom, float *size);
|
||||
struct DRWShadingGroup *shgroup_instance_objspace_solid(struct DRWPass *pass, struct Batch *geom, float (*obmat)[4]);
|
||||
struct DRWShadingGroup *shgroup_instance_objspace_wire(struct DRWPass *pass, struct Batch *geom, float (*obmat)[4]);
|
||||
struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance_bone_envelope_wire(struct DRWPass *pass, struct Batch *geom, float (*obmat)[4]);
|
||||
struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass, struct Batch *geom, float (*obmat)[4]);
|
||||
struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct Gwn_Batch *geom, float *size);
|
||||
struct DRWShadingGroup *shgroup_instance_objspace_solid(struct DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4]);
|
||||
struct DRWShadingGroup *shgroup_instance_objspace_wire(struct DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4]);
|
||||
struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct Gwn_Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct Gwn_Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct Gwn_Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct Gwn_Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
|
||||
struct DRWShadingGroup *shgroup_instance_bone_envelope_wire(struct DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4]);
|
||||
struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4]);
|
||||
|
||||
int DRW_object_wire_theme_get(struct Object *ob, struct SceneLayer *sl, float **r_color);
|
||||
float *DRW_color_background_blend_get(int theme_id);
|
||||
|
||||
@@ -181,10 +181,10 @@ struct DRWInterface {
|
||||
/* UBO */
|
||||
int ubo_bind; /* next ubo binding point */
|
||||
/* Dynamic batch */
|
||||
Batch *instance_batch; /* contains instances attributes */
|
||||
Gwn_Batch *instance_batch; /* contains instances attributes */
|
||||
GLuint instance_vbo; /* same as instance_batch but generated from DRWCalls */
|
||||
int instance_count;
|
||||
VertexFormat vbo_format;
|
||||
Gwn_VertFormat vbo_format;
|
||||
};
|
||||
|
||||
struct DRWPass {
|
||||
@@ -211,7 +211,7 @@ typedef struct DRWCall {
|
||||
DRWCallHeader head;
|
||||
|
||||
float obmat[4][4];
|
||||
Batch *geometry;
|
||||
Gwn_Batch *geometry;
|
||||
|
||||
Object *ob; /* Optional */
|
||||
ID *ob_data; /* Optional. */
|
||||
@@ -241,8 +241,8 @@ struct DRWShadingGroup {
|
||||
DRWState state_extra; /* State changes for this batch only (or'd with the pass's state) */
|
||||
int type;
|
||||
|
||||
Batch *instance_geom; /* Geometry to instance */
|
||||
Batch *batch_geom; /* Result of call batching */
|
||||
Gwn_Batch *instance_geom; /* Geometry to instance */
|
||||
Gwn_Batch *batch_geom; /* Result of call batching */
|
||||
|
||||
#ifdef USE_GPU_SELECT
|
||||
/* backlink to pass we're in */
|
||||
@@ -600,7 +600,7 @@ static DRWInterface *DRW_interface_create(GPUShader *shader)
|
||||
interface->tex_bind = GPU_max_textures() - 1;
|
||||
interface->ubo_bind = GPU_max_ubo_binds() - 1;
|
||||
|
||||
memset(&interface->vbo_format, 0, sizeof(VertexFormat));
|
||||
memset(&interface->vbo_format, 0, sizeof(Gwn_VertFormat));
|
||||
|
||||
BLI_listbase_clear(&interface->uniforms);
|
||||
BLI_listbase_clear(&interface->attribs);
|
||||
@@ -773,7 +773,7 @@ DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPa
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, Batch *geom)
|
||||
DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, Gwn_Batch *geom)
|
||||
{
|
||||
DRWShadingGroup *shgroup = DRW_shgroup_material_create(material, pass);
|
||||
|
||||
@@ -785,7 +785,7 @@ DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *materi
|
||||
return shgroup;
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, Batch *geom)
|
||||
DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, Gwn_Batch *geom)
|
||||
{
|
||||
DRWShadingGroup *shgroup = DRW_shgroup_create(shader, pass);
|
||||
|
||||
@@ -846,7 +846,7 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup)
|
||||
BATCH_DISCARD_ALL_SAFE(shgroup->batch_geom);
|
||||
}
|
||||
|
||||
void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Batch *instances)
|
||||
void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *instances)
|
||||
{
|
||||
BLI_assert(shgroup->type == DRW_SHG_INSTANCE);
|
||||
BLI_assert(shgroup->interface->instance_batch == NULL);
|
||||
@@ -854,7 +854,7 @@ void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Batch *instance
|
||||
shgroup->interface->instance_batch = instances;
|
||||
}
|
||||
|
||||
void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Batch *geom, float (*obmat)[4])
|
||||
void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4])
|
||||
{
|
||||
BLI_assert(geom != NULL);
|
||||
|
||||
@@ -874,7 +874,7 @@ void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Batch *geom, float (*obmat)[
|
||||
BLI_addtail(&shgroup->calls, call);
|
||||
}
|
||||
|
||||
void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, Batch *geom, Object *ob)
|
||||
void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob)
|
||||
{
|
||||
BLI_assert(geom != NULL);
|
||||
|
||||
@@ -918,7 +918,7 @@ void DRW_shgroup_call_generate_add(
|
||||
|
||||
static void sculpt_draw_cb(
|
||||
DRWShadingGroup *shgroup,
|
||||
void (*draw_fn)(DRWShadingGroup *shgroup, Batch *geom),
|
||||
void (*draw_fn)(DRWShadingGroup *shgroup, Gwn_Batch *geom),
|
||||
void *user_data)
|
||||
{
|
||||
Object *ob = user_data;
|
||||
@@ -927,7 +927,7 @@ static void sculpt_draw_cb(
|
||||
if (pbvh) {
|
||||
BKE_pbvh_draw_cb(
|
||||
pbvh, NULL, NULL, false,
|
||||
(void (*)(void *, Batch *))draw_fn, shgroup);
|
||||
(void (*)(void *, Gwn_Batch *))draw_fn, shgroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1106,8 +1106,8 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup)
|
||||
DRWInterface *interface = shgroup->interface;
|
||||
int nbr = interface->instance_count;
|
||||
|
||||
PrimitiveType type = (shgroup->type == DRW_SHG_POINT_BATCH) ? PRIM_POINTS :
|
||||
(shgroup->type == DRW_SHG_TRIANGLE_BATCH) ? PRIM_TRIANGLES : PRIM_LINES;
|
||||
Gwn_PrimType type = (shgroup->type == DRW_SHG_POINT_BATCH) ? GWN_PRIM_POINTS :
|
||||
(shgroup->type == DRW_SHG_TRIANGLE_BATCH) ? GWN_PRIM_TRIS : GWN_PRIM_LINES;
|
||||
|
||||
if (nbr == 0)
|
||||
return;
|
||||
@@ -1117,12 +1117,12 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup)
|
||||
for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next) {
|
||||
BLI_assert(attrib->size <= 4); /* matrices have no place here for now */
|
||||
if (attrib->type == DRW_ATTRIB_FLOAT) {
|
||||
attrib->format_id = VertexFormat_add_attrib(
|
||||
&interface->vbo_format, attrib->name, COMP_F32, attrib->size, KEEP_FLOAT);
|
||||
attrib->format_id = GWN_vertformat_attr_add(
|
||||
&interface->vbo_format, attrib->name, GWN_COMP_F32, attrib->size, GWN_FETCH_FLOAT);
|
||||
}
|
||||
else if (attrib->type == DRW_ATTRIB_INT) {
|
||||
attrib->format_id = VertexFormat_add_attrib(
|
||||
&interface->vbo_format, attrib->name, COMP_I8, attrib->size, KEEP_INT);
|
||||
attrib->format_id = GWN_vertformat_attr_add(
|
||||
&interface->vbo_format, attrib->name, GWN_COMP_I8, attrib->size, GWN_FETCH_INT);
|
||||
}
|
||||
else {
|
||||
BLI_assert(false);
|
||||
@@ -1130,22 +1130,22 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup)
|
||||
}
|
||||
}
|
||||
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&interface->vbo_format);
|
||||
VertexBuffer_allocate_data(vbo, nbr);
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&interface->vbo_format);
|
||||
GWN_vertbuf_data_alloc(vbo, nbr);
|
||||
|
||||
int j = 0;
|
||||
for (DRWCallDynamic *call = shgroup->calls.first; call; call = call->head.next, j++) {
|
||||
int i = 0;
|
||||
for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) {
|
||||
VertexBuffer_set_attrib(vbo, attrib->format_id, j, call->data[i]);
|
||||
GWN_vertbuf_attr_set(vbo, attrib->format_id, j, call->data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO make the batch dynamic instead of freeing it every times */
|
||||
if (shgroup->batch_geom)
|
||||
Batch_discard_all(shgroup->batch_geom);
|
||||
GWN_batch_discard_all(shgroup->batch_geom);
|
||||
|
||||
shgroup->batch_geom = Batch_create(type, vbo, NULL);
|
||||
shgroup->batch_geom = GWN_batch_create(type, vbo, NULL);
|
||||
}
|
||||
|
||||
static void shgroup_dynamic_instance(DRWShadingGroup *shgroup)
|
||||
@@ -1630,24 +1630,24 @@ static void draw_geometry_prepare(
|
||||
GPU_shader_uniform_vector(shgroup->shader, interface->clipplanes, 4, DST.num_clip_planes, (float *)DST.clip_planes_eq);
|
||||
}
|
||||
|
||||
static void draw_geometry_execute(DRWShadingGroup *shgroup, Batch *geom)
|
||||
static void draw_geometry_execute(DRWShadingGroup *shgroup, Gwn_Batch *geom)
|
||||
{
|
||||
DRWInterface *interface = shgroup->interface;
|
||||
/* step 2 : bind vertex array & draw */
|
||||
Batch_set_program(geom, GPU_shader_get_program(shgroup->shader), GPU_shader_get_interface(shgroup->shader));
|
||||
GWN_batch_program_set(geom, GPU_shader_get_program(shgroup->shader), GPU_shader_get_interface(shgroup->shader));
|
||||
if (interface->instance_batch) {
|
||||
Batch_draw_stupid_instanced_with_batch(geom, interface->instance_batch);
|
||||
GWN_batch_draw_stupid_instanced_with_batch(geom, interface->instance_batch);
|
||||
}
|
||||
else if (interface->instance_vbo) {
|
||||
Batch_draw_stupid_instanced(geom, interface->instance_vbo, interface->instance_count, interface->attribs_count,
|
||||
GWN_batch_draw_stupid_instanced(geom, interface->instance_vbo, interface->instance_count, interface->attribs_count,
|
||||
interface->attribs_stride, interface->attribs_size, interface->attribs_loc);
|
||||
}
|
||||
else {
|
||||
Batch_draw_stupid(geom);
|
||||
GWN_batch_draw_stupid(geom);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*obmat)[4], ID *ob_data)
|
||||
static void draw_geometry(DRWShadingGroup *shgroup, Gwn_Batch *geom, const float (*obmat)[4], ID *ob_data)
|
||||
{
|
||||
float *texcoloc = NULL;
|
||||
float *texcosize = NULL;
|
||||
@@ -2143,9 +2143,9 @@ void DRW_transform_to_display(GPUTexture *tex)
|
||||
{
|
||||
DRW_state_set(DRW_STATE_WRITE_COLOR);
|
||||
|
||||
VertexFormat *vert_format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(vert_format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int texco = VertexFormat_add_attrib(vert_format, "texCoord", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *vert_format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
const float dither = 1.0f;
|
||||
|
||||
@@ -2167,7 +2167,7 @@ void DRW_transform_to_display(GPUTexture *tex)
|
||||
immUniformMatrix4fv("ModelViewProjectionMatrix", mat);
|
||||
|
||||
/* Full screen triangle */
|
||||
immBegin(PRIM_TRIANGLES, 3);
|
||||
immBegin(GWN_PRIM_TRIS, 3);
|
||||
immAttrib2f(texco, 0.0f, 0.0f);
|
||||
immVertex2f(pos, -1.0f, -1.0f);
|
||||
|
||||
@@ -2889,7 +2889,7 @@ static void DRW_debug_gpu_stats(void)
|
||||
|
||||
/* Memory Stats */
|
||||
unsigned int tex_mem = GPU_texture_memory_usage_get();
|
||||
unsigned int vbo_mem = VertexBuffer_get_memory_usage();
|
||||
unsigned int vbo_mem = GWN_vertbuf_get_memory_usage();
|
||||
|
||||
sprintf(pass_name, "GPU Memory");
|
||||
draw_stat(&rect, 0, v, pass_name, sizeof(pass_name));
|
||||
|
||||
@@ -211,9 +211,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
|
||||
glDepthMask(GL_FALSE); /* disable write in zbuffer */
|
||||
#endif
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
|
||||
@@ -250,7 +250,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
|
||||
if (gridline_ct == 0)
|
||||
goto drawgrid_cleanup; /* nothing to draw */
|
||||
|
||||
immBegin(PRIM_LINES, gridline_ct * 2);
|
||||
immBegin(GWN_PRIM_LINES, gridline_ct * 2);
|
||||
}
|
||||
|
||||
float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar);
|
||||
@@ -303,7 +303,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
|
||||
if (gridline_ct == 0)
|
||||
goto drawgrid_cleanup; /* nothing to draw */
|
||||
|
||||
immBegin(PRIM_LINES, gridline_ct * 2);
|
||||
immBegin(GWN_PRIM_LINES, gridline_ct * 2);
|
||||
|
||||
if (grids_to_draw == 2) {
|
||||
UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2);
|
||||
@@ -378,13 +378,13 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
|
||||
|
||||
unsigned char col_bg[3], col_grid_emphasise[3], col_grid_light[3];
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
|
||||
|
||||
immBegin(PRIM_LINES, vertex_ct);
|
||||
immBegin(GWN_PRIM_LINES, vertex_ct);
|
||||
|
||||
/* draw normal grid lines */
|
||||
UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10);
|
||||
@@ -466,12 +466,12 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
|
||||
if (show_axis_x || show_axis_y || show_axis_z) {
|
||||
/* draw axis lines -- sometimes grid floor is off, other times we still need to draw the Z axis */
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR);
|
||||
immBegin(PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2);
|
||||
immBegin(GWN_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2);
|
||||
|
||||
if (show_axis_x) {
|
||||
UI_make_axis_color(col_grid, col_axis, 'X');
|
||||
@@ -570,9 +570,9 @@ void DRW_draw_background(void)
|
||||
/* Gradient background Color */
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
unsigned char col_hi[3], col_lo[3];
|
||||
|
||||
gpuPushMatrix();
|
||||
@@ -584,7 +584,7 @@ void DRW_draw_background(void)
|
||||
UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo);
|
||||
UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi);
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 4);
|
||||
immAttrib3ubv(color, col_lo);
|
||||
immVertex2f(pos, -1.0f, -1.0f);
|
||||
immVertex2f(pos, 1.0f, -1.0f);
|
||||
@@ -662,10 +662,10 @@ void DRW_draw_cursor(void)
|
||||
const float f10 = 0.5f;
|
||||
const float f20 = 1.0f;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
unsigned int wpos = VertexFormat_add_attrib(format, "world_pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
unsigned int wpos = GWN_vertformat_attr_add(format, "world_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
/* XXX Using instance shader without instance */
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR);
|
||||
@@ -676,7 +676,7 @@ void DRW_draw_cursor(void)
|
||||
|
||||
const int segments = 16;
|
||||
|
||||
immBegin(PRIM_LINE_LOOP, segments);
|
||||
immBegin(GWN_PRIM_LINE_LOOP, segments);
|
||||
immAttrib3fv(wpos, co);
|
||||
|
||||
for (int i = 0; i < segments; ++i) {
|
||||
@@ -695,7 +695,7 @@ void DRW_draw_cursor(void)
|
||||
|
||||
UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color);
|
||||
|
||||
immBegin(PRIM_LINES, 8);
|
||||
immBegin(GWN_PRIM_LINES, 8);
|
||||
immAttrib3ubv(color, crosshair_color);
|
||||
immAttrib3fv(wpos, co);
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
|
||||
if (ob == obedit) {
|
||||
Curve *cu = ob->data;
|
||||
/* Get geometry cache */
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
geom = DRW_cache_curve_edge_wire_get(ob);
|
||||
DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
|
||||
|
||||
@@ -194,7 +194,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob)
|
||||
if (ob->type == OB_LATTICE) {
|
||||
if (ob == obedit) {
|
||||
/* Get geometry cache */
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
geom = DRW_cache_lattice_wire_get(ob);
|
||||
DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
|
||||
|
||||
@@ -381,7 +381,7 @@ static void EDIT_MESH_cache_init(void *vedata)
|
||||
DRW_shgroup_uniform_block(stl->g_data->facefill_occluded_shgrp, "globalsBlock", globals_ubo);
|
||||
|
||||
/* we need a full screen pass to combine the result */
|
||||
struct Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
|
||||
psl->mix_occlude = DRW_pass_create(
|
||||
"Mix Occluded Wires",
|
||||
@@ -399,7 +399,7 @@ static void edit_mesh_add_ob_to_pass(
|
||||
Scene *scene, Object *ob, DRWShadingGroup *face_shgrp, DRWShadingGroup *ledges_shgrp,
|
||||
DRWShadingGroup *lverts_shgrp, DRWShadingGroup *facedot_shgrp, DRWShadingGroup *facefill_shgrp)
|
||||
{
|
||||
struct Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter;
|
||||
struct Gwn_Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter;
|
||||
ToolSettings *tsettings = scene->toolsettings;
|
||||
|
||||
DRW_cache_mesh_wire_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts);
|
||||
@@ -427,7 +427,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
|
||||
View3D *v3d = draw_ctx->v3d;
|
||||
Scene *scene = draw_ctx->scene;
|
||||
Object *obedit = scene->obedit;
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
if (ob == obedit) {
|
||||
@@ -462,7 +462,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
|
||||
}
|
||||
|
||||
if (vnormals_do || lnormals_do) {
|
||||
struct Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts;
|
||||
struct Gwn_Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts;
|
||||
DRW_cache_mesh_normals_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts);
|
||||
|
||||
if (vnormals_do) {
|
||||
|
||||
@@ -178,7 +178,7 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
/* Get geometry cache */
|
||||
struct Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
|
||||
@@ -178,7 +178,7 @@ static void EDIT_SURFACE_cache_populate(void *vedata, Object *ob)
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
/* Get geometry cache */
|
||||
struct Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
|
||||
@@ -199,7 +199,7 @@ static void EDIT_TEXT_cache_populate(void *vedata, Object *ob)
|
||||
if (ob == obedit) {
|
||||
const Curve *cu = ob->data;
|
||||
/* Get geometry cache */
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
if (cu->flag & CU_FAST) {
|
||||
geom = DRW_cache_text_edge_wire_get(ob);
|
||||
|
||||
@@ -626,7 +626,7 @@ static void DRW_shgroup_empty_image(
|
||||
image_calc_aspect(ob->data, ob->iuser, empty_image_data->image_aspect);
|
||||
|
||||
if (tex) {
|
||||
struct Batch *geom = DRW_cache_image_plane_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_image_plane_get();
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(
|
||||
e_data.object_empty_image_sh, psl->non_meshes, geom);
|
||||
DRW_shgroup_attrib_float(grp, "objectColor", 4);
|
||||
@@ -644,7 +644,7 @@ static void DRW_shgroup_empty_image(
|
||||
}
|
||||
|
||||
{
|
||||
struct Batch *geom = DRW_cache_image_plane_wire_get();
|
||||
struct Gwn_Batch *geom = DRW_cache_image_plane_wire_get();
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(
|
||||
e_data.object_empty_image_wire_sh, psl->non_meshes, geom);
|
||||
DRW_shgroup_attrib_float(grp, "color", 3);
|
||||
@@ -708,7 +708,7 @@ static void OBJECT_cache_init(void *vedata)
|
||||
|
||||
{
|
||||
DRWState state = DRW_STATE_WRITE_COLOR;
|
||||
struct Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
static float alphaOcclu = 0.35f;
|
||||
static float one = 1.0f;
|
||||
static float alpha1 = 5.0f / 6.0f;
|
||||
@@ -787,7 +787,7 @@ static void OBJECT_cache_init(void *vedata)
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND;
|
||||
psl->outlines_resolve = DRW_pass_create("Outlines Resolve Pass", state);
|
||||
|
||||
struct Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_sh, psl->outlines_resolve);
|
||||
DRW_shgroup_uniform_buffer(grp, "outlineBluredColor", &e_data.outlines_blur_tx);
|
||||
@@ -799,7 +799,7 @@ static void OBJECT_cache_init(void *vedata)
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND;
|
||||
psl->grid = DRW_pass_create("Infinite Grid Pass", state);
|
||||
|
||||
struct Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
static float mat[4][4];
|
||||
unit_m4(mat);
|
||||
|
||||
@@ -850,7 +850,7 @@ static void OBJECT_cache_init(void *vedata)
|
||||
|
||||
{
|
||||
/* Non Meshes Pass (Camera, empties, lamps ...) */
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
DRWState state =
|
||||
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
@@ -954,7 +954,7 @@ static void OBJECT_cache_init(void *vedata)
|
||||
/* TODO
|
||||
* for now we create multiple times the same VBO with only lamp center coordinates
|
||||
* but ideally we would only create it once */
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
/* start with buflimit because we don't want stipples */
|
||||
geom = DRW_cache_single_line_get();
|
||||
@@ -1001,7 +1001,7 @@ static void OBJECT_cache_init(void *vedata)
|
||||
{
|
||||
/* -------- STIPPLES ------- */
|
||||
/* TODO port to shader stipple */
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
/* Relationship Lines */
|
||||
stl->g_data->relationship_lines = shgroup_dynlines_uniform_color(psl->non_meshes, ts.colorWire);
|
||||
@@ -1587,7 +1587,7 @@ static void OBJECT_cache_populate_particles(Object *ob,
|
||||
unit_m4(mat);
|
||||
|
||||
if (draw_as != PART_DRAW_PATH) {
|
||||
struct Batch *geom = DRW_cache_particles_get_dots(psys);
|
||||
struct Gwn_Batch *geom = DRW_cache_particles_get_dots(psys);
|
||||
DRWShadingGroup *shgrp = NULL;
|
||||
static int screen_space[2] = {0, 1};
|
||||
static float def_prim_col[3] = {0.5f, 0.5f, 0.5f};
|
||||
@@ -1654,7 +1654,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
||||
if (do_outlines) {
|
||||
Object *obedit = scene->obedit;
|
||||
if (ob != obedit && !((ob == draw_ctx->obact) && (ob->mode & OB_MODE_ALL_PAINT))) {
|
||||
struct Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
theme_id = DRW_object_wire_theme_get(ob, sl, NULL);
|
||||
DRWShadingGroup *shgroup = shgroup_theme_id_to_outline_or(stl, theme_id, NULL);
|
||||
@@ -1672,7 +1672,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
||||
if (me->totpoly == 0) {
|
||||
Object *obedit = scene->obedit;
|
||||
if (ob != obedit) {
|
||||
struct Batch *geom = DRW_cache_mesh_edges_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_mesh_edges_get(ob);
|
||||
if (geom) {
|
||||
if (theme_id == TH_UNDEFINED) {
|
||||
theme_id = DRW_object_wire_theme_get(ob, sl, NULL);
|
||||
@@ -1693,7 +1693,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
Object *obedit = scene->obedit;
|
||||
if (ob != obedit) {
|
||||
struct Batch *geom = DRW_cache_lattice_wire_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob);
|
||||
if (theme_id == TH_UNDEFINED) {
|
||||
theme_id = DRW_object_wire_theme_get(ob, sl, NULL);
|
||||
}
|
||||
@@ -1708,7 +1708,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
Object *obedit = scene->obedit;
|
||||
if (ob != obedit) {
|
||||
struct Batch *geom = DRW_cache_curve_edge_wire_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob);
|
||||
if (theme_id == TH_UNDEFINED) {
|
||||
theme_id = DRW_object_wire_theme_get(ob, sl, NULL);
|
||||
}
|
||||
|
||||
@@ -297,9 +297,9 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
|
||||
|
||||
if (me->mloopuv != NULL) {
|
||||
if (use_material_slots) {
|
||||
struct Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
|
||||
struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
|
||||
if ((me->totcol == 0) || (geom_array == NULL)) {
|
||||
struct Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
|
||||
ok = true;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
|
||||
}
|
||||
}
|
||||
else {
|
||||
struct Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
|
||||
if (geom && stl->g_data->shgroup_image_array[0]) {
|
||||
DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
|
||||
ok = true;
|
||||
@@ -325,14 +325,14 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
struct Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
|
||||
}
|
||||
|
||||
/* Face Mask */
|
||||
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
|
||||
if (use_face_sel) {
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
/* Note: ideally selected faces wouldn't show interior wire. */
|
||||
const bool use_wire = true;
|
||||
geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, use_face_sel);
|
||||
|
||||
@@ -147,7 +147,7 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
|
||||
bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
|
||||
const Mesh *me = ob->data;
|
||||
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
world_light = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_shading") ? 0.5f : 1.0f;
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
|
||||
const Mesh *me = ob->data;
|
||||
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
|
||||
const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
|
||||
struct Batch *geom;
|
||||
struct Gwn_Batch *geom;
|
||||
|
||||
world_light = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_shading") ? 0.5f : 1.0f;
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ static void PARTICLE_cache_populate(void *vedata, Object *ob)
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
/* Get geometry cache */
|
||||
struct Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
|
||||
@@ -142,7 +142,7 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale
|
||||
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
|
||||
float color[3];
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
/* set backdrop drawing color */
|
||||
acf->get_backdrop_color(ac, ale, color);
|
||||
@@ -231,7 +231,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f
|
||||
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
|
||||
float color[3];
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
/* set backdrop drawing color */
|
||||
acf->get_backdrop_color(ac, ale, color);
|
||||
@@ -3862,7 +3862,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
|
||||
/* for F-Curves, draw color-preview of curve behind checkbox */
|
||||
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -3918,7 +3918,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
|
||||
|
||||
/* draw red underline if channel is disabled */
|
||||
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) {
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -3927,7 +3927,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
|
||||
|
||||
glLineWidth(2.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, (float)offset, yminc);
|
||||
immVertex2f(pos, (float)v2d->cur.xmax, yminc);
|
||||
immEnd();
|
||||
@@ -3946,7 +3946,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
|
||||
short draw_sliders = 0;
|
||||
float ymin_ofs = 0.0f;
|
||||
float color[3];
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@
|
||||
static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const bool time)
|
||||
{
|
||||
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned char col[4];
|
||||
float xscale, x, y;
|
||||
char numstr[32] = " t"; /* t is the character to start replacing from */
|
||||
@@ -128,15 +128,15 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
|
||||
|
||||
glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* Draw a light green line to indicate current frame */
|
||||
immUniformThemeColor(TH_CFRAME);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */
|
||||
immVertex2f(pos, x, v2d->cur.ymax);
|
||||
immEnd();
|
||||
@@ -163,8 +163,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
|
||||
@@ -351,8 +351,8 @@ static void draw_marker(
|
||||
if (flag & DRAW_MARKERS_LINES)
|
||||
#endif
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -369,7 +369,7 @@ static void draw_marker(
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, xpos + 0.5f, 12.0f);
|
||||
immVertex2f(pos, xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
|
||||
immEnd();
|
||||
@@ -452,7 +452,7 @@ void ED_markers_draw(const bContext *C, int flag)
|
||||
v2d = UI_view2d_fromcontext(C);
|
||||
|
||||
if (flag & DRAW_MARKERS_MARGIN) {
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
const unsigned char shade[4] = {0, 0, 0, 16};
|
||||
|
||||
@@ -585,7 +585,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
|
||||
copy_v4_v4(unsel_mhcol, unsel_color);
|
||||
unsel_mhcol[3] *= 0.8f;
|
||||
|
||||
unsigned int pos_id = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos_id = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
/* NOTE: the tradeoff for changing colors between each draw is dwarfed by the cost of checking validity */
|
||||
for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) {
|
||||
@@ -618,14 +618,14 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
|
||||
|
||||
if (key_ct > 0) {
|
||||
/* draw keys */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos_id = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int size_id = VertexFormat_add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color_id = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
unsigned int outline_color_id = VertexFormat_add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
|
||||
unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
||||
GPU_enable_program_point_size();
|
||||
immBegin(PRIM_POINTS, key_ct);
|
||||
immBegin(GWN_PRIM_POINTS, key_ct);
|
||||
|
||||
for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
|
||||
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
|
||||
|
||||
@@ -440,7 +440,7 @@ static float sk_clampPointSize(SK_Point *pt, float size)
|
||||
|
||||
static void sk_drawPoint(SK_Point *pt, float size, float color[4])
|
||||
{
|
||||
Batch *batch = NULL;
|
||||
Gwn_Batch *batch = NULL;
|
||||
|
||||
gpuTranslate3fv(pt->p);
|
||||
|
||||
@@ -450,9 +450,9 @@ static void sk_drawPoint(SK_Point *pt, float size, float color[4])
|
||||
|
||||
batch = Batch_get_sphere(0);
|
||||
Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
Batch_Uniform4fv(batch, "color", color);
|
||||
GWN_batch_uniform_4fv(batch, "color", color);
|
||||
|
||||
Batch_draw(batch);
|
||||
GWN_batch_draw(batch);
|
||||
|
||||
gpuPopMatrix();
|
||||
}
|
||||
@@ -462,8 +462,8 @@ static void sk_drawEdge(SK_Point *pt0, SK_Point *pt1, float size, float color[4]
|
||||
float vec1[3], vec2[3] = { 0, 0, 1 }, axis[3];
|
||||
float angle, length;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
sub_v3_v3v3(vec1, pt1->p, pt0->p);
|
||||
length = normalize_v3(vec1);
|
||||
@@ -489,8 +489,8 @@ static void sk_drawNormal(SK_Point *pt, float size, float height)
|
||||
float angle;
|
||||
float color[3] = { 0.0f, 1.0f, 1.0f };
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
gpuPushMatrix();
|
||||
|
||||
|
||||
@@ -471,9 +471,9 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
|
||||
float color[3];
|
||||
UI_GetThemeColor3fv(TH_WIRE, color);
|
||||
|
||||
Batch *sphere = Batch_get_sphere(0);
|
||||
Gwn_Batch *sphere = Batch_get_sphere(0);
|
||||
Batch_set_builtin_program(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
Batch_Uniform3fv(sphere, "color", color);
|
||||
GWN_batch_uniform_3fv(sphere, "color", color);
|
||||
|
||||
/* scale to edit-mode space */
|
||||
gpuPushMatrix();
|
||||
@@ -491,7 +491,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuScaleUniform(radius);
|
||||
Batch_draw(sphere);
|
||||
GWN_batch_draw(sphere);
|
||||
gpuPopMatrix();
|
||||
|
||||
location_prev = selem->location_local;
|
||||
@@ -514,15 +514,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
|
||||
}
|
||||
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
imm_cpack(0x0);
|
||||
immBegin(PRIM_LINE_STRIP, stroke_len);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
|
||||
glLineWidth(3.0f);
|
||||
|
||||
if (v3d->zbuf) {
|
||||
@@ -536,7 +536,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
|
||||
immEnd();
|
||||
|
||||
imm_cpack(0xffffffff);
|
||||
immBegin(PRIM_LINE_STRIP, stroke_len);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
|
||||
glLineWidth(1.0f);
|
||||
|
||||
for (int i = 0; i < stroke_len; i++) {
|
||||
|
||||
@@ -149,14 +149,14 @@ static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, f
|
||||
|
||||
/* draw triangulation data */
|
||||
if (tot_triangles > 0) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
/* Draw all triangles for filling the polygon */
|
||||
immBegin(PRIM_TRIANGLES, tot_triangles * 3);
|
||||
immBegin(GWN_PRIM_TRIS, tot_triangles * 3);
|
||||
/* TODO: use batch instead of immediate mode, to share vertices */
|
||||
|
||||
const tGPspoint *pt;
|
||||
@@ -207,9 +207,9 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
|
||||
return;
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
const tGPspoint *pt = points;
|
||||
|
||||
@@ -217,7 +217,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
|
||||
/* if drawing a single point, draw it larger */
|
||||
glPointSize((float)(thickness + 2) * points->pressure);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
gp_set_tpoint_varying_color(pt, ink, color);
|
||||
immVertex2iv(pos, &pt->x);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
|
||||
/* draw stroke curve */
|
||||
glLineWidth(max_ff(oldpressure * thickness, 1.0));
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
immBeginAtMost(PRIM_LINE_STRIP, totpoints);
|
||||
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints);
|
||||
|
||||
/* TODO: implement this with a geometry shader to draw one continuous tapered stroke */
|
||||
|
||||
@@ -246,7 +246,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
|
||||
draw_points = 0;
|
||||
|
||||
glLineWidth(max_ff(pt->pressure * thickness, 1.0f));
|
||||
immBeginAtMost(PRIM_LINE_STRIP, totpoints - i + 1);
|
||||
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1);
|
||||
|
||||
/* need to roll-back one point to ensure that there are no gaps in the stroke */
|
||||
if (i != 0) {
|
||||
@@ -318,14 +318,14 @@ static void gp_draw_stroke_volumetric_buffer(const tGPspoint *points, int totpoi
|
||||
if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
|
||||
return;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int size = VertexFormat_add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
|
||||
GPU_enable_program_point_size();
|
||||
immBegin(PRIM_POINTS, totpoints);
|
||||
immBegin(GWN_PRIM_POINTS, totpoints);
|
||||
|
||||
const tGPspoint *pt = points;
|
||||
for (int i = 0; i < totpoints; i++, pt++) {
|
||||
@@ -345,14 +345,14 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points, int totpoints
|
||||
int offsx, int offsy, int winx, int winy,
|
||||
const float diff_mat[4][4], const float ink[4])
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int size = VertexFormat_add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
|
||||
GPU_enable_program_point_size();
|
||||
immBegin(PRIM_POINTS, totpoints);
|
||||
immBegin(GWN_PRIM_POINTS, totpoints);
|
||||
|
||||
const bGPDspoint *pt = points;
|
||||
for (int i = 0; i < totpoints; i++, pt++) {
|
||||
@@ -378,14 +378,14 @@ static void gp_draw_stroke_volumetric_3d(
|
||||
const bGPDspoint *points, int totpoints, short thickness,
|
||||
const float ink[4])
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int size = VertexFormat_add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
|
||||
GPU_enable_program_point_size();
|
||||
immBegin(PRIM_POINTS, totpoints);
|
||||
immBegin(GWN_PRIM_POINTS, totpoints);
|
||||
|
||||
const bGPDspoint *pt = points;
|
||||
for (int i = 0; i < totpoints && pt; i++, pt++) {
|
||||
@@ -521,18 +521,18 @@ static void gp_draw_stroke_fill(
|
||||
|
||||
unsigned int pos;
|
||||
if (gps->flag & GP_STROKE_3DSPACE) {
|
||||
pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
else {
|
||||
pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
}
|
||||
|
||||
immUniformColor4fv(color);
|
||||
|
||||
/* Draw all triangles for filling the polygon (cache must be calculated before) */
|
||||
immBegin(PRIM_TRIANGLES, gps->tot_triangles * 3);
|
||||
immBegin(GWN_PRIM_TRIS, gps->tot_triangles * 3);
|
||||
/* TODO: use batch instead of immediate mode, to share vertices */
|
||||
|
||||
bGPDtriangle *stroke_triangle = gps->triangles;
|
||||
@@ -591,8 +591,8 @@ static void gp_draw_stroke_point(
|
||||
float fpt[3];
|
||||
mul_v3_m4v3(fpt, diff_mat, &pt->x);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
if (sflag & GP_STROKE_3DSPACE) {
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
|
||||
@@ -610,7 +610,7 @@ static void gp_draw_stroke_point(
|
||||
/* set point thickness (since there's only one of these) */
|
||||
immUniform1f("size", (float)(thickness + 2) * pt->pressure);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex3fv(pos, fpt);
|
||||
immEnd();
|
||||
|
||||
@@ -633,9 +633,9 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
|
||||
}
|
||||
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
|
||||
|
||||
@@ -643,7 +643,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
|
||||
|
||||
/* draw stroke curve */
|
||||
glLineWidth(max_ff(curpressure * thickness, 1.0f));
|
||||
immBeginAtMost(PRIM_LINE_STRIP, totpoints + cyclic_add);
|
||||
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints + cyclic_add);
|
||||
const bGPDspoint *pt = points;
|
||||
for (int i = 0; i < totpoints; i++, pt++) {
|
||||
gp_set_point_varying_color(pt, ink, color);
|
||||
@@ -664,7 +664,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
|
||||
|
||||
curpressure = pt->pressure;
|
||||
glLineWidth(max_ff(curpressure * thickness, 1.0f));
|
||||
immBeginAtMost(PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
|
||||
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
|
||||
|
||||
/* need to roll-back one point to ensure that there are no gaps in the stroke */
|
||||
if (i != 0) {
|
||||
@@ -732,12 +732,12 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, int totpoints, short thi
|
||||
int i;
|
||||
float fpt[3];
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
immBegin(PRIM_TRIANGLE_STRIP, totpoints * 2 + 4);
|
||||
immBegin(GWN_PRIM_TRI_STRIP, totpoints * 2 + 4);
|
||||
|
||||
/* get x and y coordinates from first point */
|
||||
mul_v3_m4v3(fpt, diff_mat, &points->x);
|
||||
@@ -1166,21 +1166,21 @@ static void gp_draw_strokes_edit(
|
||||
UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, selectColor);
|
||||
selectColor[3] = alpha;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos; /* specified later */
|
||||
unsigned int size = VertexFormat_add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
if (gps->flag & GP_STROKE_3DSPACE) {
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
|
||||
}
|
||||
else {
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR);
|
||||
}
|
||||
|
||||
immBegin(PRIM_POINTS, gps->totpoints);
|
||||
immBegin(GWN_PRIM_POINTS, gps->totpoints);
|
||||
|
||||
/* Draw start and end point differently if enabled stroke direction hint */
|
||||
bool show_direction_hint = (gpd->flag & GP_DATA_SHOW_DIRECTION) && (gps->totpoints > 1);
|
||||
|
||||
@@ -981,8 +981,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda
|
||||
GP_EditBrush_Data *brush = gpsculpt_get_brush(CTX_data_scene(C));
|
||||
|
||||
if (brush) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
@@ -1849,8 +1849,8 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
|
||||
tGPsdata *p = (tGPsdata *)p_ptr;
|
||||
|
||||
if (p->paintmode == GP_PAINTMODE_ERASER) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
const uint shdr_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
@@ -109,7 +109,7 @@ typedef enum eKeyframeShapeDrawOpts {
|
||||
} eKeyframeShapeDrawOpts;
|
||||
|
||||
/* draw simple diamond-shape keyframe */
|
||||
/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(PRIM_POINTS, n), then call this n times */
|
||||
/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(GWN_PRIM_POINTS, n), then call this n times */
|
||||
void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type, short mode, float alpha,
|
||||
unsigned int pos_id, unsigned int size_id, unsigned int color_id, unsigned int outline_color_id);
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float
|
||||
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
|
||||
int a;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
/* mult */
|
||||
for (a = 0; a < 7; a++) {
|
||||
@@ -124,7 +124,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4fv(col);
|
||||
|
||||
immBegin(filled ? PRIM_TRIANGLE_FAN : PRIM_LINE_LOOP, vert_ct);
|
||||
immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_ct);
|
||||
/* start with corner right-bottom */
|
||||
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
|
||||
immVertex2f(pos, maxx - rad, miny);
|
||||
@@ -202,9 +202,9 @@ void UI_draw_roundbox_shade_x(
|
||||
int vert_count = 0;
|
||||
int a;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_F32, 4, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
@@ -226,7 +226,7 @@ void UI_draw_roundbox_shade_x(
|
||||
vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1;
|
||||
vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1;
|
||||
|
||||
immBegin(filled ? PRIM_TRIANGLE_FAN : PRIM_LINE_LOOP, vert_count);
|
||||
immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count);
|
||||
|
||||
/* start with corner right-bottom */
|
||||
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
|
||||
@@ -327,9 +327,9 @@ void UI_draw_roundbox_shade_y(
|
||||
mul_v2_fl(vec[a], rad);
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_F32, 4, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
@@ -347,7 +347,7 @@ void UI_draw_roundbox_shade_y(
|
||||
vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1;
|
||||
vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1;
|
||||
|
||||
immBegin(filled ? PRIM_TRIANGLE_FAN : PRIM_LINE_LOOP, vert_count);
|
||||
immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count);
|
||||
|
||||
/* start with corner right-bottom */
|
||||
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
|
||||
@@ -430,8 +430,8 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo
|
||||
{
|
||||
int ofs_y = 4 * U.pixelsize;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4fv(color);
|
||||
@@ -445,9 +445,9 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo
|
||||
/* based on UI_draw_roundbox_gl_mode, check on making a version which allows us to skip some sides */
|
||||
void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highlight[3], unsigned char highlight_fade[3])
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int col = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
/* add a 1px offset, looks nicer */
|
||||
const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - U.pixelsize;
|
||||
const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize;
|
||||
@@ -466,7 +466,7 @@ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highligh
|
||||
}
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
immBeginAtMost(PRIM_LINE_STRIP, 25);
|
||||
immBeginAtMost(GWN_PRIM_LINE_STRIP, 25);
|
||||
|
||||
immAttrib3ubv(col, highlight);
|
||||
|
||||
@@ -579,8 +579,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
|
||||
*
|
||||
* \Note This functionn is to be used with the 2D dashed shader enabled.
|
||||
*
|
||||
* \param pos is a PRIM_FLOAT, 2, KEEP_FLOAT vertex attrib
|
||||
* \param line_origin is a PRIM_FLOAT, 2, KEEP_FLOAT vertex attrib
|
||||
* \param pos is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib
|
||||
* \param line_origin is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib
|
||||
*
|
||||
* The next 4 parameters are the offsets for the view, not the zones.
|
||||
*/
|
||||
@@ -643,7 +643,7 @@ static void histogram_draw_one(
|
||||
/* curve outline */
|
||||
glLineWidth(1.5);
|
||||
|
||||
immBegin(PRIM_LINE_STRIP, res);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, res);
|
||||
for (int i = 0; i < res; i++) {
|
||||
float x2 = x + i * (w / (float)res);
|
||||
immVertex2f(pos_attrib, x2, y + (data[i] * h));
|
||||
@@ -652,7 +652,7 @@ static void histogram_draw_one(
|
||||
}
|
||||
else {
|
||||
/* under the curve */
|
||||
immBegin(PRIM_TRIANGLE_STRIP, res * 2);
|
||||
immBegin(GWN_PRIM_TRI_STRIP, res * 2);
|
||||
immVertex2f(pos_attrib, x, y);
|
||||
immVertex2f(pos_attrib, x, y + (data[0] * h));
|
||||
for (int i = 1; i < res; i++) {
|
||||
@@ -666,7 +666,7 @@ static void histogram_draw_one(
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
immBegin(PRIM_LINE_STRIP, res);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, res);
|
||||
for (int i = 0; i < res; i++) {
|
||||
float x2 = x + i * (w / (float)res);
|
||||
immVertex2f(pos_attrib, x2, y + (data[i] * h));
|
||||
@@ -711,8 +711,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
||||
(rect.xmax + 1) - (rect.xmin - 1),
|
||||
(rect.ymax + 1) - (rect.ymin - 1));
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -726,7 +726,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
}
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
|
||||
immVertex2f(pos, rect.xmin, rect.ymin + fac * h);
|
||||
immVertex2f(pos, rect.xmax, rect.ymin + fac * h);
|
||||
@@ -762,21 +762,21 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
||||
|
||||
static void waveform_draw_one(float *waveform, int nbr, const float col[3])
|
||||
{
|
||||
VertexFormat format = {0};
|
||||
unsigned int pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat format = {0};
|
||||
unsigned int pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(vbo, nbr);
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, nbr);
|
||||
|
||||
VertexBuffer_fill_attrib(vbo, pos_id, waveform);
|
||||
GWN_vertbuf_attr_fill(vbo, pos_id, waveform);
|
||||
|
||||
/* TODO store the Batch inside the scope */
|
||||
Batch *batch = Batch_create(PRIM_POINTS, vbo, NULL);
|
||||
/* TODO store the Gwn_Batch inside the scope */
|
||||
Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL);
|
||||
Batch_set_builtin_program(batch, GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
Batch_Uniform4f(batch, "color", col[0], col[1], col[2], 1.0f);
|
||||
Batch_draw(batch);
|
||||
GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f);
|
||||
GWN_batch_draw(batch);
|
||||
|
||||
Batch_discard_all(batch);
|
||||
GWN_batch_discard_all(batch);
|
||||
}
|
||||
|
||||
void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
|
||||
@@ -843,15 +843,15 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
|
||||
|
||||
/* draw grid lines here */
|
||||
immBegin(PRIM_LINES, 12);
|
||||
immBegin(GWN_PRIM_LINES, 12);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
immVertex2f(pos, rect.xmin + 22, yofs + (i * 0.2f) * h);
|
||||
@@ -862,7 +862,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
|
||||
/* 3 vertical separation */
|
||||
if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
|
||||
for (int i = 1; i < 3; i++) {
|
||||
immVertex2f(pos, rect.xmin + i * w3, rect.ymin);
|
||||
@@ -873,7 +873,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
}
|
||||
|
||||
/* separate min max zone on the right */
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, rect.xmin + w, rect.ymin);
|
||||
immVertex2f(pos, rect.xmin + w, rect.ymax);
|
||||
immEnd();
|
||||
@@ -881,7 +881,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
/* 16-235-240 level in case of ITU-R BT601/709 */
|
||||
immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f);
|
||||
if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) {
|
||||
immBegin(PRIM_LINES, 8);
|
||||
immBegin(GWN_PRIM_LINES, 8);
|
||||
|
||||
immVertex2f(pos, rect.xmin + 22, yofs + h * 16.0f / 255.0f);
|
||||
immVertex2f(pos, rect.xmax + 1, yofs + h * 16.0f / 255.0f);
|
||||
@@ -899,7 +899,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
}
|
||||
/* 7.5 IRE black point level for NTSC */
|
||||
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, rect.xmin, yofs + h * 0.075f);
|
||||
immVertex2f(pos, rect.xmax + 1, yofs + h * 0.075f);
|
||||
immEnd();
|
||||
@@ -928,7 +928,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
CLAMP(min, rect.ymin, rect.ymax);
|
||||
CLAMP(max, rect.ymin, rect.ymax);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, rect.xmax - 3, min);
|
||||
immVertex2f(pos, rect.xmax - 3, max);
|
||||
immEnd();
|
||||
@@ -982,7 +982,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
||||
CLAMP(min, rect.ymin, rect.ymax);
|
||||
CLAMP(max, rect.ymin, rect.ymax);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, rect.xmin + w + 2 + c * 2, min);
|
||||
immVertex2f(pos, rect.xmin + w + 2 + c * 2, max);
|
||||
immEnd();
|
||||
@@ -1026,7 +1026,7 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.12f);
|
||||
dangle = DEG2RADF(2.5f);
|
||||
dampli = 2.5f / 200.0f;
|
||||
immBegin(PRIM_LINE_LOOP, 4);
|
||||
immBegin(GWN_PRIM_LINE_LOOP, 4);
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
|
||||
@@ -1038,22 +1038,22 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente
|
||||
dampli = 0.2f * tampli;
|
||||
dangle2 = DEG2RADF(5.0f);
|
||||
dampli2 = 0.5f * dampli;
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2));
|
||||
immEnd();
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2));
|
||||
immEnd();
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2));
|
||||
immEnd();
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2));
|
||||
@@ -1100,15 +1100,15 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
||||
(rect.xmax + 1) - (rect.xmin - 1),
|
||||
(rect.ymax + 1) - (rect.ymin - 1));
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
|
||||
/* draw grid elements */
|
||||
/* cross */
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
|
||||
immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery);
|
||||
immVertex2f(pos, centerx + (diam * 0.5f) + 5, centery);
|
||||
@@ -1121,7 +1121,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
||||
/* circles */
|
||||
for (int j = 0; j < 5; j++) {
|
||||
const int increment = 15;
|
||||
immBegin(PRIM_LINE_LOOP, (int)(360 / increment));
|
||||
immBegin(GWN_PRIM_LINE_LOOP, (int)(360 / increment));
|
||||
for (int i = 0; i <= 360 - increment; i += increment) {
|
||||
const float a = DEG2RADF((float)i);
|
||||
const float r = (j + 1) * 0.1f;
|
||||
@@ -1132,7 +1132,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
||||
/* skin tone line */
|
||||
immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5f, skin_rad));
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1f, skin_rad));
|
||||
immEnd();
|
||||
@@ -1169,7 +1169,7 @@ static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, floa
|
||||
{
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, x1 + halfwidth, y1);
|
||||
immVertex2f(pos, x1, y1 + height);
|
||||
immVertex2f(pos, x1 - halfwidth, y1);
|
||||
@@ -1182,7 +1182,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f
|
||||
{
|
||||
glEnable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH);
|
||||
|
||||
immBegin(fill ? PRIM_TRIANGLES : PRIM_LINE_LOOP, 3);
|
||||
immBegin(fill ? GWN_PRIM_TRIS : GWN_PRIM_LINE_LOOP, 3);
|
||||
immVertex2f(pos, x1 + halfwidth, y1);
|
||||
immVertex2f(pos, x1, y1 + height);
|
||||
immVertex2f(pos, x1 - halfwidth, y1);
|
||||
@@ -1193,7 +1193,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f
|
||||
|
||||
static void ui_draw_colorband_handle_box(unsigned int pos, float x1, float y1, float x2, float y2, bool fill)
|
||||
{
|
||||
immBegin(fill ? PRIM_TRIANGLE_FAN : PRIM_LINE_LOOP, 4);
|
||||
immBegin(fill ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4);
|
||||
immVertex2f(pos, x1, y1);
|
||||
immVertex2f(pos, x1, y2);
|
||||
immVertex2f(pos, x2, y2);
|
||||
@@ -1233,7 +1233,7 @@ static void ui_draw_colorband_handle(
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", active ? 4.0f : 2.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(shdr_pos, x, y1);
|
||||
immVertex2f(shdr_pos, x, y2);
|
||||
immEnd();
|
||||
@@ -1304,8 +1304,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
float sizey_solid = sizey * 0.25f;
|
||||
float y1 = rect->ymin;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
position = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
|
||||
|
||||
/* Drawing the checkerboard. */
|
||||
@@ -1317,8 +1317,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
|
||||
/* New format */
|
||||
format = immVertexFormat();
|
||||
position = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
color = VertexFormat_add_attrib(format, "color", COMP_F32, 4, KEEP_FLOAT);
|
||||
position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
/* layer: color ramp */
|
||||
@@ -1332,7 +1332,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
v1[1] = y1 + sizey_solid;
|
||||
v2[1] = rect->ymax;
|
||||
|
||||
immBegin(PRIM_TRIANGLE_STRIP, (sizex + 1) * 2);
|
||||
immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2);
|
||||
for (int a = 0; a <= sizex; a++) {
|
||||
float pos = ((float)a) / sizex;
|
||||
do_colorband(coba, pos, colf);
|
||||
@@ -1351,7 +1351,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
v1[1] = y1;
|
||||
v2[1] = y1 + sizey_solid;
|
||||
|
||||
immBegin(PRIM_TRIANGLE_STRIP, (sizex + 1) * 2);
|
||||
immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2);
|
||||
for (int a = 0; a <= sizex; a++) {
|
||||
float pos = ((float)a) / sizex;
|
||||
do_colorband(coba, pos, colf);
|
||||
@@ -1372,7 +1372,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
|
||||
/* New format */
|
||||
format = immVertexFormat();
|
||||
position = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* layer: box outline */
|
||||
@@ -1383,14 +1383,14 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
glEnable(GL_BLEND);
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(position, x1, y1);
|
||||
immVertex2f(position, x1 + sizex, y1);
|
||||
immEnd();
|
||||
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(position, x1, y1 - 1);
|
||||
immVertex2f(position, x1 + sizex, y1 - 1);
|
||||
immEnd();
|
||||
@@ -1443,18 +1443,18 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
||||
gpuTranslate2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect));
|
||||
gpuScaleUniform(size);
|
||||
|
||||
Batch *sphere = Batch_get_sphere(2);
|
||||
Gwn_Batch *sphere = Batch_get_sphere(2);
|
||||
Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING);
|
||||
Batch_Uniform4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f);
|
||||
Batch_Uniform3fv(sphere, "light", light);
|
||||
Batch_draw(sphere);
|
||||
GWN_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f);
|
||||
GWN_batch_uniform_3fv(sphere, "light", light);
|
||||
GWN_batch_draw(sphere);
|
||||
|
||||
/* restore */
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
/* AA circle */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor3ubv((unsigned char *)wcol->inner);
|
||||
|
||||
@@ -1483,7 +1483,7 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo
|
||||
float line_count = floorf((rect->xmax - fx) / dx) + 1.0f +
|
||||
floorf((rect->ymax - fy) / dy) + 1.0f;
|
||||
|
||||
immBegin(PRIM_LINES, (int)line_count * 2);
|
||||
immBegin(GWN_PRIM_LINES, (int)line_count * 2);
|
||||
while (fx < rect->xmax) {
|
||||
immVertex2f(pos, fx, rect->ymin);
|
||||
immVertex2f(pos, fx, rect->ymax);
|
||||
@@ -1556,8 +1556,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* backdrop */
|
||||
@@ -1592,7 +1592,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f);
|
||||
/* axes */
|
||||
gl_shaded_color((unsigned char *)wcol->inner, -50);
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (-offsy));
|
||||
immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (-offsy));
|
||||
immVertex2f(pos, rect->xmin + zoomx * (-offsx), rect->ymin);
|
||||
@@ -1605,7 +1605,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
#if 0
|
||||
if (cumap->flag & CUMA_DRAW_CFRA) {
|
||||
immUniformColor3ub(0x60, 0xc0, 0x40);
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin);
|
||||
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax);
|
||||
immEnd();
|
||||
@@ -1614,7 +1614,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
/* sample option */
|
||||
|
||||
if (cumap->flag & CUMA_DRAW_SAMPLE) {
|
||||
immBegin(PRIM_LINES, 2); /* will draw one of the following 3 lines */
|
||||
immBegin(GWN_PRIM_LINES, 2); /* will draw one of the following 3 lines */
|
||||
if (but->a1 == UI_GRAD_H) {
|
||||
float tsample[3];
|
||||
float hsv[3];
|
||||
@@ -1650,7 +1650,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
immUniformColor3ubv((unsigned char *)wcol->item);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
immBegin(PRIM_LINE_STRIP, (CM_TABLE+1) + 2);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE+1) + 2);
|
||||
|
||||
if (cuma->table == NULL)
|
||||
curvemapping_changed(cumap, false);
|
||||
@@ -1687,13 +1687,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
|
||||
/* the points, use aspect to make them visible on edges */
|
||||
format = immVertexFormat();
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int col = VertexFormat_add_attrib(format, "color", COMP_F32, 4, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
|
||||
cmp = cuma->curve;
|
||||
glPointSize(3.0f);
|
||||
immBegin(PRIM_POINTS, cuma->totpoint);
|
||||
immBegin(GWN_PRIM_POINTS, cuma->totpoint);
|
||||
for (int a = 0; a < cuma->totpoint; a++) {
|
||||
float color[4];
|
||||
if (cmp[a].flag & CUMA_SELECT)
|
||||
@@ -1713,7 +1713,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
||||
|
||||
/* outline */
|
||||
format = immVertexFormat();
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor3ubv((unsigned char *)wcol->outline);
|
||||
@@ -1803,16 +1803,16 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
||||
BLI_rctf_size_x(&rect),
|
||||
BLI_rctf_size_y(&rect));
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int col = VertexFormat_add_attrib(format, "color", COMP_F32, 4, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
|
||||
UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel);
|
||||
UI_GetThemeColor4fv(TH_MARKER_OUTLINE, col_outline);
|
||||
|
||||
/* Do stipple cross with geometry */
|
||||
immBegin(PRIM_LINES, 7*2*2);
|
||||
immBegin(GWN_PRIM_LINES, 7*2*2);
|
||||
float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f};
|
||||
for (int axe = 0; axe < 2; ++axe) {
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
@@ -1892,13 +1892,13 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
||||
float x = 0.5f * (recti->xmin + recti->xmax);
|
||||
float y = 0.5f * (recti->ymin + recti->ymax);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ubv(but->col);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 16);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 16);
|
||||
for (int a = 0; a < 16; a++)
|
||||
immVertex2f(pos, x + size * si[a], y + size * co[a]);
|
||||
immEnd();
|
||||
@@ -1906,7 +1906,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
||||
immUniformColor4ub(0, 0, 0, 150);
|
||||
glLineWidth(1);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
immBegin(PRIM_LINE_LOOP, 16);
|
||||
immBegin(GWN_PRIM_LINE_LOOP, 16);
|
||||
for (int a = 0; a < 16; a++)
|
||||
immVertex2f(pos, x + size * si[a], y + size * co[a]);
|
||||
immEnd();
|
||||
@@ -1989,13 +1989,13 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
immBegin(PRIM_TRIANGLES, 54);
|
||||
immBegin(GWN_PRIM_TRIS, 54);
|
||||
|
||||
/* accumulated outline boxes to make shade not linear, is more pleasant */
|
||||
ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
|
||||
|
||||
@@ -223,11 +223,11 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float
|
||||
viconutil_set_point(pts[1], cx - d2, cy - d);
|
||||
viconutil_set_point(pts[2], cx + d2, cy);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4f(0.2f, 0.2f, 0.2f, alpha);
|
||||
|
||||
immBegin(PRIM_TRIANGLES, 3);
|
||||
immBegin(GWN_PRIM_TRIS, 3);
|
||||
immVertex2iv(pos, pts[0]);
|
||||
immVertex2iv(pos, pts[1]);
|
||||
immVertex2iv(pos, pts[2]);
|
||||
@@ -253,15 +253,15 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha,
|
||||
int xco = x + w / 2;
|
||||
int yco = y + h / 2;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos_id = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int size_id = VertexFormat_add_attrib(format, "size", COMP_F32, 1, KEEP_FLOAT);
|
||||
unsigned int color_id = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
unsigned int outline_color_id = VertexFormat_add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
|
||||
unsigned int color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
unsigned int outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
||||
GPU_enable_program_point_size();
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
|
||||
/* draw keyframe
|
||||
* - size: 0.6 * h (found out experimentally... dunno why!)
|
||||
@@ -316,7 +316,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU
|
||||
const int b = x + w / 3 * 2;
|
||||
const int c = x + w;
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* XXX: Include alpha into this... */
|
||||
@@ -1025,9 +1025,9 @@ static void icon_draw_texture(
|
||||
y2 = (iy + ih) * icongltex.invh;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, icongltex.id);
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int texCoord = VertexFormat_add_attrib(format, "texCoord", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
if (rgb) immUniformColor3fvAlpha(rgb, alpha);
|
||||
@@ -1035,7 +1035,7 @@ static void icon_draw_texture(
|
||||
|
||||
immUniform1i("image", 0);
|
||||
|
||||
immBegin(PRIM_TRIANGLE_STRIP, 4);
|
||||
immBegin(GWN_PRIM_TRI_STRIP, 4);
|
||||
immAttrib2f(texCoord, x1, y2);
|
||||
immVertex2f(pos, x, y + h);
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float
|
||||
|
||||
glLineWidth(2.0);
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
|
||||
immVertex2f(pos, x1, y1);
|
||||
immVertex2f(pos, x2, y2);
|
||||
@@ -477,7 +477,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect)
|
||||
glEnable(GL_BLEND);
|
||||
immUniformColor4ub(255, 255, 255, 50);
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
|
||||
immVertex2f(pos, xmin, ymin);
|
||||
immVertex2f(pos, xmax, ymax);
|
||||
@@ -489,7 +489,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect)
|
||||
|
||||
immUniformColor4ub(0, 0, 0, 50);
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
|
||||
immVertex2f(pos, xmin, ymin + 1);
|
||||
immVertex2f(pos, xmax, ymax + 1);
|
||||
@@ -591,7 +591,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
|
||||
headrect.ymin = headrect.ymax;
|
||||
headrect.ymax = headrect.ymin + floor(PNL_HEADER / block->aspect + 0.001f);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
{
|
||||
@@ -606,7 +606,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
|
||||
immUniformThemeColor(TH_PANEL_HEADER);
|
||||
immRectf(pos, minx, headrect.ymin + 1, maxx, y);
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
|
||||
immVertex2f(pos, minx, y);
|
||||
immVertex2f(pos, maxx, y);
|
||||
@@ -626,14 +626,14 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
|
||||
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, minx, y);
|
||||
immVertex2f(pos, maxx, y);
|
||||
immEnd();
|
||||
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, minx, y - 1);
|
||||
immVertex2f(pos, maxx, y - 1);
|
||||
immEnd();
|
||||
@@ -663,7 +663,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
|
||||
/* horizontal title */
|
||||
if (is_closed_x == false) {
|
||||
ui_draw_aligned_panel_header(style, block, &headrect, 'h');
|
||||
pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
/* itemrect smaller */
|
||||
itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
|
||||
@@ -686,7 +686,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
|
||||
else if (is_closed_x) {
|
||||
/* draw vertical title */
|
||||
ui_draw_aligned_panel_header(style, block, &headrect, 'v');
|
||||
pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
}
|
||||
/* an open panel */
|
||||
else {
|
||||
@@ -1568,9 +1568,9 @@ static void ui_panel_category_draw_tab(
|
||||
{0.98, 0.805}};
|
||||
int a;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
/* mult */
|
||||
for (a = 0; a < 4; a++) {
|
||||
@@ -1592,7 +1592,7 @@ static void ui_panel_category_draw_tab(
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
immBegin(filled ? PRIM_TRIANGLE_FAN : PRIM_LINE_STRIP, vert_ct);
|
||||
immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_STRIP, vert_ct);
|
||||
|
||||
immAttrib3ubv(color, col);
|
||||
|
||||
@@ -1780,7 +1780,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
|
||||
/* begin drawing */
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* draw the background */
|
||||
@@ -1839,7 +1839,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
|
||||
|
||||
/* tab blackline */
|
||||
if (!is_active) {
|
||||
pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor3ubv(theme_col_tab_divider);
|
||||
@@ -1869,7 +1869,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* tab blackline remaining (last tab) */
|
||||
pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
if (pc_dyn->prev == NULL) {
|
||||
immUniformColor3ubv(theme_col_tab_divider);
|
||||
|
||||
@@ -197,11 +197,11 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4fv(draw_color);
|
||||
immBegin(PRIM_TRIANGLES, 3 * WIDGET_AA_JITTER);
|
||||
immBegin(GWN_PRIM_TRIS, 3 * WIDGET_AA_JITTER);
|
||||
|
||||
/* for each AA step */
|
||||
for (int j = 0; j < WIDGET_AA_JITTER; j++) {
|
||||
@@ -549,7 +549,7 @@ static void widget_scroll_circle(uiWidgetTrias *tria, const rcti *rect, float tr
|
||||
|
||||
static void widget_trias_draw(uiWidgetTrias *tria, unsigned int pos)
|
||||
{
|
||||
immBegin(PRIM_TRIANGLES, tria->tot * 3);
|
||||
immBegin(GWN_PRIM_TRIS, tria->tot * 3);
|
||||
for (int i = 0; i < tria->tot; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
immVertex2fv(pos, tria->vec[tria->index[i][j]]);
|
||||
@@ -677,7 +677,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
float inner_v_half[WIDGET_SIZE_MAX][2];
|
||||
float x_mid = 0.0f; /* used for dumb clamping of values */
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
|
||||
|
||||
/* checkers */
|
||||
@@ -716,7 +716,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
}
|
||||
else {
|
||||
/* simple fill */
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ubv((unsigned char *)wcol->inner);
|
||||
|
||||
@@ -730,9 +730,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
unsigned char col_array[WIDGET_SIZE_MAX][4];
|
||||
unsigned char *col_pt = &col_array[0][0];
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int col = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
@@ -765,7 +765,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
UI_GetThemeColor4ubv(TH_WIDGET_EMBOSS, emboss);
|
||||
}
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
for (j = 0; j < WIDGET_AA_JITTER; j++) {
|
||||
@@ -796,7 +796,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
wcol->item[2],
|
||||
(unsigned char)((float)wcol->item[3] / WIDGET_AA_JITTER)};
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ubv(tcol);
|
||||
|
||||
@@ -1384,7 +1384,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
|
||||
selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4ubv((unsigned char *)wcol->item);
|
||||
@@ -1416,7 +1416,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
t = 0;
|
||||
}
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor3f(0.2f, 0.6f, 0.9f);
|
||||
@@ -2214,7 +2214,7 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
|
||||
/* we draw a number of increasing size alpha quad strips */
|
||||
alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout;
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -2267,7 +2267,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
|
||||
|
||||
static void ui_hsv_cursor(float x, float y)
|
||||
{
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -2362,13 +2362,13 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
|
||||
|
||||
ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, tot + 2);
|
||||
immBegin(GWN_PRIM_TRI_FAN, tot + 2);
|
||||
immAttrib3fv(color, colcent);
|
||||
immVertex2f(pos, centx, centy);
|
||||
|
||||
@@ -2389,7 +2389,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
|
||||
|
||||
/* fully rounded outline */
|
||||
format = immVertexFormat();
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -2473,12 +2473,12 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
|
||||
}
|
||||
|
||||
/* old below */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int col = VertexFormat_add_attrib(format, "color", COMP_F32, 4, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
immBegin(PRIM_TRIANGLES, steps * 3 * 6);
|
||||
immBegin(GWN_PRIM_TRIS, steps * 3 * 6);
|
||||
for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */
|
||||
const float dx_next = dx + color_step;
|
||||
|
||||
@@ -2634,7 +2634,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
|
||||
ui_hsv_cursor(x, y);
|
||||
|
||||
/* outline */
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor3ub(0, 0, 0);
|
||||
imm_draw_line_box(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
|
||||
@@ -2707,14 +2707,14 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol)
|
||||
30
|
||||
};
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
immUniformColor4ubv(col);
|
||||
glLineWidth(1.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, rect->xmin, y);
|
||||
immVertex2f(pos, rect->xmax, y);
|
||||
immEnd();
|
||||
@@ -2798,7 +2798,7 @@ void ui_draw_link_bezier(const rcti *rect, const float color[4])
|
||||
float coord_array[LINK_RESOL + 1][2];
|
||||
|
||||
if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) {
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
#if 0 /* unused */
|
||||
@@ -2810,7 +2810,7 @@ void ui_draw_link_bezier(const rcti *rect, const float color[4])
|
||||
|
||||
immUniformColor4fv(color);
|
||||
|
||||
immBegin(PRIM_LINE_STRIP, LINK_RESOL + 1);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, LINK_RESOL + 1);
|
||||
for (int i = 0; i <= LINK_RESOL; ++i)
|
||||
immVertex2fv(pos, coord_array[i]);
|
||||
immEnd();
|
||||
@@ -3162,11 +3162,11 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
|
||||
|
||||
bw += (bw < 0.5f) ? 0.5f : -0.5f;
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor3f(bw, bw, bw);
|
||||
immBegin(PRIM_TRIANGLES, 3);
|
||||
immBegin(GWN_PRIM_TRIS, 3);
|
||||
immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.9f * height);
|
||||
immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.5f * height);
|
||||
immVertex2f(pos, rect->xmin + 0.5f * width, rect->ymin + 0.9f * height);
|
||||
@@ -3521,7 +3521,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
|
||||
/* note: drawextra can change rect +1 or -1, to match round errors of existing previews */
|
||||
but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* make mask to draw over image */
|
||||
@@ -4083,10 +4083,10 @@ static void draw_disk_shaded(
|
||||
unsigned char r_col[4];
|
||||
unsigned int pos, col;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
if (shaded) {
|
||||
col = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
}
|
||||
else {
|
||||
@@ -4094,7 +4094,7 @@ static void draw_disk_shaded(
|
||||
immUniformColor4ubv((unsigned char *)col1);
|
||||
}
|
||||
|
||||
immBegin(PRIM_TRIANGLE_STRIP, subd * 2);
|
||||
immBegin(GWN_PRIM_TRI_STRIP, subd * 2);
|
||||
for (i = 0; i < subd; i++) {
|
||||
float a;
|
||||
|
||||
@@ -4163,8 +4163,8 @@ void ui_draw_pie_center(uiBlock *block)
|
||||
}
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ubv((unsigned char *)btheme->tui.wcol_pie_menu.outline);
|
||||
|
||||
|
||||
@@ -1325,12 +1325,12 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
|
||||
if (vertex_count == 0)
|
||||
return;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
immBegin(PRIM_LINES, vertex_count);
|
||||
immBegin(GWN_PRIM_LINES, vertex_count);
|
||||
|
||||
/* vertical lines */
|
||||
if (flag & V2D_VERTICAL_LINES) {
|
||||
@@ -1467,15 +1467,15 @@ void UI_view2d_constant_grid_draw(View2D *v2d)
|
||||
count_y = (v2d->cur.ymax - start_y) / step + 1;
|
||||
|
||||
if (count_x > 0 || count_y > 0) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
float theme_color[3];
|
||||
|
||||
UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
immBegin(PRIM_LINES, count_x * 2 + count_y * 2 + 4);
|
||||
immBegin(GWN_PRIM_LINES, count_x * 2 + count_y * 2 + 4);
|
||||
|
||||
immAttrib3fv(color, theme_color);
|
||||
for (int i = 0; i < count_x ; start_x += step, i++) {
|
||||
@@ -1518,14 +1518,14 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
|
||||
vertex_count += 2 * ((int)((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1);
|
||||
vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
immBeginAtMost(PRIM_LINES, vertex_count);
|
||||
immBeginAtMost(GWN_PRIM_LINES, vertex_count);
|
||||
|
||||
for (int level = 0; level < totlevels; ++level) {
|
||||
UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color);
|
||||
@@ -1839,8 +1839,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
|
||||
/* clean rect behind slider, but not with transparent background */
|
||||
if (scrollers_back_color[3] == 255) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -1946,8 +1946,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
|
||||
/* clean rect behind slider, but not with transparent background */
|
||||
if (scrollers_back_color[3] == 255) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float matrix[4][4
|
||||
const float len = arrow->line_len;
|
||||
const float draw_line_ofs = (arrow->manipulator.line_width * 0.5f) / arrow->manipulator.scale;
|
||||
|
||||
uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix(matrix);
|
||||
@@ -90,12 +90,12 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float matrix[4][4
|
||||
|
||||
immUniformColor4fv(color);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, 0.0f, 0.0f);
|
||||
immVertex2f(pos, 0.0f, len);
|
||||
immEnd();
|
||||
|
||||
immBegin(PRIM_TRIANGLES, 3);
|
||||
immBegin(GWN_PRIM_TRIS, 3);
|
||||
immVertex2f(pos, size_h, len);
|
||||
immVertex2f(pos, -size_h, len);
|
||||
immVertex2f(pos, 0.0f, len + size * 1.7f);
|
||||
|
||||
@@ -101,7 +101,7 @@ static void manipulator_arrow_matrix_world_get(wmManipulator *mpr, float r_matri
|
||||
|
||||
static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float color[4])
|
||||
{
|
||||
uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
bool unbind_shader = true;
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
@@ -109,7 +109,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
|
||||
if (arrow->style & ED_MANIPULATOR_ARROW_STYLE_CROSS) {
|
||||
immUniformColor4fv(color);
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
immVertex3f(pos, -1.0f, 0.0f, 0.0f);
|
||||
immVertex3f(pos, 1.0f, 0.0f, 0.0f);
|
||||
immVertex3f(pos, 0.0f, -1.0f, 0.0f);
|
||||
@@ -127,7 +127,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
|
||||
};
|
||||
|
||||
glLineWidth(arrow->manipulator.line_width);
|
||||
wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, PRIM_LINE_LOOP);
|
||||
wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP);
|
||||
}
|
||||
else {
|
||||
#ifdef USE_MANIPULATOR_CUSTOM_ARROWS
|
||||
@@ -140,7 +140,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
|
||||
};
|
||||
|
||||
glLineWidth(arrow->manipulator.line_width);
|
||||
wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, PRIM_LINE_STRIP);
|
||||
wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP);
|
||||
|
||||
|
||||
/* *** draw arrow head *** */
|
||||
|
||||
@@ -86,12 +86,12 @@ typedef struct Cage2D {
|
||||
static void rect_transform_draw_corners(
|
||||
const rctf *r, const float offsetx, const float offsety, const float color[3])
|
||||
{
|
||||
uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor3fv(color);
|
||||
|
||||
immBegin(PRIM_LINES, 16);
|
||||
immBegin(GWN_PRIM_LINES, 16);
|
||||
|
||||
immVertex2f(pos, r->xmin, r->ymin + offsety);
|
||||
immVertex2f(pos, r->xmin, r->ymin);
|
||||
@@ -175,14 +175,14 @@ static void rect_transform_draw_interaction(
|
||||
return;
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint color = VertexFormat_add_attrib(format, "color", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
|
||||
glLineWidth(line_width + 3.0);
|
||||
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immAttrib3f(color, 0.0f, 0.0f, 0.0f);
|
||||
immVertex2fv(pos, verts[0]);
|
||||
immVertex2fv(pos, verts[1]);
|
||||
@@ -191,7 +191,7 @@ static void rect_transform_draw_interaction(
|
||||
|
||||
glLineWidth(line_width);
|
||||
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immAttrib3fv(color, col);
|
||||
immVertex2fv(pos, verts[0]);
|
||||
immVertex2fv(pos, verts[1]);
|
||||
|
||||
@@ -130,8 +130,8 @@ static void dial_geom_draw(
|
||||
|
||||
glLineWidth(dial->manipulator.line_width);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
if (clip_plane) {
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR);
|
||||
@@ -168,13 +168,13 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[
|
||||
gpuPushMatrix();
|
||||
gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f);
|
||||
|
||||
uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4fv(col);
|
||||
|
||||
immBegin(PRIM_LINE_STRIP, 2);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 2);
|
||||
immVertex3f(pos, 0.0f, 0.0f, 0.0f);
|
||||
immVertex3fv(pos, co_outer);
|
||||
immEnd();
|
||||
@@ -189,8 +189,8 @@ static void dial_ghostarc_draw(
|
||||
{
|
||||
const float width_inner = DIAL_WIDTH - dial->manipulator.line_width * 0.5f / U.manipulator_size;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformColor4fv(color);
|
||||
imm_draw_disk_partial_fill(
|
||||
|
||||
@@ -96,8 +96,8 @@ static void grab_geom_draw(
|
||||
|
||||
glLineWidth(grab3d->manipulator.line_width);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
|
||||
@@ -64,52 +64,52 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo
|
||||
* So we don't need to re-created and discard it every time */
|
||||
|
||||
const bool use_lighting = true || (!select && ((U.manipulator_flag & USER_MANIPULATOR_SHADED) != 0));
|
||||
VertexBuffer *vbo;
|
||||
ElementList *el;
|
||||
Batch *batch;
|
||||
ElementListBuilder elb = {0};
|
||||
Gwn_VertBuf *vbo;
|
||||
Gwn_IndexBuf *el;
|
||||
Gwn_Batch *batch;
|
||||
Gwn_IndexBufBuilder elb = {0};
|
||||
|
||||
VertexFormat format = {0};
|
||||
uint pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
Gwn_VertFormat format = {0};
|
||||
uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
uint nor_id;
|
||||
|
||||
if (use_lighting) {
|
||||
nor_id = VertexFormat_add_attrib(&format, "nor", COMP_I16, 3, NORMALIZE_INT_TO_FLOAT);
|
||||
nor_id = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
}
|
||||
|
||||
/* Elements */
|
||||
ElementListBuilder_init(&elb, PRIM_TRIANGLES, info->ntris, info->nverts);
|
||||
GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, info->ntris, info->nverts);
|
||||
for (int i = 0; i < info->ntris; ++i) {
|
||||
const unsigned short *idx = &info->indices[i * 3];
|
||||
add_triangle_vertices(&elb, idx[0], idx[1], idx[2]);
|
||||
GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
|
||||
}
|
||||
el = ElementList_build(&elb);
|
||||
el = GWN_indexbuf_build(&elb);
|
||||
|
||||
vbo = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(vbo, info->nverts);
|
||||
vbo = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, info->nverts);
|
||||
|
||||
VertexBuffer_fill_attrib(vbo, pos_id, info->verts);
|
||||
GWN_vertbuf_attr_fill(vbo, pos_id, info->verts);
|
||||
|
||||
if (use_lighting) {
|
||||
/* Normals are expected to be smooth. */
|
||||
VertexBuffer_fill_attrib(vbo, nor_id, info->normals);
|
||||
GWN_vertbuf_attr_fill(vbo, nor_id, info->normals);
|
||||
}
|
||||
|
||||
batch = Batch_create(PRIM_TRIANGLES, vbo, el);
|
||||
batch = GWN_batch_create(GWN_PRIM_TRIS, vbo, el);
|
||||
Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
Batch_Uniform4fv(batch, "color", color);
|
||||
GWN_batch_uniform_4fv(batch, "color", color);
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
// glEnable(GL_DEPTH_TEST);
|
||||
|
||||
Batch_draw(batch);
|
||||
GWN_batch_draw(batch);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
// glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
Batch_discard_all(batch);
|
||||
GWN_batch_discard_all(batch);
|
||||
}
|
||||
|
||||
void wm_manipulator_vec_draw(
|
||||
|
||||
@@ -79,10 +79,10 @@ static void manipulator_primitive_draw_geom(
|
||||
}
|
||||
|
||||
if (vert_count > 0) {
|
||||
uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, PRIM_TRIANGLE_FAN);
|
||||
wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, PRIM_LINE_LOOP);
|
||||
wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, GWN_PRIM_TRI_FAN);
|
||||
wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, GWN_PRIM_LINE_LOOP);
|
||||
immUnbindProgram();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
|
||||
return;
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
@@ -133,7 +133,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
|
||||
/* this could be split into its own loop */
|
||||
if (draw_type == MASK_DT_OUTLINE) {
|
||||
glLineWidth(3.0f);
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2fv(pos, point_pos);
|
||||
immVertex2fv(pos, handle_pos);
|
||||
immEnd();
|
||||
@@ -153,7 +153,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
|
||||
}
|
||||
|
||||
glLineWidth(1.0f);
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2fv(pos, point_pos);
|
||||
immVertex2fv(pos, handle_pos);
|
||||
immEnd();
|
||||
@@ -177,7 +177,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
|
||||
immUniform4fv("outlineColor", point_color);
|
||||
immUniformColor3fvAlpha(point_color, 0.25f);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex2fv(pos, handle_pos);
|
||||
immEnd();
|
||||
|
||||
@@ -211,8 +211,8 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
|
||||
|
||||
mask_spline_color_get(masklay, spline, is_spline_sel, rgb_spline);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
|
||||
immUniform1f("size", 0.7f * handle_size);
|
||||
@@ -250,7 +250,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
|
||||
immUniformThemeColor(TH_HANDLE_VERTEX);
|
||||
}
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex2fv(pos, feather_point);
|
||||
immEnd();
|
||||
|
||||
@@ -319,7 +319,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
|
||||
else
|
||||
immUniformThemeColor(TH_HANDLE_VERTEX);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex2fv(pos, vert);
|
||||
immEnd();
|
||||
|
||||
@@ -349,7 +349,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
|
||||
immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
immUniform1f("size", 12.0f);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex2f(pos, x, y);
|
||||
immEnd();
|
||||
|
||||
@@ -370,7 +370,7 @@ static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char r
|
||||
}
|
||||
}
|
||||
|
||||
static void mask_draw_array(unsigned int pos, PrimitiveType prim_type, const float (*points)[2], unsigned int vertex_ct)
|
||||
static void mask_draw_array(unsigned int pos, Gwn_PrimType prim_type, const float (*points)[2], unsigned int vertex_ct)
|
||||
{
|
||||
immBegin(prim_type, vertex_ct);
|
||||
for (unsigned int i = 0; i < vertex_ct; ++i) {
|
||||
@@ -383,7 +383,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
|
||||
const bool is_feather, const bool is_active,
|
||||
const unsigned char rgb_spline[4], const char draw_type)
|
||||
{
|
||||
const PrimitiveType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? PRIM_LINE_LOOP : PRIM_LINE_STRIP;
|
||||
const Gwn_PrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GWN_PRIM_LINE_LOOP : GWN_PRIM_LINE_STRIP;
|
||||
const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
|
||||
unsigned char rgb_tmp[4];
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
@@ -401,8 +401,8 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
|
||||
}
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
switch (draw_type) {
|
||||
|
||||
@@ -815,12 +815,12 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra
|
||||
unsigned int num_lines = BLI_listbase_count(&masklay->splines_shapes);
|
||||
|
||||
if (num_lines > 0) {
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ub(255, 175, 0, 255);
|
||||
|
||||
immBegin(PRIM_LINES, 2 * num_lines);
|
||||
immBegin(GWN_PRIM_LINES, 2 * num_lines);
|
||||
|
||||
for (MaskLayerShape *masklay_shape = masklay->splines_shapes.first;
|
||||
masklay_shape;
|
||||
|
||||
@@ -1002,13 +1002,13 @@ static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd)
|
||||
copy_v3_v3(v2, ray_hit_best[1]);
|
||||
}
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformThemeColor(TH_TRANSFORM);
|
||||
glLineWidth(2.0);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex3fv(pos, v1);
|
||||
immVertex3fv(pos, v2);
|
||||
immEnd();
|
||||
@@ -1044,7 +1044,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix(kcd->ob->obmat);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
@@ -1055,7 +1055,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor3ubv(kcd->colors.line);
|
||||
glLineWidth(2.0);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex3fv(pos, kcd->prev.cage);
|
||||
immVertex3fv(pos, kcd->curr.cage);
|
||||
immEnd();
|
||||
@@ -1065,7 +1065,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor3ubv(kcd->colors.point);
|
||||
glPointSize(11);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex3fv(pos, kcd->prev.cage);
|
||||
immEnd();
|
||||
}
|
||||
@@ -1074,7 +1074,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor3ubv(kcd->colors.curpoint);
|
||||
glPointSize(9);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex3fv(pos, kcd->prev.cage);
|
||||
immEnd();
|
||||
}
|
||||
@@ -1083,7 +1083,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor3ubv(kcd->colors.edge);
|
||||
glLineWidth(2.0);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex3fv(pos, kcd->curr.edge->v1->cageco);
|
||||
immVertex3fv(pos, kcd->curr.edge->v2->cageco);
|
||||
immEnd();
|
||||
@@ -1092,7 +1092,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor3ubv(kcd->colors.point);
|
||||
glPointSize(11);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex3fv(pos, kcd->curr.cage);
|
||||
immEnd();
|
||||
}
|
||||
@@ -1101,7 +1101,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor3ubv(kcd->colors.curpoint);
|
||||
glPointSize(9);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex3fv(pos, kcd->curr.cage);
|
||||
immEnd();
|
||||
}
|
||||
@@ -1117,7 +1117,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor4ubv(kcd->colors.point_a);
|
||||
glPointSize(11);
|
||||
|
||||
immBeginAtMost(PRIM_POINTS, kcd->totlinehit);
|
||||
immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit);
|
||||
|
||||
lh = kcd->linehits;
|
||||
for (i = 0; i < kcd->totlinehit; i++, lh++) {
|
||||
@@ -1132,7 +1132,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor4ubv(kcd->colors.curpoint_a);
|
||||
glPointSize(7);
|
||||
|
||||
immBeginAtMost(PRIM_POINTS, kcd->totlinehit);
|
||||
immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit);
|
||||
|
||||
lh = kcd->linehits;
|
||||
for (i = 0; i < kcd->totlinehit; i++, lh++) {
|
||||
@@ -1153,7 +1153,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor3ubv(kcd->colors.line);
|
||||
glLineWidth(1.0);
|
||||
|
||||
immBeginAtMost(PRIM_LINES, BLI_mempool_count(kcd->kedges) * 2);
|
||||
immBeginAtMost(GWN_PRIM_LINES, BLI_mempool_count(kcd->kedges) * 2);
|
||||
|
||||
BLI_mempool_iternew(kcd->kedges, &iter);
|
||||
for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) {
|
||||
@@ -1174,7 +1174,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
immUniformColor3ubv(kcd->colors.point);
|
||||
glPointSize(5.0);
|
||||
|
||||
immBeginAtMost(PRIM_POINTS, BLI_mempool_count(kcd->kverts));
|
||||
immBeginAtMost(GWN_PRIM_POINTS, BLI_mempool_count(kcd->kverts));
|
||||
|
||||
BLI_mempool_iternew(kcd->kverts, &iter);
|
||||
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
|
||||
|
||||
@@ -108,13 +108,13 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix(lcd->ob->obmat);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformColor3ub(255, 0, 255);
|
||||
|
||||
if (lcd->totedge > 0) {
|
||||
immBegin(PRIM_LINES, lcd->totedge * 2);
|
||||
immBegin(GWN_PRIM_LINES, lcd->totedge * 2);
|
||||
|
||||
for (int i = 0; i < lcd->totedge; i++) {
|
||||
immVertex3fv(pos, lcd->edges[i][0]);
|
||||
@@ -127,7 +127,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
if (lcd->totpoint > 0) {
|
||||
glPointSize(3.0f);
|
||||
|
||||
immBegin(PRIM_POINTS, lcd->totpoint);
|
||||
immBegin(GWN_PRIM_POINTS, lcd->totpoint);
|
||||
|
||||
for (int i = 0; i < lcd->totpoint; i++) {
|
||||
immVertex3fv(pos, lcd->points[i]);
|
||||
|
||||
@@ -2712,7 +2712,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
|
||||
brush = &pset->brush[pset->brushtype];
|
||||
|
||||
if (brush) {
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4ub(255, 255, 255, 128);
|
||||
|
||||
@@ -92,12 +92,12 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
immBegin(PRIM_LINE_STRIP, 5);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 5);
|
||||
|
||||
/* right */
|
||||
immAttrib4ub(color, 0, 0, 0, 30);
|
||||
@@ -222,16 +222,16 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
|
||||
|
||||
BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immAttrib4ub(color, 255, 0, 0, alpha_debug);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
imm_draw_line_box(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax);
|
||||
|
||||
immAttrib4ub(color, 0, 255, 255, alpha_debug);
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
immVertex2f(pos, click_rect.xmin, click_rect.ymin);
|
||||
immVertex2f(pos, click_rect.xmax, click_rect.ymax);
|
||||
immVertex2f(pos, click_rect.xmin, click_rect.ymax);
|
||||
@@ -255,12 +255,12 @@ static void area_draw_azone(short x1, short y1, short x2, short y2)
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int col = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
immBegin(PRIM_LINES, 12);
|
||||
immBegin(GWN_PRIM_LINES, 12);
|
||||
|
||||
immAttrib4ub(col, 255, 255, 255, 180);
|
||||
immVertex2f(pos, x1, y2);
|
||||
@@ -297,8 +297,8 @@ static void region_draw_azone_icon(AZone *az)
|
||||
float midx = az->x1 + (az->x2 - az->x1) * 0.5f;
|
||||
float midy = az->y1 + (az->y2 - az->y1) * 0.5f;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
/* outlined circle */
|
||||
GPU_enable_program_point_size(); /* TODO: make a fixed-size shader to avoid this */
|
||||
@@ -307,7 +307,7 @@ static void region_draw_azone_icon(AZone *az)
|
||||
immUniform4f("outlineColor", 0.2f, 0.2f, 0.2f, 0.9f);
|
||||
immUniform1f("outlineWidth", 1.0f);
|
||||
immUniform1f("size", 9.5f);
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immBegin(GWN_PRIM_POINTS, 1);
|
||||
immVertex2f(pos, midx, midy);
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
@@ -316,7 +316,7 @@ static void region_draw_azone_icon(AZone *az)
|
||||
/* + */
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4f(0.2f, 0.2f, 0.2f, 0.9f);
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(GWN_PRIM_LINES, 4);
|
||||
immVertex2f(pos, midx, midy - 2);
|
||||
immVertex2f(pos, midx, midy + 3);
|
||||
immVertex2f(pos, midx - 2, midy);
|
||||
@@ -330,8 +330,8 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2)
|
||||
float width = 0.1f * U.widget_unit;
|
||||
float pad = 0.2f * U.widget_unit;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
@@ -566,8 +566,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
|
||||
/* for debugging unneeded area redraws and partial redraw */
|
||||
#if 0
|
||||
glEnable(GL_BLEND);
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4f(drand48(), drand48(), drand48(), 0.1f);
|
||||
immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin,
|
||||
@@ -2015,8 +2015,8 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c
|
||||
/* view should be in pixelspace */
|
||||
UI_view2d_view_restore(C);
|
||||
glEnable(GL_BLEND);
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformThemeColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
|
||||
immRecti(pos, 0, 0, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct) + 1);
|
||||
@@ -2164,8 +2164,8 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4fv(fill_color);
|
||||
immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1);
|
||||
@@ -2383,8 +2383,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
|
||||
/* set up rect */
|
||||
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y);
|
||||
/* draw top box */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformThemeColor(TH_METADATA_BG);
|
||||
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||
@@ -2408,8 +2408,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
|
||||
/* set up box rect */
|
||||
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin);
|
||||
/* draw top box */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformThemeColor(TH_METADATA_BG);
|
||||
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||
@@ -2437,8 +2437,8 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
|
||||
UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
|
||||
UI_view2d_view_to_region(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformThemeColorShade(TH_BACK, 20);
|
||||
@@ -2470,12 +2470,12 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
|
||||
int count_large = 1.0f / (4.0f * gridstep);
|
||||
|
||||
if (count_fine > 0) {
|
||||
VertexFormat_clear(format);
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned color = VertexFormat_add_attrib(format, "color", COMP_F32, 3, KEEP_FLOAT);
|
||||
GWN_vertformat_clear(format);
|
||||
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
immBegin(PRIM_LINES, 4 * count_fine + 4 * count_large);
|
||||
immBegin(GWN_PRIM_LINES, 4 * count_fine + 4 * count_large);
|
||||
|
||||
float theme_color[3];
|
||||
UI_GetThemeColorShade3fv(TH_BACK, (int)(20.0f * (1.0f - blendfac)), theme_color);
|
||||
@@ -2545,7 +2545,7 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect)
|
||||
|
||||
void ED_region_cache_draw_background(const ARegion *ar)
|
||||
{
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ub(128, 128, 255, 64);
|
||||
immRecti(pos, 0, 0, ar->winx, 8 * UI_DPI_FAC);
|
||||
@@ -2565,7 +2565,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f
|
||||
|
||||
BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformThemeColor(TH_CFRAME);
|
||||
immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);
|
||||
@@ -2579,7 +2579,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f
|
||||
void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segments, const int *points, const int sfra, const int efra)
|
||||
{
|
||||
if (num_segments) {
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ub(128, 128, 255, 128);
|
||||
|
||||
|
||||
@@ -139,9 +139,9 @@ static int get_cached_work_texture(int *r_w, int *r_h)
|
||||
|
||||
static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state)
|
||||
{
|
||||
VertexFormat *vert_format = immVertexFormat();
|
||||
state->pos = VertexFormat_add_attrib(vert_format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
state->texco = VertexFormat_add_attrib(vert_format, "texCoord", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *vert_format = immVertexFormat();
|
||||
state->pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
state->texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
/* To be used before calling immDrawPixelsTex
|
||||
@@ -303,7 +303,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_UNSIGNED_BYTE, &uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
|
||||
}
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 4);
|
||||
immAttrib2f(texco, (float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h);
|
||||
immVertex2f(pos, rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * yzoom);
|
||||
|
||||
@@ -693,28 +693,28 @@ void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, flo
|
||||
delta_y = min_ff(delta_y, border->ymax - border->ymin);
|
||||
|
||||
/* left bottom corner */
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, border->xmin, border->ymin + delta_y);
|
||||
immVertex2f(pos, border->xmin, border->ymin);
|
||||
immVertex2f(pos, border->xmin + delta_x, border->ymin);
|
||||
immEnd();
|
||||
|
||||
/* left top corner */
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, border->xmin, border->ymax - delta_y);
|
||||
immVertex2f(pos, border->xmin, border->ymax);
|
||||
immVertex2f(pos, border->xmin + delta_x, border->ymax);
|
||||
immEnd();
|
||||
|
||||
/* right bottom corner */
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, border->xmax - delta_x, border->ymin);
|
||||
immVertex2f(pos, border->xmax, border->ymin);
|
||||
immVertex2f(pos, border->xmax, border->ymin + delta_y);
|
||||
immEnd();
|
||||
|
||||
/* right top corner */
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2f(pos, border->xmax - delta_x, border->ymax);
|
||||
immVertex2f(pos, border->xmax, border->ymax);
|
||||
immVertex2f(pos, border->xmax, border->ymax - delta_y);
|
||||
|
||||
@@ -94,7 +94,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
|
||||
}
|
||||
}
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 5);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 5);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
immVertex2f(pos, points[i].x, points[i].y);
|
||||
@@ -102,7 +102,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
|
||||
|
||||
immEnd();
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 5);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 5);
|
||||
|
||||
for (i = 4; i < 8; i++) {
|
||||
immVertex2f(pos, points[i].x, points[i].y);
|
||||
@@ -175,7 +175,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
|
||||
}
|
||||
}
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 5);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 5);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
immVertex2f(pos, points[i].x, points[i].y);
|
||||
@@ -183,7 +183,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos)
|
||||
|
||||
immEnd();
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 5);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 5);
|
||||
|
||||
for (i = 4; i < 8; i++) {
|
||||
immVertex2f(pos, points[i].x, points[i].y);
|
||||
@@ -246,7 +246,7 @@ static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, shor
|
||||
return;
|
||||
}
|
||||
|
||||
immBegin(PRIM_LINES, count);
|
||||
immBegin(GWN_PRIM_LINES, count);
|
||||
|
||||
/* right border area */
|
||||
if (x2 < sizex - 1) {
|
||||
@@ -304,7 +304,7 @@ void ED_screen_draw(wmWindow *win)
|
||||
|
||||
wmSubWindowSet(win, screen->mainwin);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* Note: first loop only draws if U.pixelsize > 1, skip otherwise */
|
||||
@@ -368,7 +368,7 @@ void ED_screen_draw(wmWindow *win)
|
||||
glEnable(GL_BLEND);
|
||||
immUniformColor4ub(255, 255, 255, 100);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
if (sa3->flag & AREA_FLAG_DRAWSPLIT_H) {
|
||||
immVertex2f(pos, sa3->totrct.xmin, win->eventstate->y);
|
||||
@@ -378,7 +378,7 @@ void ED_screen_draw(wmWindow *win)
|
||||
|
||||
immUniformColor4ub(0, 0, 0, 100);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
immVertex2f(pos, sa3->totrct.xmin, win->eventstate->y + 1);
|
||||
immVertex2f(pos, sa3->totrct.xmax, win->eventstate->y + 1);
|
||||
@@ -391,7 +391,7 @@ void ED_screen_draw(wmWindow *win)
|
||||
|
||||
immUniformColor4ub(0, 0, 0, 100);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
immVertex2f(pos, win->eventstate->x + 1, sa3->totrct.ymin);
|
||||
immVertex2f(pos, win->eventstate->x + 1, sa3->totrct.ymax);
|
||||
@@ -433,7 +433,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2
|
||||
const float ofs_between_areas)
|
||||
{
|
||||
const float ofs_h = ofs_between_areas * 0.5f;
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4fv(col);
|
||||
@@ -446,7 +446,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2
|
||||
.ymax = sa->totrct.ymax * scale[1] - ofs_h
|
||||
};
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 4);
|
||||
immVertex2f(pos, rect.xmin, rect.ymin);
|
||||
immVertex2f(pos, rect.xmax, rect.ymin);
|
||||
immVertex2f(pos, rect.xmax, rect.ymax);
|
||||
|
||||
@@ -456,8 +456,8 @@ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUS
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
|
||||
@@ -660,9 +660,9 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
|
||||
}
|
||||
|
||||
/* set quad color. Colored overlay does not get blending */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int texCoord = VertexFormat_add_attrib(format, "texCoord", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
if (col) {
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
@@ -676,7 +676,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
|
||||
/* draw textured quad */
|
||||
immUniform1i("image", GL_TEXTURE0);
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 4);
|
||||
immAttrib2f(texCoord, 0.0f, 0.0f);
|
||||
immVertex2f(pos, quad.xmin, quad.ymin);
|
||||
immAttrib2f(texCoord, 1.0f, 0.0f);
|
||||
@@ -745,9 +745,9 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
|
||||
gpuTranslate2f(-center[0], -center[1]);
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int texCoord = VertexFormat_add_attrib(format, "texCoord", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
|
||||
@@ -758,7 +758,7 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
|
||||
/* draw textured quad */
|
||||
immUniform1i("image", GL_TEXTURE0);
|
||||
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immBegin(GWN_PRIM_TRI_FAN, 4);
|
||||
immAttrib2f(texCoord, 0.0f, 0.0f);
|
||||
immVertex2f(pos, quad.xmin, quad.ymin);
|
||||
immAttrib2f(texCoord, 1.0f, 0.0f);
|
||||
@@ -819,7 +819,7 @@ BLI_INLINE void draw_tri_point(
|
||||
{co[0] + w, co[1] - w},
|
||||
};
|
||||
|
||||
immBegin(PRIM_LINE_LOOP, 3);
|
||||
immBegin(GWN_PRIM_LINE_LOOP, 3);
|
||||
immVertex2fv(pos, tri[0]);
|
||||
immVertex2fv(pos, tri[1]);
|
||||
immVertex2fv(pos, tri[2]);
|
||||
@@ -828,7 +828,7 @@ BLI_INLINE void draw_tri_point(
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
glLineWidth(1.0f);
|
||||
|
||||
immBegin(PRIM_LINE_LOOP, 3);
|
||||
immBegin(GWN_PRIM_LINE_LOOP, 3);
|
||||
immVertex2fv(pos, tri[0]);
|
||||
immVertex2fv(pos, tri[1]);
|
||||
immVertex2fv(pos, tri[2]);
|
||||
@@ -863,7 +863,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
glLineWidth(3.0f);
|
||||
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, 3);
|
||||
immVertex2fv(pos, bez->vec[0]);
|
||||
immVertex2fv(pos, bez->vec[1]);
|
||||
immVertex2fv(pos, bez->vec[2]);
|
||||
@@ -877,7 +877,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez
|
||||
else {
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
}
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2fv(pos, bez->vec[0]);
|
||||
immVertex2fv(pos, bez->vec[1]);
|
||||
immEnd();
|
||||
@@ -888,7 +888,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez
|
||||
else {
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
}
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2fv(pos, bez->vec[1]);
|
||||
immVertex2fv(pos, bez->vec[2]);
|
||||
immEnd();
|
||||
@@ -905,7 +905,7 @@ static void paint_draw_curve_cursor(Brush *brush)
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* draw the bezier handles and the curve segment between the current and next point */
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -936,7 +936,7 @@ static void paint_draw_curve_cursor(Brush *brush)
|
||||
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
glLineWidth(3.0f);
|
||||
immBegin(PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
|
||||
for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) {
|
||||
immVertex2fv(pos, v[j]);
|
||||
}
|
||||
@@ -944,7 +944,7 @@ static void paint_draw_curve_cursor(Brush *brush)
|
||||
|
||||
immUniformColor4f(0.9f, 0.9f, 1.0f, 0.5f);
|
||||
glLineWidth(1.0f);
|
||||
immBegin(PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
|
||||
immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
|
||||
for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) {
|
||||
immVertex2fv(pos, v[j]);
|
||||
}
|
||||
@@ -1089,7 +1089,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
||||
glEnable(GL_BLEND); /* TODO: also set blend mode? */
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* set brush color */
|
||||
|
||||
@@ -722,15 +722,15 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
glLineWidth(4.0);
|
||||
immUniformColor4ub(0, 0, 0, 255);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2i(pos, x, y);
|
||||
immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]);
|
||||
immEnd();
|
||||
@@ -738,7 +738,7 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda
|
||||
glLineWidth(2.0);
|
||||
immUniformColor4ub(255, 255, 255, 255);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2i(pos, x, y);
|
||||
immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]);
|
||||
immEnd();
|
||||
|
||||
@@ -147,11 +147,11 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ubv(paint->paint_cursor_col);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, x, y);
|
||||
immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
|
||||
immEnd();
|
||||
@@ -170,7 +170,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -183,7 +183,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
if (stroke->constrain_line) {
|
||||
immVertex2f(shdr_pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
|
||||
|
||||
@@ -213,7 +213,7 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu
|
||||
alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
|
||||
}
|
||||
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor3fvAlpha(brush->add_col, alpha);
|
||||
|
||||
|
||||
@@ -204,8 +204,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
||||
/* first backdrop strips */
|
||||
y = (float)(-ACHANNEL_HEIGHT(ac));
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
@@ -319,7 +319,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
|
||||
if (saction->flag & SACTION_MOVING) {
|
||||
immUniformColor3f(0.0f, 0.0f, 0.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immVertex2f(pos, saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD);
|
||||
immVertex2f(pos, saction->timeslide, v2d->cur.ymax);
|
||||
immEnd();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user