diff options
author | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2014-05-30 07:56:55 +0400 |
---|---|---|
committer | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2014-05-30 07:56:55 +0400 |
commit | 5d3b635d310d39ca1e8fba85de313623c8d0c238 (patch) | |
tree | 2c2bfe28ca8b154d25a3a2b700cbb3dc1783110e | |
parent | 6eff1cbebcf0766d2fe69db9b0fb3f76ede2c06b (diff) |
Fixed compile errors associated with merge from soc-2013-viewport_fx and MSVC2010
not tested
31 files changed, 335 insertions, 328 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 03246501460..097c0009623 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -164,10 +164,10 @@ static int blf_global_font_init(void) if (global_font_default == -1) { printf("Warning: Can't find default font!\n"); - return FALSE; + return false; } else { - return TRUE; + return true; } } diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 6bc5cd3d797..aa3fff748d3 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -180,7 +180,7 @@ void blf_font_draw(FontBLF *font, const char *str, size_t len) int pen_x = 0, pen_y = 0; size_t i = 0; GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table; - int needs_end = FALSE; + int needs_end = false; BLF_KERNING_VARS(font, has_kerning, kern_mode); @@ -219,7 +219,7 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len) FT_Vector delta; int pen_x = 0, pen_y = 0; GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table; - int needs_end = FALSE; + int needs_end = false; BLF_KERNING_VARS(font, has_kerning, kern_mode); @@ -256,7 +256,7 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth) int pen_x = 0, pen_y = 0; size_t i = 0; GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table; - int needs_end = FALSE; + int needs_end = false; blf_font_ensure_ascii_table(font); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index c2cb7c4b37f..dcde9a60176 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -420,8 +420,8 @@ void blf_glyph_render( if (!need_begin) { gpuEnd(); - need_begin = TRUE; - *needs_end = FALSE; + need_begin = true; + *needs_end = false; } GPU_CHECK_NO_ERROR(); @@ -489,14 +489,14 @@ GPU_CHECK_NO_ERROR(); if (font->tex_bind_state != g->tex) { if (!need_begin) { gpuEnd(); - need_begin = TRUE; + need_begin = true; } gpuBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = g->tex)); } if (need_begin) { gpuBegin(GL_QUADS); - *needs_end = TRUE; + *needs_end = true; } if (font->flags & BLF_SHADOW) { diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 12981040d63..1c0a5ef4046 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -177,9 +177,8 @@ typedef enum DMDirtyFlag { DM_DIRTY_NORMALS = 1 << 2, } DMDirtyFlag; -typedef struct DerivedMesh DerivedMesh; -struct DerivedMesh { - /** Private DerivedMesh data, only for internal DerivedMesh use */ +typedef struct DerivedMesh { + /** Private struct DerivedMesh data, only for internal struct DerivedMesh use */ CustomData vertData, edgeData, faceData, loopData, polyData; int numVertData, numEdgeData, numTessFaceData, numLoopData, numPolyData; int needsFree; /* checked on ->release, is set to 0 for cached results */ @@ -196,102 +195,102 @@ struct DerivedMesh { char cd_flag; /** Calculate vert and face normals */ - void (*calcNormals)(DerivedMesh *dm); + void (*calcNormals)(struct DerivedMesh *dm); /** Calculate loop (split) normals */ - void (*calcLoopNormals)(DerivedMesh *dm, const float split_angle); + void (*calcLoopNormals)(struct DerivedMesh *dm, const float split_angle); /** Recalculates mesh tessellation */ - void (*recalcTessellation)(DerivedMesh *dm); + void (*recalcTessellation)(struct DerivedMesh *dm); /* Misc. Queries */ /* Also called in Editmode */ - int (*getNumVerts)(DerivedMesh *dm); - int (*getNumEdges)(DerivedMesh *dm); - int (*getNumTessFaces)(DerivedMesh *dm); - int (*getNumLoops)(DerivedMesh *dm); - int (*getNumPolys)(DerivedMesh *dm); + int (*getNumVerts)(struct DerivedMesh *dm); + int (*getNumEdges)(struct DerivedMesh *dm); + int (*getNumTessFaces)(struct DerivedMesh *dm); + int (*getNumLoops)(struct DerivedMesh *dm); + int (*getNumPolys)(struct DerivedMesh *dm); /** Copy a single vert/edge/tessellated face from the derived mesh into * *{vert/edge/face}_r. note that the current implementation * of this function can be quite slow, iterating over all * elements (editmesh) */ - void (*getVert)(DerivedMesh *dm, int index, struct MVert *r_vert); - void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *r_edge); - void (*getTessFace)(DerivedMesh *dm, int index, struct MFace *r_face); + void (*getVert)(struct DerivedMesh *dm, int index, struct MVert *r_vert); + void (*getEdge)(struct DerivedMesh *dm, int index, struct MEdge *r_edge); + void (*getTessFace)(struct DerivedMesh *dm, int index, struct MFace *r_face); /** Return a pointer to the entire array of verts/edges/face from the * derived mesh. if such an array does not exist yet, it will be created, * and freed on the next ->release(). consider using getVert/Edge/Face if * you are only interested in a few verts/edges/faces. */ - struct MVert *(*getVertArray)(DerivedMesh * dm); - struct MEdge *(*getEdgeArray)(DerivedMesh * dm); - struct MFace *(*getTessFaceArray)(DerivedMesh * dm); - struct MLoop *(*getLoopArray)(DerivedMesh * dm); - struct MPoly *(*getPolyArray)(DerivedMesh * dm); + struct MVert *(*getVertArray)(struct DerivedMesh * dm); + struct MEdge *(*getEdgeArray)(struct DerivedMesh * dm); + struct MFace *(*getTessFaceArray)(struct DerivedMesh * dm); + struct MLoop *(*getLoopArray)(struct DerivedMesh * dm); + struct MPoly *(*getPolyArray)(struct DerivedMesh * dm); /** Copy all verts/edges/faces from the derived mesh into * *{vert/edge/face}_r (must point to a buffer large enough) */ - void (*copyVertArray)(DerivedMesh *dm, struct MVert *r_vert); - void (*copyEdgeArray)(DerivedMesh *dm, struct MEdge *r_edge); - void (*copyTessFaceArray)(DerivedMesh *dm, struct MFace *r_face); - void (*copyLoopArray)(DerivedMesh *dm, struct MLoop *r_loop); - void (*copyPolyArray)(DerivedMesh *dm, struct MPoly *r_poly); + void (*copyVertArray)(struct DerivedMesh *dm, struct MVert *r_vert); + void (*copyEdgeArray)(struct DerivedMesh *dm, struct MEdge *r_edge); + void (*copyTessFaceArray)(struct DerivedMesh *dm, struct MFace *r_face); + void (*copyLoopArray)(struct DerivedMesh *dm, struct MLoop *r_loop); + void (*copyPolyArray)(struct DerivedMesh *dm, struct MPoly *r_poly); /** Return a copy of all verts/edges/faces from the derived mesh * it is the caller's responsibility to free the returned pointer */ - struct MVert *(*dupVertArray)(DerivedMesh * dm); - struct MEdge *(*dupEdgeArray)(DerivedMesh * dm); - struct MFace *(*dupTessFaceArray)(DerivedMesh * dm); - struct MLoop *(*dupLoopArray)(DerivedMesh * dm); - struct MPoly *(*dupPolyArray)(DerivedMesh * dm); + struct MVert *(*dupVertArray)(struct DerivedMesh * dm); + struct MEdge *(*dupEdgeArray)(struct DerivedMesh * dm); + struct MFace *(*dupTessFaceArray)(struct DerivedMesh * dm); + struct MLoop *(*dupLoopArray)(struct DerivedMesh * dm); + struct MPoly *(*dupPolyArray)(struct DerivedMesh * dm); /** Return a pointer to a single element of vert/edge/face custom data * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ - void *(*getVertData)(DerivedMesh *dm, int index, int type); - void *(*getEdgeData)(DerivedMesh *dm, int index, int type); - void *(*getTessFaceData)(DerivedMesh *dm, int index, int type); - void *(*getPolyData)(DerivedMesh *dm, int index, int type); + void *(*getVertData)(struct DerivedMesh *dm, int index, int type); + void *(*getEdgeData)(struct DerivedMesh *dm, int index, int type); + void *(*getTessFaceData)(struct DerivedMesh *dm, int index, int type); + void *(*getPolyData)(struct DerivedMesh *dm, int index, int type); /** Return a pointer to the entire array of vert/edge/face custom data * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ - void *(*getVertDataArray)(DerivedMesh *dm, int type); - void *(*getEdgeDataArray)(DerivedMesh *dm, int type); - void *(*getTessFaceDataArray)(DerivedMesh *dm, int type); - void *(*getLoopDataArray)(DerivedMesh *dm, int type); - void *(*getPolyDataArray)(DerivedMesh *dm, int type); + void *(*getVertDataArray)(struct DerivedMesh *dm, int type); + void *(*getEdgeDataArray)(struct DerivedMesh *dm, int type); + void *(*getTessFaceDataArray)(struct DerivedMesh *dm, int type); + void *(*getLoopDataArray)(struct DerivedMesh *dm, int type); + void *(*getPolyDataArray)(struct DerivedMesh *dm, int type); /** Retrieves the base CustomData structures for * verts/edges/tessfaces/loops/facdes*/ - CustomData *(*getVertDataLayout)(DerivedMesh * dm); - CustomData *(*getEdgeDataLayout)(DerivedMesh * dm); - CustomData *(*getTessFaceDataLayout)(DerivedMesh * dm); - CustomData *(*getLoopDataLayout)(DerivedMesh * dm); - CustomData *(*getPolyDataLayout)(DerivedMesh * dm); + CustomData *(*getVertDataLayout)(struct DerivedMesh * dm); + CustomData *(*getEdgeDataLayout)(struct DerivedMesh * dm); + CustomData *(*getTessFaceDataLayout)(struct DerivedMesh * dm); + CustomData *(*getLoopDataLayout)(struct DerivedMesh * dm); + CustomData *(*getPolyDataLayout)(struct DerivedMesh * dm); /** Copies all customdata for an element source into dst at index dest */ - void (*copyFromVertCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); - void (*copyFromEdgeCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); - void (*copyFromFaceCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); + void (*copyFromVertCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest); + void (*copyFromEdgeCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest); + void (*copyFromFaceCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest); /** Optional grid access for subsurf */ - int (*getNumGrids)(DerivedMesh *dm); - int (*getGridSize)(DerivedMesh *dm); - struct CCGElem **(*getGridData)(DerivedMesh * dm); - DMGridAdjacency *(*getGridAdjacency)(DerivedMesh * dm); - int *(*getGridOffset)(DerivedMesh * dm); - void (*getGridKey)(DerivedMesh *dm, struct CCGKey *key); - DMFlagMat *(*getGridFlagMats)(DerivedMesh * dm); - unsigned int **(*getGridHidden)(DerivedMesh * dm); + int (*getNumGrids)(struct DerivedMesh *dm); + int (*getGridSize)(struct DerivedMesh *dm); + struct CCGElem **(*getGridData)(struct DerivedMesh * dm); + DMGridAdjacency *(*getGridAdjacency)(struct DerivedMesh * dm); + int *(*getGridOffset)(struct DerivedMesh * dm); + void (*getGridKey)(struct DerivedMesh *dm, struct CCGKey *key); + DMFlagMat *(*getGridFlagMats)(struct DerivedMesh * dm); + unsigned int **(*getGridHidden)(struct DerivedMesh * dm); /** Iterate over each mapped vertex in the derived mesh, calling the @@ -299,7 +298,7 @@ struct DerivedMesh { * coordinate and normal. For historical reasons the normal can be * passed as a float or short array, only one should be non-NULL. */ - void (*foreachMappedVert)(DerivedMesh *dm, + void (*foreachMappedVert)(struct DerivedMesh *dm, void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), void *userData, @@ -309,7 +308,7 @@ struct DerivedMesh { * given function with the original edge and the mapped edge's new * coordinates. */ - void (*foreachMappedEdge)(DerivedMesh *dm, + void (*foreachMappedEdge)(struct DerivedMesh *dm, void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), void *userData); @@ -317,7 +316,7 @@ struct DerivedMesh { /** Iterate over each mapped loop in the derived mesh, calling the given function * with the original loop index and the mapped loops's new coordinate and normal. */ - void (*foreachMappedLoop)(DerivedMesh *dm, + void (*foreachMappedLoop)(struct DerivedMesh *dm, void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]), void *userData, @@ -327,7 +326,7 @@ struct DerivedMesh { * given function with the original face and the mapped face's (or * faces') center and normal. */ - void (*foreachMappedFaceCenter)(DerivedMesh *dm, + void (*foreachMappedFaceCenter)(struct DerivedMesh *dm, void (*func)(void *userData, int index, const float cent[3], const float no[3]), void *userData, @@ -337,46 +336,46 @@ struct DerivedMesh { * * Also called in Editmode */ - void (*getMinMax)(DerivedMesh *dm, float r_min[3], float r_max[3]); + void (*getMinMax)(struct DerivedMesh *dm, float r_min[3], float r_max[3]); /** Direct Access Operations * - Can be undefined * - Must be defined for modifiers that only deform however */ /** Get vertex location, undefined if index is not valid */ - void (*getVertCo)(DerivedMesh *dm, int index, float r_co[3]); + void (*getVertCo)(struct DerivedMesh *dm, int index, float r_co[3]); /** Fill the array (of length .getNumVerts()) with all vertex locations */ - void (*getVertCos)(DerivedMesh *dm, float (*r_cos)[3]); + void (*getVertCos)(struct DerivedMesh *dm, float (*r_cos)[3]); /** Get smooth vertex normal, undefined if index is not valid */ - void (*getVertNo)(DerivedMesh *dm, int index, float r_no[3]); - void (*getPolyNo)(DerivedMesh *dm, int index, float r_no[3]); + void (*getVertNo)(struct DerivedMesh *dm, int index, float r_no[3]); + void (*getPolyNo)(struct DerivedMesh *dm, int index, float r_no[3]); /** Get a map of vertices to faces */ - const struct MeshElemMap *(*getPolyMap)(struct Object *ob, DerivedMesh *dm); + const struct MeshElemMap *(*getPolyMap)(struct Object *ob, struct DerivedMesh *dm); /** Get the BVH used for paint modes */ - struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm); + struct PBVH *(*getPBVH)(struct Object *ob, struct DerivedMesh *dm); /* Drawing Operations */ /** Draw all vertices as bgl points (no options) */ - void (*drawVerts)(DerivedMesh *dm); + void (*drawVerts)(struct DerivedMesh *dm); /** Draw edges in the UV mesh (if exists) */ - void (*drawUVEdges)(DerivedMesh *dm); + void (*drawUVEdges)(struct DerivedMesh *dm); /** Draw all edges as lines (no options) * * Also called for *final* editmode DerivedMeshes */ - void (*drawEdges)(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges); + void (*drawEdges)(struct DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges); /** Draw all loose edges (edges w/ no adjoining faces) */ - void (*drawLooseEdges)(DerivedMesh *dm); + void (*drawLooseEdges)(struct DerivedMesh *dm); /** Draw all faces * o Set face normal or vertex normal based on inherited face flag @@ -385,13 +384,13 @@ struct DerivedMesh { * * Also called for *final* editmode DerivedMeshes */ - void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4], + void (*drawFacesSolid)(struct DerivedMesh *dm, float (*partial_redraw_planes)[4], bool fast, DMSetMaterial setMaterial); /** Draw all faces using MTFace * - Drawing options too complicated to enumerate, look at code. */ - void (*drawFacesTex)(DerivedMesh *dm, + void (*drawFacesTex)(struct DerivedMesh *dm, DMSetDrawOptionsTex setDrawOptions, DMCompareDrawOptions compareDrawOptions, void *userData); @@ -400,7 +399,7 @@ struct DerivedMesh { * o setMaterial is called for every different material nr * o Only if setMaterial returns true */ - void (*drawFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial); + void (*drawFacesGLSL)(struct DerivedMesh *dm, DMSetMaterial setMaterial); /** Draw mapped faces (no color, or texture) * - Only if !setDrawOptions or @@ -417,7 +416,7 @@ struct DerivedMesh { * lighting is disabled), in which case the implementation should draw as * smooth shaded. */ - void (*drawMappedFaces)(DerivedMesh *dm, + void (*drawMappedFaces)(struct DerivedMesh *dm, DMSetDrawOptions setDrawOptions, DMSetMaterial setMaterial, DMCompareDrawOptions compareDrawOptions, @@ -427,7 +426,7 @@ struct DerivedMesh { /** Draw mapped faces using MTFace * - Drawing options too complicated to enumerate, look at code. */ - void (*drawMappedFacesTex)(DerivedMesh *dm, + void (*drawMappedFacesTex)(struct DerivedMesh *dm, DMSetDrawOptions setDrawOptions, DMCompareDrawOptions compareDrawOptions, void *userData); @@ -437,7 +436,7 @@ struct DerivedMesh { * - setDrawOptions is called for every face * - Only if setMaterial and setDrawOptions return true */ - void (*drawMappedFacesGLSL)(DerivedMesh *dm, + void (*drawMappedFacesGLSL)(struct DerivedMesh *dm, DMSetMaterial setMaterial, DMSetDrawOptions setDrawOptions, void *userData); @@ -446,7 +445,7 @@ struct DerivedMesh { * - Only if !setDrawOptions or setDrawOptions(userData, mapped-edge) * returns true */ - void (*drawMappedEdges)(DerivedMesh *dm, + void (*drawMappedEdges)(struct DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData); @@ -457,7 +456,7 @@ struct DerivedMesh { * * NOTE: This routine is optional! */ - void (*drawMappedEdgesInterp)(DerivedMesh *dm, + void (*drawMappedEdgesInterp)(struct DerivedMesh *dm, DMSetDrawOptions setDrawOptions, DMSetDrawInterpOptions setDrawInterpOptions, void *userData); @@ -466,14 +465,14 @@ struct DerivedMesh { * - setMaterial is called for every different material nr * - setFace is called to verify if a face must be hidden */ - void (*drawMappedFacesMat)(DerivedMesh *dm, + void (*drawMappedFacesMat)(struct DerivedMesh *dm, void (*setMaterial)(void *userData, int matnr, void *attribs), bool (*setFace)(void *userData, int index), void *userData); - /** Release reference to the DerivedMesh. This function decides internally - * if the DerivedMesh will be freed, or cached for later use. */ - void (*release)(DerivedMesh *dm); -}; + /** Release reference to the struct DerivedMesh. This function decides internally + * if the struct DerivedMesh will be freed, or cached for later use. */ + void (*release)(struct DerivedMesh *dm); +} DerivedMesh; /** utility function to initialize a DerivedMesh's function pointers to * the default implementation (for those functions which have a default) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 69b85a95a60..0b71ea2440d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -44,6 +44,7 @@ #include "BKE_paint.h" #include "BKE_editmesh.h" #include "BKE_curve.h" +#include "BKE_DerivedMesh.h" /* external */ @@ -1637,52 +1638,6 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } } - if (do_draw && numdata != 0) { - offset = 0; - if (attribs.totorco && attribs.orco.array) { - copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]); - copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v2]); - copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v3]); - offset += sizeof(float) * 3; - } - for (b = 0; b < attribs.tottface; b++) { - if (attribs.tface[b].array) { - MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]); - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]); - - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]); - offset += sizeof(float) * 2; - } - } - for (b = 0; b < attribs.totmcol; b++) { - if (attribs.mcol[b].array) { - MCol *cp = &attribs.mcol[b].array[a * 4 + 0]; - GLubyte col[4]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); - cp = &attribs.mcol[b].array[a * 4 + 1]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); - cp = &attribs.mcol[b].array[a * 4 + 2]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); - offset += sizeof(unsigned char) * 4; - } - } - if (attribs.tottang && attribs.tang.array) { - const float *tang = attribs.tang.array[a * 4 + 0]; - copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); - tang = attribs.tang.array[a * 4 + 1]; - copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang); - tang = attribs.tang.array[a * 4 + 2]; - copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang); - offset += sizeof(float) * 4; - } - (void)offset; - } - curface++; - if (mface->v4) { if (do_draw && numdata != 0) { offset = 0; if (attribs.totorco && attribs.orco.array) { @@ -1717,7 +1672,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } } if (attribs.tottang && attribs.tang.array) { - const float *tang = attribs.tang.array[a * 4 + 2]; + const float *tang = attribs.tang.array[a * 4 + 0]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); tang = attribs.tang.array[a * 4 + 1]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang); @@ -1732,72 +1687,120 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, if (do_draw && numdata != 0) { offset = 0; if (attribs.totorco && attribs.orco.array) { - copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v3]); - copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v4]); - copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v1]); + copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v2]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v3]); offset += sizeof(float) * 3; } for (b = 0; b < attribs.tottface; b++) { if (attribs.tface[b].array) { MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]); - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]); - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]); + + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]); offset += sizeof(float) * 2; } } for (b = 0; b < attribs.totmcol; b++) { if (attribs.mcol[b].array) { - MCol *cp = &attribs.mcol[b].array[a * 4 + 2]; + MCol *cp = &attribs.mcol[b].array[a * 4 + 0]; GLubyte col[4]; col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); - cp = &attribs.mcol[b].array[a * 4 + 3]; + cp = &attribs.mcol[b].array[a * 4 + 1]; col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); - cp = &attribs.mcol[b].array[a * 4 + 0]; + cp = &attribs.mcol[b].array[a * 4 + 2]; col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); offset += sizeof(unsigned char) * 4; } } if (attribs.tottang && attribs.tang.array) { - float *tang = attribs.tang.array[a * 4 + 2]; + const float *tang = attribs.tang.array[a * 4 + 2]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); - tang = attribs.tang.array[a * 4 + 3]; + tang = attribs.tang.array[a * 4 + 1]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang); - tang = attribs.tang.array[a * 4 + 0]; + tang = attribs.tang.array[a * 4 + 2]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang); offset += sizeof(float) * 4; } (void)offset; } curface++; - i++; + if (mface->v4) { + if (do_draw && numdata != 0) { + offset = 0; + if (attribs.totorco && attribs.orco.array) { + copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v3]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v4]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v1]); + offset += sizeof(float) * 3; + } + for (b = 0; b < attribs.tottface; b++) { + if (attribs.tface[b].array) { + MTFace *tf = &attribs.tface[b].array[a]; + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]); + offset += sizeof(float) * 2; + } + } + for (b = 0; b < attribs.totmcol; b++) { + if (attribs.mcol[b].array) { + MCol *cp = &attribs.mcol[b].array[a * 4 + 2]; + GLubyte col[4]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 3]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 0]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); + offset += sizeof(unsigned char) * 4; + } + } + if (attribs.tottang && attribs.tang.array) { + float *tang = attribs.tang.array[a * 4 + 2]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); + tang = attribs.tang.array[a * 4 + 3]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang); + tang = attribs.tang.array[a * 4 + 0]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang); + offset += sizeof(float) * 4; + } + (void)offset; + } + curface++; + i++; + } } } - } - numfaces = curface - start; - if (numfaces > 0) { - if (do_draw) { - if (numdata != 0) { - GPU_buffer_unlock(buffer); - GPU_interleaved_attrib_setup(buffer, datatypes, numdata); - } + numfaces = curface - start; + if (numfaces > 0) { + if (do_draw) { + if (numdata != 0) { + GPU_buffer_unlock(buffer); + GPU_interleaved_attrib_setup(buffer, datatypes, numdata); + } - if (GPU_commit_aspect()) - glDrawArrays(GL_TRIANGLES, start * 3, (curface - start) * 3); + if (GPU_commit_aspect()) + glDrawArrays(GL_TRIANGLES, start * 3, (curface - start) * 3); + } } + GPU_buffer_unbind(); } - GPU_buffer_unbind(); + GPU_buffer_free(buffer); } - GPU_buffer_free(buffer); } // SSS Disable Smooth GPU_aspect_disable(GPU_ASPECT_BASIC, GPU_BASIC_SMOOTH); } + static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial) { dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL); diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 0d29e154923..f16fe3d3a67 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1158,7 +1158,7 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, new_matnr = efa->mat_nr + 1; if (new_matnr != matnr) { if (matnr != -1) - glEnd(); + gpuEnd(); do_draw = setMaterial(matnr = new_matnr, &gattribs); if (do_draw) { @@ -1279,7 +1279,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, new_matnr = efa->mat_nr + 1; if (new_matnr != matnr) { if (matnr != -1) - glEnd(); + gpuEnd(); setMaterial(userData, matnr = new_matnr, &gattribs); DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); @@ -1328,7 +1328,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, } if (matnr != -1) { - glEnd(); + gpuEnd(); } // SSS Disable Smooth diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 9b95f24a2c2..8cea5f933b9 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2132,7 +2132,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, CCGElem *vda, *vdb; if (ln) { - glBegin(GL_QUADS); + gpuBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { float *aco = CCG_grid_elem_co(&key, faceGridData, x, y); @@ -2141,23 +2141,23 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1); PASSATTRIB(0, 1, 1); - glNormal3sv(ln[0][1]); - glVertex3fv(dco); + gpuNormal3sv(ln[0][1]); + gpuVertex3fv(dco); PASSATTRIB(1, 1, 2); - glNormal3sv(ln[0][2]); - glVertex3fv(cco); + gpuNormal3sv(ln[0][2]); + gpuVertex3fv(cco); PASSATTRIB(1, 0, 3); - glNormal3sv(ln[0][3]); - glVertex3fv(bco); + gpuNormal3sv(ln[0][3]); + gpuVertex3fv(bco); PASSATTRIB(0, 0, 0); - glNormal3sv(ln[0][0]); - glVertex3fv(aco); + gpuNormal3sv(ln[0][0]); + gpuVertex3fv(aco); ln++; a++; } } - glEnd(); + gpuEnd(); } else if (drawSmooth) { for (y = 0; y < gridFaces; y++) { @@ -2315,7 +2315,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, CCGElem *vda, *vdb; if (ln) { - glBegin(GL_QUADS); + gpuBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { float *aco = CCG_grid_elem_co(&key, faceGridData, x, y + 0); @@ -2324,23 +2324,23 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1); PASSATTRIB(0, 1, 1); - glNormal3sv(ln[0][1]); - glVertex3fv(dco); + gpuNormal3sv(ln[0][1]); + gpuVertex3fv(dco); PASSATTRIB(1, 1, 2); - glNormal3sv(ln[0][2]); - glVertex3fv(cco); + gpuNormal3sv(ln[0][2]); + gpuVertex3fv(cco); PASSATTRIB(1, 0, 3); - glNormal3sv(ln[0][3]); - glVertex3fv(bco); + gpuNormal3sv(ln[0][3]); + gpuVertex3fv(bco); PASSATTRIB(0, 0, 0); - glNormal3sv(ln[0][0]); - glVertex3fv(aco); + gpuNormal3sv(ln[0][0]); + gpuVertex3fv(aco); ln++; a++; } } - glEnd(); + gpuEnd(); } else if (drawSmooth) { for (y = 0; y < gridFaces; y++) { @@ -2530,7 +2530,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, ln++; } } - glEnd(); + gpuEnd(); } else if (drawSmooth) { // SSS Enable Smooth @@ -2758,7 +2758,7 @@ static void ccgDM_drawMappedFaces( CCGElem *faceGridData = (CCGElem*)ccgSubSurf_getFaceGridDataArray(ss, f, S); if (ln) { - glBegin(GL_QUADS); + gpuBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { float *a = CCG_grid_elem_co(&key, faceGridData, x, y + 0); @@ -2766,24 +2766,24 @@ static void ccgDM_drawMappedFaces( float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1); float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1); - if (cp) glColor3ub(cp[7], cp[6], cp[5]); - glNormal3sv(ln[0][1]); - glVertex3fv(d); - if (cp) glColor3ub(cp[11], cp[10], cp[9]); - glNormal3sv(ln[0][2]); - glVertex3fv(c); - if (cp) glColor3ub(cp[15], cp[14], cp[13]); - glNormal3sv(ln[0][3]); - glVertex3fv(b); - if (cp) glColor3ub(cp[3], cp[2], cp[1]); - glNormal3sv(ln[0][0]); - glVertex3fv(a); + if (cp) gpuColor3ub(cp[7], cp[6], cp[5]); + gpuNormal3sv(ln[0][1]); + gpuVertex3fv(d); + if (cp) gpuColor3ub(cp[11], cp[10], cp[9]); + gpuNormal3sv(ln[0][2]); + gpuVertex3fv(c); + if (cp) gpuColor3ub(cp[15], cp[14], cp[13]); + gpuNormal3sv(ln[0][3]); + gpuVertex3fv(b); + if (cp) gpuColor3ub(cp[3], cp[2], cp[1]); + gpuNormal3sv(ln[0][0]); + gpuVertex3fv(a); if (cp) cp += 16; ln++; } } - glEnd(); + gpuEnd(); } else if (drawSmooth) { for (y = 0; y < gridFaces; y++) { diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h index cf10fe53a5d..693d2b782cc 100644 --- a/source/blender/blenlib/BLI_bitmap.h +++ b/source/blender/blenlib/BLI_bitmap.h @@ -30,6 +30,8 @@ * \ingroup bli */ +#include "MEM_guardedalloc.h" + typedef unsigned int BLI_bitmap; /* warning: the bitmap does not keep track of its own size or check diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index b915ec64d11..f0a8459f5bb 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1556,7 +1556,7 @@ void rotate_m4_right(float mat[][4], const char axis) for(i=0; i<3; i++) { tmpf = mat[rotmat[1]][i]; - mat[rotmat[1]][i] = -1.0*mat[rotmat[0]][i]; + mat[rotmat[1]][i] = -1.0f*mat[rotmat[0]][i]; mat[rotmat[0]][i] = tmpf; } @@ -2206,24 +2206,19 @@ void pseudoinverse_m4_m4(float Ainv[4][4], float A[4][4], float epsilon) void mat4_ortho_set(float m[][4], float left, float right, float bottom, float top, float nearVal, float farVal) { - - m[0][0] = 2.0/(right-left); m[1][0] = 0.0f; m[2][0] = 0.0f; m[3][0] = -((double)right+left)/(right-left); - m[0][1] = 0.0f; m[1][1] = 2.0/(top-bottom);m[2][1] = 0.0f; m[3][1] = -((double)top+bottom)/(top-bottom); - m[0][2] = 0.0f; m[1][2] = 0.0f; m[2][2] = -2.0/(farVal-nearVal); m[3][2] = -((double)farVal+nearVal)/(farVal-nearVal); - m[0][3] = 0.0f; m[1][3] = 0.0f; m[2][3] = 0.0f; m[3][3] = 1.0; - - + m[0][0] = 2.0f/(right-left); m[1][0] = 0.0f; m[2][0] = 0.0f; m[3][0] = -(right+left)/(right-left); + m[0][1] = 0.0f; m[1][1] = 2.0f/(top-bottom); m[2][1] = 0.0f; m[3][1] = -(top+bottom)/(top-bottom); + m[0][2] = 0.0f; m[1][2] = 0.0f; m[2][2] = -2.0f/(farVal-nearVal); m[3][2] = -(farVal+nearVal)/(farVal-nearVal); + m[0][3] = 0.0f; m[1][3] = 0.0f; m[2][3] = 0.0f; m[3][3] = 1.0f; } void mat4_frustum_set(float m[][4], float left, float right, float bottom, float top, float nearVal, float farVal) { - - m[0][0] = 2.0*nearVal/(right-left); m[1][0] = 0.0f; m[2][0] = (right+left)/(right-left); m[3][0] = 0.0f; - m[0][1] = 0.0f; m[1][1] = 2.0*nearVal/(top-bottom); m[2][1] = (top+bottom)/(top-bottom); m[3][1] = 0.0f; - m[0][2] = 0.0f; m[1][2] = 0.0f; m[2][2] = -(farVal+nearVal)/(farVal-nearVal); m[3][2] = -2.0*farVal*nearVal/(farVal-nearVal); - m[0][3] = 0.0f; m[1][3] = 0.0f; m[2][3] = - 1.0f; m[3][3] = 0.0f; - + m[0][0] = 2.0f*nearVal/(right-left); m[1][0] = 0.0f; m[2][0] = (right+left)/(right-left); m[3][0] = 0.0f; + m[0][1] = 0.0f; m[1][1] = 2.0f*nearVal/(top-bottom); m[2][1] = (top+bottom)/(top-bottom); m[3][1] = 0.0f; + m[0][2] = 0.0f; m[1][2] = 0.0f; m[2][2] = -(farVal+nearVal)/(farVal-nearVal); m[3][2] = -2.0f*farVal*nearVal/(farVal-nearVal); + m[0][3] = 0.0f; m[1][3] = 0.0f; m[2][3] = -1.0f; m[3][3] = 0.0f; } /* diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 98ccbd38805..f9839731029 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2992,11 +2992,11 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { /* Yes, the color vector has 4 components, BUT we only want to be using 3 of them! */ - glColor3fv(color); + gpuColor3fv(color); } else { float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f; - glColor4f(color[0], color[1], color[2], alpha); + gpuColor4f(color[0], color[1], color[2], alpha); } /* only on top left corner, to show that this channel sits on top of the preceding ones diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 2065ae36351..d161e0c0ca4 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -203,7 +203,7 @@ struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, con KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]); /* Find a given ID in the KeyingSet */ -bool ANIM_keyingset_find_id(struct KeyingSet *ks, ID *id); +bool ANIM_keyingset_find_id(struct KeyingSet *ks, struct ID *id); /* for RNA type registrations... */ void ANIM_keyingset_info_register(struct KeyingSetInfo *ksi); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3f8e643988f..d9e47e74c40 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -476,10 +476,11 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines, int das if (dashInactiveLines) UI_ThemeColor(TH_GRID); else if (line->flag & UI_SELECT) + gpuGray3f(100.0f/255.0f); else if (highlightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) UI_ThemeColor(TH_TEXT_HI); else - gpuColor3P(CPACK_BLACK); + gpuGray3f(0); ui_draw_link_bezier(&rect); } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 80e4b75315b..5d226ed096a 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -988,48 +988,43 @@ static void ui_draw_colorband_handle_tri_hlight(float x1, float y1, float halfwi { float v[2]; - glEnable(GL_LINE_SMOOTH); + GPU_aspect_enable(GPU_ASPECT_RASTER, GPU_RASTER_AA); - glBegin(GL_LINE_STRIP); + gpuBegin(GL_LINE_STRIP); copy_v2_fl2(v, x1 + halfwidth, y1); - glVertex2fv(v); + gpuVertex2fv(v); copy_v2_fl2(v, x1, y1 + height); - glVertex2fv(v); + gpuVertex2fv(v); copy_v2_fl2(v, x1 - halfwidth, y1); - glVertex2fv(v); - glEnd(); + gpuVertex2fv(v); + gpuEnd(); - glDisable(GL_LINE_SMOOTH); + GPU_aspect_disable(GPU_ASPECT_RASTER, GPU_RASTER_AA); } static void ui_draw_colorband_handle_tri(float x1, float y1, float halfwidth, float height, bool fill) { float v[2]; - if (fill) { - glPolygonMode(GL_FRONT, GL_FILL); - glEnable(GL_POLYGON_SMOOTH); - } - else { - glPolygonMode(GL_FRONT, GL_LINE); - glEnable(GL_LINE_SMOOTH); + if (!fill) { + gpuPolygonMode(GL_LINE); } - glBegin(GL_TRIANGLES); + GPU_aspect_enable(GPU_ASPECT_RASTER, GPU_RASTER_AA); + + gpuBegin(GL_TRIANGLES); copy_v2_fl2(v, x1 + halfwidth, y1); - glVertex2fv(v); + gpuVertex2fv(v); copy_v2_fl2(v, x1, y1 + height); - glVertex2fv(v); + gpuVertex2fv(v); copy_v2_fl2(v, x1 - halfwidth, y1); - glVertex2fv(v); - glEnd(); + gpuVertex2fv(v); + gpuEnd(); - if (fill) { - glDisable(GL_POLYGON_SMOOTH); - } - else { - glDisable(GL_LINE_SMOOTH); - glPolygonMode(GL_FRONT, GL_FILL); + GPU_aspect_disable(GPU_ASPECT_RASTER, GPU_RASTER_AA); + + if (!fill) { + gpuPolygonMode(GL_FILL); /* return to default */ } } @@ -1037,26 +1032,23 @@ static void ui_draw_colorband_handle_box(float x1, float y1, float x2, float y2, { float v[2]; - if (fill) { - glPolygonMode(GL_FRONT, GL_FILL); - } - else { - glPolygonMode(GL_FRONT, GL_LINE); + if (!fill) { + gpuPolygonMode(GL_LINE); } - glBegin(GL_QUADS); + gpuBegin(GL_QUADS); copy_v2_fl2(v, x1, y1); - glVertex2fv(v); + gpuVertex2fv(v); copy_v2_fl2(v, x1, y2); - glVertex2fv(v); + gpuVertex2fv(v); copy_v2_fl2(v, x2, y2); - glVertex2fv(v); + gpuVertex2fv(v); copy_v2_fl2(v, x2, y1); - glVertex2fv(v); - glEnd(); + gpuVertex2fv(v); + gpuEnd(); if (!fill) { - glPolygonMode(GL_FRONT, GL_FILL); + gpuPolygonMode(GL_FILL); /* return to default */ } } @@ -1081,18 +1073,18 @@ static void ui_draw_colorband_handle( y1 = floorf(y1 + 0.5f); if (active || half_width < min_width) { - glBegin(GL_LINES); - glColor3ub(0, 0, 0); - glVertex2f(x, y1); - glVertex2f(x, y2); - glEnd(); - setlinestyle(active ? 2 : 1); - glBegin(GL_LINES); - glColor3ub(200, 200, 200); - glVertex2f(x, y1); - glVertex2f(x, y2); - glEnd(); - setlinestyle(0); + gpuBegin(GL_LINES); + gpuColor3ub(0, 0, 0); + gpuVertex2f(x, y1); + gpuVertex2f(x, y2); + gpuEnd(); + GPU_raster_set_line_style(active ? 2 : 1); + gpuBegin(GL_LINES); + gpuColor3ub(200, 200, 200); + gpuVertex2f(x, y1); + gpuVertex2f(x, y2); + gpuEnd(); + GPU_raster_set_line_style(0); /* hide handles when zoomed out too far */ if (half_width < min_width) { @@ -1103,7 +1095,7 @@ static void ui_draw_colorband_handle( /* shift handle down */ y1 = y1 - half_width; - glColor3ub(0, 0, 0); + gpuColor3ub(0, 0, 0); ui_draw_colorband_handle_box(x - half_width, y1 - 1, x + half_width, y1 + height, false); /* draw all triangles blended */ @@ -1112,30 +1104,30 @@ static void ui_draw_colorband_handle( ui_draw_colorband_handle_tri(x, y1 + height, half_width, half_width, true); if (active) - glColor3ub(196, 196, 196); + gpuColor3ub(196, 196, 196); else - glColor3ub(128, 128, 128); + gpuColor3ub(128, 128, 128); ui_draw_colorband_handle_tri(x, y1 + height, half_width, half_width, true); if (active) - glColor3ub(255, 255, 255); + gpuColor3ub(255, 255, 255); else - glColor3ub(196, 196, 196); + gpuColor3ub(196, 196, 196); ui_draw_colorband_handle_tri_hlight(x, y1 + height - 1, (half_width - 1), (half_width - 1)); - glColor3ub(0, 0, 0); + gpuColor3ub(0, 0, 0); ui_draw_colorband_handle_tri_hlight(x, y1 + height, half_width, half_width); glDisable(GL_BLEND); - glColor3ub(128, 128, 128); + gpuColor3ub(128, 128, 128); ui_draw_colorband_handle_box(x - (half_width - 1), y1, x + (half_width - 1), y1 + height, true); if (display) { IMB_colormanagement_scene_linear_to_display_v3(colf, display); } - glColor3fv(colf); + gpuColor3fv(colf); ui_draw_colorband_handle_box(x - (half_width - 2), y1 + 1, x + (half_width - 2), y1 + height - 2, true); } @@ -1233,14 +1225,14 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti /* layer: box outline */ gpuColor4f(0.0, 0.0, 0.0, 1.0); - fdrawbox(x1, y1, x1 + sizex, rect->ymax); + gpuDrawWireRectf(x1, y1, x1 + sizex, rect->ymax); /* layer: box outline */ glEnable(GL_BLEND); gpuColor4f(0.0f, 0.0f, 0.0f, 0.5f); - fdrawline(x1, y1, x1 + sizex, y1); + gpuDrawLinef(x1, y1, x1 + sizex, y1); gpuColor4f(1.0f, 1.0f, 1.0f, 0.25f); - fdrawline(x1, y1 - 1, x1 + sizex, y1 - 1); + gpuDrawLinef(x1, y1 - 1, x1 + sizex, y1 - 1); glDisable(GL_BLEND); /* layer: draw handles */ diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index fc3ef1a27cd..a88cf1b5b9b 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1545,7 +1545,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* begin drawing */ - glEnable(GL_LINE_SMOOTH); + //glEnable(GL_LINE_SMOOTH); // XXX jwilkins: this seems to be the only place that requires AA line drawing with the basic aspect /* draw the background */ if (is_alpha) { @@ -1654,7 +1654,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) pc_dyn->rect.xmin = v2d->mask.xmin; } - glDisable(GL_LINE_SMOOTH); + //glDisable(GL_LINE_SMOOTH); // XXX jwilkins: this seems to be the only place that requires AA line drawing with the basic aspect BLF_disable(fontid, BLF_ROTATION); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index b1cde208fa8..f924e372d34 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -309,7 +309,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline MEM_freeN(feather_points); if (is_smooth) { - GPU_aspect_enable(GPU_ASPECT_RASTER, GPU_ASPECT_SMOOTH); + GPU_aspect_enable(GPU_ASPECT_RASTER, GPU_RASTER_AA); glEnable(GL_BLEND); } @@ -374,7 +374,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline GPU_point_size(1); if (is_smooth) { - GPU_aspect_disable(GPU_ASPECT_RASTER, GPU_RASTER_SMOOTH); + GPU_aspect_disable(GPU_ASPECT_RASTER, GPU_RASTER_AA); glDisable(GL_BLEND); } } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 3b9393e8856..3bddf0d0f48 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2037,8 +2037,8 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect) void ED_region_cache_draw_background(const ARegion *ar) { - glColor4ub(128, 128, 255, 64); - glRecti(0, 0, ar->winx, 8 * UI_DPI_FAC); + gpuColor4ub(128, 128, 255, 64); + gpuSingleFilledRecti(0, 0, ar->winx, 8 * UI_DPI_FAC); } void ED_region_cache_draw_curfra_label(const int framenr, const float x, const float y) @@ -2054,7 +2054,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]); - glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); + gpuSingleFilledRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); UI_ThemeColor(TH_TEXT); BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f); @@ -2066,7 +2066,7 @@ void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segme if (num_segments) { int a; - glColor4ub(128, 128, 255, 128); + gpuColor4ub(128, 128, 255, 128); for (a = 0; a < num_segments; a++) { float x1, x2; @@ -2074,7 +2074,7 @@ void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segme x1 = (float)(points[a * 2] - sfra) / (efra - sfra + 1) * ar->winx; x2 = (float)(points[a * 2 + 1] - sfra + 1) / (efra - sfra + 1) * ar->winx; - glRecti(x1, 0, x2, 8 * UI_DPI_FAC); + gpuSingleFilledRecti(x1, 0, x2, 8 * UI_DPI_FAC); } } } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 7941d6088a7..4fbadedd611 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -94,6 +94,13 @@ #include "paint_intern.h" +/* Defines and Structs */ +/* FTOCHAR as inline function */ +BLI_INLINE unsigned char f_to_char(const float val) +{ + return FTOCHAR(val); +} + /* ProjectionPaint defines */ /* approx the number of buckets to have under the brush, diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 797a881ce79..830715af4de 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -65,8 +65,9 @@ #include "paint_intern.h" #include "uvedit_intern.h" -#include "BIF_gl.h" -#include "BIF_glutil.h" +#include "GPU_blender_aspect.h" +#include "GPU_primitives.h" +#include "GPU_raster.h" #include "UI_view2d.h" @@ -207,18 +208,16 @@ 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); } - glPushMatrix(); + GPU_raster_begin(); - glTranslatef((float)x, (float)y, 0.0f); - - glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha); - glEnable(GL_LINE_SMOOTH); + gpuColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha); + GPU_aspect_enable(GPU_ASPECT_RASTER, GPU_RASTER_AA); glEnable(GL_BLEND); - glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size, 40); + gpuDrawCircle(x, y, size, 40); glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_aspect_disable(GPU_ASPECT_RASTER, GPU_RASTER_AA); - glPopMatrix(); + GPU_raster_end(); } #undef PX_SIZE_FADE_MAX #undef PX_SIZE_FADE_MIN diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 3b6ed52a7cc..a68b433b57e 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -951,7 +951,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) x = (cfra - sfra) / (efra - sfra + 1) * ar->winx; UI_ThemeColor(TH_CFRAME); - glRecti(x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC); + gpuSingleFilledRecti(x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC); ED_region_cache_draw_curfra_label(cfra, x, 8.0f * UI_DPI_FAC); if (mask != NULL) { diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 9cf648eeef6..5206d2dd326 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -115,7 +115,7 @@ void make_unique_prop_names(bContext *C, char *str) bActuator *act; ID **idar; short a, obcount, propcount=0, nr; - const char **names; + char **names; /* this function is called by a Button, and gives the current * stringpointer as an argument, this is the one that can change diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index df12d58d0a2..a8cfe75e8a8 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -38,6 +38,7 @@ #include "ED_sequencer.h" #include "ED_types.h" #include "ED_space_api.h" +#include "ED_anim_api.h" #include "UI_interface.h" #include "UI_resources.h" diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 764c9b65b7b..d08c7df617a 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -1108,8 +1108,7 @@ static void draw_mesh_paint_light_begin(void) } static void draw_mesh_paint_light_end(void) { - glDisable(GL_COLOR_MATERIAL); - glDisable(GL_LIGHTING); + GPU_aspect_disable(GPU_ASPECT_BASIC, GPU_BASIC_LIGHTING); GPU_disable_material(); } @@ -1156,7 +1155,7 @@ void draw_mesh_paint_vcolor_faces(DerivedMesh *dm, const bool use_light, DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); } else { - glColor3f(1.0f, 1.0f, 1.0f); + gpuColor3P(CPACK_WHITE); dm->drawMappedFaces(dm, facemask_cb, GPU_enable_material, NULL, user_data, DM_DRAW_ALWAYS_SMOOTH); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index d50728c134b..4c3109b4223 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2423,8 +2423,8 @@ static void draw_dm_loop_normals__mapFunc(void *userData, int vertex_index, int } mul_v3_fl(vec, data->normalsize); add_v3_v3(vec, co); - glVertex3fv(co); - glVertex3fv(vec); + gpuVertex3fv(co); + gpuVertex3fv(vec); } } } @@ -2438,9 +2438,9 @@ static void draw_dm_loop_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv calcDrawDMNormalScale(ob, &data); - glBegin(GL_LINES); + gpuBegin(GL_LINES); dm->foreachMappedLoop(dm, draw_dm_loop_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL); - glEnd(); + gpuEnd(); } /* Draw faces with color set based on selection diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6e795fa39ea..5fb58fc0767 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2754,10 +2754,10 @@ static void view3d_draw_objects( ED_region_pixelspace(ar); drawgrid(&scene->unit, ar, v3d, grid_unit); /* XXX make function? replaces persp(1) */ - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(rv3d->winmat); - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(rv3d->viewmat); + gpuMatrixMode(GL_PROJECTION); + gpuLoadMatrix(rv3d->winmat); + gpuMatrixMode(GL_MODELVIEW); + gpuLoadMatrix(rv3d->viewmat); } } } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index a0ca518dbb8..3c1bdc0be8f 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -176,7 +176,7 @@ void draw_mesh_paint_weight_faces(struct DerivedMesh *dm, const bool do_light, void draw_mesh_paint_vcolor_faces(struct DerivedMesh *dm, const bool use_light, void *facemask_cb, void *user_data, const struct Mesh *me); -void draw_mesh_paint_weight_edges(RegionView3D *rv3d, struct DerivedMesh *dm, +void draw_mesh_paint_weight_edges(struct RegionView3D *rv3d, struct DerivedMesh *dm, const bool use_depth, const bool use_alpha, void *edgemask_cb, void *user_data); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index fb4d8c2cf80..21843c340d6 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1143,7 +1143,7 @@ static void draw_manipulator_rotate( preOrthoFront(ortho, matt, 0); if (is_picksel) GPU_select_load(MAN_ROT_X); - else manipulator_setcolor(v3d, 'X', colcode, 255); + else set_manipulator_color(v3d, 'X', colcode, 255); gpuPushMatrix(); gpuRotateRight('Y'); @@ -1158,7 +1158,7 @@ static void draw_manipulator_rotate( preOrthoFront(ortho, matt, 1); if (is_picksel) GPU_select_load(MAN_ROT_Y); - else manipulator_setcolor(v3d, 'Y', colcode, 255); + else set_manipulator_color(v3d, 'Y', colcode, 255); gpuPushMatrix(); gpuRotateRight(-'X'); @@ -1206,7 +1206,7 @@ static void draw_manipulator_rotate( /* X handle on Z axis */ if (drawflags & MAN_ROT_X) { preOrthoFront(ortho, rv3d->twmat, 0); - glPushMatrix(); + gpuPushMatrix(); if (is_picksel) GPU_select_load(MAN_ROT_X); else set_manipulator_color(v3d, 'X', colcode, 255); @@ -1426,10 +1426,8 @@ static void draw_manipulator_translate( glDisable(GL_DEPTH_TEST); /* center circle, do not add to selection when shift is pressed (planar constraint) */ - if (is_picksel && shift==0) { + if (is_picksel && shift==0) GPU_select_load(MAN_TRANS_C); else set_manipulator_color(v3d, 'C', colcode, 255); - } - gpuPushMatrix(); size = screen_aligned(rv3d, rv3d->twmat); @@ -1474,7 +1472,7 @@ static void draw_manipulator_translate( if (is_picksel) { GPU_select_load(MAN_TRANS_Z); } - set_manipulator_color(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2])); + set_manipulator_color(v3d, 'Z', colcode, axisBlendAngle(rv3d->tw_idot[2])); gpuDrawElements(GL_TRIANGLES); gpuTranslate(0.0, 0.0, -dz); } @@ -1487,7 +1485,7 @@ static void draw_manipulator_translate( GPU_select_load(MAN_TRANS_X); } gpuRotateAxis(90.0, 'Y'); - set_manipulator_color(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0])); + set_manipulator_color(v3d, 'X', colcode, axisBlendAngle(rv3d->tw_idot[0])); gpuDrawElements(GL_TRIANGLES); gpuRotateAxis(-90.0, 'Y'); gpuTranslate(-dz, 0.0, 0.0); diff --git a/source/blender/gpu/GPU_deprecated.h b/source/blender/gpu/GPU_deprecated.h index 33ae7efec65..7fbf9ef36c3 100644 --- a/source/blender/gpu/GPU_deprecated.h +++ b/source/blender/gpu/GPU_deprecated.h @@ -640,7 +640,11 @@ #define glLineStipple DO_NOT_USE_glLineStipple #undef glPolygonStipple #define glPolygonStipple DO_NOT_USE_glPolygonStipple +#undef glPolygonMode +#define glPolygonMode DO_NOT_USE_glPolygonMode #undef glLineWidth #define glLineWidth DO_NOT_USE_glLineWidth +#undef GL_LINE_SMOOTH +#define GL_LINE_SMOOTH DO_NOT_USE_GL_LINE_SMOOTH #endif /* _GPU_DEPRECATED_H_ */ diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index b4078bf234e..5b3e1929384 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -32,6 +32,8 @@ * \ingroup gpu */ +#include "BLI_sys_types.h" + #include <stddef.h> #ifdef __cplusplus diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 9bd5a95e489..d1e3a38d1bb 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -41,6 +41,8 @@ #include "GPU_draw.h" #include "GPU_glew.h" #include "GPU_immediate.h" +#include "GPU_raster.h" + /* internal */ #include "intern/gpu_extensions_intern.h" @@ -2723,9 +2725,9 @@ void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf) }; if (leaf) - glColor4f(0.0, 1.0, 0.0, 0.5); + gpuColor4f(0.0, 1.0, 0.0, 0.5); else - glColor4f(1.0, 0.0, 0.0, 0.5); + gpuColor4f(1.0, 0.0, 0.0, 0.5); glVertexPointer(3, GL_FLOAT, 0, &quads[0][0][0]); glDrawArrays(GL_QUADS, 0, 16); @@ -2733,19 +2735,22 @@ void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf) void GPU_init_draw_pbvh_BB(void) { + GPU_raster_begin(); + glPushAttrib(GL_ENABLE_BIT); glDisable(GL_CULL_FACE); glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); + gpuPolygonMode(GL_LINE); + GPU_aspect_enable(GPU_ASPECT_BASIC, GPU_BASIC_LIGHTING); glEnable(GL_BLEND); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); } void GPU_end_draw_pbvh_BB(void) { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + gpuPolygonMode(GL_FILL); glPopAttrib(); + + GPU_raster_end(); } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index d2976b248af..4cab5ba76b2 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1858,7 +1858,7 @@ int GPU_enable_material(int nr, void *attribs) } if (GMS.use_matcaps) - glColor3f(1.0, 1.0, 1.0f); + gpuColor3P(CPACK_WHITE); } else { /* or do a basic material */ diff --git a/source/blender/gpu/intern/gpu_pixels.c b/source/blender/gpu/intern/gpu_pixels.c index 3e3410be539..144c602759a 100644 --- a/source/blender/gpu/intern/gpu_pixels.c +++ b/source/blender/gpu/intern/gpu_pixels.c @@ -56,7 +56,7 @@ static struct GPUShader* PIXELS_SHADER = NULL; static struct GPUcommon PIXELS_COMMON = {0}; -static bool PIXELS_FAILED = FALSE; +static bool PIXELS_FAILED = false; static GLfloat PIXELS_POS[3] = { 0, 0, 0 }; |