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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/CMakeLists.txt3
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c49
-rw-r--r--source/blender/editors/animation/anim_draw.c46
-rw-r--r--source/blender/editors/animation/anim_markers.c39
-rw-r--r--source/blender/editors/animation/keyframes_draw.c75
-rw-r--r--source/blender/editors/armature/CMakeLists.txt3
-rw-r--r--source/blender/editors/armature/editarmature.c2
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c128
-rw-r--r--source/blender/editors/armature/reeb.c80
-rw-r--r--source/blender/editors/gpencil/CMakeLists.txt3
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c161
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c20
-rw-r--r--source/blender/editors/include/BIF_gl.h56
-rw-r--r--source/blender/editors/include/BIF_glutil.h46
-rw-r--r--source/blender/editors/include/ED_mesh.h2
-rw-r--r--source/blender/editors/include/ED_node.h1
-rw-r--r--source/blender/editors/include/ED_view3d.h2
-rw-r--r--source/blender/editors/include/UI_resources.h5
-rw-r--r--source/blender/editors/interface/CMakeLists.txt2
-rw-r--r--source/blender/editors/interface/interface.c28
-rw-r--r--source/blender/editors/interface/interface_draw.c1070
-rw-r--r--source/blender/editors/interface/interface_icons.c235
-rw-r--r--source/blender/editors/interface/interface_ops.c2
-rw-r--r--source/blender/editors/interface/interface_panel.c109
-rw-r--r--source/blender/editors/interface/interface_regions.c8
-rw-r--r--source/blender/editors/interface/interface_widgets.c455
-rw-r--r--source/blender/editors/interface/resources.c118
-rw-r--r--source/blender/editors/interface/view2d.c192
-rw-r--r--source/blender/editors/mask/CMakeLists.txt1
-rw-r--r--source/blender/editors/mask/mask_draw.c136
-rw-r--r--source/blender/editors/mask/mask_select.c2
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt3
-rw-r--r--source/blender/editors/mesh/editface.c2
-rw-r--r--source/blender/editors/mesh/editmesh_bvh.c2
-rw-r--r--source/blender/editors/mesh/editmesh_bvh.h2
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c109
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c22
-rw-r--r--source/blender/editors/mesh/editmesh_select.c37
-rw-r--r--source/blender/editors/mesh/editmesh_slide.c39
-rw-r--r--source/blender/editors/physics/CMakeLists.txt3
-rw-r--r--source/blender/editors/physics/particle_edit.c22
-rw-r--r--source/blender/editors/render/CMakeLists.txt2
-rw-r--r--source/blender/editors/render/render_opengl.c3
-rw-r--r--source/blender/editors/render/render_preview.c2
-rw-r--r--source/blender/editors/screen/CMakeLists.txt3
-rw-r--r--source/blender/editors/screen/area.c232
-rw-r--r--source/blender/editors/screen/glutil.c432
-rw-r--r--source/blender/editors/screen/screen_edit.c104
-rw-r--r--source/blender/editors/screen/screendump.c11
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt2
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c62
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c17
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c37
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c21
-rw-r--r--source/blender/editors/space_action/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_action/action_draw.c73
-rw-r--r--source/blender/editors/space_action/space_action.c6
-rw-r--r--source/blender/editors/space_buttons/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c4
-rw-r--r--source/blender/editors/space_clip/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c73
-rw-r--r--source/blender/editors/space_clip/clip_draw.c446
-rw-r--r--source/blender/editors/space_clip/clip_editor.c2
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c49
-rw-r--r--source/blender/editors/space_clip/clip_utils.c38
-rw-r--r--source/blender/editors/space_clip/space_clip.c12
-rw-r--r--source/blender/editors/space_clip/tracking_select.c2
-rw-r--r--source/blender/editors/space_console/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_console/console_draw.c8
-rw-r--r--source/blender/editors/space_console/space_console.c4
-rw-r--r--source/blender/editors/space_file/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_file/file_draw.c32
-rw-r--r--source/blender/editors/space_file/fsmenu.c3
-rw-r--r--source/blender/editors/space_file/space_file.c8
-rw-r--r--source/blender/editors/space_graph/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_graph/graph_draw.c186
-rw-r--r--source/blender/editors/space_graph/space_graph.c32
-rw-r--r--source/blender/editors/space_image/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_image/image_draw.c98
-rw-r--r--source/blender/editors/space_image/space_image.c5
-rw-r--r--source/blender/editors/space_info/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_info/info_draw.c5
-rw-r--r--source/blender/editors/space_info/space_info.c4
-rw-r--r--source/blender/editors/space_info/textview.c30
-rw-r--r--source/blender/editors/space_logic/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_logic/logic_window.c3
-rw-r--r--source/blender/editors/space_logic/space_logic.c5
-rw-r--r--source/blender/editors/space_nla/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_nla/nla_draw.c198
-rw-r--r--source/blender/editors/space_nla/space_nla.c6
-rw-r--r--source/blender/editors/space_node/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_node/drawnode.c1010
-rw-r--r--source/blender/editors/space_node/node_draw.c85
-rw-r--r--source/blender/editors/space_node/node_select.c2
-rw-r--r--source/blender/editors/space_outliner/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c90
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c4
-rw-r--r--source/blender/editors/space_script/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_script/space_script.c4
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c317
-rw-r--r--source/blender/editors/space_text/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_text/space_text.c4
-rw-r--r--source/blender/editors/space_text/text_draw.c270
-rw-r--r--source/blender/editors/space_time/CMakeLists.txt3
-rw-r--r--source/blender/editors/space_time/space_time.c82
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_view3d/drawanimviz.c117
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c1016
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c225
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2946
-rw-r--r--source/blender/editors/space_view3d/drawvolume.c48
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_composite.c28
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c611
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c77
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c49
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h6
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c34
-rw-r--r--source/blender/editors/transform/CMakeLists.txt3
-rw-r--r--source/blender/editors/transform/transform.c567
-rw-r--r--source/blender/editors/transform/transform.h7
-rw-r--r--source/blender/editors/transform/transform_constraints.c100
-rw-r--r--source/blender/editors/transform/transform_generics.c41
-rw-r--r--source/blender/editors/transform/transform_manipulator.c764
-rw-r--r--source/blender/editors/transform/transform_snap.c130
-rw-r--r--source/blender/editors/util/CMakeLists.txt1
-rw-r--r--source/blender/editors/uvedit/CMakeLists.txt3
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c232
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c4
133 files changed, 7557 insertions, 6981 deletions
diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt
index 9e1e44e411d..0de1e201b85 100644
--- a/source/blender/editors/animation/CMakeLists.txt
+++ b/source/blender/editors/animation/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -58,4 +59,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_animation "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 9ceecd60bef..027ff1a08e8 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -69,8 +69,8 @@
#include "ED_anim_api.h"
#include "ED_keyframing.h"
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -110,14 +110,14 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa
short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0;
short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
float color[3];
-
+
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
- glColor3fv(color);
-
+ gpuCurrentColor3fv(color);
+
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
uiSetRoundBox((expanded) ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
- uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
+ uiDrawBox(GL_TRIANGLE_FAN, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
}
@@ -138,10 +138,10 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
- glColor3fv(color);
+ gpuCurrentColor3fv(color);
/* no rounded corner - just rectangular box */
- glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
+ gpuSingleFilledRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
}
/* helper method to test if group colors should be drawn */
@@ -219,10 +219,10 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
- glColor3fv(color);
+ gpuCurrentColor3fv(color);
/* no rounded corners - just rectangular box */
- glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
+ gpuSingleFilledRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
}
/* Indention + Offset ------------------------------------------- */
@@ -406,14 +406,14 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
- glColor3fv(color);
+ gpuCurrentColor3fv(color);
/* rounded corners on LHS only
* - top and bottom
* - special hack: make the top a bit higher, since we are first...
*/
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
- uiDrawBox(GL_POLYGON, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
+ uiDrawBox(GL_TRIANGLE_FAN, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
}
/* name for summary entries */
@@ -779,11 +779,11 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc
/* set backdrop drawing color */
acf->get_backdrop_color(ac, ale, color);
- glColor3fv(color);
+ gpuCurrentColor3fv(color);
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
uiSetRoundBox(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
- uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
+ uiDrawBox(GL_TRIANGLE_FAN, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
}
/* name for group entries */
@@ -2943,17 +2943,15 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
ymid = y - 7;
/* y-coordinates for text is only 4 down from middle */
ytext = y - 4;
-
+
/* check if channel is selected */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
selected = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
else
selected = 0;
-
- /* set blending again, as may not be set in previous step */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
glEnable(GL_BLEND);
-
+
/* step 1) draw backdrop ........................................... */
if (acf->draw_backdrop)
acf->draw_backdrop(ac, ale, yminc, ymaxc);
@@ -2986,13 +2984,13 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever
* color the curve has stored
*/
- glColor3fv(fcu->color);
+ gpuCurrentColor3fv(fcu->color);
/* just a solid color rect
* hardcoded 17 pixels width is slightly wider than icon width, so that
* there's a slight border around it
*/
- glRectf(offset, yminc, offset + 17, ymaxc);
+ gpuSingleFilledRectf(offset, yminc, offset + 17, ymaxc);
}
/* icon is drawn as widget now... */
@@ -3025,10 +3023,9 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* draw red underline if channel is disabled */
if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) {
/* FIXME: replace hardcoded color here, and check on extents! */
- glColor3f(1.0f, 0.0f, 0.0f);
+ gpuCurrentColor3x(CPACK_RED);
glLineWidth(2.0);
- fdrawline((float)(offset), yminc,
- (float)(v2d->cur.xmax), yminc);
+ gpuSingleLinef(offset, yminc, v2d->cur.xmax, yminc); // DOODLE: single thick colored line
glLineWidth(1.0);
}
}
@@ -3045,7 +3042,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* get and set backdrop color */
acf->get_backdrop_color(ac, ale, color);
- glColor3fv(color);
+ gpuCurrentColor3fv(color);
/* check if we need to show the sliders */
if ((ac->sl) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) {
@@ -3090,7 +3087,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
* - starts from the point where the first toggle/slider starts,
* - ends past the space that might be reserved for a scroller
*/
- glRectf(v2d->cur.xmax - (float)offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
+ gpuSingleFilledRectf(v2d->cur.xmax - offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc);
}
}
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 0f0584ad8fe..81db69f87dc 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -45,12 +45,17 @@
#include "RNA_access.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
+#include "BIF_glutil.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "GPU_compatibility.h"
+
/* *************************************************** */
/* TIME CODE FORMATTING */
@@ -182,7 +187,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, float cfra, short time)
/* because the frame number text is subject to the same scaling as the contents of the view */
UI_view2d_getscale(v2d, &xscale, &yscale);
- glScalef(1.0f / xscale, 1.0f, 1.0f);
+ gpuScale(1.0f / xscale, 1.0f, 1.0f);
/* get timecode string
* - padding on str-buf passed so that it doesn't sit on the frame indicator
@@ -201,14 +206,14 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, float cfra, short time)
/* draw green box around/behind text */
UI_ThemeColorShade(TH_CFRAME, 0);
- glRectf(x, y, x + slen, y + 15);
+ gpuSingleFilledRectf(x, y, x + slen, y + 15);
/* draw current frame number - black text */
UI_ThemeColor(TH_TEXT);
UI_DrawString(x - 5, y + 3, numstr);
/* restore view transform */
- glScalef(xscale, 1.0, 1.0);
+ gpuScale(xscale, 1.0, 1.0);
}
/* General call for drawing current frame indicator in animation editor */
@@ -216,26 +221,30 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
{
Scene *scene = CTX_data_scene(C);
float vec[2];
-
+
/* Draw a light green line to indicate current frame */
vec[0] = (float)(scene->r.cfra * scene->r.framelen);
-
+
UI_ThemeColor(TH_CFRAME);
if (flag & DRAWCFRA_WIDE)
glLineWidth(3.0);
else
glLineWidth(2.0);
-
- glBegin(GL_LINE_STRIP);
+
+ gpuImmediateFormat_V2();
+
+ gpuBegin(GL_LINE_STRIP);
vec[1] = v2d->cur.ymin - 500.0f; /* XXX arbitrary... want it go to bottom */
- glVertex2fv(vec);
-
+ gpuVertex2fv(vec);
+
vec[1] = v2d->cur.ymax;
- glVertex2fv(vec);
- glEnd();
-
+ gpuVertex2fv(vec);
+ gpuEnd();
+
+ gpuImmediateUnformat();
+
glLineWidth(1.0);
-
+
/* Draw current frame number in a little box */
if (flag & DRAWCFRA_SHOW_NUMBOX) {
UI_view2d_view_orthoSpecial(CTX_wm_region(C), v2d, 1);
@@ -254,17 +263,16 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d)
/* only draw this if preview range is set */
if (PRVRANGEON) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+ gpuCurrentColor4x(CPACK_BLACK, 0.4f);
/* only draw two separate 'curtains' if there's no overlap between them */
if (PSFRA < PEFRA) {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
+ gpuSingleFilledRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
glDisable(GL_BLEND);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 852f3fa5469..a29787cd8d7 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -53,7 +53,6 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "UI_interface.h"
@@ -70,6 +69,9 @@
#include "ED_transform.h"
#include "ED_types.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
/* ************* Marker API **************** */
/* helper function for getting the list of markers to work on */
@@ -357,10 +359,9 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
ypixels = BLI_rcti_size_y(&v2d->mask);
UI_view2d_getscale(v2d, &xscale, &yscale);
- glScalef(1.0f / xscale, 1.0f, 1.0f);
+ gpuScale(1.0f / xscale, 1.0f, 1.0f);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* vertical line - dotted */
#ifdef DURIAN_CAMERA_SWITCH
@@ -370,17 +371,18 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
#endif
{
setlinestyle(3);
-
- if (marker->flag & SELECT)
- glColor4ub(255, 255, 255, 96);
- else
- glColor4ub(0, 0, 0, 96);
-
- glBegin(GL_LINES);
- glVertex2f((xpos * xscale) + 0.5f, 12.0f);
- glVertex2f((xpos * xscale) + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
- glEnd();
-
+
+ gpuCurrentColor4x(
+ (marker->flag & SELECT) ? CPACK_WHITE : CPACK_BLACK,
+ 0.376f);
+
+ // DOODLE single 2D line, stippled
+ gpuSingleLinef(
+ (xpos * xscale) + 0.5f,
+ 12.0f,
+ (xpos * xscale) + 0.5f,
+ (v2d->cur.ymax + 12.0f) * yscale);
+
setlinestyle(0);
}
@@ -422,17 +424,14 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
#ifdef DURIAN_CAMERA_SWITCH
if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) {
- float col[4];
- glGetFloatv(GL_CURRENT_COLOR, col);
- col[3] = 0.4;
- glColor4fv(col);
+ gpuCurrentAlpha(0.4f);
}
#endif
- UI_DrawString(x, y, marker->name);
+ UI_DrawString(x, y, marker->name); // DOODLE text label
}
- glScalef(xscale, 1.0f, 1.0f);
+ gpuScale(xscale, 1.0f, 1.0f);
}
/* Draw Scene-Markers in time window */
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index e520a95aa95..c41c71c5fc7 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -66,8 +66,8 @@
#include "BKE_material.h"
#include "BKE_global.h" // XXX remove me!
-
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -550,45 +550,14 @@ static const float _unit_diamond_shape[4][2] = {
/* draw a simple diamond shape with OpenGL */
void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha)
{
- static GLuint displist1 = 0;
- static GLuint displist2 = 0;
-
- /* initialize 2 display lists for diamond shape - one empty, one filled */
- if (displist1 == 0) {
- displist1 = glGenLists(1);
- glNewList(displist1, GL_COMPILE);
-
- glBegin(GL_LINE_LOOP);
- glVertex2fv(_unit_diamond_shape[0]);
- glVertex2fv(_unit_diamond_shape[1]);
- glVertex2fv(_unit_diamond_shape[2]);
- glVertex2fv(_unit_diamond_shape[3]);
- glEnd();
-
- glEndList();
- }
- if (displist2 == 0) {
- displist2 = glGenLists(1);
- glNewList(displist2, GL_COMPILE);
-
- glBegin(GL_QUADS);
- glVertex2fv(_unit_diamond_shape[0]);
- glVertex2fv(_unit_diamond_shape[1]);
- glVertex2fv(_unit_diamond_shape[2]);
- glVertex2fv(_unit_diamond_shape[3]);
- glEnd();
-
- glEndList();
- }
-
/* tweak size of keyframe shape according to type of keyframe
* - 'proper' keyframes have key_type = 0, so get drawn at full size
*/
hsize -= 0.5f * key_type;
/* adjust view transform before starting */
- glTranslatef(x, y, 0.0f);
- glScalef(1.0f / xscale * hsize, hsize, 1.0f);
+ gpuTranslate(x, y, 0.0f);
+ gpuScale(1.0f / xscale * hsize, hsize, 1.0f);
/* anti-aliased lines for more consistent appearance */
glEnable(GL_LINE_SMOOTH);
@@ -599,22 +568,22 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel,
switch (key_type) {
case BEZT_KEYTYPE_BREAKDOWN: /* bluish frames for now */
{
- if (sel) glColor4f(0.33f, 0.75f, 0.93f, alpha);
- else glColor4f(0.70f, 0.86f, 0.91f, alpha);
+ if (sel) gpuCurrentColor4f(0.33f, 0.75f, 0.93f, alpha);
+ else gpuCurrentColor4f(0.70f, 0.86f, 0.91f, alpha);
}
break;
case BEZT_KEYTYPE_EXTREME: /* redish frames for now */
{
- if (sel) glColor4f(0.95f, 0.5f, 0.5f, alpha);
- else glColor4f(0.91f, 0.70f, 0.80f, alpha);
+ if (sel) gpuCurrentColor4f(0.95f, 0.5f, 0.5f, alpha);
+ else gpuCurrentColor4f(0.91f, 0.70f, 0.80f, alpha);
}
break;
case BEZT_KEYTYPE_JITTER: /* greenish frames for now? */
{
- if (sel) glColor4f(0.38f, 0.75f, 0.26f, alpha);
- else glColor4f(0.58f, 0.90f, 0.46f, alpha);
+ if (sel) gpuCurrentColor4f(0.38f, 0.75f, 0.26f, alpha);
+ else gpuCurrentColor4f(0.58f, 0.90f, 0.46f, alpha);
}
break;
@@ -622,26 +591,36 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel,
default:
{
if (sel) UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha));
- else glColor4f(0.91f, 0.91f, 0.91f, alpha);
+ else gpuCurrentColor4f(0.91f, 0.91f, 0.91f, alpha);
}
break;
}
- glCallList(displist2);
+ gpuBegin(GL_QUADS);
+ gpuVertex2fv(_unit_diamond_shape[0]);
+ gpuVertex2fv(_unit_diamond_shape[1]);
+ gpuVertex2fv(_unit_diamond_shape[2]);
+ gpuVertex2fv(_unit_diamond_shape[3]);
+ gpuEnd();
}
if (ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH)) {
/* exterior - black frame */
- glColor4f(0.0f, 0.0f, 0.0f, alpha);
+ gpuCurrentColor4x(CPACK_BLACK, alpha);
- glCallList(displist1);
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2fv(_unit_diamond_shape[0]);
+ gpuVertex2fv(_unit_diamond_shape[1]);
+ gpuVertex2fv(_unit_diamond_shape[2]);
+ gpuVertex2fv(_unit_diamond_shape[3]);
+ gpuEnd();
}
glDisable(GL_LINE_SMOOTH);
/* restore view transform */
- glScalef(xscale / hsize, 1.0f / hsize, 1.0f);
- glTranslatef(-x, -y, 0.0f);
+ gpuScale(xscale / hsize, 1.0f / hsize, 1.0f);
+ gpuTranslate(-x, -y, 0.0f);
}
static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, float ypos, short channelLocked)
@@ -665,7 +644,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
else
UI_ThemeColor4(TH_STRIP);
- glRectf(ab->start, ypos - 5, ab->end, ypos + 5);
+ gpuSingleFilledRectf(ab->start, ypos - 5, ab->end, ypos + 5);
}
}
}
diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt
index 2bd9956ef5a..92d7b3daffb 100644
--- a/source/blender/editors/armature/CMakeLists.txt
+++ b/source/blender/editors/armature/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -59,4 +60,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_armature "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index e801d3689e5..3846a5a2380 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -69,7 +69,7 @@
#include "BKE_modifier.h"
#include "DNA_object_types.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "RNA_access.h"
#include "RNA_define.h"
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index f9cf4a29269..27b62114bd6 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -49,7 +49,9 @@
#include "ED_view3d.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "ED_armature.h"
#include "armature_intern.h"
#include "BIF_retarget.h"
@@ -443,13 +445,15 @@ static float sk_clampPointSize(SK_Point *pt, float size)
return max_ff(size * pt->size, size / 2);
}
-static void sk_drawPoint(GLUquadric *quad, SK_Point *pt, float size)
+static void sk_drawPoint(struct GPUprim3 *prim, SK_Point *pt, float size)
{
- glTranslatef(pt->p[0], pt->p[1], pt->p[2]);
- gluSphere(quad, sk_clampPointSize(pt, size), 8, 8);
+ gpuTranslate(pt->p[0], pt->p[1], pt->p[2]);
+
+ gpuDrawSphere(prim, sk_clampPointSize(pt, size));
+ //GLU Sphere(quad, sk_clampPointSize(pt, size), 8, 8);
}
-static void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float size)
+static void sk_drawEdge(struct GPUprim3 *prim, SK_Point *pt0, SK_Point *pt1, float size)
{
float vec1[3], vec2[3] = {0, 0, 1}, axis[3];
float angle, length;
@@ -464,17 +468,18 @@ static void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float si
angle = angle_normalized_v3v3(vec2, vec1);
- glRotatef(angle * (float)(180.0 / M_PI) + 180.0f, axis[0], axis[1], axis[2]);
+ gpuRotateVector(angle + M_PI, axis);
- gluCylinder(quad, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8);
+ gpuDrawCylinder(prim, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length);
+ //GLU Cylinder(quad, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8);
}
-static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float height)
+static void sk_drawNormal(struct GPUprim3 *prim, SK_Point *pt, float size, float height)
{
float vec2[3] = {0, 0, 1}, axis[3];
float angle;
- glPushMatrix();
+ gpuPushMatrix();
cross_v3_v3v3(axis, vec2, pt->no);
@@ -484,34 +489,35 @@ static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float heig
angle = angle_normalized_v3v3(vec2, pt->no);
- glRotatef(angle * (float)(180.0 / M_PI), axis[0], axis[1], axis[2]);
+ gpuRotateVector(angle, axis);
- glColor3f(0, 1, 1);
- gluCylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
+ gpuCurrentColor3x(CPACK_CYAN);
- glPopMatrix();
+ gpuDrawCylinder(prim, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height));
+ //GLU Cylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
+
+ gpuPopMatrix();
}
static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end)
{
float rgb[3];
int i;
- GLUquadric *quad = gluNewQuadric();
- gluQuadricNormals(quad, GLU_SMOOTH);
+ struct GPUprim3 prim = GPU_PRIM_LOFI_SOLID;
if (id != -1) {
glLoadName(id);
for (i = 0; i < stk->nb_points; i++) {
- glPushMatrix();
+ gpuPushMatrix();
- sk_drawPoint(quad, stk->points + i, 0.1);
+ sk_drawPoint(&prim, stk->points + i, 0.1);
if (i > 0) {
- sk_drawEdge(quad, stk->points + i - 1, stk->points + i, 0.1);
+ sk_drawEdge(&prim, stk->points + i - 1, stk->points + i, 0.1);
}
- glPopMatrix();
+ gpuPopMatrix();
}
}
@@ -525,37 +531,35 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int
for (i = 0; i < stk->nb_points; i++) {
SK_Point *pt = stk->points + i;
- glPushMatrix();
+ gpuPushMatrix();
if (pt->type == PT_EXACT) {
- glColor3f(0, 0, 0);
- sk_drawPoint(quad, pt, 0.15);
- sk_drawNormal(quad, pt, 0.05, 0.9);
+ gpuCurrentColor3x(CPACK_BLACK);
+ sk_drawPoint(&prim, pt, 0.15);
+ sk_drawNormal(&prim, pt, 0.05, 0.9);
}
if (i >= start && i <= end) {
- glColor3f(0.3, 0.3, 0.3);
+ gpuCurrentGray3f(0.300f);
}
else {
- glColor3fv(rgb);
+ gpuCurrentColor3fv(rgb);
}
if (pt->type != PT_EXACT) {
- sk_drawPoint(quad, pt, 0.1);
+ sk_drawPoint(&prim, pt, 0.1);
}
if (i > 0) {
- sk_drawEdge(quad, pt - 1, pt, 0.1);
+ sk_drawEdge(&prim, pt - 1, pt, 0.1);
}
- glPopMatrix();
+ gpuPopMatrix();
add_v3_v3(rgb, d_rgb);
}
}
-
- gluDeleteQuadric(quad);
}
static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *iter, NextSubdivisionFunc next_subdividion)
@@ -565,8 +569,7 @@ static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *ite
int bone_start = 0;
int end = iter->length;
int index;
- GLUquadric *quad = gluNewQuadric();
- gluQuadricNormals(quad, GLU_SMOOTH);
+ struct GPUprim3 prim = GPU_PRIM_LOFI_SOLID;
iter->head(iter);
copy_v3_v3(head, iter->p);
@@ -575,22 +578,20 @@ static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *ite
while (index != -1) {
SK_Point *pt = stk->points + index;
- glPushMatrix();
+ gpuPushMatrix();
- glColor3f(0, 1, 0);
- sk_drawPoint(quad, pt, 0.15);
+ gpuCurrentColor3x(CPACK_GREEN);
+ sk_drawPoint(&prim, pt, 0.15);
- sk_drawNormal(quad, pt, 0.05, 0.9);
+ sk_drawNormal(&prim, pt, 0.05, 0.9);
- glPopMatrix();
+ gpuPopMatrix();
copy_v3_v3(head, tail);
bone_start = index; // start next bone from current index
index = next_subdividion(toolsettings, iter, bone_start, end, head, tail);
}
-
- gluDeleteQuadric(quad);
}
static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk)
@@ -2030,7 +2031,7 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
ToolSettings *ts = scene->toolsettings;
SK_Stroke *stk;
- glClear(GL_DEPTH_BUFFER_BIT);
+ gpuClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
if (with_names) {
@@ -2068,34 +2069,30 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
}
if (last != NULL) {
- GLUquadric *quad = gluNewQuadric();
- gluQuadricNormals(quad, GLU_SMOOTH);
+ struct GPUprim3 prim = GPU_PRIM_LOFI_SOLID;
- glPushMatrix();
+ gpuPushMatrix();
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
switch (sketch->next_point.mode) {
case PT_SNAP:
- glColor3f(0, 1, 0);
+ gpuCurrentColor3x(CPACK_GREEN);
break;
case PT_PROJECT:
- glColor3f(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
break;
}
- sk_drawPoint(quad, &sketch->next_point, 0.1);
+ sk_drawPoint(&prim, &sketch->next_point, 0.1);
- glColor4f(selected_rgb[0], selected_rgb[1], selected_rgb[2], 0.3);
+ gpuCurrentColor4f(selected_rgb[0], selected_rgb[1], selected_rgb[2], 0.3);
- sk_drawEdge(quad, last, &sketch->next_point, 0.1);
+ sk_drawEdge(&prim, last, &sketch->next_point, 0.1);
glDisable(GL_BLEND);
- glPopMatrix();
-
- gluDeleteQuadric(quad);
+ gpuPopMatrix();
}
}
}
@@ -2103,6 +2100,8 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
#if 0
if (sketch->depth_peels.first != NULL)
{
+ static GPUimmediate *dl = NULL;
+
float colors[8][3] = {
{1, 0, 0},
{0, 1, 0},
@@ -2114,22 +2113,29 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
{0, 0, 0}
};
DepthPeel *p;
- GLUquadric *quad = gluNewQuadric();
- gluQuadricNormals(quad, GLU_SMOOTH);
+ struct GPUprim3 prim = GPU_PRIM_LORES_SOLID;
for (p = sketch->depth_peels.first; p; p = p->next)
{
int index = GET_INT_FROM_POINTER(p->ob);
index = (index >> 5) & 7;
- glColor3fv(colors[index]);
- glPushMatrix();
- glTranslatef(p->p[0], p->p[1], p->p[2]);
- gluSphere(quad, 0.02, 8, 8);
- glPopMatrix();
- }
+ gpuCurrentColor3fv(colors[index]);
+ gpuPushMatrix();
+ gpuTranslate(p->p[0], p->p[1], p->p[2]);
+
+ if (!dl) {
+ gpuPushImmediate();
+ gpuSingleSphere(&prim, 0.02);
+ //GLU Sphere(quad, 0.02, 8, 8);
+ dl = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleRepeat(dl);
+ }
- gluDeleteQuadric(quad);
+ gpuPopMatrix();
+ }
}
#endif
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index b1bf13db69b..d782d30e1f0 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -3340,12 +3340,12 @@ void REEB_draw()
ReebGraph *rg;
ReebArc *arc;
int i = 0;
-
+
if (GLOBAL_RG == NULL)
{
return;
}
-
+
if (GLOBAL_RG->link_up && G.scene->toolsettings->skgen_options & SKGEN_DISP_ORIG)
{
for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up) ;
@@ -3355,10 +3355,11 @@ void REEB_draw()
for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up) ;
}
-
+
glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE));
-
+
glDisable(GL_DEPTH_TEST);
+
for (arc = rg->arcs.first; arc; arc = arc->next, i++)
{
ReebArcIterator arc_iter;
@@ -3366,76 +3367,80 @@ void REEB_draw()
float vec[3];
char text[128];
char *s = text;
-
+
glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE) + 2);
- glColor3f(0, 0, 0);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(arc->head->p);
-
+ gpuCurrentColor3x(CPACK_BLACK);
+
+ gpuImmediateFormat_V3(); // DOODLE: REEB (commented out)
+
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(arc->head->p);
+
if (arc->bcount)
{
initArcIterator(iter, arc, arc->head);
for (IT_next(iter); IT_stopped(iter) == 0; IT_next(iter))
{
- glVertex3fv(iter->p);
+ gpuVertex3fv(iter->p);
}
}
-
- glVertex3fv(arc->tail->p);
- glEnd();
+
+ gpuVertex3fv(arc->tail->p);
+ gpuEnd();
glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE));
if (arc->symmetry_level == 1)
{
- glColor3f(1, 0, 0);
+ gpuCurrentColor3f(CPACK_RED);
}
else if (arc->symmetry_flag == SYM_SIDE_POSITIVE || arc->symmetry_flag == SYM_SIDE_NEGATIVE)
{
- glColor3f(1, 0.5f, 0);
+ gpuCurrentColor3f(1, 0.5f, 0);
}
else if (arc->symmetry_flag >= SYM_SIDE_RADIAL)
{
- glColor3f(0.5f, 1, 0);
+ gpuCurrentColor3f(0.5f, 1, 0);
}
else {
- glColor3f(1, 1, 0);
+ gpuCurrentColor3f(CPACK_YELLOW);
}
- glBegin(GL_LINE_STRIP);
- glVertex3fv(arc->head->p);
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(arc->head->p);
if (arc->bcount)
{
initArcIterator(iter, arc, arc->head);
for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter))
{
- glVertex3fv(iter->p);
+ gpuVertex3fv(iter->p);
}
}
-
- glVertex3fv(arc->tail->p);
- glEnd();
-
+ gpuVertex3fv(arc->tail->p);
+ gpuEnd();
+
if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED)
{
- glColor3f(1, 1, 1);
- glBegin(GL_POINTS);
- glVertex3fv(arc->head->p);
- glVertex3fv(arc->tail->p);
-
- glColor3f(0.5f, 0.5f, 1);
+ gpuCurrentColor3x(CPACK_WHITE);
+ gpuBegin(GL_POINTS);
+ gpuVertex3fv(arc->head->p);
+ gpuVertex3fv(arc->tail->p);
+
+ gpuColor3f(0.5f, 0.5f, 1);
if (arc->bcount)
{
initArcIterator(iter, arc, arc->head);
for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter))
{
- glVertex3fv(iter->p);
+ gpuVertex3fv(iter->p);
}
}
- glEnd();
+ gpuEnd();
}
-
+
+ gpuImmediateUnformat();
+
if (G.scene->toolsettings->skgen_options & SKGEN_DISP_INDEX)
{
mid_v3_v3v3(vec, arc->head->p, arc->tail->p);
@@ -3450,8 +3455,8 @@ void REEB_draw()
{
s += sprintf(s, "l:%0.3f", arc->length);
}
-
- glColor3f(0, 1, 0);
+
+ gpuCurrentColor3f(CPACK_GREEN);
glRasterPos3fv(vec);
BMF_DrawString(G.fonts, text);
}
@@ -3461,14 +3466,15 @@ void REEB_draw()
sprintf(text, " %i", arc->head->index);
glRasterPos3fv(arc->head->p);
BMF_DrawString(G.fonts, text);
-
+
sprintf(text, " %i", arc->tail->index);
glRasterPos3fv(arc->tail->p);
BMF_DrawString(G.fonts, text);
}
}
+
glEnable(GL_DEPTH_TEST);
-
+
glLineWidth(1.0);
glPointSize(1.0);
}
diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt
index 762db26bc4f..35caedcfd17 100644
--- a/source/blender/editors/gpencil/CMakeLists.txt
+++ b/source/blender/editors/gpencil/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
+ ../../gpu
../../../../intern/guardedalloc
)
@@ -51,4 +52,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_gpencil "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 11e07584405..0ee2c96e322 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -53,13 +53,14 @@
#include "WM_api.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "ED_gpencil.h"
#include "ED_sequencer.h"
#include "ED_view3d.h"
+#include "GPU_primitives.h"
+
#include "gpencil_intern.h"
/* ************************************************** */
@@ -101,9 +102,9 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn
/* if drawing a single point, draw it larger */
if (totpoints == 1) {
/* draw point */
- glBegin(GL_POINTS);
- glVertex2iv(&points->x);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex2f(points->x, points->y);
+ gpuEnd();
}
else if (sflag & GP_STROKE_ERASER) {
/* don't draw stroke at all! */
@@ -115,29 +116,30 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn
if (G.debug & G_DEBUG) setlinestyle(2);
glLineWidth(oldpressure * thickness);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
* and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
*/
if (fabsf(pt->pressure - oldpressure) > 0.2f) {
- glEnd();
+ gpuEnd();
glLineWidth(pt->pressure * thickness);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
- if (i != 0) glVertex2iv(&(pt - 1)->x);
+ if (i != 0)
+ gpuVertex2f((pt - 1)->x, (pt -1)->y);
/* now the point we want... */
- glVertex2iv(&pt->x);
-
+ gpuVertex2f(pt->x, pt->y);
+
oldpressure = pt->pressure;
}
else
- glVertex2iv(&pt->x);
+ gpuVertex2f(pt->x, pt->y);
}
- glEnd();
+ gpuEnd();
/* reset for predictable OpenGL context */
glLineWidth(1.0f);
@@ -154,13 +156,13 @@ static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dfla
{
/* draw point */
if (sflag & GP_STROKE_3DSPACE) {
- glBegin(GL_POINTS);
- glVertex3fv(&points->x);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex3fv(&points->x);
+ gpuEnd();
}
else {
float co[2];
-
+
/* get coordinates of point */
if (sflag & GP_STROKE_2DSPACE) {
co[0] = points->x;
@@ -174,29 +176,19 @@ static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dfla
co[0] = (points->x / 100 * winx) + offsx;
co[1] = (points->y / 100 * winy) + offsy;
}
-
+
/* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok
* - also mandatory in if Image Editor 'image-based' dot
*/
if ((thickness < GP_DRAWTHICKNESS_SPECIAL) ||
((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)))
{
- glBegin(GL_POINTS);
- glVertex2fv(co);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex2fv(co);
+ gpuEnd();
}
else {
- /* draw filled circle as is done in circf (but without the matrix push/pops which screwed things up) */
- GLUquadricObj *qobj = gluNewQuadric();
-
- gluQuadricDrawStyle(qobj, GLU_FILL);
-
- /* need to translate drawing position, but must reset after too! */
- glTranslatef(co[0], co[1], 0.0);
- gluDisk(qobj, 0.0, thickness, 32, 1);
- glTranslatef(-co[0], -co[1], 0.0);
-
- gluDeleteQuadric(qobj);
+ gpuDrawDisk(co[0], co[1], thickness, 32);
}
}
}
@@ -209,36 +201,36 @@ static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness
int i;
/* draw stroke curve */
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
* and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
*/
if (fabsf(pt->pressure - oldpressure) > 0.2f) {
- glEnd();
+ gpuEnd();
glLineWidth(pt->pressure * thickness);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
- if (i != 0) glVertex3fv(&(pt - 1)->x);
+ if (i != 0) gpuVertex3fv(&(pt - 1)->x);
/* now the point we want... */
- glVertex3fv(&pt->x);
+ gpuVertex3fv(&pt->x);
oldpressure = pt->pressure;
}
else {
- glVertex3fv(&pt->x);
+ gpuVertex3fv(&pt->x);
}
}
- glEnd();
+ gpuEnd();
/* draw debug points of curve on top? */
if (debug) {
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
for (i = 0, pt = points; i < totpoints && pt; i++, pt++)
- glVertex3fv(&pt->x);
- glEnd();
+ gpuVertex3fv(&pt->x);
+ gpuEnd();
}
}
@@ -260,25 +252,25 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
bGPDspoint *pt;
int i;
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
if (sflag & GP_STROKE_2DSPACE) {
- glVertex2f(pt->x, pt->y);
+ gpuVertex2f(pt->x, pt->y);
}
else if (sflag & GP_STROKE_2DIMAGE) {
const float x = (pt->x * winx) + offsx;
const float y = (pt->y * winy) + offsy;
- glVertex2f(x, y);
+ gpuVertex2f(x, y);
}
else {
const float x = (pt->x / 100 * winx) + offsx;
const float y = (pt->y / 100 * winy) + offsy;
- glVertex2f(x, y);
+ gpuVertex2f(x, y);
}
}
- glEnd();
+ gpuEnd();
}
/* tessellation code - draw stroke as series of connected quads with connection
@@ -290,7 +282,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
int i;
glShadeModel(GL_FLAT);
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) {
float s0[2], s1[2]; /* segment 'center' points */
@@ -342,8 +334,8 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
t1[0] = sc[0] + mt[0];
t1[1] = sc[1] + mt[1];
- glVertex2fv(t0);
- glVertex2fv(t1);
+ gpuVertex2fv(t0);
+ gpuVertex2fv(t1);
/* calculate points for start of segment */
mt[0] = m2[0] * pthick;
@@ -355,10 +347,10 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
t1[1] = s0[1] + mt[1];
/* draw this line twice (first to finish off start cap, then for stroke) */
- glVertex2fv(t1);
- glVertex2fv(t0);
- glVertex2fv(t0);
- glVertex2fv(t1);
+ gpuVertex2fv(t1);
+ gpuVertex2fv(t0);
+ gpuVertex2fv(t0);
+ gpuVertex2fv(t1);
}
/* if not the first segment, use bisector of angle between segments */
else {
@@ -391,10 +383,10 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
t1[1] = s0[1] + mt[1];
/* draw this line twice (once for end of current segment, and once for start of next) */
- glVertex2fv(t1);
- glVertex2fv(t0);
- glVertex2fv(t0);
- glVertex2fv(t1);
+ gpuVertex2fv(t1);
+ gpuVertex2fv(t0);
+ gpuVertex2fv(t0);
+ gpuVertex2fv(t1);
}
/* if last segment, also draw end of segment (defined as segment's normal) */
@@ -412,10 +404,10 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
t1[1] = s1[1] + mt[1];
/* draw this line twice (once for end of stroke, and once for endcap)*/
- glVertex2fv(t1);
- glVertex2fv(t0);
- glVertex2fv(t0);
- glVertex2fv(t1);
+ gpuVertex2fv(t1);
+ gpuVertex2fv(t0);
+ gpuVertex2fv(t0);
+ gpuVertex2fv(t1);
/* draw end cap as last step
@@ -431,15 +423,15 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
t1[0] = sc[0] + mt[0];
t1[1] = sc[1] + mt[1];
- glVertex2fv(t1);
- glVertex2fv(t0);
+ gpuVertex2fv(t1);
+ gpuVertex2fv(t0);
}
/* store stroke's 'natural' normal for next stroke to use */
copy_v2_v2(pm, m2);
}
- glEnd();
+ gpuEnd();
}
/* draw debug points of curve on top? (original stroke points) */
@@ -447,25 +439,25 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
bGPDspoint *pt;
int i;
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
if (sflag & GP_STROKE_2DSPACE) {
- glVertex2fv(&pt->x);
+ gpuVertex2fv(&pt->x);
}
else if (sflag & GP_STROKE_2DIMAGE) {
const float x = (float)((pt->x * winx) + offsx);
const float y = (float)((pt->y * winy) + offsy);
- glVertex2f(x, y);
+ gpuVertex2f(x, y);
}
else {
const float x = (float)(pt->x / 100 * winx) + offsx;
const float y = (float)(pt->y / 100 * winy) + offsy;
- glVertex2f(x, y);
+ gpuVertex2f(x, y);
}
}
- glEnd();
+ gpuEnd();
}
}
@@ -478,7 +470,7 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int
bGPDstroke *gps;
/* set color first (may need to reset it again later too) */
- glColor4fv(color);
+ gpuCurrentColor4fv(color);
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn - checks here generally fall into pairs */
@@ -540,7 +532,9 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int
static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag)
{
bGPDlayer *gpl;
-
+
+ gpuImmediateFormat_V3();
+
/* reset line drawing style (in case previous user didn't reset) */
setlinestyle(0);
@@ -548,7 +542,6 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
glEnable(GL_LINE_SMOOTH);
/* turn on alpha-blending */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
/* loop over layers, drawing them */
@@ -572,7 +565,7 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
glLineWidth(lthick);
copy_v4_v4(color, gpl->color); // just for copying 4 array elements
copy_v4_v4(tcolor, gpl->color); // additional copy of color (for ghosting)
- glColor4fv(color);
+ gpuCurrentColor4fv(color);
glPointSize((float)(gpl->thickness + 2));
/* apply xray layer setting */
@@ -614,7 +607,7 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
}
/* restore alpha */
- glColor4fv(color);
+ gpuCurrentColor4fv(color);
}
else {
/* draw the strokes for the ghost frames (at half of the alpha set by user) */
@@ -629,7 +622,7 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
}
/* restore alpha */
- glColor4fv(color);
+ gpuCurrentColor4fv(color);
}
}
@@ -656,7 +649,8 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
/* restore initial gl conditions */
glLineWidth(1.0);
glPointSize(1.0);
- glColor4f(0, 0, 0, 1);
+
+ gpuImmediateUnformat();
}
/* ----- Grease Pencil Sketches Drawing API ------ */
@@ -679,7 +673,7 @@ void draw_gpencil_2dimage(const bContext *C)
gpd = gpencil_data_get_active(C); // XXX
if (gpd == NULL) return;
-
+
/* calculate rect */
switch (sa->spacetype) {
case SPACE_IMAGE: /* image */
@@ -749,7 +743,11 @@ void draw_gpencil_view2d(const bContext *C, short onlyv2d)
dflag |= GP_DRAWDATA_IEDITHACK;
/* draw it! */
- if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS);
+
+ if (onlyv2d) {
+ dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS);
+ }
+
gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag);
}
@@ -784,9 +782,12 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d)
winx = ar->winx;
winy = ar->winy;
}
-
+
/* draw it! */
- if (only3d) dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
+
+ if (only3d) {
+ dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
+ }
gp_draw_data(gpd, offsx, offsy, winx, winy, CFRA, dflag);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index e04bbc1f2bf..3fbd4a8f736 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -59,7 +59,6 @@
#include "ED_view3d.h"
#include "ED_clip.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "RNA_access.h"
@@ -68,6 +67,9 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "gpencil_intern.h"
/* ******************************************* */
@@ -1339,21 +1341,15 @@ 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) {
- glPushMatrix();
-
- glTranslatef((float)x, (float)y, 0.0f);
-
- glColor4ub(255, 255, 255, 128);
+ gpuCurrentColor4x(CPACK_WHITE, 0.500f);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
-
- glutil_draw_lined_arc(0.0, M_PI * 2.0, p->radius, 40);
-
+
+ gpuSingleCircle(x, y, p->radius, 40);
+
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
-
- glPopMatrix();
}
}
@@ -1564,7 +1560,7 @@ static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event)
p->curtime = PIL_check_seconds_timer();
/* handle pressure sensitivity (which is supplied by tablets) */
- if (event->custom == EVT_DATA_TABLET) {
+ if (event->customdatatype == EVT_DATA_TABLET) {
wmTabletData *wmtab = event->customdata;
tablet = (wmtab->Active != EVT_TABLET_NONE);
diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h
deleted file mode 100644
index 479e0b65177..00000000000
--- a/source/blender/editors/include/BIF_gl.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- * os dependent include locations of gl.h
- */
-
-/** \file BIF_gl.h
- * \ingroup editorui
- */
-
-#ifndef __BIF_GL_H__
-#define __BIF_GL_H__
-
-#include "GL/glew.h"
-
-/*
- * these should be phased out. cpack should be replaced in
- * code with calls to glColor3ub. - zr
- */
-/*
- *
- * This define converts a numerical value to the equivalent 24-bit
- * color, while not being endian-sensitive. On little-endians, this
- * is the same as doing a 'naive' indexing, on big-endian, it is not!
- * */
-#define cpack(x) glColor3ub( ((x) & 0xFF), (((x) >> 8) & 0xFF), (((x) >> 16) & 0xFF) )
-
-#define glMultMatrixf(x) glMultMatrixf( (float *)(x))
-#define glLoadMatrixf(x) glLoadMatrixf( (float *)(x))
-
-#define GLA_PIXEL_OFS 0.375f
-
-#endif /* #ifdef __BIF_GL_H__ */
-
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index 577113927d1..6ba6209414e 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -33,13 +33,9 @@
struct rcti;
struct rctf;
-void fdrawbezier(float vec[4][3]);
-void fdrawline(float x1, float y1, float x2, float y2);
-void fdrawbox(float x1, float y1, float x2, float y2);
-void sdrawline(short x1, short y1, short x2, short y2);
+//void fdrawbezier(float vec[4][3]);
void sdrawtri(short x1, short y1, short x2, short y2);
void sdrawtrifill(short x1, short y1, short x2, short y2);
-void sdrawbox(short x1, short y1, short x2, short y2);
void sdrawXORline(int x0, int y0, int x1, int y1);
void sdrawXORline4(int nr, int x0, int y0, int x1, int y1);
@@ -56,31 +52,6 @@ extern unsigned char stipple_quarttone[128];
extern unsigned char stipple_diag_stripes_pos[128];
extern unsigned char stipple_diag_stripes_neg[128];
-/**
- * Draw a lined (non-looping) arc with the given
- * \a radius, starting at angle \a start and arcing
- * through \a angle. The arc is centered at the origin
- * and drawn in the XY plane.
- *
- * \param start The initial angle (in radians).
- * \param angle The length of the arc (in radians).
- * \param radius The arc radius.
- * \param nsegments The number of segments to use in drawing the arc.
- */
-void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments);
-
-/**
- * Draw a filled arc with the given \a radius,
- * starting at angle \a start and arcing through
- * \a angle. The arc is centered at the origin
- * and drawn in the XY plane.
- *
- * \param start The initial angle (in radians).
- * \param angle The length of the arc (in radians).
- * \param radius The arc radius.
- * \param nsegments The number of segments to use in drawing the arc.
- */
-void glutil_draw_filled_arc(float start, float angle, float radius, int nsegments);
/**
* Routines an integer value as obtained by glGetIntegerv.
@@ -192,15 +163,6 @@ void gla2DGetMap(gla2DDrawInfo *di, struct rctf *rect);
void gla2DSetMap(gla2DDrawInfo *di, struct rctf *rect);
-/* use this for platform hacks. glPointSize is solved here */
-void bglBegin(int mode);
-void bglEnd(void);
-// int bglPointHack(void); /* UNUSED */
-void bglVertex3fv(const float vec[3]);
-void bglVertex3f(float x, float y, float z);
-void bglVertex2fv(const float vec[2]);
-/* intel gfx cards frontbuffer problem */
-// void bglFlush(void); /* UNUSED */
void set_inverted_drawing(int enable);
void setlinestyle(int nr);
@@ -209,11 +171,13 @@ void bglPolygonOffset(float viewdist, float dist);
/* For caching opengl matrices (gluProject/gluUnProject) */
typedef struct bglMats {
- double modelview[16];
- double projection[16];
+ float modelview[16];
+ float projection[16];
int viewport[4];
} bglMats;
void bgl_get_mats(bglMats *mats);
+#define GLA_PIXEL_OFS 0.375f
+
#endif /* __BIF_GLUTIL_H__ */
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 865da8f0e6e..b9811bf0a93 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -151,7 +151,7 @@ struct BMFace *EDBM_face_find_nearest(struct ViewContext *vc, float *r_dist);
int EDBM_select_pick(struct bContext *C, const int mval[2], short extend, short deselect, short toggle);
void EDBM_selectmode_set(struct BMEditMesh *em);
-void EDBM_selectmode_convert(struct BMEditMesh *em, const short selectmode_old, const short selectmode_new);
+void EDBM_selectmode_convert(struct BMEditMesh *em, short selectmode_old, short selectmode_new);
/* user access this */
int EDBM_selectmode_toggle(struct bContext *C, const short selectmode_new,
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index 32baa8883e1..3abf0522015 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -54,7 +54,6 @@ typedef enum {
/* drawnode.c */
void ED_node_init_butfuncs(void);
void ED_node_sample_set(const float col[4]);
-void ED_node_draw_snap(struct View2D *v2d, const float cent[2], float size, NodeBorder border);
/* node_draw.c */
void ED_node_tree_update(struct SpaceNode *snode, struct Scene *scene);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index bd85e93f1af..b2fadece72d 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -220,8 +220,6 @@ void ED_view3d_clipping_disable(void);
float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]);
-void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]);
-
/* backbuffer select and draw support */
void view3d_validate_backbuf(struct ViewContext *vc);
struct ImBuf *view3d_read_backbuf(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index f4e921e2fa4..ffe156da355 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -232,20 +232,25 @@ struct PointerRNA;
// sets the color
void UI_ThemeColor(int colorid);
+void UI_ThemeAppendColor(int colorid);
// sets the color plus alpha
void UI_ThemeColor4(int colorid);
// sets color plus offset for shade
void UI_ThemeColorShade(int colorid, int offset);
+void UI_ThemeAppendColorShade(int colorid, int offset);
// sets color plus offset for alpha
void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset);
+void UI_ThemeAppendColorShadeAlpha(int colorid, int coloffset, int alphaoffset);
// sets color, which is blend between two theme colors
void UI_ThemeColorBlend(int colorid1, int colorid2, float fac);
+void UI_ThemeAppendColorBlend(int colorid1, int colorid2, float fac);
// same, with shade offset
void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset);
+void UI_ThemeAppendColorBlendShade(int colorid1, int colorid2, float fac, int offset);
void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset);
// returns one value, not scaled
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index 8ba86673f87..89e7603109a 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -70,4 +70,6 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 535239cd462..264aa895fc5 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -57,7 +57,8 @@
#include "BKE_screen.h"
#include "BKE_idprop.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_compatibility.h"
#include "BLF_api.h"
#include "BLF_translation.h"
@@ -497,11 +498,11 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines)
rect.ymax = BLI_rctf_cent_y(&line->to->rect);
if (line->flag & UI_SELECT)
- glColor3ub(100, 100, 100);
+ gpuCurrentGray3f(0.392f);
else if (highlightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)))
UI_ThemeColor(TH_TEXT_HI);
else
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
ui_draw_link_bezier(&rect);
}
@@ -1034,9 +1035,6 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
if (multisample_enabled)
glDisable(GL_MULTISAMPLE_ARB);
- /* we set this only once */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
/* scale fonts */
ui_fontscale(&style.paneltitle.points, block->aspect);
ui_fontscale(&style.grouplabel.points, block->aspect);
@@ -1047,11 +1045,11 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
ui_but_to_pixelrect(&rect, ar, block, NULL);
/* pixel space for AA widgets */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPushMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPushMatrix();
+ gpuLoadIdentity();
wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
@@ -1074,10 +1072,10 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
}
/* restore matrix */
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPopMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPopMatrix();
if (multisample_enabled)
glEnable(GL_MULTISAMPLE_ARB);
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 4d96ad810d4..80003222faa 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -50,7 +50,9 @@
#include "IMB_imbuf_types.h"
#include "IMB_colormanagement.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "BLF_api.h"
@@ -87,49 +89,53 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r
mul_v2_fl(vec[a], rad);
}
- glBegin(mode);
+ gpuImmediateFormat_V2(); // DOODLE: ui box, a rounded rectangle
+ gpuBegin(mode);
+
+
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
- glVertex2f(maxx - rad, miny);
+ gpuVertex2f(maxx - rad, miny);
for (a = 0; a < 7; a++) {
- glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
+ gpuVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
}
- glVertex2f(maxx, miny + rad);
+ gpuVertex2f(maxx, miny + rad);
}
- else glVertex2f(maxx, miny);
-
+ else gpuVertex2f(maxx, miny);
+
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
- glVertex2f(maxx, maxy - rad);
+ gpuVertex2f(maxx, maxy - rad);
for (a = 0; a < 7; a++) {
- glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
+ gpuVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
}
- glVertex2f(maxx - rad, maxy);
+ gpuVertex2f(maxx - rad, maxy);
}
- else glVertex2f(maxx, maxy);
-
+ else gpuVertex2f(maxx, maxy);
+
/* corner left-top */
if (roundboxtype & UI_CNR_TOP_LEFT) {
- glVertex2f(minx + rad, maxy);
+ gpuVertex2f(minx + rad, maxy);
for (a = 0; a < 7; a++) {
- glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
+ gpuVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
}
- glVertex2f(minx, maxy - rad);
+ gpuVertex2f(minx, maxy - rad);
}
- else glVertex2f(minx, maxy);
-
+ else gpuVertex2f(minx, maxy);
+
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
- glVertex2f(minx, miny + rad);
+ gpuVertex2f(minx, miny + rad);
for (a = 0; a < 7; a++) {
- glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
+ gpuVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
}
- glVertex2f(minx + rad, miny);
+ gpuVertex2f(minx + rad, miny);
}
- else glVertex2f(minx, miny);
-
- glEnd();
+ else gpuVertex2f(minx, miny);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
static void round_box_shade_col(const float col1[3], float const col2[3], const float fac)
@@ -139,7 +145,7 @@ static void round_box_shade_col(const float col1[3], float const col2[3], const
col[0] = (fac * col1[0] + (1.0f - fac) * col2[0]);
col[1] = (fac * col1[1] + (1.0f - fac) * col2[1]);
col[2] = (fac * col1[2] + (1.0f - fac) * col2[2]);
- glColor3fv(col);
+ gpuColor3fv(col);
}
/* linear horizontal shade within button or in outline */
@@ -157,8 +163,8 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
for (a = 0; a < 7; a++) {
mul_v2_fl(vec[a], rad);
}
- /* get current color, needs to be outside of glBegin/End */
- glGetFloatv(GL_CURRENT_COLOR, color);
+ /* get current color, needs to be outside of gpuBegin/End */
+ gpuGetCurrentColor4fv(color);
/* 'shade' defines strength of shading */
coltop[0] = min_ff(1.0f, color[0] + shadetop);
@@ -169,84 +175,84 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
coldown[2] = max_ff(0.0f, color[2] + shadedown);
glShadeModel(GL_SMOOTH);
- glBegin(mode);
+ gpuBegin(mode);
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
round_box_shade_col(coltop, coldown, 0.0);
- glVertex2f(maxx - rad, miny);
+ gpuVertex2f(maxx - rad, miny);
for (a = 0; a < 7; a++) {
round_box_shade_col(coltop, coldown, vec[a][1] * idiv);
- glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
+ gpuVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
}
round_box_shade_col(coltop, coldown, rad * idiv);
- glVertex2f(maxx, miny + rad);
+ gpuVertex2f(maxx, miny + rad);
}
else {
round_box_shade_col(coltop, coldown, 0.0);
- glVertex2f(maxx, miny);
+ gpuVertex2f(maxx, miny);
}
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
round_box_shade_col(coltop, coldown, (div - rad) * idiv);
- glVertex2f(maxx, maxy - rad);
+ gpuVertex2f(maxx, maxy - rad);
for (a = 0; a < 7; a++) {
round_box_shade_col(coltop, coldown, (div - rad + vec[a][1]) * idiv);
- glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
+ gpuVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
}
round_box_shade_col(coltop, coldown, 1.0);
- glVertex2f(maxx - rad, maxy);
+ gpuVertex2f(maxx - rad, maxy);
}
else {
round_box_shade_col(coltop, coldown, 1.0);
- glVertex2f(maxx, maxy);
+ gpuVertex2f(maxx, maxy);
}
/* corner left-top */
if (roundboxtype & UI_CNR_TOP_LEFT) {
round_box_shade_col(coltop, coldown, 1.0);
- glVertex2f(minx + rad, maxy);
+ gpuVertex2f(minx + rad, maxy);
for (a = 0; a < 7; a++) {
round_box_shade_col(coltop, coldown, (div - vec[a][1]) * idiv);
- glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
+ gpuVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
}
round_box_shade_col(coltop, coldown, (div - rad) * idiv);
- glVertex2f(minx, maxy - rad);
+ gpuVertex2f(minx, maxy - rad);
}
else {
round_box_shade_col(coltop, coldown, 1.0);
- glVertex2f(minx, maxy);
+ gpuVertex2f(minx, maxy);
}
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
round_box_shade_col(coltop, coldown, rad * idiv);
- glVertex2f(minx, miny + rad);
+ gpuVertex2f(minx, miny + rad);
for (a = 0; a < 7; a++) {
round_box_shade_col(coltop, coldown, (rad - vec[a][1]) * idiv);
- glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
+ gpuVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
}
round_box_shade_col(coltop, coldown, 0.0);
- glVertex2f(minx + rad, miny);
+ gpuVertex2f(minx + rad, miny);
}
else {
round_box_shade_col(coltop, coldown, 0.0);
- glVertex2f(minx, miny);
+ gpuVertex2f(minx, miny);
}
- glEnd();
+ gpuEnd();
glShadeModel(GL_FLAT);
}
@@ -266,8 +272,8 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
for (a = 0; a < 7; a++) {
mul_v2_fl(vec[a], rad);
}
- /* get current color, needs to be outside of glBegin/End */
- glGetFloatv(GL_CURRENT_COLOR, color);
+ /* get current color, needs to be outside of gpuBegin/End */
+ gpuGetCurrentColor4fv(color);
/* 'shade' defines strength of shading */
colLeft[0] = min_ff(1.0f, color[0] + shadeLeft);
@@ -278,102 +284,98 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
colRight[2] = max_ff(0.0f, color[2] + shadeRight);
glShadeModel(GL_SMOOTH);
- glBegin(mode);
+ gpuBegin(mode);
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
round_box_shade_col(colLeft, colRight, 0.0);
- glVertex2f(maxx - rad, miny);
+ gpuVertex2f(maxx - rad, miny);
for (a = 0; a < 7; a++) {
round_box_shade_col(colLeft, colRight, vec[a][0] * idiv);
- glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
+ gpuVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
}
round_box_shade_col(colLeft, colRight, rad * idiv);
- glVertex2f(maxx, miny + rad);
+ gpuVertex2f(maxx, miny + rad);
}
else {
round_box_shade_col(colLeft, colRight, 0.0);
- glVertex2f(maxx, miny);
+ gpuVertex2f(maxx, miny);
}
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
round_box_shade_col(colLeft, colRight, 0.0);
- glVertex2f(maxx, maxy - rad);
+ gpuVertex2f(maxx, maxy - rad);
for (a = 0; a < 7; a++) {
round_box_shade_col(colLeft, colRight, (div - rad - vec[a][0]) * idiv);
- glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
+ gpuVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
}
round_box_shade_col(colLeft, colRight, (div - rad) * idiv);
- glVertex2f(maxx - rad, maxy);
+ gpuVertex2f(maxx - rad, maxy);
}
else {
round_box_shade_col(colLeft, colRight, 0.0);
- glVertex2f(maxx, maxy);
+ gpuVertex2f(maxx, maxy);
}
/* corner left-top */
if (roundboxtype & UI_CNR_TOP_LEFT) {
round_box_shade_col(colLeft, colRight, (div - rad) * idiv);
- glVertex2f(minx + rad, maxy);
+ gpuVertex2f(minx + rad, maxy);
for (a = 0; a < 7; a++) {
round_box_shade_col(colLeft, colRight, (div - rad + vec[a][0]) * idiv);
- glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
+ gpuVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
}
round_box_shade_col(colLeft, colRight, 1.0);
- glVertex2f(minx, maxy - rad);
+ gpuVertex2f(minx, maxy - rad);
}
else {
round_box_shade_col(colLeft, colRight, 1.0);
- glVertex2f(minx, maxy);
+ gpuVertex2f(minx, maxy);
}
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
round_box_shade_col(colLeft, colRight, 1.0);
- glVertex2f(minx, miny + rad);
+ gpuVertex2f(minx, miny + rad);
for (a = 0; a < 7; a++) {
round_box_shade_col(colLeft, colRight, (vec[a][0]) * idiv);
- glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
+ gpuVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
}
round_box_shade_col(colLeft, colRight, 1.0);
- glVertex2f(minx + rad, miny);
+ gpuVertex2f(minx + rad, miny);
}
else {
round_box_shade_col(colLeft, colRight, 1.0);
- glVertex2f(minx, miny);
+ gpuVertex2f(minx, miny);
}
- glEnd();
+ gpuEnd();
glShadeModel(GL_FLAT);
}
/* plain antialiased unfilled rectangle */
void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad)
{
- float color[4];
-
if (roundboxtype & UI_RB_ALPHA) {
- glGetFloatv(GL_CURRENT_COLOR, color);
- color[3] = 0.5;
- glColor4fv(color);
+ gpuCurrentAlpha(0.5f);
glEnable(GL_BLEND);
}
-
+
/* set antialias line */
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
-
+
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
}
@@ -381,16 +383,12 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad)
/* (old, used in outliner) plain antialiased filled box */
void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
{
- float color[4];
-
if (roundboxtype & UI_RB_ALPHA) {
- glGetFloatv(GL_CURRENT_COLOR, color);
- color[3] = 0.5;
- glColor4fv(color);
+ gpuCurrentAlpha(0.5f);
glEnable(GL_BLEND);
}
-
- ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad);
+
+ ui_draw_anti_roundbox(GL_TRIANGLE_FAN, minx, miny, maxx, maxy, rad);
}
@@ -400,23 +398,25 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
/* text_draw.c uses this */
void uiEmboss(float x1, float y1, float x2, float y2, int sel)
{
-
+ gpuImmediateFormat_C4_V2(); // DOODLE: fixed number of colored lines
+ gpuBegin(GL_LINES);
+
/* below */
- if (sel) glColor3ub(200, 200, 200);
- else glColor3ub(50, 50, 50);
- fdrawline(x1, y1, x2, y1);
+ gpuCurrentGray3f(sel ? 0.784f : 0.196f);
+ gpuAppendLinef(x1, y1, x2, y1);
/* right */
- fdrawline(x2, y1, x2, y2);
+ gpuAppendLinef(x2, y1, x2, y2);
/* top */
- if (sel) glColor3ub(50, 50, 50);
- else glColor3ub(200, 200, 200);
- fdrawline(x1, y2, x2, y2);
+ gpuCurrentGray3f(!sel ? 0.784f : 0.196f);
+ gpuAppendLinef(x1, y2, x2, y2);
/* left */
- fdrawline(x1, y1, x1, y2);
-
+ gpuAppendLinef(x1, y1, x1, y2);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
/* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */
@@ -435,18 +435,18 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
/* scissor doesn't seem to be doing the right thing...? */
#if 0
- //glColor4f(1.0, 0.f, 0.f, 1.f);
- //fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
+ //gpuCurrentColor3x(CPACK_RED);
+ //gpuSingleWireRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
w = BLI_rcti_size_x(rect);
h = BLI_rcti_size_y(rect);
/* prevent drawing outside widget area */
- glGetIntegerv(GL_SCISSOR_BOX, scissor);
- glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
+ gpuGetSizeBox(GL_SCISSOR_BOX, scissor);
+ gpuScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
#endif
glEnable(GL_BLEND);
- glColor4f(0.0, 0.0, 0.0, 0.0);
+ gpuCurrentColor4x(CPACK_BLACK, 0.000f);
glaDrawPixelsSafe((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
//glaDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
@@ -455,7 +455,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
#if 0
// restore scissortest
- glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+ gpuScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
#endif
#endif
@@ -531,10 +531,10 @@ static void ui_draw_but_CHARTAB(uiBut *but)
/* Start drawing the button itself */
glShadeModel(GL_SMOOTH);
- glColor3ub(200, 200, 200);
- glRectf((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
+ gpuCurrentGray3f(0.784f);
+ gpuSingleFilledRectf((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
for (y = 0; y < 6; y++) {
/* Do not draw more than the category allows */
if (cs > charmax) break;
@@ -545,12 +545,12 @@ static void ui_draw_but_CHARTAB(uiBut *but)
if (cs > charmax) break;
/* Draw one grid cell */
- glBegin(GL_LINE_LOOP);
- glVertex2f(sx, sy);
- glVertex2f(ex, sy);
- glVertex2f(ex, ey);
- glVertex2f(sx, ey);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(sx, sy);
+ gpuVertex2f(ex, sy);
+ gpuVertex2f(ex, ey);
+ gpuVertex2f(sx, ey);
+ gpuEnd();
/* Draw character inside the cell */
memset(wstr, 0, sizeof(wchar_t) * 2);
@@ -635,25 +635,30 @@ static void ui_draw_but_CHARTAB(uiBut *but)
static void draw_scope_end(const rctf *rect, GLint *scissor)
{
float scaler_x1, scaler_x2;
-
+
/* restore scissortest */
- glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+ gpuScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+
/* scale widget */
scaler_x1 = rect->xmin + BLI_rctf_size_x(rect) / 2 - SCOPE_RESIZE_PAD;
scaler_x2 = rect->xmin + BLI_rctf_size_x(rect) / 2 + SCOPE_RESIZE_PAD;
-
- glColor4f(0.f, 0.f, 0.f, 0.25f);
- fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4);
- fdrawline(scaler_x1, rect->ymin - 7, scaler_x2, rect->ymin - 7);
- glColor4f(1.f, 1.f, 1.f, 0.25f);
- fdrawline(scaler_x1, rect->ymin - 5, scaler_x2, rect->ymin - 5);
- fdrawline(scaler_x1, rect->ymin - 8, scaler_x2, rect->ymin - 8);
-
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: fixed number of colored lines
+ gpuBegin(GL_LINES);
+
+ gpuCurrentColor4x(CPACK_BLACK, 0.250f);
+ gpuAppendLinef(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4);
+ gpuAppendLinef(scaler_x1, rect->ymin - 7, scaler_x2, rect->ymin - 7);
+
+ gpuCurrentColor4x(CPACK_WHITE, 0.250f);
+ gpuAppendLinef(scaler_x1, rect->ymin - 5, scaler_x2, rect->ymin - 5);
+ gpuAppendLinef(scaler_x1, rect->ymin - 8, scaler_x2, rect->ymin - 8);
+
+ gpuEnd();
+ gpuImmediateUnformat();
+
/* outline */
- glColor4f(0.f, 0.f, 0.f, 0.5f);
+ gpuCurrentColor4x(CPACK_BLACK, 0.500f);
uiSetRoundBox(UI_CNR_ALL);
uiDrawBox(GL_LINE_LOOP, rect->xmin - 1, rect->ymin, rect->xmax + 1, rect->ymax + 1, 3.0f);
}
@@ -662,54 +667,57 @@ static void histogram_draw_one(float r, float g, float b, float alpha,
float x, float y, float w, float h, float *data, int res, const short is_line)
{
int i;
-
- if (is_line) {
+ if (is_line) {
glLineWidth(1.5);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- glColor4f(r, g, b, alpha);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE); /* non-standard blend function */
+ gpuCurrentColor4f(r, g, b, alpha);
/* curve outline */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_LINE_SMOOTH);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0; i < res; i++) {
float x2 = x + i * (w / (float)res);
- glVertex2f(x2, y + (data[i] * h));
+ gpuVertex2f(x2, y + (data[i] * h));
}
- glEnd();
+ gpuEnd();
glDisable(GL_LINE_SMOOTH);
glLineWidth(1.0);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
}
else {
/* under the curve */
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- glColor4f(r, g, b, alpha);
+ gpuCurrentColor4f(r, g, b, alpha);
glShadeModel(GL_FLAT);
- glBegin(GL_QUAD_STRIP);
- glVertex2f(x, y);
- glVertex2f(x, y + (data[0] * h));
+
+ gpuBegin(GL_TRIANGLE_STRIP); // DOODLE: line graph drawn using quads, locking done by function callee
+ gpuVertex2f(x, y);
+ gpuVertex2f(x, y + (data[0] * h));
for (i = 1; i < res; i++) {
float x2 = x + i * (w / (float)res);
- glVertex2f(x2, y + (data[i] * h));
- glVertex2f(x2, y);
+ gpuVertex2f(x2, y + (data[i] * h));
+ gpuVertex2f(x2, y);
}
- glEnd();
+ gpuEnd();
/* curve outline */
- glColor4f(0.f, 0.f, 0.f, 0.25f);
+ gpuCurrentColor4x(CPACK_BLACK, 0.250f);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
glEnable(GL_LINE_SMOOTH);
- glBegin(GL_LINE_STRIP);
+
+ gpuBegin(GL_LINE_STRIP); // DOODLE: line graph drawn using a line strip, locking done by callee
for (i = 0; i < res; i++) {
float x2 = x + i * (w / (float)res);
- glVertex2f(x2, y + (data[i] * h));
+ gpuVertex2f(x2, y + (data[i] * h));
}
- glEnd();
+ gpuEnd();
+
glDisable(GL_LINE_SMOOTH);
}
}
@@ -724,7 +732,6 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
int i;
float w, h;
const short is_line = (hist->flag & HISTO_FLAG_LINE) != 0;
- //float alpha;
GLint scissor[4];
rect.xmin = (float)recti->xmin + 1;
@@ -736,33 +743,36 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
h = BLI_rctf_size_y(&rect) * hist->ymax;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glColor4f(0.f, 0.f, 0.f, 0.3f);
+
+ gpuCurrentColor4x(CPACK_BLACK, 0.300f);
uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
/* need scissor test, histogram can draw outside of boundary */
- glGetIntegerv(GL_VIEWPORT, scissor);
- glScissor(ar->winrct.xmin + (rect.xmin - 1),
+ gpuGetSizeBox(GL_VIEWPORT, scissor);
+ gpuScissor(ar->winrct.xmin + (rect.xmin - 1),
ar->winrct.ymin + (rect.ymin - 1),
(rect.xmax + 1) - (rect.xmin - 1),
(rect.ymax + 1) - (rect.ymin - 1));
- glColor4f(1.f, 1.f, 1.f, 0.08f);
+ gpuCurrentColor4x(CPACK_WHITE, 0.080f);
+
+ gpuImmediateFormat_V2(); /* lock both for grid and histogram */ // DOODLE: 4 monochrome lines and 1 or 3 histograms
+
/* draw grid lines here */
for (i = 1; i < (HISTOGRAM_TOT_GRID_LINES + 1); i++) {
const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES;
/* so we can tell the 1.0 color point */
if (i == HISTOGRAM_TOT_GRID_LINES) {
- glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
+ gpuCurrentColor4f(1.0f, 1.0f, 1.0f, 0.5f);
}
- fdrawline(rect.xmin, rect.ymin + fac * h, rect.xmax, rect.ymin + fac * h);
- fdrawline(rect.xmin + fac * w, rect.ymin, rect.xmin + fac * w, rect.ymax);
+ gpuAppendLinef(rect.xmin, rect.ymin + fac * h, rect.xmax, rect.ymin + fac * h);
+ gpuAppendLinef(rect.xmin + fac * w, rect.ymin, rect.xmin + fac * w, rect.ymax);
}
-
+ gpuEnd();
+
if (hist->mode == HISTO_MODE_LUMA) {
histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_luma, res, is_line);
}
@@ -777,7 +787,9 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B)
histogram_draw_one(0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res, is_line);
}
-
+
+ gpuImmediateUnformat();
+
/* outline, scale gripper */
draw_scope_end(&rect, scissor);
}
@@ -795,9 +807,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors pre multiplied by alpha for speed up */
float min, max;
-
+
if (scopes == NULL) return;
-
+
rect.xmin = (float)recti->xmin + 1;
rect.xmax = (float)recti->xmax - 1;
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
@@ -809,94 +821,108 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f;
w3 = w / 3.0f;
-
+
/* log scale for alpha */
alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
-
+
for (c = 0; c < 3; c++) {
for (i = 0; i < 3; i++) {
colors_alpha[c][i] = colors[c][i] * alpha;
colorsycc_alpha[c][i] = colorsycc[c][i] * alpha;
}
}
-
+
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glColor4f(0.f, 0.f, 0.f, 0.3f);
+
+ gpuCurrentColor4x(CPACK_BLACK, 0.300f);
uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
/* need scissor test, waveform can draw outside of boundary */
- glGetIntegerv(GL_VIEWPORT, scissor);
- glScissor(ar->winrct.xmin + (rect.xmin - 1),
+ gpuGetSizeBox(GL_VIEWPORT, scissor);
+ gpuScissor(ar->winrct.xmin + (rect.xmin - 1),
ar->winrct.ymin + (rect.ymin - 1),
(rect.xmax + 1) - (rect.xmin - 1),
(rect.ymax + 1) - (rect.ymin - 1));
- glColor4f(1.f, 1.f, 1.f, 0.08f);
+ gpuCurrentColor4x(CPACK_WHITE, 0.080f);
+
/* draw grid lines here */
+ gpuImmediateFormat_V2(); // DOODLE: fixed number of monochrome lines, a grid
+ gpuBegin(GL_LINES);
+ for (i = 0; i < 6; i++) {
+ gpuAppendLinef(rect.xmin + 22, yofs + (i / 5.f) * h, rect.xmax + 1, yofs + (i / 5.f) * h);
+ }
+ gpuEnd();
+ gpuImmediateUnformat();
+
+ /* draw text on grid */
+ BLF_draw_default_lock(); // DOODLE: grid of numbers
for (i = 0; i < 6; i++) {
char str[4];
BLI_snprintf(str, sizeof(str), "%-3d", i * 20);
str[3] = '\0';
- fdrawline(rect.xmin + 22, yofs + (i / 5.f) * h, rect.xmax + 1, yofs + (i / 5.f) * h);
BLF_draw_default(rect.xmin + 1, yofs - 5 + (i / 5.f) * h, 0, str, sizeof(str) - 1);
- /* in the loop because blf_draw reset it */
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
+ BLF_draw_default_unlock();
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: variable number of lines, colors passed mainly to reduce number of batches
+ gpuBegin(GL_LINES);
+
/* 3 vertical separation */
if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
for (i = 1; i < 3; i++) {
- fdrawline(rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax);
+ gpuAppendLinef(rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax);
}
}
-
+
/* separate min max zone on the right */
- fdrawline(rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax);
+ gpuAppendLinef(rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax);
/* 16-235-240 level in case of ITU-R BT601/709 */
- glColor4f(1.f, 0.4f, 0.f, 0.2f);
+ gpuColor4f(1.0f, 0.4f, 0.0f, 0.200f);
if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) {
- fdrawline(rect.xmin + 22, yofs + h * 16.0f / 255.0f, rect.xmax + 1, yofs + h * 16.0f / 255.0f);
- fdrawline(rect.xmin + 22, yofs + h * 235.0f / 255.0f, rect.xmin + w3, yofs + h * 235.0f / 255.0f);
- fdrawline(rect.xmin + 3 * w3, yofs + h * 235.0f / 255.0f, rect.xmax + 1, yofs + h * 235.0f / 255.0f);
- fdrawline(rect.xmin + w3, yofs + h * 240.0f / 255.0f, rect.xmax + 1, yofs + h * 240.0f / 255.0f);
+ gpuAppendLinef(rect.xmin + 22, yofs + h * 16.0f / 255.0f, rect.xmax + 1, yofs + h * 16.0f / 255.0f);
+ gpuAppendLinef(rect.xmin + 22, yofs + h * 235.0f / 255.0f, rect.xmin + w3, yofs + h * 235.0f / 255.0f);
+ gpuAppendLinef(rect.xmin + 3 * w3, yofs + h * 235.0f / 255.0f, rect.xmax + 1, yofs + h * 235.0f / 255.0f);
+ gpuAppendLinef(rect.xmin + w3, yofs + h * 240.0f / 255.0f, rect.xmax + 1, yofs + h * 240.0f / 255.0f);
}
/* 7.5 IRE black point level for NTSC */
- if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA)
- fdrawline(rect.xmin, yofs + h * 0.075f, rect.xmax + 1, yofs + h * 0.075f);
+ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
+ gpuAppendLinef(rect.xmin, yofs + h * 0.075f, rect.xmax + 1, yofs + h * 0.075f);
+ }
+
+ gpuEnd();
+ gpuImmediateUnformat();
if (scopes->ok && scopes->waveform_1 != NULL) {
-
+ GPUarrays arrays = GPU_ARRAYS_V2F;
+
+ glBlendFunc(GL_ONE, GL_ONE); /* non-standard blend function */
+
+ gpuImmediateFormat_V2();
+
/* LUMA (1 channel) */
- glBlendFunc(GL_ONE, GL_ONE);
- glColor3f(alpha, alpha, alpha);
+ gpuCurrentGray3f(alpha);
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
- glBlendFunc(GL_ONE, GL_ONE);
-
- glPushMatrix();
- glEnableClientState(GL_VERTEX_ARRAY);
-
- glTranslatef(rect.xmin, yofs, 0.f);
- glScalef(w, h, 0.f);
- glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_1);
- glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glPopMatrix();
+ gpuPushMatrix();
+ gpuTranslate(rect.xmin, yofs, 0);
+ gpuScale(w, h, 0);
+
+ arrays.vertexPointer = scopes->waveform_1;
+ gpuDrawClientArrays(GL_POINTS, &arrays, 0, scopes->waveform_tot);
+
+ gpuPopMatrix();
/* min max */
- glColor3f(0.5f, 0.5f, 0.5f);
+ gpuCurrentGray3f(0.500f);
min = yofs + scopes->minmax[0][0] * h;
max = yofs + scopes->minmax[0][1] * h;
CLAMP(min, rect.ymin, rect.ymax);
CLAMP(max, rect.ymin, rect.ymax);
- fdrawline(rect.xmax - 3, min, rect.xmax - 3, max);
+ gpuDrawLinef(rect.xmax - 3, min, rect.xmax - 3, max);
}
-
/* RGB / YCC (3 channels) */
else if (ELEM4(scopes->wavefrm_mode,
SCOPES_WAVEFRM_RGB,
@@ -904,50 +930,54 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
SCOPES_WAVEFRM_YCC_709,
SCOPES_WAVEFRM_YCC_JPEG))
{
+ GPUarrays arrays = GPU_ARRAYS_V2F;
+
int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB);
-
- glBlendFunc(GL_ONE, GL_ONE);
-
- glPushMatrix();
- glEnableClientState(GL_VERTEX_ARRAY);
-
- glTranslatef(rect.xmin, yofs, 0.f);
- glScalef(w3, h, 0.f);
-
- glColor3fv((rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
- glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_1);
- glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
-
- glTranslatef(1.f, 0.f, 0.f);
- glColor3fv((rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
- glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_2);
- glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
-
- glTranslatef(1.f, 0.f, 0.f);
- glColor3fv((rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
- glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_3);
- glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glPopMatrix();
-
+ gpuPushMatrix();
+
+ gpuTranslate(rect.xmin, yofs, 0);
+ gpuScale(w3, h, 0);
+
+ gpuCurrentColor3fv((rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
+ arrays.vertexPointer = scopes->waveform_1;
+ gpuDrawClientArrays(GL_POINTS, &arrays, 0, scopes->waveform_tot);
+
+ gpuTranslate(1, 0, 0);
+ gpuCurrentColor3fv((rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
+ arrays.vertexPointer = scopes->waveform_2;
+ gpuDrawClientArrays(GL_POINTS, &arrays, 0, scopes->waveform_tot);
+
+ gpuTranslate(1, 0, 0);
+ gpuCurrentColor3fv((rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
+ arrays.vertexPointer = scopes->waveform_3;
+ gpuDrawClientArrays(GL_POINTS, &arrays, 0, scopes->waveform_tot);
+
+ gpuPopMatrix();
+
/* min max */
for (c = 0; c < 3; c++) {
- if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB)
- glColor3f(colors[c][0] * 0.75f, colors[c][1] * 0.75f, colors[c][2] * 0.75f);
- else
- glColor3f(colorsycc[c][0] * 0.75f, colorsycc[c][1] * 0.75f, colorsycc[c][2] * 0.75f);
+ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) {
+ gpuCurrentColor3f(colors[c][0] * 0.75f, colors[c][1] * 0.75f, colors[c][2] * 0.75f);
+ }
+ else {
+ gpuCurrentColor3f(colorsycc[c][0] * 0.75f, colorsycc[c][1] * 0.75f, colorsycc[c][2] * 0.75f);
+ }
+
min = yofs + scopes->minmax[c][0] * h;
max = yofs + scopes->minmax[c][1] * h;
CLAMP(min, rect.ymin, rect.ymax);
CLAMP(max, rect.ymin, rect.ymax);
- fdrawline(rect.xmin + w + 2 + c * 2, min, rect.xmin + w + 2 + c * 2, max);
+
+ gpuDrawLinef(rect.xmin + w + 2 + c * 2, min, rect.xmin + w + 2 + c * 2, max); // DOODLE: single line
}
}
-
+
+ gpuImmediateUnformat();
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
}
-
+
/* outline, scale gripper */
draw_scope_end(&rect, scissor);
}
@@ -977,42 +1007,43 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, co
tampli = sqrtf(u * u + v * v);
/* small target vary by 2.5 degree and 2.5 IRE unit */
- glColor4f(1.0f, 1.0f, 1.0, 0.12f);
+ gpuCurrentColor4x(CPACK_WHITE, 0.120f);
+
dangle = DEG2RADF(2.5f);
dampli = 2.5f / 200.0f;
- glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
- glEnd();
+
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
+ gpuEnd();
/* big target vary by 10 degree and 20% amplitude */
- glColor4f(1.0f, 1.0f, 1.0, 0.12f);
dangle = DEG2RADF(10.0f);
dampli = 0.2f * tampli;
dangle2 = DEG2RADF(5.0f);
dampli2 = 0.5f * dampli;
- glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2));
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2));
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2));
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
- glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2));
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2));
+ gpuEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2f(polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2));
+ gpuEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2f(polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2));
+ gpuEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
+ gpuVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2));
+ gpuEnd();
}
void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
@@ -1027,78 +1058,94 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
{0.75, 0.0, 0.0}, {0.75, 0.75, 0.0}, {0.0, 0.75, 0.0},
{0.0, 0.75, 0.75}, {0.0, 0.0, 0.75}, {0.75, 0.0, 0.75}};
GLint scissor[4];
-
+
rect.xmin = (float)recti->xmin + 1;
rect.xmax = (float)recti->xmax - 1;
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
-
+
w = BLI_rctf_size_x(&rect);
h = BLI_rctf_size_y(&rect);
centerx = rect.xmin + w / 2;
centery = rect.ymin + h / 2;
diam = (w < h) ? w : h;
-
+
alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
-
+
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glColor4f(0.f, 0.f, 0.f, 0.3f);
+
+ gpuCurrentColor4x(CPACK_BLACK, 0.300f);
uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
/* need scissor test, hvectorscope can draw outside of boundary */
- glGetIntegerv(GL_VIEWPORT, scissor);
- glScissor(ar->winrct.xmin + (rect.xmin - 1),
+ gpuGetSizeBox(GL_VIEWPORT, scissor);
+ gpuScissor(ar->winrct.xmin + (rect.xmin - 1),
ar->winrct.ymin + (rect.ymin - 1),
(rect.xmax + 1) - (rect.xmin - 1),
(rect.ymax + 1) - (rect.ymin - 1));
-
- glColor4f(1.f, 1.f, 1.f, 0.08f);
+
+ gpuCurrentColor4x(CPACK_WHITE, 0.080f);
+
/* draw grid elements */
+
/* cross */
- fdrawline(centerx - (diam / 2) - 5, centery, centerx + (diam / 2) + 5, centery);
- fdrawline(centerx, centery - (diam / 2) - 5, centerx, centery + (diam / 2) + 5);
+ gpuImmediateFormat_V2(); // DOODLE: cross, fixed number of lines, and 5 circles
+
+ gpuBegin(GL_LINES);
+ gpuAppendLinef(centerx - (diam / 2) - 5, centery, centerx + (diam / 2) + 5, centery);
+ gpuAppendLinef(centerx, centery - (diam / 2) - 5, centerx, centery + (diam / 2) + 5);
+ gpuEnd();
+
/* circles */
for (j = 0; j < 5; j++) {
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0; i <= 360; i = i + 15) {
const float a = DEG2RADF((float)i);
const float r = (j + 1) / 10.0f;
- glVertex2f(polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a));
+ gpuVertex2f(polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a));
}
- glEnd();
+ gpuEnd();
}
+
/* skin tone line */
- glColor4f(1.f, 0.4f, 0.f, 0.2f);
- fdrawline(polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5, skin_rad),
- polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1, skin_rad));
+ gpuCurrentColor4f(1.0f, 0.4f, 0.0f, 0.200f);
+ gpuDrawLinef(
+ polar_to_x(centerx, diam, 0.5f, skin_rad),
+ polar_to_y(centery, diam, 0.5f, skin_rad),
+ polar_to_x(centerx, diam, 0.1f, skin_rad),
+ polar_to_y(centery, diam, 0.1f, skin_rad));
+
/* saturation points */
- for (i = 0; i < 6; i++)
+ for (i = 0; i < 6; i++) {
vectorscope_draw_target(centerx, centery, diam, colors[i]);
-
+ }
+
if (scopes->ok && scopes->vecscope != NULL) {
+ GPUarrays arrays = GPU_ARRAYS_V2F;
+
+ glBlendFunc(GL_ONE, GL_ONE); /* non-standard blendfunc */
+
/* pixel point cloud */
- glBlendFunc(GL_ONE, GL_ONE);
- glColor3f(alpha, alpha, alpha);
+ gpuCurrentGray3f(alpha);
- glPushMatrix();
- glEnableClientState(GL_VERTEX_ARRAY);
+ gpuPushMatrix();
+ gpuTranslate(centerx, centery, 0);
+ gpuScale(diam, diam, 0);
- glTranslatef(centerx, centery, 0.f);
- glScalef(diam, diam, 0.f);
+ arrays.vertexPointer = scopes->vecscope;
+ gpuDrawClientArrays(GL_POINTS, &arrays, 0, scopes->waveform_tot);
- glVertexPointer(2, GL_FLOAT, 0, scopes->vecscope);
- glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glPopMatrix();
+ gpuPopMatrix();
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
}
+ gpuImmediateUnformat();
+
/* outline, scale gripper */
draw_scope_end(&rect, scissor);
-
+
glDisable(GL_BLEND);
}
@@ -1123,52 +1170,54 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
sizex = rect->xmax - x1;
sizey = rect->ymax - y1;
+ gpuImmediateFormat_C4_V2();
+
/* first background, to show tranparency */
- glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
- glRectf(x1, y1, x1 + sizex, y1 + sizey);
+ gpuCurrentColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
+ gpuDrawFilledRectf(x1, y1, x1 + sizex, y1 + sizey);
glEnable(GL_POLYGON_STIPPLE);
- glColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
+ gpuCurrentColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
glPolygonStipple(checker_stipple_sml);
- glRectf(x1, y1, x1 + sizex, y1 + sizey);
+ gpuDrawFilledRectf(x1, y1, x1 + sizex, y1 + sizey);
glDisable(GL_POLYGON_STIPPLE);
glShadeModel(GL_FLAT);
glEnable(GL_BLEND);
-
+
cbd = coba->data;
-
+
v1[0] = v2[0] = x1;
v1[1] = y1;
v2[1] = y1 + sizey;
-
- glBegin(GL_QUAD_STRIP);
-
- glColor4fv(&cbd->r);
- glVertex2fv(v1);
- glVertex2fv(v2);
+
+ gpuBegin(GL_TRIANGLE_STRIP);
+
+ gpuColor4fv(&cbd->r);
+ gpuVertex2fv(v1);
+ gpuVertex2fv(v2);
for (a = 1; a <= sizex; a++) {
pos = ((float)a) / (sizex - 1);
do_colorband(coba, pos, colf);
if (display)
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
-
+
v1[0] = v2[0] = x1 + a;
-
- glColor4fv(colf);
- glVertex2fv(v1);
- glVertex2fv(v2);
+
+ gpuColor4fv(colf);
+ gpuVertex2fv(v1);
+ gpuVertex2fv(v2);
}
-
- glEnd();
+
+ gpuEnd();
glShadeModel(GL_FLAT);
glDisable(GL_BLEND);
-
+
/* outline */
- glColor4f(0.0, 0.0, 0.0, 1.0);
- fdrawbox(x1, y1, x1 + sizex, y1 + sizey);
-
+ gpuCurrentColor3x(CPACK_BLACK);
+ gpuDrawWireRectf(x1, y1, x1 + sizex, y1 + sizey);
+
/* help lines */
v1[0] = v2[0] = v3[0] = x1;
v1[1] = y1;
@@ -1176,146 +1225,159 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
v2[1] = y1 + 0.5f * sizey;
v2a[1] = y1 + 0.75f * sizey;
v3[1] = y1 + sizey;
-
-
+
+
cbd = coba->data;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
for (a = 0; a < coba->tot; a++, cbd++) {
v1[0] = v2[0] = v3[0] = v1a[0] = v2a[0] = x1 + cbd->pos * sizex;
-
+
if (a == coba->cur) {
- glColor3ub(0, 0, 0);
- glVertex2fv(v1);
- glVertex2fv(v3);
- glEnd();
-
+ gpuColor3x(CPACK_BLACK);
+ gpuVertex2fv(v1);
+ gpuVertex2fv(v3);
+ gpuEnd();
+
setlinestyle(2);
- glBegin(GL_LINES);
- glColor3ub(255, 255, 255);
- glVertex2fv(v1);
- glVertex2fv(v3);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuColor3x(CPACK_WHITE);
+ gpuVertex2fv(v1);
+ gpuVertex2fv(v3);
+ gpuEnd();
setlinestyle(0);
- glBegin(GL_LINES);
-
+ gpuBegin(GL_LINES);
+
#if 0
- glColor3ub(0, 0, 0);
- glVertex2fv(v1);
- glVertex2fv(v1a);
- glColor3ub(255, 255, 255);
- glVertex2fv(v1a);
- glVertex2fv(v2);
- glColor3ub(0, 0, 0);
- glVertex2fv(v2);
- glVertex2fv(v2a);
- glColor3ub(255, 255, 255);
- glVertex2fv(v2a);
- glVertex2fv(v3);
+ gpuColor3x(CPACK_BLACK);
+
+ gpuVertex2fv(v1);
+ gpuVertex2fv(v1a);
+
+ gpuVertex2fv(v2);
+ gpuVertex2fv(v2a);
+
+ gpuColor3x(CPACK_WHITE);
+
+ gpuVertex2fv(v1a);
+ gpuVertex2fv(v2);
+
+ gpuVertex2fv(v2a);
+ gpuVertex2fv(v3);
#endif
}
else {
- glColor3ub(0, 0, 0);
- glVertex2fv(v1);
- glVertex2fv(v2);
-
- glColor3ub(255, 255, 255);
- glVertex2fv(v2);
- glVertex2fv(v3);
+ gpuColor3x(CPACK_BLACK);
+ gpuVertex2fv(v1);
+ gpuVertex2fv(v2);
+
+ gpuColor3x(CPACK_WHITE);
+ gpuVertex2fv(v2);
+ gpuVertex2fv(v3);
}
}
- glEnd();
+ gpuEnd();
+ gpuImmediateUnformat();
}
void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
{
- static GLuint displist = 0;
+ static GPUimmediate *displist = NULL;
+ static GPUindex *index = NULL;
+
int a, old[8];
GLfloat diff[4], diffn[4] = {1.0f, 1.0f, 1.0f, 1.0f};
float vec0[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float dir[4], size;
-
+
/* store stuff */
- glGetMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
+ gpuGetMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
/* backdrop */
- glColor3ubv((unsigned char *)wcol->inner);
+ gpuCurrentColor3ubv((unsigned char *)wcol->inner);
uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f);
+ uiDrawBox(GL_TRIANGLE_FAN, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f);
/* sphere color */
- glMaterialfv(GL_FRONT, GL_DIFFUSE, diffn);
+ gpuMaterialfv(GL_FRONT, GL_DIFFUSE, diffn);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
/* disable blender light */
for (a = 0; a < 8; a++) {
- old[a] = glIsEnabled(GL_LIGHT0 + a);
- glDisable(GL_LIGHT0 + a);
+ old[a] = gpuIsLightEnabled(a);
+ gpuDisableLight(a);
}
/* own light */
- glEnable(GL_LIGHT7);
- glEnable(GL_LIGHTING);
+ gpuEnableLight(7);
+ gpuEnableLighting();
ui_get_but_vectorf(but, dir);
dir[3] = 0.0f; /* glLightfv needs 4 args, 0.0 is sun */
- glLightfv(GL_LIGHT7, GL_POSITION, dir);
- glLightfv(GL_LIGHT7, GL_DIFFUSE, diffn);
- glLightfv(GL_LIGHT7, GL_SPECULAR, vec0);
- glLightf(GL_LIGHT7, GL_CONSTANT_ATTENUATION, 1.0f);
- glLightf(GL_LIGHT7, GL_LINEAR_ATTENUATION, 0.0f);
+ gpuLightfv(7, GL_POSITION, dir);
+ gpuLightfv(7, GL_DIFFUSE, diffn);
+ gpuLightfv(7, GL_SPECULAR, vec0);
+ gpuLightf(7, GL_CONSTANT_ATTENUATION, 1.0f);
+ gpuLightf(7, GL_LINEAR_ATTENUATION, 0.0f);
/* transform to button */
- glPushMatrix();
- glTranslatef(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f);
+ gpuPushMatrix();
+ gpuTranslate(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f);
if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
size = BLI_rcti_size_x(rect) / 200.f;
else
size = BLI_rcti_size_y(rect) / 200.f;
- glScalef(size, size, size);
+ gpuScale(size, size, size);
- if (displist == 0) {
- GLUquadricObj *qobj;
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
-
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_FILL);
- glShadeModel(GL_SMOOTH);
- gluSphere(qobj, 100.0, 32, 24);
- glShadeModel(GL_FLAT);
- gluDeleteQuadric(qobj);
+ glShadeModel(GL_SMOOTH);
+
+ if (!displist) {
+ GPUprim3 prim = GPU_PRIM_HIFI_SOLID;
+ prim.usegs = 32;
+ prim.vsegs = 24;
+
+ gpuPushImmediate();
+ gpuImmediateMaxVertexCount(800);
- glEndList();
+ index = gpuNewIndex();
+ gpuImmediateIndex(index);
+ gpuImmediateMaxIndexCount(4608);
+
+ gpuSingleSphere(&prim, 100);
+
+ displist = gpuPopImmediate();
}
- else glCallList(displist);
-
+ else {
+ gpuImmediateSingleRepeatElements(displist);
+ }
+
+ glShadeModel(GL_FLAT);
+
/* restore */
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
glDisable(GL_CULL_FACE);
- glMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
- glDisable(GL_LIGHT7);
+ gpuMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
+ gpuDisableLight(7);
/* AA circle */
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
- glColor3ubv((unsigned char *)wcol->inner);
- glutil_draw_lined_arc(0.0f, M_PI * 2.0, 100.0f, 32);
+ gpuCurrentColor3ubv((unsigned char *)wcol->inner);
+ gpuSingleFastCircleXY(100.0f);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
/* matrix after circle */
- glPopMatrix();
+ gpuPopMatrix();
/* enable blender light */
for (a = 0; a < 8; a++) {
if (old[a])
- glEnable(GL_LIGHT0 + a);
+ gpuEnableLight(a);
}
}
@@ -1323,13 +1385,13 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o
{
float dx, dy, fx, fy;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
dx = step * zoomx;
fx = rect->xmin + zoomx * (-offsx);
if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin));
while (fx < rect->xmax) {
- glVertex2f(fx, rect->ymin);
- glVertex2f(fx, rect->ymax);
+ gpuVertex2f(fx, rect->ymin);
+ gpuVertex2f(fx, rect->ymax);
fx += dx;
}
@@ -1337,17 +1399,17 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o
fy = rect->ymin + zoomy * (-offsy);
if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin));
while (fy < rect->ymax) {
- glVertex2f(rect->xmin, fy);
- glVertex2f(rect->xmax, fy);
+ gpuVertex2f(rect->xmin, fy);
+ gpuVertex2f(rect->xmax, fy);
fy += dy;
}
- glEnd();
+ gpuEnd();
}
static void gl_shaded_color(unsigned char *col, int shade)
{
- glColor3ub(col[0] - shade > 0 ? col[0] - shade : 0,
+ gpuCurrentColor3ub(col[0] - shade > 0 ? col[0] - shade : 0,
col[1] - shade > 0 ? col[1] - shade : 0,
col[2] - shade > 0 ? col[2] - shade : 0);
}
@@ -1372,13 +1434,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
cuma = &cumap->cm[cumap->cur];
/* need scissor test, curve can draw outside of boundary */
- glGetIntegerv(GL_VIEWPORT, scissor);
+ gpuGetSizeBox(GL_VIEWPORT, scissor);
scissor_new.xmin = ar->winrct.xmin + rect->xmin;
scissor_new.ymin = ar->winrct.ymin + rect->ymin;
scissor_new.xmax = ar->winrct.xmin + rect->xmax;
scissor_new.ymax = ar->winrct.ymin + rect->ymax;
BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new);
- glScissor(scissor_new.xmin,
+ gpuScissor(scissor_new.xmin,
scissor_new.ymin,
BLI_rcti_size_x(&scissor_new),
BLI_rcti_size_y(&scissor_new));
@@ -1393,7 +1455,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
if (but->a1 == UI_GRAD_H) {
/* magic trigger for curve backgrounds */
rcti grid;
- float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
+ float col[3] = {0,0,0}; /* dummy arg */
grid.xmin = rect->xmin + zoomx * (-offsx);
grid.xmax = rect->xmax + zoomx * (-offsx);
@@ -1404,24 +1466,23 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
/* grid, hsv uses different grid */
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4ub(0, 0, 0, 48);
+ gpuCurrentColor4x(CPACK_BLACK, 0.188f);
ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.1666666f);
glDisable(GL_BLEND);
}
else {
if (cumap->flag & CUMA_DO_CLIP) {
gl_shaded_color((unsigned char *)wcol->inner, -20);
- glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
- glColor3ubv((unsigned char *)wcol->inner);
- glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx),
- rect->ymin + zoomy * (cumap->clipr.ymin - offsy),
- rect->xmin + zoomx * (cumap->clipr.xmax - offsx),
- rect->ymin + zoomy * (cumap->clipr.ymax - offsy));
+ gpuSingleFilledRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ gpuCurrentColor3ubv((unsigned char *)wcol->inner);
+ gpuSingleFilledRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx),
+ rect->ymin + zoomy * (cumap->clipr.ymin - offsy),
+ rect->xmin + zoomx * (cumap->clipr.xmax - offsx),
+ rect->ymin + zoomy * (cumap->clipr.ymax - offsy));
}
else {
- glColor3ubv((unsigned char *)wcol->inner);
- glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ gpuCurrentColor3ubv((unsigned char *)wcol->inner);
+ gpuSingleFilledRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
/* grid, every 0.25 step */
@@ -1432,23 +1493,23 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f);
/* axes */
gl_shaded_color((unsigned char *)wcol->inner, -50);
- glBegin(GL_LINES);
- glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy));
- glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy));
- glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy));
+ gpuVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy));
+ gpuVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin);
+ gpuVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax);
+ gpuEnd();
}
/* cfra option */
/* XXX 2.48 */
#if 0
if (cumap->flag & CUMA_DRAW_CFRA) {
- glColor3ub(0x60, 0xc0, 0x40);
- glBegin(GL_LINES);
- glVertex2f(rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax);
- glEnd();
+ gpuCurrentColor3ub(0x60, 0xc0, 0x40);
+ gpuBegin(GL_LINES);
+ gpuVertex2f(rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin);
+ gpuVertex2f(rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax);
+ gpuEnd();
}
#endif
/* sample option */
@@ -1457,44 +1518,43 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
if (but->a1 == UI_GRAD_H) {
float tsample[3];
float hsv[3];
+ gpuCurrentGray3f(0.941f);
linearrgb_to_srgb_v3_v3(tsample, cumap->sample);
rgb_to_hsv_v(tsample, hsv);
- glColor3ub(240, 240, 240);
- glBegin(GL_LINES);
- glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymax);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymin);
+ gpuVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymax);
+ gpuEnd();
}
else if (cumap->cur == 3) {
float lum = rgb_to_bw(cumap->sample);
- glColor3ub(240, 240, 240);
- glBegin(GL_LINES);
- glVertex2f(rect->xmin + zoomx * (lum - offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx * (lum - offsx), rect->ymax);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(rect->xmin + zoomx * (lum - offsx), rect->ymin);
+ gpuVertex2f(rect->xmin + zoomx * (lum - offsx), rect->ymax);
+ gpuEnd();
}
else {
if (cumap->cur == 0)
- glColor3ub(240, 100, 100);
+ gpuCurrentColor3ub(240, 100, 100);
else if (cumap->cur == 1)
- glColor3ub(100, 240, 100);
+ gpuCurrentColor3ub(100, 240, 100);
else
- glColor3ub(100, 100, 240);
+ gpuCurrentColor3ub(100, 100, 240);
- glBegin(GL_LINES);
- glVertex2f(rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymax);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymin);
+ gpuVertex2f(rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymax);
+ gpuEnd();
}
}
/* the curve */
- glColor3ubv((unsigned char *)wcol->item);
+ gpuCurrentColor3ubv((unsigned char *)wcol->item);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
if (cuma->table == NULL)
curvemapping_changed(cumap, FALSE);
@@ -1502,35 +1562,35 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
/* first point */
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
- glVertex2f(rect->xmin, rect->ymin + zoomy * (cmp[0].y - offsy));
+ gpuVertex2f(rect->xmin, rect->ymin + zoomy * (cmp[0].y - offsy));
}
else {
fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
- glVertex2f(fx, fy);
+ gpuVertex2f(fx, fy);
}
for (a = 0; a <= CM_TABLE; a++) {
fx = rect->xmin + zoomx * (cmp[a].x - offsx);
fy = rect->ymin + zoomy * (cmp[a].y - offsy);
- glVertex2f(fx, fy);
+ gpuVertex2f(fx, fy);
}
/* last point */
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
- glVertex2f(rect->xmax, rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy));
+ gpuVertex2f(rect->xmax, rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy));
}
else {
fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);
- glVertex2f(fx, fy);
+ gpuVertex2f(fx, fy);
}
- glEnd();
+ gpuEnd();
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
/* the points, use aspect to make them visible on edges */
cmp = cuma->curve;
glPointSize(3.0f);
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
for (a = 0; a < cuma->totpoint; a++) {
if (cmp[a].flag & CUMA_SELECT)
UI_ThemeColor(TH_TEXT_HI);
@@ -1538,17 +1598,17 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
UI_ThemeColor(TH_TEXT);
fac[0] = rect->xmin + zoomx * (cmp[a].x - offsx);
fac[1] = rect->ymin + zoomy * (cmp[a].y - offsy);
- bglVertex2fv(fac);
+ gpuSprite2fv(fac);
}
- bglEnd();
+ gpuEndSprites();
glPointSize(1.0f);
/* restore scissortest */
- glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+ gpuScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
/* outline */
- glColor3ubv((unsigned char *)wcol->outline);
- fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+ gpuCurrentColor3ubv((unsigned char *)wcol->outline);
+ gpuSingleWireRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
@@ -1567,19 +1627,18 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
height = BLI_rctf_size_y(&rect);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* need scissor test, preview image can draw outside of boundary */
- glGetIntegerv(GL_VIEWPORT, scissor);
- glScissor(ar->winrct.xmin + (rect.xmin - 1),
+ gpuGetSizeBox(GL_VIEWPORT, scissor);
+ gpuScissor(ar->winrct.xmin + (rect.xmin - 1),
ar->winrct.ymin + (rect.ymin - 1),
(rect.xmax + 1) - (rect.xmin - 1),
(rect.ymax + 1) - (rect.ymin - 1));
if (scopes->track_disabled) {
- glColor4f(0.7f, 0.3f, 0.3f, 0.3f);
+ gpuCurrentColor4f(0.7f, 0.3f, 0.3f, 0.3f);
uiSetRoundBox(15);
- uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
ok = 1;
}
@@ -1613,29 +1672,29 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
int a;
ImBuf *drawibuf;
- glPushMatrix();
+ gpuPushMatrix();
track_pos[0] = scopes->track_pos[0];
track_pos[1] = scopes->track_pos[1];
/* draw content of pattern area */
- glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin + rect.ymin, scissor[2], scissor[3]);
+ gpuScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin + rect.ymin, scissor[2], scissor[3]);
if (width > 0 && height > 0) {
drawibuf = scopes->track_preview;
if (scopes->use_track_mask) {
- glColor4f(0.0f, 0.0f, 0.0f, 0.3f);
+ gpuCurrentColor4x(CPACK_BLACK, 0.300f);
uiSetRoundBox(15);
- uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
}
glaDrawPixelsSafe(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y,
drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
/* draw cross for pizel position */
- glTranslatef(rect.xmin + track_pos[0], rect.ymin + track_pos[1], 0.f);
- glScissor(ar->winrct.xmin + rect.xmin,
+ gpuTranslate(rect.xmin + track_pos[0], rect.ymin + track_pos[1], 0.f);
+ gpuScissor(ar->winrct.xmin + rect.xmin,
ar->winrct.ymin + rect.ymin,
BLI_rctf_size_x(&rect),
BLI_rctf_size_y(&rect));
@@ -1650,25 +1709,25 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
UI_ThemeColor(TH_MARKER_OUTLINE);
}
- glBegin(GL_LINES);
- glVertex2f(-10.0f, 0.0f);
- glVertex2f(10.0f, 0.0f);
- glVertex2f(0.0f, -10.0f);
- glVertex2f(0.0f, 10.0f);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(-10.0f, 0.0f);
+ gpuVertex2f(10.0f, 0.0f);
+ gpuVertex2f(0.0f, -10.0f);
+ gpuVertex2f(0.0f, 10.0f);
+ gpuEnd();
}
}
glDisable(GL_LINE_STIPPLE);
- glPopMatrix();
+ gpuPopMatrix();
ok = 1;
}
if (!ok) {
- glColor4f(0.f, 0.f, 0.f, 0.3f);
+ gpuCurrentColor4x(CPACK_BLACK, 0.300f);
uiSetRoundBox(15);
- uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
}
/* outline, scale gripper */
@@ -1686,34 +1745,43 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s
glShadeModel(GL_SMOOTH);
/* right quad */
- glBegin(GL_POLYGON);
- glColor4ub(0, 0, 0, alpha);
- glVertex2f(maxx, miny);
- glVertex2f(maxx, maxy - 0.3f * shadsize);
- glColor4ub(0, 0, 0, 0);
- glVertex2f(maxx + shadsize, maxy - 0.75f * shadsize);
- glVertex2f(maxx + shadsize, miny);
- glEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
+
+ gpuColor4x(CPACK_BLACK, alpha);
+ gpuVertex2f(maxx, miny);
+ gpuVertex2f(maxx, maxy - 0.3f * shadsize);
+
+ gpuColor4x(CPACK_BLACK, 0.000f);
+ gpuVertex2f(maxx + shadsize, maxy - 0.75f * shadsize);
+ gpuVertex2f(maxx + shadsize, miny);
+
+ gpuEnd();
/* corner shape */
- glBegin(GL_POLYGON);
- glColor4ub(0, 0, 0, alpha);
- glVertex2f(maxx, miny);
- glColor4ub(0, 0, 0, 0);
- glVertex2f(maxx + shadsize, miny);
- glVertex2f(maxx + 0.7f * shadsize, miny - 0.7f * shadsize);
- glVertex2f(maxx, miny - shadsize);
- glEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
+
+ gpuColor4x(CPACK_BLACK, alpha);
+ gpuVertex2f(maxx, miny);
+
+ gpuColor4x(CPACK_BLACK, 0.000f);
+ gpuVertex2f(maxx + shadsize, miny);
+ gpuVertex2f(maxx + 0.7f * shadsize, miny - 0.7f * shadsize);
+ gpuVertex2f(maxx, miny - shadsize);
+
+ gpuEnd();
/* bottom quad */
- glBegin(GL_POLYGON);
- glColor4ub(0, 0, 0, alpha);
- glVertex2f(minx + 0.3f * shadsize, miny);
- glVertex2f(maxx, miny);
- glColor4ub(0, 0, 0, 0);
- glVertex2f(maxx, miny - shadsize);
- glVertex2f(minx + 0.5f * shadsize, miny - shadsize);
- glEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
+
+ gpuColor4x(CPACK_BLACK, alpha);
+ gpuVertex2f(minx + 0.3f * shadsize, miny);
+ gpuVertex2f(maxx, miny);
+
+ gpuColor4x(CPACK_BLACK, 0.000f);
+ gpuVertex2f(maxx, miny - shadsize);
+ gpuVertex2f(minx + 0.5f * shadsize, miny - shadsize);
+
+ gpuEnd();
glDisable(GL_BLEND);
glShadeModel(GL_FLAT);
@@ -1757,18 +1825,18 @@ void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int
calpha = dalpha;
for (; i--; a -= aspect) {
/* alpha ranges from 2 to 20 or so */
- glColor4f(0.0f, 0.0f, 0.0f, calpha);
+ gpuCurrentColor4x(CPACK_BLACK, calpha);
calpha += dalpha;
-
- uiDrawBox(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + a, rad + a);
+
+ uiDrawBox(GL_TRIANGLE_FAN, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + a, rad + a);
}
-
+
/* outline emphasis */
glEnable(GL_LINE_SMOOTH);
- glColor4ub(0, 0, 0, 100);
+ gpuCurrentColor4x(CPACK_BLACK, 0.392f);
uiDrawBox(GL_LINE_LOOP, rct->xmin - 0.5f, rct->ymin - 0.5f, rct->xmax + 0.5f, rct->ymax + 0.5f, radius + 0.5f);
glDisable(GL_LINE_SMOOTH);
-
+
glDisable(GL_BLEND);
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index bb0cc1176d8..a0aadedf7a5 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -63,7 +63,9 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_compatibility.h"
+
#include "BIF_glutil.h"
#include "ED_datafiles.h"
@@ -206,22 +208,22 @@ static void viconutil_set_point(GLint pt[2], int x, int y)
static void viconutil_draw_tri(GLint(*pts)[2])
{
- glBegin(GL_TRIANGLES);
- glVertex2iv(pts[0]);
- glVertex2iv(pts[1]);
- glVertex2iv(pts[2]);
- glEnd();
+ gpuBegin(GL_TRIANGLES);
+ gpuVertex2iv(pts[0]);
+ gpuVertex2iv(pts[1]);
+ gpuVertex2iv(pts[2]);
+ gpuEnd();
}
static void viconutil_draw_lineloop(GLint(*pts)[2], int numPoints)
{
int i;
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
for (i = 0; i < numPoints; i++) {
- glVertex2iv(pts[i]);
+ gpuVertex2iv(pts[i]);
}
- glEnd();
+ gpuEnd();
}
static void viconutil_draw_lineloop_smooth(GLint(*pts)[2], int numPoints)
@@ -235,16 +237,16 @@ static void viconutil_draw_points(GLint(*pts)[2], int numPoints, int pointSize)
{
int i;
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
for (i = 0; i < numPoints; i++) {
int x = pts[i][0], y = pts[i][1];
- glVertex2i(x - pointSize, y - pointSize);
- glVertex2i(x + pointSize, y - pointSize);
- glVertex2i(x + pointSize, y + pointSize);
- glVertex2i(x - pointSize, y + pointSize);
+ gpuVertex2i(x - pointSize, y - pointSize);
+ gpuVertex2i(x + pointSize, y - pointSize);
+ gpuVertex2i(x + pointSize, y + pointSize);
+ gpuVertex2i(x - pointSize, y + pointSize);
}
- glEnd();
+ gpuEnd();
}
/* Drawing functions */
@@ -259,14 +261,15 @@ static void vicon_x_draw(int x, int y, int w, int h, float alpha)
glEnable(GL_LINE_SMOOTH);
glLineWidth(2.5);
-
- glColor4f(0.0, 0.0, 0.0, alpha);
- glBegin(GL_LINES);
- glVertex2i(x, y);
- glVertex2i(x + w, y + h);
- glVertex2i(x + w, y);
- glVertex2i(x, y + h);
- glEnd();
+
+ gpuCurrentColor4x(CPACK_BLACK, alpha);
+
+ gpuBegin(GL_LINES);
+ gpuVertex2i(x, y);
+ gpuVertex2i(x + w, y + h);
+ gpuVertex2i(x + w, y);
+ gpuVertex2i(x, y + h);
+ gpuEnd();
glLineWidth(1.0);
@@ -279,26 +282,32 @@ static void vicon_view3d_draw(int x, int y, int w, int h, float alpha)
int cy = y + h / 2;
int d = MAX2(2, h / 3);
- glColor4f(0.5, 0.5, 0.5, alpha);
- glBegin(GL_LINES);
- glVertex2i(x, cy - d);
- glVertex2i(x + w, cy - d);
- glVertex2i(x, cy + d);
- glVertex2i(x + w, cy + d);
-
- glVertex2i(cx - d, y);
- glVertex2i(cx - d, y + h);
- glVertex2i(cx + d, y);
- glVertex2i(cx + d, y + h);
- glEnd();
-
- glColor4f(0.0, 0.0, 0.0, alpha);
- glBegin(GL_LINES);
- glVertex2i(x, cy);
- glVertex2i(x + w, cy);
- glVertex2i(cx, y);
- glVertex2i(cx, y + h);
- glEnd();
+ gpuCurrentGray4f(0.500f, alpha);
+
+ gpuBegin(GL_LINES);
+
+ gpuVertex2i(x, cy - d);
+ gpuVertex2i(x + w, cy - d);
+ gpuVertex2i(x, cy + d);
+ gpuVertex2i(x + w, cy + d);
+
+ gpuVertex2i(cx - d, y);
+ gpuVertex2i(cx - d, y + h);
+ gpuVertex2i(cx + d, y);
+ gpuVertex2i(cx + d, y + h);
+
+ gpuEnd();
+
+ gpuCurrentColor4x(CPACK_BLACK, alpha);
+
+ gpuBegin(GL_LINES);
+
+ gpuVertex2i(x, cy);
+ gpuVertex2i(x + w, cy);
+ gpuVertex2i(cx, y);
+ gpuVertex2i(cx, y + h);
+
+ gpuEnd();
}
static void vicon_edit_draw(int x, int y, int w, int h, float alpha)
@@ -310,10 +319,10 @@ static void vicon_edit_draw(int x, int y, int w, int h, float alpha)
viconutil_set_point(pts[2], x + w - 3, y + h - 3);
viconutil_set_point(pts[3], x + 3, y + h - 3);
- glColor4f(0.0, 0.0, 0.0, alpha);
+ gpuCurrentColor4x(CPACK_BLACK, alpha);
viconutil_draw_lineloop(pts, 4);
- glColor3f(1, 1, 0.0);
+ gpuCurrentColor3x(CPACK_YELLOW);
viconutil_draw_points(pts, 4, 1);
}
@@ -325,13 +334,13 @@ static void vicon_editmode_hlt_draw(int x, int y, int w, int h, float alpha)
viconutil_set_point(pts[1], x + 3, y + 4);
viconutil_set_point(pts[2], x + w - 3, y + 4);
- glColor4f(0.5, 0.5, 0.5, alpha);
+ gpuCurrentGray4f(0.500f, alpha);
viconutil_draw_tri(pts);
- glColor4f(0.0, 0.0, 0.0, 1);
+ gpuCurrentColor4x(CPACK_BLACK, 1);
viconutil_draw_lineloop_smooth(pts, 3);
- glColor3f(1, 1, 0.0);
+ gpuCurrentColor3x(CPACK_YELLOW);
viconutil_draw_points(pts, 3, 1);
}
@@ -343,10 +352,10 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(a
viconutil_set_point(pts[1], x + 3, y + 4);
viconutil_set_point(pts[2], x + w - 3, y + 4);
- glColor4f(0.0f, 0.0f, 0.0f, 1);
+ gpuCurrentColor3x(CPACK_BLACK);
viconutil_draw_lineloop_smooth(pts, 3);
- glColor3f(0.9f, 0.9f, 0.9f);
+ gpuCurrentGray3f(0.900f);
viconutil_draw_points(pts, 3, 1);
}
@@ -362,16 +371,21 @@ static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h),
viconutil_set_point(pts[2], cx + d2, cy);
glShadeModel(GL_SMOOTH);
- glBegin(GL_TRIANGLES);
- glColor4f(0.8f, 0.8f, 0.8f, alpha);
- glVertex2iv(pts[0]);
- glVertex2iv(pts[1]);
- glColor4f(0.3f, 0.3f, 0.3f, alpha);
- glVertex2iv(pts[2]);
- glEnd();
+
+ gpuBegin(GL_TRIANGLES);
+
+ gpuGray4f(0.800f, alpha);
+ gpuVertex2iv(pts[0]);
+ gpuVertex2iv(pts[1]);
+
+ gpuGray4f(0.300f, alpha);
+ gpuVertex2iv(pts[2]);
+
+ gpuEnd();
+
glShadeModel(GL_FLAT);
- glColor4f(0.0f, 0.0f, 0.0f, 1);
+ gpuCurrentColor3x(CPACK_BLACK);
viconutil_draw_lineloop_smooth(pts, 3);
}
@@ -386,15 +400,15 @@ 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);
- glColor4f(0.2f, 0.2f, 0.2f, alpha);
+ gpuCurrentGray4f(0.200f, alpha);
- glShadeModel(GL_SMOOTH);
- glBegin(GL_TRIANGLES);
- glVertex2iv(pts[0]);
- glVertex2iv(pts[1]);
- glVertex2iv(pts[2]);
- glEnd();
- glShadeModel(GL_FLAT);
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_TRIANGLES);
+ gpuVertex2iv(pts[0]);
+ gpuVertex2iv(pts[1]);
+ gpuVertex2iv(pts[2]);
+ gpuEnd();
+ gpuImmediateUnformat();
}
static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), float alpha)
@@ -409,16 +423,21 @@ static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), f
viconutil_set_point(pts[2], cx, cy - d2);
glShadeModel(GL_SMOOTH);
- glBegin(GL_TRIANGLES);
- glColor4f(0.8f, 0.8f, 0.8f, alpha);
- glVertex2iv(pts[0]);
- glVertex2iv(pts[1]);
- glColor4f(0.3f, 0.3f, 0.3f, alpha);
- glVertex2iv(pts[2]);
- glEnd();
+
+ gpuBegin(GL_TRIANGLES);
+
+ gpuGray4f(0.800f, alpha);
+ gpuVertex2iv(pts[0]);
+ gpuVertex2iv(pts[1]);
+
+ gpuGray4f(0.300f, alpha);
+ gpuVertex2iv(pts[2]);
+
+ gpuEnd();
+
glShadeModel(GL_FLAT);
- glColor4f(0.0f, 0.0f, 0.0f, 1);
+ gpuCurrentColor3x(CPACK_BLACK);
viconutil_draw_lineloop_smooth(pts, 3);
}
@@ -428,13 +447,13 @@ static void vicon_move_up_draw(int x, int y, int w, int h, float UNUSED(alpha))
glEnable(GL_LINE_SMOOTH);
glLineWidth(1);
- glColor3f(0.0, 0.0, 0.0);
+ gpuCurrentColor3x(CPACK_BLACK);
- glBegin(GL_LINE_STRIP);
- glVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
- glVertex2i(x + w / 2, y + h / 2 - d + 1);
- glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
+ gpuVertex2i(x + w / 2, y + h / 2 - d + 1);
+ gpuVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
+ gpuEnd();
glLineWidth(1.0);
glDisable(GL_LINE_SMOOTH);
@@ -446,13 +465,13 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha)
glEnable(GL_LINE_SMOOTH);
glLineWidth(1);
- glColor3f(0.0, 0.0, 0.0);
+ gpuCurrentColor3x(CPACK_BLACK);
- glBegin(GL_LINE_STRIP);
- glVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
- glVertex2i(x + w / 2, y + h / 2 - d - 1);
- glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
+ gpuVertex2i(x + w / 2, y + h / 2 - d - 1);
+ gpuVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
+ gpuEnd();
glLineWidth(1.0);
glDisable(GL_LINE_SMOOTH);
@@ -508,7 +527,7 @@ static void init_brush_icons(void)
#undef INIT_BRUSH_ICON
}
-
+#include REAL_GL_MODE
static void init_internal_icons(void)
{
bTheme *btheme = UI_GetTheme();
@@ -595,8 +614,11 @@ static void init_internal_icons(void)
IMB_freeImBuf(bbuf);
}
+#include FAKE_GL_MODE
+
#endif /* WITH_HEADLESS */
+
static void init_iconfile_list(struct ListBase *list)
{
IconFile *ifile;
@@ -919,32 +941,41 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy
{
float x1, x2, y1, y2;
- if (rgb) glColor4f(rgb[0], rgb[1], rgb[2], alpha);
- else glColor4f(1.0f, 1.0f, 1.0f, alpha);
+ if (rgb) {
+ gpuCurrentColor4f(rgb[0], rgb[1], rgb[2], alpha);
+ }
+ else {
+ gpuCurrentColor4x(CPACK_WHITE, alpha);
+ }
x1 = ix * icongltex.invw;
x2 = (ix + ih) * icongltex.invw;
y1 = iy * icongltex.invh;
y2 = (iy + ih) * icongltex.invh;
-
+#include REAL_GL_MODE
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, icongltex.id);
- glBegin(GL_QUADS);
- glTexCoord2f(x1, y1);
- glVertex2f(x, y);
+ gpuImmediateFormat_T2_V2(); // DOODLE: icon, single quad with texture
+ gpuBegin(GL_TRIANGLE_FAN);
+
+ gpuTexCoord2f(x1, y1);
+ gpuVertex2f(x, y);
+
+ gpuTexCoord2f(x2, y1);
+ gpuVertex2f(x + w, y);
- glTexCoord2f(x2, y1);
- glVertex2f(x + w, y);
+ gpuTexCoord2f(x2, y2);
+ gpuVertex2f(x + w, y + h);
- glTexCoord2f(x2, y2);
- glVertex2f(x + w, y + h);
+ gpuTexCoord2f(x1, y2);
+ gpuVertex2f(x, y + h);
- glTexCoord2f(x1, y2);
- glVertex2f(x, y + h);
- glEnd();
+ gpuEnd();
+ gpuImmediateUnformat();
glBindTexture(GL_TEXTURE_2D, 0);
+#include FAKE_GL_MODE
glDisable(GL_TEXTURE_2D);
}
@@ -1015,9 +1046,9 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
if (!pi->rect[size]) return; /* something has gone wrong! */
/* preview images use premul alpha ... */
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */
icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], 1.0f, NULL, is_preview);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
}
}
}
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index e7a5f993d32..f2c14d005af 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -54,7 +54,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "UI_interface.h"
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 2b170ea546b..3afdf3361d8 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -50,7 +50,9 @@
#include "BKE_context.h"
#include "BKE_screen.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "WM_api.h"
@@ -330,15 +332,15 @@ static void ui_offset_panel_block(uiBlock *block)
#if 0 /*UNUSED 2.5*/
static void uiPanelPush(uiBlock *block)
{
- glPushMatrix();
+ gpuPushMatrix();
if (block->panel)
- glTranslatef((float)block->panel->ofsx, (float)block->panel->ofsy, 0.0);
+ gpuTranslate((float)block->panel->ofsx, (float)block->panel->ofsy, 0.0);
}
static void uiPanelPop(uiBlock *UNUSED(block))
{
- glPopMatrix();
+ gpuPopMatrix();
}
#endif
@@ -371,18 +373,21 @@ static void ui_draw_tria_rect(const rctf *rect, char dir)
static void ui_draw_anti_x(float x1, float y1, float x2, float y2)
{
-
/* set antialias line */
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glLineWidth(2.0);
-
- fdrawline(x1, y1, x2, y2);
- fdrawline(x1, y2, x2, y1);
-
+
+ gpuImmediateFormat_V2(); // DOODLE: an X, two thick lines, mono
+ gpuBegin(GL_LINES);
+ gpuAppendLinef(x1, y1, x2, y2);
+ gpuAppendLinef(x1, y2, x2, y1);
+ gpuEnd();
+ gpuImmediateUnformat();
+
glLineWidth(1.0);
-
+
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
@@ -412,13 +417,21 @@ static void ui_draw_panel_scalewidget(rcti *rect)
dy = 0.5f * (ymax - ymin);
glEnable(GL_BLEND);
- glColor4ub(255, 255, 255, 50);
- fdrawline(xmin, ymin, xmax, ymax);
- fdrawline(xmin + dx, ymin, xmax, ymax - dy);
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: scale widget, fixed number of colored lines
+ gpuBegin(GL_LINES);
+
+ gpuColor4x(CPACK_WHITE, 0.196f);
+ gpuAppendLinef(xmin, ymin, xmax, ymax);
+ gpuAppendLinef(xmin + dx, ymin, xmax, ymax - dy);
- glColor4ub(0, 0, 0, 50);
- fdrawline(xmin, ymin + 1, xmax, ymax + 1);
- fdrawline(xmin + dx, ymin + 1, xmax, ymax - dy + 1);
+ gpuColor4x(CPACK_BLACK, 0.196f);
+ gpuAppendLinef(xmin, ymin + 1, xmax, ymax + 1);
+ gpuAppendLinef(xmin + dx, ymin + 1, xmax, ymax - dy + 1);
+
+ gpuEnd();
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
}
@@ -436,15 +449,23 @@ static void ui_draw_panel_dragwidget(const rctf *rect)
dy = 0.333f * (ymax - ymin);
glEnable(GL_BLEND);
- glColor4ub(255, 255, 255, 50);
- fdrawline(xmin, ymax, xmax, ymin);
- fdrawline(xmin + dx, ymax, xmax, ymin + dy);
- fdrawline(xmin + 2 * dx, ymax, xmax, ymin + 2 * dy);
-
- glColor4ub(0, 0, 0, 50);
- fdrawline(xmin, ymax + 1, xmax, ymin + 1);
- fdrawline(xmin + dx, ymax + 1, xmax, ymin + dy + 1);
- fdrawline(xmin + 2 * dx, ymax + 1, xmax, ymin + 2 * dy + 1);
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: draw widge, 6 mono lines
+ gpuBegin(GL_LINES);
+
+ gpuColor4x(CPACK_WHITE, 0.196f);
+ gpuAppendLinef(xmin, ymax, xmax, ymin);
+ gpuAppendLinef(xmin + dx, ymax, xmax, ymin + dy);
+ gpuAppendLinef(xmin + 2 * dx, ymax, xmax, ymin + 2 * dy);
+
+ gpuColor4x(CPACK_BLACK, 0.196f);
+ gpuAppendLinef(xmin, ymax + 1, xmax, ymin + 1);
+ gpuAppendLinef(xmin + dx, ymax + 1, xmax, ymin + dy + 1);
+ gpuAppendLinef(xmin + 2 * dx, ymax + 1, xmax, ymin + 2 * dy + 1);
+
+ gpuEnd();
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
}
@@ -519,32 +540,44 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
if (btheme->tui.panel.show_header) {
/* draw with background color */
- glEnable(GL_BLEND);
- glColor4ubv((unsigned char *)btheme->tui.panel.header);
- glRectf(minx, headrect.ymin + 1, maxx, y);
+ gpuCurrentColor4ubv((unsigned char *)btheme->tui.panel.header);
+ gpuSingleFilledRectf(minx, headrect.ymin + 1, maxx, y);
+
+ gpuImmediateFormat_V2(); // DOODLE: 2 lines, mono
+ gpuBegin(GL_LINES);
- fdrawline(minx, y, maxx, y);
- fdrawline(minx, y, maxx, y);
+ gpuAppendLinef(minx, y, maxx, y);
+
+ gpuAppendLinef(minx, y, maxx, y);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
else if (!(panel->runtime_flag & PNL_FIRST)) {
/* draw embossed separator */
minx += 5.0f / block->aspect;
maxx -= 5.0f / block->aspect;
-
- glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
- fdrawline(minx, y, maxx, y);
- glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
- fdrawline(minx, y - 1, maxx, y - 1);
- glDisable(GL_BLEND);
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: 2 lines, colored
+ gpuBegin(GL_LINES);
+
+ gpuColor4x(CPACK_BLACK, 0.500f);
+ gpuAppendLinef(minx, y, maxx, y);
+
+ gpuColor4x(CPACK_WHITE, 0.250f);
+ gpuAppendLinef(minx, y - 1, maxx, y - 1);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
glDisable(GL_BLEND);
}
-
+
/* horizontal title */
if (!(panel->flag & PNL_CLOSEDX)) {
ui_draw_aligned_panel_header(style, block, &headrect, 'h');
-
+
/* itemrect smaller */
itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index c1547593f96..4712e03d454 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -56,7 +56,9 @@
#include "RNA_access.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
+#include "GPU_utility.h"
+
#include "UI_interface.h"
#include "UI_interface_icons.h"
@@ -397,10 +399,12 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
bbox.ymin = bbox.ymax - data->lineh;
for (i = 0; i < data->totline; i++) {
- glColor3fv(tip_colors[data->color_id[i]]);
+ GPU_STRING_MARKER("tooltip text start");
+ gpuCurrentColor3fv(tip_colors[data->color_id[i]]);
uiStyleFontDraw(&data->fstyle, &bbox, data->lines[i]);
bbox.ymin -= data->lineh + data->spaceh;
bbox.ymax -= data->lineh + data->spaceh;
+ GPU_STRING_MARKER("tooltip text end");
}
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 527f383c837..c43fc4bc4e4 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -49,7 +49,9 @@
#include "RNA_access.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "BLF_api.h"
@@ -195,43 +197,40 @@ GLubyte checker_stipple_sml[32 * 32 / 8] =
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3)
{
- float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}};
- float color[4];
int j;
-
+
glEnable(GL_BLEND);
- glGetFloatv(GL_CURRENT_COLOR, color);
- color[3] *= 0.125f;
- glColor4fv(color);
+ gpuMultCurrentAlpha(0.125f);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, tri_arr);
+ gpuImmediateFormat_V2();
+ gpuBegin(GL_TRIANGLES);
/* for each AA step */
for (j = 0; j < WIDGET_AA_JITTER; j++) {
- glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
- glDrawArrays(GL_TRIANGLES, 0, 3);
- glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
+ const GLfloat dx = jit[j][0];
+ const GLfloat dy = jit[j][1];
+ gpuVertex2f(x1 + dx, y1 + dy);
+ gpuVertex2f(x2 + dx, y2 + dy);
+ gpuVertex2f(x3 + dx, y3 + dy);
}
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuEnd();
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
}
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad)
{
- float color[4];
int j;
-
+
glEnable(GL_BLEND);
- glGetFloatv(GL_CURRENT_COLOR, color);
- color[3] *= 0.125f;
- glColor4fv(color);
-
+ gpuMultCurrentAlpha(0.125f);
+
for (j = 0; j < WIDGET_AA_JITTER; j++) {
- glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
+ gpuTranslate(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
uiDrawBox(mode, minx, miny, maxx, maxy, rad);
- glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
+ gpuTranslate(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
}
glDisable(GL_BLEND);
@@ -556,12 +555,30 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize
tria->index = scroll_circle_face;
}
-static void widget_trias_draw(uiWidgetTrias *tria)
+static void widget_trias_append(uiWidgetTrias *tria)
{
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, tria->vec);
- glDrawElements(GL_TRIANGLES, tria->tot * 3, GL_UNSIGNED_INT, tria->index);
- glDisableClientState(GL_VERTEX_ARRAY);
+ int i, j;
+
+ if (tria->tot > 0) {
+ for (j = 0; j < WIDGET_AA_JITTER; j++) {
+ const float dx = jit[j][0];
+ const float dy = jit[j][1];
+
+ for (i = 0; i < tria->tot; i++) {
+ float *v;
+ unsigned *index = tria->index[i];
+
+ v = tria->vec[index[0]];
+ gpuVertex2f(v[0]+dx, v[1]+dy);
+
+ v = tria->vec[index[1]];
+ gpuVertex2f(v[0]+dx, v[1]+dy);
+
+ v = tria->vec[index[2]];
+ gpuVertex2f(v[0]+dx, v[1]+dy);
+ }
+ }
+ }
}
static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect)
@@ -661,106 +678,93 @@ static void widgetbase_outline(uiWidgetBase *wtb)
float quad_strip[WIDGET_SIZE_MAX * 2 + 2][2]; /* + 2 because the last pair is wrapped */
widget_verts_to_quad_strip(wtb, wtb->totvert, quad_strip);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, quad_strip);
- glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert * 2 + 2);
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuSingleClientArrays_V2F(GL_TRIANGLE_STRIP, quad_strip, 0, 0, 2*(wtb->totvert) + 2);
}
static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
{
int j, a;
-
+
glEnable(GL_BLEND);
+ // DOODLE: widgetbase_draw
+
/* backdrop non AA */
if (wtb->inner) {
if (wcol->shaded == 0) {
+ GPUarrays arrays = GPU_ARRAYS_V2F;
+
+ gpuImmediateFormat_V2();
+
if (wcol->alpha_check) {
float inner_v_half[WIDGET_SIZE_MAX][2];
- float x_mid = 0.0f; /* used for dumb clamping of values */
+ float x_mid = 0; /* used for dumb clamping of values */
/* dark checkers */
- glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
- glDrawArrays(GL_POLYGON, 0, wtb->totvert);
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuCurrentColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
+ arrays.vertexPointer = wtb->inner_v;
+ gpuDrawClientArrays(GL_TRIANGLE_FAN, &arrays, 0, wtb->totvert);
/* light checkers */
glEnable(GL_POLYGON_STIPPLE);
- glColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
+ gpuCurrentColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
glPolygonStipple(checker_stipple_sml);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
- glDrawArrays(GL_POLYGON, 0, wtb->totvert);
- glDisableClientState(GL_VERTEX_ARRAY);
-
+ gpuRepeat();
glDisable(GL_POLYGON_STIPPLE);
- /* alpha fill */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glColor4ubv((unsigned char *)wcol->inner);
- glEnableClientState(GL_VERTEX_ARRAY);
+ gpuCurrentColor4ubv((unsigned char *)wcol->inner);
+ gpuRepeat();
for (a = 0; a < wtb->totvert; a++) {
x_mid += wtb->inner_v[a][0];
}
- x_mid /= wtb->totvert;
-
- glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
- glDrawArrays(GL_POLYGON, 0, wtb->totvert);
- glDisableClientState(GL_VERTEX_ARRAY);
- /* 1/2 solid color */
- glColor4ub(wcol->inner[0], wcol->inner[1], wcol->inner[2], 255);
+ x_mid /= wtb->totvert;
for (a = 0; a < wtb->totvert; a++) {
inner_v_half[a][0] = MIN2(wtb->inner_v[a][0], x_mid);
inner_v_half[a][1] = wtb->inner_v[a][1];
}
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, inner_v_half);
- glDrawArrays(GL_POLYGON, 0, wtb->totvert);
- glDisableClientState(GL_VERTEX_ARRAY);
+ /* 1/2 solid color */
+ gpuCurrentColor4ub(wcol->inner[0], wcol->inner[1], wcol->inner[2], 255);
+ arrays.vertexPointer = inner_v_half;
+ gpuDrawClientArrays(GL_TRIANGLE_FAN, &arrays, 0, wtb->totvert);
}
else {
/* simple fill */
- glColor4ubv((unsigned char *)wcol->inner);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
- glDrawArrays(GL_POLYGON, 0, wtb->totvert);
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuCurrentColor4ubv((unsigned char *)wcol->inner);
+ arrays.vertexPointer = wtb->inner_v;
+ gpuDrawClientArrays(GL_TRIANGLE_FAN, &arrays, 0, wtb->totvert);
}
+
+ gpuImmediateUnformat();
}
else {
char col1[4], col2[4];
unsigned char col_array[WIDGET_SIZE_MAX * 4];
unsigned char *col_pt = col_array;
-
+
shadecolors4(col1, col2, wcol->inner, wcol->shadetop, wcol->shadedown);
-
+
glShadeModel(GL_SMOOTH);
for (a = 0; a < wtb->totvert; a++, col_pt += 4) {
round_box_shade_col4_r(col_pt, col1, col2, wtb->inner_uv[a][wtb->shadedir]);
}
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
- glColorPointer(4, GL_UNSIGNED_BYTE, 0, col_array);
- glDrawArrays(GL_POLYGON, 0, wtb->totvert);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
+ gpuSingleClientArrays_C4UB_V2F(
+ GL_TRIANGLE_FAN,
+ col_array,
+ 0,
+ wtb->inner_v,
+ 0,
+ 0,
+ wtb->totvert);
glShadeModel(GL_FLAT);
}
}
-
+
/* for each AA step */
if (wtb->outline) {
float quad_strip[WIDGET_SIZE_MAX * 2 + 2][2]; /* + 2 because the last pair is wrapped */
@@ -777,56 +781,83 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
widget_verts_to_quad_strip_open(wtb, wtb->halfwayvert, quad_strip_emboss);
}
- glEnableClientState(GL_VERTEX_ARRAY);
+ gpuImmediateFormat_C4_V2();
+ gpuBegin(GL_QUADS);
for (j = 0; j < WIDGET_AA_JITTER; j++) {
- glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
-
+ float dx = jit[j][0];
+ float dy = jit[j][1];
+ int i;
+
/* outline */
- glColor4ubv(tcol);
+ gpuColor4ubv(tcol);
+ for (i = 0; i < 2*wtb->totvert; i += 2) {
+ gpuVertex2f(
+ quad_strip[i+0][0] + dx,
+ quad_strip[i+0][1] + dy);
+
+ gpuVertex2f(
+ quad_strip[i+1][0] + dx,
+ quad_strip[i+1][1] + dy);
+
+ gpuVertex2f(
+ quad_strip[i+3][0] + dx,
+ quad_strip[i+3][1] + dy);
+
+ gpuVertex2f(
+ quad_strip[i+2][0] + dx,
+ quad_strip[i+2][1] + dy);
+ }
- glVertexPointer(2, GL_FLOAT, 0, quad_strip);
- glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert * 2 + 2);
-
/* emboss bottom shadow */
- if (wtb->emboss) {
- glColor4f(1.0f, 1.0f, 1.0f, 0.02f);
-
- glVertexPointer(2, GL_FLOAT, 0, quad_strip_emboss);
- glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert * 2);
+ if (0 && wtb->emboss) {
+ gpuColor4x(CPACK_WHITE, 0.020f);
+ for (i = 0; i < 2*wtb->halfwayvert - 1; i += 2) {
+ gpuVertex2f(
+ quad_strip_emboss[i+0][0] + dx,
+ quad_strip_emboss[i+0][1] + dy);
+
+ gpuVertex2f(
+ quad_strip_emboss[i+1][0] + dx,
+ quad_strip_emboss[i+1][1] + dy);
+
+ gpuVertex2f(
+ quad_strip_emboss[i+3][0] + dx,
+ quad_strip_emboss[i+3][1] + dy);
+
+ gpuVertex2f(
+ quad_strip_emboss[i+2][0] + dx,
+ quad_strip_emboss[i+2][1] + dy);
+ }
}
-
- glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
}
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuEnd();
+ gpuImmediateUnformat();
}
-
+
/* decoration */
- if (wtb->tria1.tot || wtb->tria2.tot) {
- const unsigned char tcol[4] = {wcol->item[0],
- wcol->item[1],
- wcol->item[2],
- (unsigned char)((float)wcol->item[3] / WIDGET_AA_JITTER)};
- /* for each AA step */
- for (j = 0; j < WIDGET_AA_JITTER; j++) {
- glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
- if (wtb->tria1.tot) {
- glColor4ubv(tcol);
- widget_trias_draw(&wtb->tria1);
- }
- if (wtb->tria2.tot) {
- glColor4ubv(tcol);
- widget_trias_draw(&wtb->tria2);
- }
-
- glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
- }
+ gpuImmediateFormat_V2();
+
+ if (wtb->tria1.tot > 0 || wtb->tria2.tot > 0) {
+ unsigned char tcol[4];
+ tcol[0] = wcol->item[0];
+ tcol[1] = wcol->item[1];
+ tcol[2] = wcol->item[2];
+ tcol[3] = (unsigned char)((float)wcol->item[3] / WIDGET_AA_JITTER);
+
+ gpuCurrentColor4ubv(tcol);
+
+ gpuBegin(GL_TRIANGLES);
+ widget_trias_append(&wtb->tria1);
+ widget_trias_append(&wtb->tria2);
+ gpuEnd();
}
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
-
}
/* *********************** text/icon ************************************** */
@@ -1190,8 +1221,8 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
but->drawstr[selend_tmp] = ch;
- glColor3ubv((unsigned char *)wcol->item);
- glRects(rect->xmin + selsta_draw, rect->ymin + 2, rect->xmin + selwidth_draw, rect->ymax - 2);
+ gpuCurrentColor3ubv((unsigned char *)wcol->item);
+ gpuSingleFilledRecti(rect->xmin + selsta_draw, rect->ymin + 2, rect->xmin + selwidth_draw, rect->ymax - 2);
}
}
else {
@@ -1207,8 +1238,8 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
but->drawstr[pos] = ch;
}
- glColor3f(0.20, 0.6, 0.9);
- glRects(rect->xmin + t, rect->ymin + 2, rect->xmin + t + 2, rect->ymax - 2);
+ gpuCurrentColor3f(0.2f, 0.6f, 0.9f);
+ gpuSingleFilledRecti(rect->xmin + t, rect->ymin + 2, rect->xmin + t + 2, rect->ymax - 2);
}
}
}
@@ -1230,7 +1261,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
}
}
- glColor3ubv((unsigned char *)wcol->text);
+ gpuCurrentColor3ubv((unsigned char *)wcol->text);
uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs, &font_xofs, &font_yofs);
@@ -1825,23 +1856,28 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float
totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
/* inverse linear shadow alpha */
- alpha = 0.15;
- alphastep = 0.67;
-
- glEnableClientState(GL_VERTEX_ARRAY);
+ alpha = 0.15f;
+ alphastep = 0.67f;
+
+ gpuImmediateFormat_C4_V2();
+ gpuBegin(GL_TRIANGLE_STRIP);
for (step = 1; step <= radout; step++, alpha *= alphastep) {
- round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step);
-
- glColor4f(0.0f, 0.0f, 0.0f, alpha);
+ int i;
+ const int count = 2 * totvert;
+ round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step);
widget_verts_to_quad_strip_open(&wtb, totvert, quad_strip);
- glVertexPointer(2, GL_FLOAT, 0, quad_strip);
- glDrawArrays(GL_QUAD_STRIP, 0, totvert * 2);
+ gpuColor4x(CPACK_BLACK, alpha);
+
+ for (i = 0; i < count; i++) {
+ gpuVertex2fv(quad_strip[i]);
+ }
}
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuEnd();
+ gpuImmediateUnformat();
}
static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int direction)
@@ -1875,25 +1911,17 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
glDisable(GL_BLEND);
}
-
static void ui_hsv_cursor(float x, float y)
{
-
- glPushMatrix();
- glTranslatef(x, y, 0.0f);
-
- glColor3f(1.0f, 1.0f, 1.0f);
- glutil_draw_filled_arc(0.0f, M_PI * 2.0, 3.0f, 8);
-
+ gpuCurrentColor3x(CPACK_WHITE);
+ gpuDrawDisk(x, y, 3.0f, 12);
+
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
- glColor3f(0.0f, 0.0f, 0.0f);
- glutil_draw_lined_arc(0.0f, M_PI * 2.0, 3.0f, 12);
+ gpuCurrentColor3x(CPACK_BLACK);
+ gpuDrawCircle(x, y, 3.0f, 12);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
-
- glPopMatrix();
-
}
void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rcti *rect,
@@ -1926,10 +1954,12 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
float rgb[3], hsvo[3], hsv[3], col[3], colcent[3];
int a;
int color_profile = but->block->color_profile;
-
+
+ gpuImmediateFormat_C4_V3();
+
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
color_profile = FALSE;
-
+
/* color */
ui_get_but_vectorf(but, rgb);
@@ -1944,46 +1974,43 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
-
+
/* exception: if 'lock' is set
* lock the value of the color wheel to 1.
* Useful for color correction tools where you're only interested in hue. */
if (but->flag & UI_BUT_COLOR_LOCK)
hsv[2] = 1.f;
-
+
hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent + 1, colcent + 2);
-
+
glShadeModel(GL_SMOOTH);
- glBegin(GL_TRIANGLE_FAN);
- glColor3fv(colcent);
- glVertex2f(centx, centy);
-
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuColor3fv(colcent);
+ gpuVertex2f(centx, centy);
+
for (a = 0; a <= tot; a++, ang += radstep) {
float si = sin(ang);
float co = cos(ang);
-
+
ui_hsvcircle_vals_from_pos(hsv, hsv + 1, rect, centx + co * radius, centy + si * radius);
CLAMP(hsv[2], 0.0f, 1.0f); /* for display only */
hsv_to_rgb_v(hsv, col);
- glColor3fv(col);
- glVertex2f(centx + co * radius, centy + si * radius);
+ gpuColor3fv(col);
+ gpuVertex2f(centx + co * radius, centy + si * radius);
}
- glEnd();
-
+ gpuEnd();
+
glShadeModel(GL_FLAT);
-
+
/* fully rounded outline */
- glPushMatrix();
- glTranslatef(centx, centy, 0.0f);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
- glColor3ubv((unsigned char *)wcol->outline);
- glutil_draw_lined_arc(0.0f, M_PI * 2.0, radius, tot + 1);
- glDisable(GL_BLEND);
+ gpuCurrentColor3ubv((unsigned char *)wcol->outline);
+ gpuDrawCircle(centx, centy, radius, tot + 1);
glDisable(GL_LINE_SMOOTH);
- glPopMatrix();
+ glDisable(GL_BLEND);
/* cursor */
ang = 2.0f * (float)M_PI * hsvo[0] + 0.5f * (float)M_PI;
@@ -1995,6 +2022,8 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
radius = CLAMPIS(cursor_radius, 0.0f, 1.0f) * radius;
ui_hsv_cursor(centx + cosf(-ang) * radius, centy + sinf(-ang) * radius);
+
+ gpuImmediateUnformat();
}
/* ************ custom buttons, old stuff ************** */
@@ -2004,7 +2033,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa
{
const float color_step = (type == UI_GRAD_H) ? 0.02f : 0.05f;
int a;
- float h = hsv[0], s = hsv[1], v = hsv[2];
+ const float h = hsv[0], s = hsv[1], v = hsv[2];
float dx, dy, sx1, sx2, sy;
float col0[4][3]; /* left half, rect bottom to top */
float col1[4][3]; /* right half, rect bottom to top */
@@ -2116,21 +2145,21 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa
sy = rect->ymin;
dy = (float)BLI_rcti_size_y(rect) / 3.0f;
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
for (a = 0; a < 3; a++, sy += dy) {
- glColor4f(col0[a][0], col0[a][1], col0[a][2], alpha);
- glVertex2f(sx1, sy);
+ gpuColor4f(col0[a][0], col0[a][1], col0[a][2], alpha);
+ gpuVertex2f(sx1, sy);
- glColor4f(col1[a][0], col1[a][1], col1[a][2], alpha);
- glVertex2f(sx2, sy);
+ gpuColor4f(col1[a][0], col1[a][1], col1[a][2], alpha);
+ gpuVertex2f(sx2, sy);
- glColor4f(col1[a + 1][0], col1[a + 1][1], col1[a + 1][2], alpha);
- glVertex2f(sx2, sy + dy);
+ gpuColor4f(col1[a + 1][0], col1[a + 1][1], col1[a + 1][2], alpha);
+ gpuVertex2f(sx2, sy + dy);
- glColor4f(col0[a + 1][0], col0[a + 1][1], col0[a + 1][2], alpha);
- glVertex2f(sx1, sy + dy);
+ gpuColor4f(col0[a + 1][0], col0[a + 1][1], col0[a + 1][2], alpha);
+ gpuVertex2f(sx1, sy + dy);
}
- glEnd();
+ gpuEnd();
}
glShadeModel(GL_FLAT);
@@ -2145,14 +2174,16 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
float x = 0.0f, y = 0.0f;
float *hsv = ui_block_hsv_get(but->block);
float hsv_n[3];
-
+
+ gpuImmediateFormat_C4_V3();
+
copy_v3_v3(hsv_n, hsv);
-
+
ui_get_but_vectorf(but, rgb);
rgb_to_hsv_compat_v(rgb, hsv_n);
-
+
ui_draw_gradient(rect, hsv_n, but->a1, 1.0f);
-
+
switch ((int)but->a1) {
case UI_GRAD_SV:
x = hsv_n[2]; y = hsv_n[1]; break;
@@ -2167,18 +2198,20 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
case UI_GRAD_V:
x = hsv_n[2]; y = 0.5; break;
}
-
+
/* cursor */
x = rect->xmin + x * BLI_rcti_size_x(rect);
y = rect->ymin + y * BLI_rcti_size_y(rect);
CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
-
+
ui_hsv_cursor(x, y);
-
+
/* outline */
- glColor3ub(0, 0, 0);
- fdrawbox((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
+ gpuCurrentColor3x(CPACK_BLACK);
+ gpuDrawWireRectf((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
+
+ gpuImmediateUnformat();
}
/* vertical 'value' slider, using new widget code */
@@ -2189,7 +2222,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
float x, y;
float rgb[3], hsv[3], v, range;
int color_profile = but->block->color_profile;
-
+
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
color_profile = FALSE;
@@ -2204,12 +2237,12 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
/* map v from property range to [0,1] */
range = but->softmax - but->softmin;
v = (v - but->softmin) / range;
-
+
widget_init(&wtb);
-
+
/* fully rounded */
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
-
+
/* setup temp colors */
wcol_tmp.outline[0] = wcol_tmp.outline[1] = wcol_tmp.outline[2] = 0;
wcol_tmp.inner[0] = wcol_tmp.inner[1] = wcol_tmp.inner[2] = 128;
@@ -2223,9 +2256,10 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
x = rect->xmin + 0.5f * BLI_rcti_size_x(rect);
y = rect->ymin + v * BLI_rcti_size_y(rect);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
-
+
+ gpuImmediateFormat_C4_V3();
ui_hsv_cursor(x, y);
-
+ gpuImmediateUnformat();
}
@@ -2234,15 +2268,15 @@ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol)
{
int y = rect->ymin + BLI_rcti_size_y(rect) / 2 - 1;
unsigned char col[4];
-
+
col[0] = wcol->text[0];
col[1] = wcol->text[1];
col[2] = wcol->text[2];
col[3] = 7;
-
+
glEnable(GL_BLEND);
- glColor4ubv(col);
- sdrawline(rect->xmin, y, rect->xmax, y);
+ gpuCurrentColor4ubv(col);
+ gpuSingleLinei(rect->xmin, y, rect->xmax, y); // DOODLE: single line
glDisable(GL_BLEND);
}
@@ -2302,22 +2336,13 @@ int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol)
void ui_draw_link_bezier(rcti *rect)
{
float coord_array[LINK_RESOL + 1][2];
-
- if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) {
- /* we can reuse the dist variable here to increment the GL curve eval amount*/
- // const float dist = 1.0f / (float)LINK_RESOL; // UNUSED
+ if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) {
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, coord_array);
- glDrawArrays(GL_LINE_STRIP, 0, LINK_RESOL);
- glDisableClientState(GL_VERTEX_ARRAY);
-
- glDisable(GL_BLEND);
+ gpuSingleClientArrays_V2F(GL_LINE_STRIP, coord_array, 0, 0, LINK_RESOL);
glDisable(GL_LINE_SMOOTH);
-
+ glDisable(GL_BLEND);
}
}
@@ -2825,7 +2850,7 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
/* store the box bg as gl clearcolor, to retrieve later when drawing semi-transparent rects
* over the top to indicate disabled buttons */
/* XXX, this doesnt work right since the color applies to buttons outside the box too. */
- glClearColor(wcol->inner[0] / 255.0, wcol->inner[1] / 255.0, wcol->inner[2] / 255.0, 1.0);
+ gpuSetClearColor(wcol->inner[0] / 255.0, wcol->inner[1] / 255.0, wcol->inner[2] / 255.0, 1.0);
copy_v3_v3_char(wcol->inner, old_col);
}
@@ -2872,7 +2897,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
/* make mask to draw over image */
UI_GetThemeColor3ubv(TH_BACK, col);
- glColor3ubv(col);
+ gpuCurrentColor3ubv(col);
round_box__edges(&wtb, UI_CNR_ALL, rect, 0.0f, 4.0);
widgetbase_outline(&wtb);
@@ -2894,12 +2919,12 @@ static void widget_disabled(rcti *rect)
glEnable(GL_BLEND);
/* can't use theme TH_BACK or TH_PANEL... undefined */
- glGetFloatv(GL_COLOR_CLEAR_VALUE, col);
- glColor4f(col[0], col[1], col[2], 0.5f);
+ gpuGetClearColor(col);
+ gpuCurrentColor4f(col[0], col[1], col[2], 0.5f);
/* need -1 and +1 to make it work right for aligned buttons,
* but problem may be somewhere else? */
- glRectf(rect->xmin - 1, rect->ymin - 1, rect->xmax, rect->ymax + 1);
+ gpuSingleFilledRectf(rect->xmin - 1, rect->ymin - 1, rect->xmax, rect->ymax + 1);
glDisable(GL_BLEND);
}
@@ -3351,12 +3376,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
if (block) {
if (block->flag & UI_BLOCK_CLIPTOP) {
/* XXX no scaling for UI here yet */
- glColor3ubv((unsigned char *)wt->wcol.text);
+ gpuCurrentColor3ubv((unsigned char *)wt->wcol.text);
UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymax - 8, 't');
}
if (block->flag & UI_BLOCK_CLIPBOTTOM) {
/* XXX no scaling for UI here yet */
- glColor3ubv((unsigned char *)wt->wcol.text);
+ gpuCurrentColor3ubv((unsigned char *)wt->wcol.text);
UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v');
}
}
@@ -3418,7 +3443,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1) + 10;
}
- glColor3ubv((unsigned char *)wt->wcol.text);
+ gpuCurrentColor3ubv((unsigned char *)wt->wcol.text);
uiStyleFontDraw(fstyle, rect, name);
/* part text right aligned */
@@ -3473,15 +3498,15 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
bg_rect.xmax = rect->xmax - PREVIEW_PAD;
UI_GetThemeColor3ubv(TH_BUTBACK, bg_col);
- glColor4ubv((unsigned char *)wt->wcol.item);
+ gpuCurrentColor4ubv((unsigned char *)wt->wcol.item);
glEnable(GL_BLEND);
- glRecti(bg_rect.xmin, bg_rect.ymin, bg_rect.xmax, bg_rect.ymax);
+ gpuSingleFilledRecti(bg_rect.xmin, bg_rect.ymin, bg_rect.xmax, bg_rect.ymax);
glDisable(GL_BLEND);
if (state == UI_ACTIVE)
- glColor3ubv((unsigned char *)wt->wcol.text);
+ gpuCurrentColor3ubv((unsigned char *)wt->wcol.text);
else
- glColor3ubv((unsigned char *)wt->wcol.text_sel);
+ gpuCurrentColor3ubv((unsigned char *)wt->wcol.text_sel);
uiStyleFontDraw(fstyle, &trect, name);
}
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index fa5d5806bb8..a845ed27d0d 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -51,13 +51,14 @@
#include "BKE_texture.h"
-#include "BIF_gl.h"
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "interface_intern.h"
+#include "GPU_compatibility.h"
+
/* global for themes */
typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
@@ -968,8 +969,15 @@ void UI_ThemeColor(int colorid)
const unsigned char *cp;
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- glColor3ubv(cp);
+ gpuCurrentColor3ubv(cp);
+}
+void UI_ThemeAppendColor(int colorid)
+{
+ const unsigned char *cp;
+
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ gpuColor3ubv(cp);
}
/* plus alpha */
@@ -978,8 +986,7 @@ void UI_ThemeColor4(int colorid)
const unsigned char *cp;
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- glColor4ubv(cp);
-
+ gpuCurrentColor4ubv(cp);
}
/* set the color with offset for shades */
@@ -987,17 +994,41 @@ void UI_ThemeColorShade(int colorid, int offset)
{
int r, g, b;
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+
r = offset + (int) cp[0];
CLAMP(r, 0, 255);
+
g = offset + (int) cp[1];
CLAMP(g, 0, 255);
+
b = offset + (int) cp[2];
CLAMP(b, 0, 255);
- //glColor3ub(r, g, b);
- glColor4ub(r, g, b, cp[3]);
+
+ gpuCurrentColor4ub(r, g, b, cp[3]);
}
+
+// set the color with offset for shades
+void UI_ThemeAppendColorShade(int colorid, int offset)
+{
+ int r, g, b;
+ const unsigned char *cp;
+
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+
+ r = offset + (int) cp[0];
+ CLAMP(r, 0, 255);
+
+ g = offset + (int) cp[1];
+ CLAMP(g, 0, 255);
+
+ b = offset + (int) cp[2];
+ CLAMP(b, 0, 255);
+
+ gpuColor4ub(r, g, b, cp[3]);
+}
+
void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
{
int r, g, b, a;
@@ -1012,7 +1043,24 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
CLAMP(b, 0, 255);
a = alphaoffset + (int) cp[3];
CLAMP(a, 0, 255);
- glColor4ub(r, g, b, a);
+ gpuCurrentColor4ub(r, g, b, a);
+}
+
+void UI_ThemeAppendColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
+{
+ int r, g, b, a;
+ const unsigned char *cp;
+
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ r = coloffset + (int) cp[0];
+ CLAMP(r, 0, 255);
+ g = coloffset + (int) cp[1];
+ CLAMP(g, 0, 255);
+ b = coloffset + (int) cp[2];
+ CLAMP(b, 0, 255);
+ a = alphaoffset + (int) cp[3];
+ CLAMP(a, 0, 255);
+ gpuColor4ub(r, g, b, a);
}
/* blend between to theme colors, and set it */
@@ -1029,7 +1077,23 @@ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
g = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
b = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
- glColor3ub(r, g, b);
+ gpuCurrentColor3ub(r, g, b);
+}
+
+void UI_ThemeAppendColorBlend(int colorid1, int colorid2, float fac)
+{
+ int r, g, b;
+ const unsigned char *cp1, *cp2;
+
+ cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+ cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+
+ CLAMP(fac, 0.0f, 1.0f);
+ r = floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+ g = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+ b = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+
+ gpuColor3ub(r, g, b);
}
/* blend between to theme colors, shade it, and set it */
@@ -1037,7 +1101,7 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
{
int r, g, b;
const unsigned char *cp1, *cp2;
-
+
cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
@@ -1045,12 +1109,33 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
-
+
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
CLAMP(b, 0, 255);
-
- glColor3ub(r, g, b);
+
+ gpuCurrentColor3ub(r, g, b);
+}
+
+// blend between to theme colors, shade it, and set it
+void UI_ThemeAppendColorBlendShade(int colorid1, int colorid2, float fac, int offset)
+{
+ int r, g, b;
+ const unsigned char *cp1, *cp2;
+
+ cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+ cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+
+ CLAMP(fac, 0.0f, 1.0f);
+ r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+ g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+ b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+
+ CLAMP(r, 0, 255);
+ CLAMP(g, 0, 255);
+ CLAMP(b, 0, 255);
+
+ gpuColor3ub(r, g, b);
}
/* blend between to theme colors, shade it, and set it */
@@ -1073,7 +1158,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
CLAMP(b, 0, 255);
CLAMP(a, 0, 255);
- glColor4ub(r, g, b, a);
+ gpuCurrentColor4ub(r, g, b, a);
}
@@ -1204,7 +1289,7 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c
g = g < 0 ? 0 : (g > 255 ? 255 : g);
b = b < 0 ? 0 : (b > 255 ? 255 : b);
- glColor3ub(r, g, b);
+ gpuCurrentColor3ub(r, g, b);
}
void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], int offset)
@@ -1247,9 +1332,8 @@ void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned cha
void UI_ThemeClearColor(int colorid)
{
float col[3];
-
UI_GetThemeColor3fv(colorid, col);
- glClearColor(col[0], col[1], col[2], 0.0);
+ gpuSetClearColorvf(col, 0.0);
}
void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index f1a3f59bc22..b022d4121f4 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -48,7 +48,7 @@
#include "WM_api.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
#include "BLF_api.h"
@@ -1013,7 +1013,7 @@ void UI_view2d_view_ortho(View2D *v2d)
wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs);
/* XXX is this necessary? */
- glLoadIdentity();
+ gpuLoadIdentity();
}
/* Set view matrices to only use one axis of 'cur' only
@@ -1041,7 +1041,7 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis)
wmOrtho2(-xofs, ar->winx - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs);
/* XXX is this necessary? */
- glLoadIdentity();
+ gpuLoadIdentity();
}
@@ -1053,7 +1053,7 @@ void UI_view2d_view_restore(const bContext *C)
int height = BLI_rcti_size_y(&ar->winrct) + 1;
wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
- glLoadIdentity();
+ gpuLoadIdentity();
// ED_region_pixelspace(CTX_wm_region(C));
}
@@ -1199,42 +1199,43 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
{
float vec1[2], vec2[2];
int a, step;
-
+
/* check for grid first, as it may not exist */
- if (grid == NULL)
+ if (grid == NULL) {
return;
-
+ }
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: 2D grid, multiple colored lines
+ gpuBegin(GL_LINES);
+
/* vertical lines */
if (flag & V2D_VERTICAL_LINES) {
/* initialize initial settings */
vec1[0] = vec2[0] = grid->startx;
vec1[1] = grid->starty;
vec2[1] = v2d->cur.ymax;
-
+
/* minor gridlines */
step = (BLI_rcti_size_x(&v2d->mask) + 1) / U.v2d_min_gridsize;
- UI_ThemeColor(TH_GRID);
-
+
+ UI_ThemeAppendColor(TH_GRID);
+
for (a = 0; a < step; a++) {
- glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
- glEnd();
-
+ gpuVertex2fv(vec1);
+ gpuVertex2fv(vec2);
+
vec2[0] = vec1[0] += grid->dx;
}
-
+
/* major gridlines */
vec2[0] = vec1[0] -= 0.5f * grid->dx;
- UI_ThemeColorShade(TH_GRID, 16);
-
+ UI_ThemeAppendColorShade(TH_GRID, 16);
+
step++;
for (a = 0; a <= step; a++) {
- glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
- glEnd();
-
+ gpuVertex2fv(vec1);
+ gpuVertex2fv(vec2);
+
vec2[0] = vec1[0] -= grid->dx;
}
}
@@ -1245,16 +1246,14 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec1[1] = vec2[1] = grid->starty;
vec1[0] = grid->startx;
vec2[0] = v2d->cur.xmax;
-
+
step = (BLI_rcti_size_y(&v2d->mask) + 1) / U.v2d_min_gridsize;
-
- UI_ThemeColor(TH_GRID);
+
+ UI_ThemeAppendColor(TH_GRID);
for (a = 0; a <= step; a++) {
- glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
- glEnd();
-
+ gpuVertex2fv(vec1);
+ gpuVertex2fv(vec2);
+
vec2[1] = vec1[1] += grid->dy;
}
@@ -1263,44 +1262,41 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
step++;
if (flag & V2D_HORIZONTAL_FINELINES) {
- UI_ThemeColorShade(TH_GRID, 16);
+ UI_ThemeAppendColorShade(TH_GRID, 16);
for (a = 0; a < step; a++) {
- glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
- glEnd();
+ gpuVertex2fv(vec1);
+ gpuVertex2fv(vec2);
vec2[1] = vec1[1] -= grid->dy;
}
}
}
-
+
/* Axes are drawn as darker lines */
- UI_ThemeColorShade(TH_GRID, -50);
-
+ UI_ThemeAppendColorShade(TH_GRID, -50);
+
/* horizontal axis */
if (flag & V2D_HORIZONTAL_AXIS) {
vec1[0] = v2d->cur.xmin;
vec2[0] = v2d->cur.xmax;
vec1[1] = vec2[1] = 0.0f;
-
- glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
- glEnd();
+
+ gpuVertex2fv(vec1);
+ gpuVertex2fv(vec2);
}
-
+
/* vertical axis */
if (flag & V2D_VERTICAL_AXIS) {
vec1[1] = v2d->cur.ymin;
vec2[1] = v2d->cur.ymax;
vec1[0] = vec2[0] = 0.0f;
-
- glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
- glEnd();
+
+ gpuVertex2fv(vec1);
+ gpuVertex2fv(vec2);
}
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
/* Draw a constant grid in given 2d-region */
@@ -1308,30 +1304,33 @@ void UI_view2d_constant_grid_draw(View2D *v2d)
{
float start, step = 25.0f;
- UI_ThemeColorShade(TH_BACK, -10);
-
+ gpuImmediateFormat_C4_V2(); // DOODLE: 2D constant grid, multiple colored lines
+ gpuBegin(GL_LINES);
+
start = v2d->cur.xmin - (float)fmod(v2d->cur.xmin, step);
- glBegin(GL_LINES);
+ UI_ThemeAppendColorShade(TH_BACK, -10);
+
for (; start < v2d->cur.xmax; start += step) {
- glVertex2f(start, v2d->cur.ymin);
- glVertex2f(start, v2d->cur.ymax);
+ gpuVertex2f(start, v2d->cur.ymin);
+ gpuVertex2f(start, v2d->cur.ymax);
}
start = v2d->cur.ymin - (float)fmod(v2d->cur.ymin, step);
for (; start < v2d->cur.ymax; start += step) {
- glVertex2f(v2d->cur.xmin, start);
- glVertex2f(v2d->cur.xmax, start);
+ gpuVertex2f(v2d->cur.xmin, start);
+ gpuVertex2f(v2d->cur.xmax, start);
}
-
+
/* X and Y axis */
- UI_ThemeColorShade(TH_BACK, -18);
- glVertex2f(0.0f, v2d->cur.ymin);
- glVertex2f(0.0f, v2d->cur.ymax);
- glVertex2f(v2d->cur.xmin, 0.0f);
- glVertex2f(v2d->cur.xmax, 0.0f);
-
- glEnd();
+ UI_ThemeAppendColorShade(TH_BACK, -18);
+ gpuVertex2f(0.0f, v2d->cur.ymin);
+ gpuVertex2f(0.0f, v2d->cur.ymax);
+ gpuVertex2f(v2d->cur.xmin, 0.0f);
+ gpuVertex2f(v2d->cur.xmax, 0.0f);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
/* Draw a multi-level grid in given 2d-region */
@@ -1340,46 +1339,51 @@ void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totl
int offset = -10;
float lstep = step;
int level;
-
+
+ gpuImmediateFormat_V2();
+
for (level = 0; level < totlevels; ++level) {
int i;
float start;
-
+
UI_ThemeColorShade(TH_BACK, offset);
i = (v2d->cur.xmin >= 0.0f ? -(int)(-v2d->cur.xmin / lstep) : (int)(v2d->cur.xmin / lstep));
start = i * lstep;
-
- glBegin(GL_LINES);
+
+ gpuBegin(GL_LINES);
+
for (; start < v2d->cur.xmax; start += lstep, ++i) {
if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
continue;
- glVertex2f(start, v2d->cur.ymin);
- glVertex2f(start, v2d->cur.ymax);
+ gpuVertex2f(start, v2d->cur.ymin);
+ gpuVertex2f(start, v2d->cur.ymax);
}
-
+
i = (v2d->cur.ymin >= 0.0f ? -(int)(-v2d->cur.ymin / lstep) : (int)(v2d->cur.ymin / lstep));
start = i * lstep;
for (; start < v2d->cur.ymax; start += lstep, ++i) {
if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
continue;
- glVertex2f(v2d->cur.xmin, start);
- glVertex2f(v2d->cur.xmax, start);
+ gpuVertex2f(v2d->cur.xmin, start);
+ gpuVertex2f(v2d->cur.xmax, start);
}
-
+
/* X and Y axis */
- UI_ThemeColorShade(TH_BACK, offset - 8);
- glVertex2f(0.0f, v2d->cur.ymin);
- glVertex2f(0.0f, v2d->cur.ymax);
- glVertex2f(v2d->cur.xmin, 0.0f);
- glVertex2f(v2d->cur.xmax, 0.0f);
-
- glEnd();
-
+ UI_ThemeAppendColorShade(TH_BACK, offset - 8);
+ gpuVertex2f(0.0f, v2d->cur.ymin);
+ gpuVertex2f(0.0f, v2d->cur.ymax);
+ gpuVertex2f(v2d->cur.xmin, 0.0f);
+ gpuVertex2f(v2d->cur.xmax, 0.0f);
+
+ gpuEnd();
+
lstep *= level_size;
offset -= 6;
}
+
+ gpuImmediateUnformat();
}
/* the price we pay for not exposting structs :( */
@@ -1644,7 +1648,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
UI_ThemeColor(TH_BACK);
- glRecti(v2d->hor.xmin, v2d->hor.ymin, v2d->hor.xmax, v2d->hor.ymax);
+ gpuSingleFilledRecti(v2d->hor.xmin, v2d->hor.ymin, v2d->hor.xmax, v2d->hor.ymax);
uiWidgetScrollDraw(&wcol, &hor, &slider, state);
}
@@ -1755,7 +1759,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
UI_ThemeColor(TH_BACK);
- glRecti(v2d->vert.xmin, v2d->vert.ymin, v2d->vert.xmax, v2d->vert.ymax);
+ gpuSingleFilledRecti(v2d->vert.xmin, v2d->vert.ymin, v2d->vert.xmax, v2d->vert.ymax);
uiWidgetScrollDraw(&wcol, &vert, &slider, state);
}
@@ -2141,10 +2145,10 @@ void UI_view2d_text_cache_draw(ARegion *ar)
/* investigate using BLF_ascender() */
const float default_height = strings.first ? BLF_height_default("28") : 0.0f;
- // glMatrixMode(GL_PROJECTION);
- // glPushMatrix();
- // glMatrixMode(GL_MODELVIEW);
- // glPushMatrix();
+ // gpuMatrixMode(GL_PROJECTION);
+ // gpuPushMatrix();
+ // gpuMatrixMode(GL_MODELVIEW);
+ // gpuPushMatrix();
ED_region_pixelspace(ar);
for (v2s = strings.first; v2s; v2s = v2s->next) {
@@ -2155,7 +2159,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
if (yofs < 1) yofs = 1;
if (col_pack_prev != v2s->col.pack) {
- glColor3ubv(v2s->col.ub);
+ gpuCurrentColor3ubv(v2s->col.ub);
col_pack_prev = v2s->col.pack;
}
@@ -2169,10 +2173,10 @@ void UI_view2d_text_cache_draw(ARegion *ar)
}
}
- // glMatrixMode(GL_PROJECTION);
- // glPopMatrix();
- // glMatrixMode(GL_MODELVIEW);
- // glPopMatrix();
+ // gpuMatrixMode(GL_PROJECTION);
+ // gpuPopMatrix();
+ // gpuMatrixMode(GL_MODELVIEW);
+ // gpuPopMatrix();
if (strings.first)
BLI_freelistN(&strings);
diff --git a/source/blender/editors/mask/CMakeLists.txt b/source/blender/editors/mask/CMakeLists.txt
index 25fb9cb6430..dba6f5f0957 100644
--- a/source/blender/editors/mask/CMakeLists.txt
+++ b/source/blender/editors/mask/CMakeLists.txt
@@ -26,6 +26,7 @@ set(INC
../../blenkernel
../../blenloader
../../blenlib
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 74cdf4c2a11..0cb19ffbbd2 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -47,7 +47,9 @@
#include "ED_clip.h"
#include "ED_mask.h" /* own include */
#include "ED_space_api.h"
-#include "BIF_gl.h"
+
+#include "GPU_colors.h"
+#include "GPU_compatibility.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -98,26 +100,26 @@ static void draw_spline_parents(MaskLayer *UNUSED(masklay), MaskSpline *spline)
if (!spline->tot_point)
return;
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0xAAAA);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &points_array[i];
BezTriple *bezt = &point->bezt;
if (point->parent.id) {
- glVertex2f(bezt->vec[1][0],
+ gpuVertex2f(bezt->vec[1][0],
bezt->vec[1][1]);
- glVertex2f(bezt->vec[1][0] - point->parent.offset[0],
+ gpuVertex2f(bezt->vec[1][0] - point->parent.offset[0],
bezt->vec[1][1] - point->parent.offset[1]);
}
}
- glEnd();
+ gpuEnd();
glDisable(GL_LINE_STIPPLE);
}
@@ -157,7 +159,12 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
mask_spline_color_get(masklay, spline, is_spline_sel, rgb_spline);
/* feather points */
+
feather_points = fp = BKE_mask_spline_feather_points(spline, &tot_feather_point);
+
+ gpuImmediateFormat_C4_V2();
+ gpuBegin(GL_POINTS);
+
for (i = 0; i < spline->tot_point; i++) {
/* watch it! this is intentionally not the deform array, only check for sel */
@@ -183,21 +190,22 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
if (sel) {
if (point == masklay->act_point)
- glColor3f(1.0f, 1.0f, 1.0f);
+ gpuColor3x(CPACK_WHITE);
else
- glColor3f(1.0f, 1.0f, 0.0f);
+ gpuColor3x(CPACK_YELLOW);
}
else {
- glColor3f(0.5f, 0.5f, 0.0f);
+ gpuColor3f(0.5f, 0.5f, 0.0f);
}
- glBegin(GL_POINTS);
- glVertex2fv(feather_point);
- glEnd();
+ gpuVertex2fv(*fp);
fp++;
}
}
+
+ gpuEnd();
+
MEM_freeN(feather_points);
/* control points */
@@ -225,56 +233,58 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
/* this could be split into its own loop */
if (draw_type == MASK_DT_OUTLINE) {
- const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
glLineWidth(3);
- glColor4ubv(rgb_gray);
- glBegin(GL_LINES);
- glVertex2fv(vert);
- glVertex2fv(handle);
- glEnd();
+ gpuCurrentGray3f(0.376f);
+ gpuBegin(GL_LINES);
+ gpuVertex2fv(vert);
+ gpuVertex2fv(handle);
+ gpuEnd();
glLineWidth(1);
}
- glColor3ubv(rgb_spline);
- glBegin(GL_LINES);
- glVertex2fv(vert);
- glVertex2fv(handle);
- glEnd();
+ gpuCurrentColor3ubv(rgb_spline);
+ gpuBegin(GL_LINES);
+ gpuVertex2fv(vert);
+ gpuVertex2fv(handle);
+ gpuEnd();
}
+ gpuBegin(GL_POINTS);
+
/* draw CV point */
if (MASKPOINT_ISSEL_KNOT(point)) {
if (point == masklay->act_point)
- glColor3f(1.0f, 1.0f, 1.0f);
+ gpuColor3x(CPACK_WHITE);
else
- glColor3f(1.0f, 1.0f, 0.0f);
+ gpuColor3x(CPACK_YELLOW);
+ }
+ else {
+ gpuColor3f(0.5f, 0.5f, 0.0f);
}
- else
- glColor3f(0.5f, 0.5f, 0.0f);
- glBegin(GL_POINTS);
- glVertex2fv(vert);
- glEnd();
+ gpuVertex2fv(vert);
/* draw handle points */
if (has_handle) {
if (MASKPOINT_ISSEL_HANDLE(point)) {
if (point == masklay->act_point)
- glColor3f(1.0f, 1.0f, 1.0f);
+ gpuColor3x(CPACK_WHITE);
else
- glColor3f(1.0f, 1.0f, 0.0f);
+ gpuColor3x(CPACK_YELLOW);
}
else {
- glColor3f(0.5f, 0.5f, 0.0f);
+ gpuColor3f(0.5f, 0.5f, 0.0f);
}
- glBegin(GL_POINTS);
- glVertex2fv(handle);
- glEnd();
+ gpuVertex2fv(handle);
}
+
+ gpuEnd();
}
glPointSize(1.0f);
+
+ gpuImmediateUnformat();
}
/* #define USE_XOR */
@@ -300,6 +310,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
// const unsigned char rgb_white[4] = {0xff, 0xff, 0xff, 0xff};
unsigned char rgb_tmp[4];
+ GPUarrays arrays = GPU_ARRAYS_V3F;
SpaceClip *sc = CTX_wm_space_clip(C);
float (*points)[2] = orig_points;
@@ -317,8 +328,9 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
}
}
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, points);
+ arrays.vertexPointer = points;
+
+ gpuImmediateFormat_V3();
switch (draw_type) {
@@ -326,15 +338,13 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
glLineWidth(3);
mask_color_active_tint(rgb_tmp, rgb_black, is_active);
- glColor4ubv(rgb_tmp);
-
- glDrawArrays(draw_method, 0, tot_point);
+ gpuCurrentColor4ubv(rgb_tmp);
+ gpuDrawClientArrays(draw_method, &arrays, 0, tot_point);
glLineWidth(1);
mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
- glColor4ubv(rgb_tmp);
- glDrawArrays(draw_method, 0, tot_point);
-
+ gpuCurrentColor4ubv(rgb_tmp);
+ gpuRepeat();
break;
case MASK_DT_DASH:
@@ -346,19 +356,17 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
glLogicOp(GL_OR);
#endif
mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
- glColor4ubv(rgb_tmp);
+ gpuCurrentColor4ubv(rgb_tmp);
glLineStipple(3, 0xaaaa);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, points);
- glDrawArrays(draw_method, 0, tot_point);
+ gpuDrawClientArrays(draw_method, &arrays, 0, tot_point);
#ifdef USE_XOR
glDisable(GL_COLOR_LOGIC_OP);
#endif
mask_color_active_tint(rgb_tmp, rgb_black, is_active);
- glColor4ubv(rgb_tmp);
+ gpuCurrentColor4ubv(rgb_tmp);
glLineStipple(3, 0x5555);
- glDrawArrays(draw_method, 0, tot_point);
+ gpuRepeat();
glDisable(GL_LINE_STIPPLE);
break;
@@ -380,16 +388,13 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
if (is_smooth == FALSE && is_feather) {
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
mask_color_active_tint(rgb_tmp, rgb_tmp, is_active);
- glColor4ubv(rgb_tmp);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, points);
- glDrawArrays(draw_method, 0, tot_point);
+ gpuCurrentColor4ubv(rgb_tmp);
+ gpuDrawClientArrays(draw_method, &arrays, 0, tot_point);
+ gpuRepeat(); // XXX: why twice?
if (is_smooth == FALSE && is_feather) {
glDisable(GL_BLEND);
}
@@ -397,8 +402,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
break;
}
- glDisableClientState(GL_VERTEX_ARRAY);
-
+ gpuImmediateUnformat();
if (points != orig_points)
MEM_freeN(points);
}
@@ -431,7 +435,6 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline
if (is_smooth) {
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, &tot_feather_point, resol, (is_fill != FALSE));
@@ -598,7 +601,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
glScalef(maxdim * zoomx, maxdim * zoomy, 0);
if (stabmat) {
- glMultMatrixf(stabmat);
+ gpuMultMatrix(stabmat);
}
/* draw! */
@@ -617,8 +620,10 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra
MaskLayer *masklay = BKE_mask_layer_active(mask);
- glBegin(GL_LINES);
- glColor4ub(255, 175, 0, 255);
+ gpuCurrentColor4ub(255, 175, 0, 255);
+
+ gpuImmediateFormat_V2();
+ gpuBegin(GL_LINES);
if (masklay) {
MaskLayerShape *masklay_shape;
@@ -632,10 +637,11 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra
/* draw_keyframe(i, CFRA, sfra, framelen, 1); */
int height = (frame == cfra) ? 22 : 10;
int x = (frame - sfra) * framelen;
- glVertex2i(x, 0);
- glVertex2i(x, height);
+ gpuVertex2i(x, 0);
+ gpuVertex2i(x, height);
}
}
- glEnd();
+ gpuEnd();
+ gpuImmediateUnlock();
}
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index cd1a47754f8..86de9cfb8d7 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -550,7 +550,7 @@ static int do_lasso_select_mask(bContext *C, const int mcords[][2], short moves,
static int clip_lasso_select_exec(bContext *C, wmOperator *op)
{
int mcords_tot;
- const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
+ int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
short select;
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index c51d2cfb2e5..d12a2322e20 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -27,6 +27,7 @@ set(INC
../../blenloader
../../bmesh
../../imbuf
+ ../../gpu
../../makesdna
../../makesrna
../../render/extern/include
@@ -77,4 +78,6 @@ if(WITH_BULLET)
add_definitions(-DWITH_BULLET)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 4350c005f95..2e3480b5964 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -51,7 +51,7 @@
#include "BKE_context.h"
#include "BKE_tessmesh.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "ED_mesh.h"
#include "ED_screen.h"
diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c
index 4324e50f914..289dc37b3e4 100644
--- a/source/blender/editors/mesh/editmesh_bvh.c
+++ b/source/blender/editors/mesh/editmesh_bvh.c
@@ -309,7 +309,7 @@ static void vertsearchcallback(void *userdata, int index, const float *UNUSED(co
}
}
-BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], const float maxdist)
+BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist)
{
BVHTreeNearest hit;
diff --git a/source/blender/editors/mesh/editmesh_bvh.h b/source/blender/editors/mesh/editmesh_bvh.h
index 53d1c36119e..fcf126cacf3 100644
--- a/source/blender/editors/mesh/editmesh_bvh.h
+++ b/source/blender/editors/mesh/editmesh_bvh.h
@@ -57,7 +57,7 @@ int BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e,
struct ARegion *ar, struct View3D *v3d, struct Object *obedit);
/*find a vert closest to co in a sphere of radius maxdist*/
-struct BMVert *BMBVH_FindClosestVert(struct BMBVHTree *tree, const float co[3], const float maxdist);
+struct BMVert *BMBVH_FindClosestVert(struct BMBVHTree *tree, const float co[3], float maxdist);
/* BMBVH_NewBVH flag parameter */
enum {
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index aed16be5b73..9e0c85a2f17 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -47,7 +47,8 @@
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
+
#include "BIF_glutil.h" /* for paint cursor */
#include "ED_screen.h"
@@ -880,14 +881,14 @@ static void knife_finish_cut(KnifeTool_OpData *UNUSED(kcd))
static void knifetool_draw_angle_snapping(KnifeTool_OpData *kcd)
{
bglMats mats;
- double u[3], u1[2], u2[2], v1[3], v2[3], dx, dy;
+ float u[3], u1[3], u2[3], v1[3], v2[3], dx, dy;
double wminx, wminy, wmaxx, wmaxy;
/* make u the window coords of prevcage */
view3d_get_transformation(kcd->ar, kcd->vc.rv3d, kcd->ob, &mats);
- gluProject(kcd->prev.cage[0], kcd->prev.cage[1], kcd->prev.cage[2],
+ gpuProject(kcd->prev.cage,
mats.modelview, mats.projection, mats.viewport,
- &u[0], &u[1], &u[2]);
+ u);
/* make u1, u2 the points on window going through u at snap angle */
wminx = kcd->ar->winrct.xmin;
@@ -958,20 +959,21 @@ static void knifetool_draw_angle_snapping(KnifeTool_OpData *kcd)
return;
}
+ u1[2] = u2[2] = 0.0f;
/* unproject u1 and u2 back into object space */
- gluUnProject(u1[0], u1[1], 0.0,
+ gpuUnProject(u1,
mats.modelview, mats.projection, mats.viewport,
- &v1[0], &v1[1], &v1[2]);
- gluUnProject(u2[0], u2[1], 0.0,
+ v1);
+ gpuUnProject(u2,
mats.modelview, mats.projection, mats.viewport,
- &v2[0], &v2[1], &v2[2]);
+ v2);
UI_ThemeColor(TH_TRANSFORM);
glLineWidth(2.0);
- glBegin(GL_LINES);
- glVertex3dv(v1);
- glVertex3dv(v2);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
+ gpuEnd();
}
static void knife_init_colors(KnifeColors *colors)
@@ -999,52 +1001,54 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glPolygonOffset(1.0f, 1.0f);
- glPushMatrix();
- glMultMatrixf(kcd->ob->obmat);
+ gpuImmediateFormat_V3();
+
+ gpuPushMatrix();
+ gpuMultMatrix(kcd->ob->obmat);
if (kcd->mode == MODE_DRAGGING) {
if (kcd->angle_snapping != ANGLE_FREE)
knifetool_draw_angle_snapping(kcd);
- glColor3ubv(kcd->colors.line);
+ gpuCurrentColor3ubv(kcd->colors.line);
glLineWidth(2.0);
- glBegin(GL_LINES);
- glVertex3fv(kcd->prev.cage);
- glVertex3fv(kcd->curr.cage);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(kcd->prev.cage);
+ gpuVertex3fv(kcd->curr.cage);
+ gpuEnd();
glLineWidth(1.0);
}
if (kcd->curr.edge) {
- glColor3ubv(kcd->colors.edge);
+ gpuCurrentColor3ubv(kcd->colors.edge);
glLineWidth(2.0);
- glBegin(GL_LINES);
- glVertex3fv(kcd->curr.edge->v1->cageco);
- glVertex3fv(kcd->curr.edge->v2->cageco);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(kcd->curr.edge->v1->cageco);
+ gpuVertex3fv(kcd->curr.edge->v2->cageco);
+ gpuEnd();
glLineWidth(1.0);
}
else if (kcd->curr.vert) {
- glColor3ubv(kcd->colors.point);
+ gpuCurrentColor3ubv(kcd->colors.point);
glPointSize(11);
- glBegin(GL_POINTS);
- glVertex3fv(kcd->curr.cage);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex3fv(kcd->curr.cage);
+ gpuEnd();
}
if (kcd->curr.bmface) {
- glColor3ubv(kcd->colors.curpoint);
+ gpuCurrentColor3ubv(kcd->colors.curpoint);
glPointSize(9);
- glBegin(GL_POINTS);
- glVertex3fv(kcd->curr.cage);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex3fv(kcd->curr.cage);
+ gpuEnd();
}
if (kcd->totlinehit > 0) {
@@ -1055,12 +1059,11 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
int i;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* draw any snapped verts first */
- glColor4ubv(kcd->colors.point_a);
+ gpuCurrentColor4ubv(kcd->colors.point_a);
glPointSize(11);
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
lh = kcd->linehits;
for (i = 0; i < kcd->totlinehit; i++, lh++) {
float sv1[3], sv2[3];
@@ -1071,26 +1074,26 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
if (len_squared_v2v2(lh->schit, sv1) < vthresh4_squared) {
copy_v3_v3(lh->cagehit, lh->kfe->v1->cageco);
- glVertex3fv(lh->cagehit);
+ gpuVertex3fv(lh->cagehit);
lh->v = lh->kfe->v1;
}
else if (len_squared_v2v2(lh->schit, sv2) < vthresh4_squared) {
copy_v3_v3(lh->cagehit, lh->kfe->v2->cageco);
- glVertex3fv(lh->cagehit);
+ gpuVertex3fv(lh->cagehit);
lh->v = lh->kfe->v2;
}
}
- glEnd();
+ gpuEnd();
/* now draw the rest */
- glColor4ubv(kcd->colors.curpoint_a);
+ gpuCurrentColor4ubv(kcd->colors.curpoint_a);
glPointSize(7);
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
lh = kcd->linehits;
for (i = 0; i < kcd->totlinehit; i++, lh++) {
- glVertex3fv(lh->cagehit);
+ gpuVertex3fv(lh->cagehit);
}
- glEnd();
+ gpuEnd();
glDisable(GL_BLEND);
}
@@ -1099,20 +1102,20 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
KnifeEdge *kfe;
glLineWidth(1.0);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
BLI_mempool_iternew(kcd->kedges, &iter);
for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) {
if (!kfe->draw)
continue;
- glColor3ubv(kcd->colors.line);
+ gpuColor3ubv(kcd->colors.line);
- glVertex3fv(kfe->v1->cageco);
- glVertex3fv(kfe->v2->cageco);
+ gpuVertex3fv(kfe->v1->cageco);
+ gpuVertex3fv(kfe->v2->cageco);
}
- glEnd();
+ gpuEnd();
glLineWidth(1.0);
}
@@ -1122,21 +1125,23 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glPointSize(5.0);
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
if (!kfv->draw)
continue;
- glColor3ubv(kcd->colors.point);
+ gpuColor3ubv(kcd->colors.point);
- glVertex3fv(kfv->cageco);
+ gpuVertex3fv(kfv->cageco);
}
- glEnd();
+ gpuEnd();
}
- glPopMatrix();
+ gpuPopMatrix();
+
+ gpuImmediateUnformat();
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index f951073155d..d4b73dd1b64 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -64,7 +64,9 @@
#include "BKE_tessmesh.h"
#include "BKE_depsgraph.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_compatibility.h"
+
#include "BIF_glutil.h" /* for paint cursor */
#include "IMB_imbuf_types.h"
@@ -117,18 +119,20 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
if (v3d && v3d->zbuf)
glDisable(GL_DEPTH_TEST);
- glPushMatrix();
- glMultMatrixf(lcd->ob->obmat);
+ gpuPushMatrix();
+ gpuMultMatrix(lcd->ob->obmat);
- glColor3ub(255, 0, 255);
- glBegin(GL_LINES);
+ gpuImmediateFormat_V3();
+ gpuCurrentColor3x(CPACK_MAGENTA);
+ gpuBegin(GL_LINES);
for (i = 0; i < lcd->totedge; i++) {
- glVertex3fv(lcd->edges[i][0]);
- glVertex3fv(lcd->edges[i][1]);
+ gpuVertex3fv(lcd->edges[i][0]);
+ gpuVertex3fv(lcd->edges[i][1]);
}
- glEnd();
+ gpuEnd();
+ gpuImmediateUnformat();
- glPopMatrix();
+ gpuPopMatrix();
if (v3d && v3d->zbuf)
glEnable(GL_DEPTH_TEST);
}
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 8e78de44baa..453c29f004f 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -61,7 +61,8 @@
#include "ED_object.h"
#include "ED_view3d.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_compatibility.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -165,14 +166,14 @@ static void draw_triangulated(const int mcords[][2], const short tot)
a = dl->parts;
fp = dl->verts;
index = dl->index;
- glBegin(GL_TRIANGLES);
+ gpuBegin(GL_TRIANGLES);
while (a--) {
- glVertex3fv(fp + 3 * index[0]);
- glVertex3fv(fp + 3 * index[1]);
- glVertex3fv(fp + 3 * index[2]);
+ gpuVertex3fv(fp + 3 * index[0]);
+ gpuVertex3fv(fp + 3 * index[1]);
+ gpuVertex3fv(fp + 3 * index[2]);
index += 3;
}
- glEnd();
+ gpuEnd();
}
BKE_displist_free(&lb);
@@ -254,21 +255,21 @@ int EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
/* draw the mask */
glDisable(GL_DEPTH_TEST);
-
- glColor3ub(0, 0, 0);
-
+
+ gpuCurrentColor3x(CPACK_BLACK);
+
/* yah, opengl doesn't do concave... tsk! */
ED_region_pixelspace(vc->ar);
draw_triangulated(mcords, tot);
-
- glBegin(GL_LINE_LOOP); /* for zero sized masks, lines */
+
+ gpuBegin(GL_LINE_LOOP); /* for zero sized masks, lines */
for (a = 0; a < tot; a++) {
- glVertex2iv(mcords[a]);
+ gpuVertex2iv(mcords[a]);
}
- glEnd();
-
- glFinish(); /* to be sure readpixels sees mask */
-
+ gpuEnd();
+
+ glFinish(); /* to be sure readpixels sees mask */ /* jwilkins: questionable */
+
/* grab mask */
bufmask = view3d_read_backbuf(vc, xmin, ymin, xmax, ymax);
@@ -281,7 +282,7 @@ int EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
/* build selection lookup */
selbuf = MEM_callocN(bm_vertoffs + 1, "selbuf");
-
+
a = (xmax - xmin + 1) * (ymax - ymin + 1);
while (a--) {
if (*dr > 0 && *dr <= bm_vertoffs && *drm == 0) selbuf[*dr] = 1;
@@ -1957,7 +1958,7 @@ void EDBM_selectmode_set(BMEditMesh *em)
}
}
-void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const short selectmode_new)
+void EDBM_selectmode_convert(BMEditMesh *em, short selectmode_old, short selectmode_new)
{
BMEdge *eed;
BMFace *efa;
diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c
index c32033054e0..e5889955fc7 100644
--- a/source/blender/editors/mesh/editmesh_slide.c
+++ b/source/blender/editors/mesh/editmesh_slide.c
@@ -40,7 +40,6 @@
#include "BKE_report.h"
#include "BKE_tessmesh.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "ED_screen.h"
@@ -58,6 +57,8 @@
#include "mesh_intern.h"
+#include "GPU_primitives.h"
+
#define VTX_SLIDE_SNAP_THRSH 15
/* Cusom VertexSlide Operator data */
@@ -324,23 +325,23 @@ static void vtx_slide_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glPushAttrib(GL_CURRENT_BIT | GL_LINE_BIT | GL_POINT_BIT);
- glPushMatrix();
- glMultMatrixf(vso->obj->obmat);
+ gpuPushMatrix();
+ gpuMultMatrix(vso->obj->obmat);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+
+ gpuImmediateFormat_V3(); // DOODLE: edge slide
if (vso->slide_mode && vso->disk_edges > 0) {
/* Draw intermediate edge frame */
UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 50, -50);
+ gpuBegin(GL_LINES);
for (i = 0; i < vso->disk_edges; i++) {
- glBegin(GL_LINES);
- glVertex3fv(vso->vtx_frame[i]);
- glVertex3fv(vso->interp);
- glEnd();
+ gpuVertex3fv(vso->vtx_frame[i]);
+ gpuVertex3fv(vso->interp);
}
+ gpuEnd();
}
/* Draw selected edge
@@ -349,25 +350,27 @@ static void vtx_slide_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glLineWidth(outline_w);
- glBegin(GL_LINES);
- bglVertex3fv(vso->sel_edge->v1->co);
- bglVertex3fv(vso->sel_edge->v2->co);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(vso->sel_edge->v1->co);
+ gpuVertex3fv(vso->sel_edge->v2->co);
+ gpuEnd();
if (vso->slide_mode) {
/* Draw interpolated vertex */
-
+
UI_ThemeColorShadeAlpha(TH_FACE_DOT, -80, -50);
glPointSize(pt_size);
- bglBegin(GL_POINTS);
- bglVertex3fv(vso->interp);
- bglEnd();
+ gpuBeginSprites();
+ gpuSprite3fv(vso->interp);
+ gpuEndSprites();
}
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
- glPopMatrix();
+ gpuPopMatrix();
glPopAttrib();
if (view3d && view3d->zbuf)
diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt
index da12a26e747..75c97e76b1d 100644
--- a/source/blender/editors/physics/CMakeLists.txt
+++ b/source/blender/editors/physics/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -59,4 +60,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_physics "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 2ac5f98927c..9121e4e55b5 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -67,7 +67,9 @@
#include "BKE_pointcache.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "ED_physics.h"
@@ -401,8 +403,8 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
static int key_test_depth(PEData *data, const float co[3], const int screen_co[2])
{
View3D *v3d= data->vc.v3d;
+ GLfloat u[3];
ViewDepths *vd = data->vc.rv3d->depths;
- double ux, uy, uz;
float depth;
/* nothing to do */
@@ -418,8 +420,8 @@ static int key_test_depth(PEData *data, const float co[3], const int screen_co[2
}
#endif
- gluProject(co[0], co[1], co[2], data->mats.modelview, data->mats.projection,
- (GLint *)data->mats.viewport, &ux, &uy, &uz);
+ gpuProject(co, data->mats.modelview, data->mats.projection,
+ (GLint *)data->mats.viewport, u);
#if 0 /* works well but too slow on some systems [#23118] */
screen_co[0] += (short)data->vc.ar->winrct.xmin;
@@ -440,7 +442,7 @@ static int key_test_depth(PEData *data, const float co[3], const int screen_co[2
return 0;
#endif
- if ((float)uz - 0.00001f > depth)
+ if (u[2] - 0.00001f > depth)
return 0;
else
return 1;
@@ -2509,18 +2511,12 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
brush= &pset->brush[pset->brushtype];
if (brush) {
- glPushMatrix();
-
- glTranslatef((float)x, (float)y, 0.0f);
-
- glColor4ub(255, 255, 255, 128);
+ gpuCurrentColor4x(CPACK_WHITE, 0.500f);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40);
+ gpuSingleCircle((float)x, (float)y, brush->size, 40);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
-
- glPopMatrix();
}
}
diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt
index 3c5fd0b4ef7..1561760f1e0 100644
--- a/source/blender/editors/render/CMakeLists.txt
+++ b/source/blender/editors/render/CMakeLists.txt
@@ -68,4 +68,6 @@ if(WITH_HEADLESS)
add_definitions(-DWITH_HEADLESS)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_render "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index effb984c083..4364ec712fd 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -31,8 +31,6 @@
#include <string.h>
#include <stddef.h>
-#include <GL/glew.h>
-
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
@@ -69,6 +67,7 @@
#include "RNA_define.h"
+#include "GPU_compatibility.h"
#include "GPU_extensions.h"
#include "wm_window.h"
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index a864fe306b3..73a250ec6a9 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -84,13 +84,13 @@
#include "IMB_imbuf_types.h"
#include "IMB_colormanagement.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "PIL_time.h"
#include "RE_pipeline.h"
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt
index 33373354aa4..909241d5093 100644
--- a/source/blender/editors/screen/CMakeLists.txt
+++ b/source/blender/editors/screen/CMakeLists.txt
@@ -26,6 +26,7 @@ set(INC
../../blenloader
../../bmesh
../../imbuf
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -51,4 +52,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_screen "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index f30e0abb4f3..ce6033f5f49 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -57,10 +57,13 @@
#include "ED_types.h"
#include "ED_fileselect.h"
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+#include REAL_GL_MODE
#include "BLF_api.h"
+#include "BIF_glutil.h"
+
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -72,33 +75,30 @@
static void region_draw_emboss(ARegion *ar, rcti *scirct)
{
rcti rect;
-
+
/* translate scissor rect to region space */
rect.xmin = scirct->xmin - ar->winrct.xmin;
rect.ymin = scirct->ymin - ar->winrct.ymin;
rect.xmax = scirct->xmax - ar->winrct.xmin;
rect.ymax = scirct->ymax - ar->winrct.ymin;
-
+
/* set transp line */
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- /* right */
- glColor4ub(0, 0, 0, 30);
- sdrawline(rect.xmax, rect.ymin, rect.xmax, rect.ymax);
-
- /* bottom */
- glColor4ub(0, 0, 0, 30);
- sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin);
-
- /* top */
- glColor4ub(255, 255, 255, 30);
- sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax);
- /* left */
- glColor4ub(255, 255, 255, 30);
- sdrawline(rect.xmin, rect.ymin, rect.xmin, rect.ymax);
-
+ gpuImmediateFormat_C4_V2(); // DOODLE: emboss, 4 lines, colored
+ gpuBegin(GL_LINES);
+
+ gpuColor4x(CPACK_BLACK, 0.118f);
+ gpuAppendLinei(rect.xmax, rect.ymin, rect.xmax, rect.ymax); /* right */
+ gpuAppendLinei(rect.xmin, rect.ymin, rect.xmax, rect.ymin); /* bottom */
+
+ gpuColor4x(CPACK_WHITE, 0.118f);
+ gpuAppendLinei(rect.xmin, rect.ymax, rect.xmax, rect.ymax); /* top */
+ gpuAppendLinei(rect.xmin, rect.ymin, rect.xmin, rect.ymax); /* left */
+
+ gpuEnd();
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
}
@@ -108,7 +108,7 @@ void ED_region_pixelspace(ARegion *ar)
int height = BLI_rcti_size_y(&ar->winrct) + 1;
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
- glLoadIdentity();
+ gpuLoadIdentity();
}
/* only exported for WM */
@@ -180,20 +180,33 @@ static void area_draw_azone(short x1, short y1, short x2, short y2)
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
-
- glColor4ub(255, 255, 255, 180);
- fdrawline(x1, y2, x2, y1);
- glColor4ub(255, 255, 255, 130);
- fdrawline(x1, y2 - dy, x2 - dx, y1);
- glColor4ub(255, 255, 255, 80);
- fdrawline(x1, y2 - 2 * dy, x2 - 2 * dx, y1);
-
- glColor4ub(0, 0, 0, 210);
- fdrawline(x1, y2 + 1, x2 + 1, y1);
- glColor4ub(0, 0, 0, 180);
- fdrawline(x1, y2 - dy + 1, x2 - dx + 1, y1);
- glColor4ub(0, 0, 0, 150);
- fdrawline(x1, y2 - 2 * dy + 1, x2 - 2 * dx + 1, y1);
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: azone, 6 lines, colored
+ gpuBegin(GL_LINES);
+
+
+ gpuColor4x(CPACK_WHITE, 0.706f);
+ gpuAppendLinef(x1, y2, x2, y1);
+
+ gpuColor4x(CPACK_WHITE, 0.510f);
+ gpuAppendLinef(x1, y2 - dy, x2 - dx, y1);
+
+ gpuColor4x(CPACK_WHITE, 0.314f);
+ gpuAppendLinef(x1, y2 - 2 * dy, x2 - 2 * dx, y1);
+
+
+ gpuColor4x(CPACK_BLACK, 0.824f);
+ gpuAppendLinef(x1, y2 + 1, x2 + 1, y1);
+
+ gpuColor4x(CPACK_BLACK, 0.706f);
+ gpuAppendLinef(x1, y2 - dy + 1, x2 - dx + 1, y1);
+
+ gpuColor4x(CPACK_BLACK, 0.588f);
+ gpuAppendLinef(x1, y2 - 2 * dy + 1, x2 - 2 * dx + 1, y1);
+
+
+ gpuEnd();
+ gpuImmediateUnformat();
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
@@ -201,36 +214,34 @@ static void area_draw_azone(short x1, short y1, short x2, short y2)
static void region_draw_azone_icon(AZone *az)
{
- GLUquadricObj *qobj = NULL;
short midx = az->x1 + (az->x2 - az->x1) / 2;
short midy = az->y1 + (az->y2 - az->y1) / 2;
-
- qobj = gluNewQuadric();
-
- glPushMatrix();
- glTranslatef(midx, midy, 0.0);
-
+
+ gpuPushMatrix();
+ gpuTranslate(midx, midy, 0.0);
+
+ gpuImmediateFormat_V2(); // DOODLE, azone icon, disk, circle, and plus (cross), 2 lines mono
+
/* outlined circle */
glEnable(GL_LINE_SMOOTH);
- glColor4f(1.f, 1.f, 1.f, 0.8f);
+ gpuCurrentColor4x(CPACK_WHITE, 0.800f);
+ gpuDrawDisk(0, 0, 4.25f, 16);
- gluQuadricDrawStyle(qobj, GLU_FILL);
- gluDisk(qobj, 0.0, 4.25f, 16, 1);
+ gpuCurrentGray4f(0.200f, 0.900f);
+ gpuDrawCircle(0, 0, 4.25, 16);
- glColor4f(0.2f, 0.2f, 0.2f, 0.9f);
-
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
- gluDisk(qobj, 0.0, 4.25f, 16, 1);
-
glDisable(GL_LINE_SMOOTH);
-
- glPopMatrix();
- gluDeleteQuadric(qobj);
-
+
+ gpuPopMatrix();
+
/* + */
- sdrawline(midx, midy - 2, midx, midy + 3);
- sdrawline(midx - 2, midy, midx + 3, midy);
+ gpuBegin(GL_LINES);
+ gpuAppendLinei(midx, midy - 2, midx, midy + 3);
+ gpuAppendLinei(midx - 2, midy, midx + 3, midy);
+ gpuEnd();
+
+ gpuImmediateUnformat();
}
static void draw_azone_plus(float x1, float y1, float x2, float y2)
@@ -238,9 +249,13 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2)
float width = 2.0f;
float pad = 4.0f;
- glRectf((x1 + x2 - width) * 0.5f, y1 + pad, (x1 + x2 + width) * 0.5f, y2 - pad);
- glRectf(x1 + pad, (y1 + y2 - width) * 0.5f, (x1 + x2 - width) * 0.5f, (y1 + y2 + width) * 0.5f);
- glRectf((x1 + x2 + width) * 0.5f, (y1 + y2 - width) * 0.5f, x2 - pad, (y1 + y2 + width) * 0.5f);
+ gpuImmediateFormat_V2();
+ gpuBegin(GL_TRIANGLES);
+ gpuAppendFilledRectf((x1 + x2 - width) * 0.5f, y1 + pad, (x1 + x2 + width) * 0.5f, y2 - pad);
+ gpuAppendFilledRectf((x1 + pad), (y1 + y2 - width) * 0.5f, (x1 + x2 - width) * 0.5f, (y1 + y2 + width) * 0.5f);
+ gpuAppendFilledRectf((x1 + x2 + width) * 0.5f, (y1 + y2 - width) * 0.5f, x2 - pad, (y1 + y2 + width) * 0.5f);
+ gpuEnd();
+ gpuImmediateUnformat();
}
static void region_draw_azone_tab_plus(AZone *az)
@@ -265,12 +280,12 @@ static void region_draw_azone_tab_plus(AZone *az)
break;
}
- glColor4f(0.05f, 0.05f, 0.05f, 0.4f);
+ gpuCurrentGray4f(0.050f, 0.400f);
uiRoundBox((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f);
glEnable(GL_BLEND);
- glColor4f(0.8f, 0.8f, 0.8f, 0.4f);
+ gpuCurrentGray4f(0.800f, 0.400f);
draw_azone_plus((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2);
glDisable(GL_BLEND);
@@ -279,60 +294,60 @@ static void region_draw_azone_tab_plus(AZone *az)
static void region_draw_azone_tab(AZone *az)
{
float col[3];
-
+
glEnable(GL_BLEND);
UI_GetThemeColor3fv(TH_HEADER, col);
- glColor4f(col[0], col[1], col[2], 0.5f);
-
+ gpuCurrentColor4f(col[0], col[1], col[2], 0.5f);
+
/* add code to draw region hidden as 'too small' */
switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_RB_ALPHA);
-
- uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
- glColor4ub(0, 0, 0, 255);
+
+ uiDrawBoxShade(GL_TRIANGLE_FAN, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
+ gpuCurrentColor3x(CPACK_BLACK);
uiRoundRect((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f);
break;
case AE_BOTTOM_TO_TOPLEFT:
uiSetRoundBox(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA);
-
- uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
- glColor4ub(0, 0, 0, 255);
+
+ uiDrawBoxShade(GL_TRIANGLE_FAN, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
+ gpuCurrentColor3x(CPACK_BLACK);
uiRoundRect((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f);
break;
case AE_LEFT_TO_TOPRIGHT:
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA);
-
- uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
- glColor4ub(0, 0, 0, 255);
+
+ uiDrawBoxShade(GL_TRIANGLE_FAN, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
+ gpuCurrentColor3x(CPACK_BLACK);
uiRoundRect((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f);
break;
case AE_RIGHT_TO_TOPLEFT:
uiSetRoundBox(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_RB_ALPHA);
-
- uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
- glColor4ub(0, 0, 0, 255);
+
+ uiDrawBoxShade(GL_TRIANGLE_FAN, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
+ gpuCurrentColor3x(CPACK_BLACK);
uiRoundRect((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f);
break;
}
-
+
glDisable(GL_BLEND);
}
static void region_draw_azone_tria(AZone *az)
{
extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); /* xxx temp */
-
+
glEnable(GL_BLEND);
//UI_GetThemeColor3fv(TH_HEADER, col);
- glColor4f(0.0f, 0.0f, 0.0f, 0.35f);
-
+ gpuCurrentColor4x(CPACK_BLACK, 0.350f);
+
/* add code to draw region hidden as 'too small' */
switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1 + az->x2) / 2, (float)az->y2);
break;
-
+
case AE_BOTTOM_TO_TOPLEFT:
ui_draw_anti_tria((float)az->x1, (float)az->y2, (float)az->x2, (float)az->y2, (float)(az->x1 + az->x2) / 2, (float)az->y1);
break;
@@ -340,13 +355,13 @@ static void region_draw_azone_tria(AZone *az)
case AE_LEFT_TO_TOPRIGHT:
ui_draw_anti_tria((float)az->x2, (float)az->y1, (float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1 + az->y2) / 2);
break;
-
+
case AE_RIGHT_TO_TOPLEFT:
ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1 + az->y2) / 2);
break;
}
-
+
glDisable(GL_BLEND);
}
@@ -361,8 +376,7 @@ void ED_area_overdraw(bContext *C)
wmSubWindowSet(win, screen->mainwin);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+
for (sa = screen->areabase.first; sa; sa = sa->next) {
AZone *az;
for (az = sa->actionzones.first; az; az = az->next) {
@@ -480,7 +494,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
/* optional header info instead? */
if (ar->headerstr) {
UI_ThemeClearColor(TH_HEADER);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_ThemeColor(TH_TEXT);
BLF_draw_default(20, 8, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
@@ -1275,7 +1289,7 @@ void ED_region_init(bContext *C, ARegion *ar)
/* UI convention */
wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
- glLoadIdentity();
+ gpuLoadIdentity();
}
void ED_region_toggle_hidden(bContext *C, ARegion *ar)
@@ -1654,7 +1668,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
/* clear */
UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
/* before setting the view */
if (vertical) {
@@ -1735,7 +1749,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
/* clear */
UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
/* set view2d view matrix for scrolling (without scrollers) */
UI_view2d_view_ortho(&ar->v2d);
@@ -1811,9 +1825,8 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
rect.ymax = BLI_rcti_size_y(&ar->winrct);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4f(0.0f, 0.0f, 0.0f, alpha);
- glRecti(rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1);
+ gpuCurrentColor4x(CPACK_BLACK, alpha);
+ gpuSingleFilledRecti(rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1);
glDisable(GL_BLEND);
/* text */
@@ -1833,7 +1846,7 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
UI_view2d_to_region_no_clip(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
- glRectf(x1, y1, x2, y2);
+ gpuSingleFilledRectf(x1, y1, x2, y2);
/* gridsize adapted to zoom level */
gridsize = 0.5f * (zoomx + zoomy);
@@ -1853,31 +1866,34 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
}
}
- /* the fine resolution level */
blendfac = 0.25f * gridsize - floorf(0.25f * gridsize);
CLAMP(blendfac, 0.0f, 1.0f);
- UI_ThemeColorShade(TH_BACK, (int)(20.0f * (1.0f - blendfac)));
+ gpuImmediateFormat_C4_V2();
+ gpuBegin(GL_LINES);
+
+ /* the fine resolution level */
fac = 0.0f;
- glBegin(GL_LINES);
+ UI_ThemeAppendColorShade(TH_BACK, (int)(20.0f * (1.0f - blendfac)));
while (fac < 1.0f) {
- glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
- glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
- glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
- glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
+ gpuVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
+ gpuVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
+ gpuVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
+ gpuVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
fac += gridstep;
}
/* the large resolution level */
- UI_ThemeColor(TH_BACK);
-
+ UI_ThemeAppendColor(TH_BACK);
fac = 0.0f;
while (fac < 1.0f) {
- glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
- glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
- glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
- glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
+ gpuVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
+ gpuVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
+ gpuVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
+ gpuVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
fac += 4.0f * gridstep;
}
- glEnd();
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index ce2d045dc80..3bd4001250d 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -43,7 +43,8 @@
#include "BLI_math.h"
#include "BLI_threads.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#ifndef GL_CLAMP_TO_EDGE
@@ -53,7 +54,6 @@
/* ******************************************** */
-/* defined in BIF_gl.h */
GLubyte stipple_halftone[128] = {
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
@@ -130,67 +130,36 @@ GLubyte stipple_diag_stripes_neg[128] = {
0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80};
-void fdrawbezier(float vec[4][3])
-{
- float dist;
- float curve_res = 24, spline_step = 0.0f;
-
- dist = 0.5f * ABS(vec[0][0] - vec[3][0]);
-
- /* check direction later, for top sockets */
- vec[1][0] = vec[0][0] + dist;
- vec[1][1] = vec[0][1];
-
- vec[2][0] = vec[3][0] - dist;
- vec[2][1] = vec[3][1];
- /* we can reuse the dist variable here to increment the GL curve eval amount*/
- dist = 1.0f / curve_res;
-
- cpack(0x0);
- glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]);
- glBegin(GL_LINE_STRIP);
- while (spline_step < 1.000001f) {
-#if 0
- if (do_shaded)
- UI_ThemeColorBlend(th_col1, th_col2, spline_step);
-#endif
- glEvalCoord1f(spline_step);
- spline_step += dist;
- }
- glEnd();
-}
+//void fdrawbezier(float vec[4][3])
+//{
+// float dist;
+// float curve_res = 24, spline_step = 0.0f;
+//
+// dist = 0.5f * ABS(vec[0][0] - vec[3][0]);
+//
+// /* check direction later, for top sockets */
+// vec[1][0] = vec[0][0] + dist;
+// vec[1][1] = vec[0][1];
+//
+// vec[2][0] = vec[3][0] - dist;
+// vec[2][1] = vec[3][1];
+// /* we can reuse the dist variable here to increment the GL curve eval amount*/
+// dist = 1.0f / curve_res;
+//
+// gpuCurrentColor3x(CPACK_BLACK);
+// glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]);
+// gpuBegin(GL_LINE_STRIP);
+// while (spline_step < 1.000001f) {
+//#if 0
+// if (do_shaded)
+// UI_ThemeColorBlend(th_col1, th_col2, spline_step);
+//#endif
+// glEvalCoord1f(spline_step);
+// spline_step += dist;
+// }
+// gpuEnd();
+//}
-void fdrawline(float x1, float y1, float x2, float y2)
-{
- float v[2];
-
- glBegin(GL_LINE_STRIP);
- v[0] = x1; v[1] = y1;
- glVertex2fv(v);
- v[0] = x2; v[1] = y2;
- glVertex2fv(v);
- glEnd();
-}
-
-void fdrawbox(float x1, float y1, float x2, float y2)
-{
- float v[2];
-
- glBegin(GL_LINE_STRIP);
-
- v[0] = x1; v[1] = y1;
- glVertex2fv(v);
- v[0] = x1; v[1] = y2;
- glVertex2fv(v);
- v[0] = x2; v[1] = y2;
- glVertex2fv(v);
- v[0] = x2; v[1] = y1;
- glVertex2fv(v);
- v[0] = x1; v[1] = y1;
- glVertex2fv(v);
-
- glEnd();
-}
void fdrawcheckerboard(float x1, float y1, float x2, float y2)
{
@@ -206,28 +175,16 @@ void fdrawcheckerboard(float x1, float y1, float x2, float y2)
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255};
- glColor3ubv(col1);
- glRectf(x1, y1, x2, y2);
- glColor3ubv(col2);
+ gpuCurrentColor3ubv(col1);
+ gpuSingleFilledRectf(x1, y1, x2, y2);
+ gpuCurrentColor3ubv(col2);
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(checker_stipple);
- glRectf(x1, y1, x2, y2);
+ gpuSingleFilledRectf(x1, y1, x2, y2);
glDisable(GL_POLYGON_STIPPLE);
}
-void sdrawline(short x1, short y1, short x2, short y2)
-{
- short v[2];
-
- glBegin(GL_LINE_STRIP);
- v[0] = x1; v[1] = y1;
- glVertex2sv(v);
- v[0] = x2; v[1] = y2;
- glVertex2sv(v);
- glEnd();
-}
-
/*
* x1,y2
* | \
@@ -240,45 +197,25 @@ static void sdrawtripoints(short x1, short y1, short x2, short y2)
{
short v[2];
v[0] = x1; v[1] = y1;
- glVertex2sv(v);
+ gpuVertex2sv(v);
v[0] = x1; v[1] = y2;
- glVertex2sv(v);
+ gpuVertex2sv(v);
v[0] = x2; v[1] = y1;
- glVertex2sv(v);
+ gpuVertex2sv(v);
}
void sdrawtri(short x1, short y1, short x2, short y2)
{
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
sdrawtripoints(x1, y1, x2, y2);
- glEnd();
+ gpuEnd();
}
void sdrawtrifill(short x1, short y1, short x2, short y2)
{
- glBegin(GL_TRIANGLES);
+ gpuBegin(GL_TRIANGLES);
sdrawtripoints(x1, y1, x2, y2);
- glEnd();
-}
-
-void sdrawbox(short x1, short y1, short x2, short y2)
-{
- short v[2];
-
- glBegin(GL_LINE_STRIP);
-
- v[0] = x1; v[1] = y1;
- glVertex2sv(v);
- v[0] = x1; v[1] = y2;
- glVertex2sv(v);
- v[0] = x2; v[1] = y2;
- glVertex2sv(v);
- v[0] = x2; v[1] = y1;
- glVertex2sv(v);
- v[0] = x1; v[1] = y1;
- glVertex2sv(v);
-
- glEnd();
+ gpuEnd();
}
@@ -312,12 +249,12 @@ void sdrawXORline(int x0, int y0, int x1, int y1)
if (x0 == x1 && y0 == y1) return;
set_inverted_drawing(1);
-
- glBegin(GL_LINES);
- glVertex2i(x0, y0);
- glVertex2i(x1, y1);
- glEnd();
-
+
+ gpuBegin(GL_LINES);
+ gpuVertex2i(x0, y0);
+ gpuVertex2i(x1, y1);
+ gpuEnd();
+
set_inverted_drawing(0);
}
@@ -330,12 +267,12 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1)
set_inverted_drawing(1);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
if (nr == -1) { /* flush */
for (nr = 0; nr < 4; nr++) {
if (flags[nr]) {
- glVertex2sv(old[nr][0]);
- glVertex2sv(old[nr][1]);
+ gpuVertex2sv(old[nr][0]);
+ gpuVertex2sv(old[nr][1]);
flags[nr] = 0;
}
}
@@ -343,8 +280,8 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1)
else {
if (nr >= 0 && nr < 4) {
if (flags[nr]) {
- glVertex2sv(old[nr][0]);
- glVertex2sv(old[nr][1]);
+ gpuVertex2sv(old[nr][0]);
+ gpuVertex2sv(old[nr][1]);
}
old[nr][0][0] = x0;
@@ -355,69 +292,32 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1)
flags[nr] = 1;
}
- glVertex2i(x0, y0);
- glVertex2i(x1, y1);
+ gpuVertex2i(x0, y0);
+ gpuVertex2i(x1, y1);
}
- glEnd();
+ gpuEnd();
set_inverted_drawing(0);
}
void fdrawXORellipse(float xofs, float yofs, float hw, float hh)
{
- if (hw == 0) return;
+ if (hw == 0) {
+ return;
+ }
set_inverted_drawing(1);
-
- glPushMatrix();
- glTranslatef(xofs, yofs, 0.0f);
- glScalef(1.0f, hh / hw, 1.0f);
- glutil_draw_lined_arc(0.0, M_PI * 2.0, hw, 20);
- glPopMatrix();
-
+ gpuSingleEllipse(xofs, yofs, hw, hh, 20);
set_inverted_drawing(0);
}
+
void fdrawXORcirc(float xofs, float yofs, float rad)
{
set_inverted_drawing(1);
-
- glPushMatrix();
- glTranslatef(xofs, yofs, 0.0);
- glutil_draw_lined_arc(0.0, M_PI * 2.0, rad, 20);
- glPopMatrix();
-
+ gpuSingleCircle(xofs, yofs, rad, 20);
set_inverted_drawing(0);
}
-void glutil_draw_filled_arc(float start, float angle, float radius, int nsegments)
-{
- int i;
-
- glBegin(GL_TRIANGLE_FAN);
- glVertex2f(0.0, 0.0);
- for (i = 0; i < nsegments; i++) {
- float t = (float) i / (nsegments - 1);
- float cur = start + t * angle;
-
- glVertex2f(cosf(cur) * radius, sinf(cur) * radius);
- }
- glEnd();
-}
-
-void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments)
-{
- int i;
-
- glBegin(GL_LINE_STRIP);
- for (i = 0; i < nsegments; i++) {
- float t = (float) i / (nsegments - 1);
- float cur = start + t * angle;
-
- glVertex2f(cosf(cur) * radius, sinf(cur) * radius);
- }
- glEnd();
-}
-
int glaGetOneInteger(int param)
{
GLint i;
@@ -484,7 +384,6 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
float *f_rect = (float *)rect;
float xzoom = glaGetOneFloat(GL_ZOOM_X), yzoom = glaGetOneFloat(GL_ZOOM_Y);
int ltexid = glaGetOneInteger(GL_TEXTURE_2D);
- int lrowlength = glaGetOneInteger(GL_UNPACK_ROW_LENGTH);
int subpart_x, subpart_y, tex_w, tex_h;
int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y;
int texid = get_cached_work_texture(&tex_w, &tex_h);
@@ -493,6 +392,7 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
* This is useful for changing alpha without using glPixelTransferf()
*/
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
glPixelStorei(GL_UNPACK_ROW_LENGTH, img_w);
glBindTexture(GL_TEXTURE_2D, texid);
@@ -554,25 +454,31 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
}
glEnable(GL_TEXTURE_2D);
- glBegin(GL_QUADS);
- glTexCoord2f((float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h);
- glVertex2f(rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * xzoom);
- glTexCoord2f((float)(subpart_w - offset_right) / tex_w, (float)(0 + offset_bot) / tex_h);
- glVertex2f(rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX, rast_y + (float)offset_bot * xzoom);
+ gpuImmediateFormat_T2_V2();
+ gpuBegin(GL_TRIANGLE_FAN);
+
+ gpuTexCoord2f((float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h);
+ gpuVertex2f(rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * xzoom);
- glTexCoord2f((float)(subpart_w - offset_right) / tex_w, (float)(subpart_h - offset_top) / tex_h);
- glVertex2f(rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX, rast_y + (float)(subpart_h - offset_top) * yzoom * scaleY);
+ gpuTexCoord2f((float)(subpart_w - offset_right) / tex_w, (float)(0 + offset_bot) / tex_h);
+ gpuVertex2f(rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX, rast_y + (float)offset_bot * xzoom);
+
+ gpuTexCoord2f((float)(subpart_w - offset_right) / tex_w, (float)(subpart_h - offset_top) / tex_h);
+ gpuVertex2f(rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX, rast_y + (float)(subpart_h - offset_top) * yzoom * scaleY);
+
+ gpuTexCoord2f((float)(0 + offset_left) / tex_w, (float)(subpart_h - offset_top) / tex_h);
+ gpuVertex2f(rast_x + (float)offset_left * xzoom, rast_y + (float)(subpart_h - offset_top) * yzoom * scaleY);
+
+ gpuEnd();
+ gpuImmediateUnformat();
- glTexCoord2f((float)(0 + offset_left) / tex_w, (float)(subpart_h - offset_top) / tex_h);
- glVertex2f(rast_x + (float)offset_left * xzoom, rast_y + (float)(subpart_h - offset_top) * yzoom * scaleY);
- glEnd();
glDisable(GL_TEXTURE_2D);
}
}
glBindTexture(GL_TEXTURE_2D, ltexid);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, lrowlength);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); /* restore default value */
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#ifdef __APPLE__
@@ -609,7 +515,7 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
float rast_x = x + off_x * xzoom;
float rast_y = y + off_y * yzoom;
- GLfloat scissor[4];
+ int scissor[4];
int draw_w, draw_h;
/* Determine the smallest number of pixels we need to draw
@@ -624,13 +530,11 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
* fails if we zoom in on one really huge pixel so that it
* covers the entire screen).
*/
- glGetFloatv(GL_SCISSOR_BOX, scissor);
- draw_w = min_ii(img_w - off_x, ceil((scissor[2] - rast_x) / xzoom));
- draw_h = min_ii(img_h - off_y, ceil((scissor[3] - rast_y) / yzoom));
+ gpuGetSizeBox(GL_SCISSOR_BOX, scissor);
+ draw_w = min_ii(img_w - off_x, ceil((float)(scissor[2] - rast_x) / xzoom));
+ draw_h = min_ii(img_h - off_y, ceil((float)(scissor[3] - rast_y) / yzoom));
if (draw_w > 0 && draw_h > 0) {
- int old_row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH);
-
/* Don't use safe RasterPos (slower) if we can avoid it. */
if (rast_x >= 0 && rast_y >= 0) {
glRasterPos2f(rast_x, rast_y);
@@ -640,6 +544,7 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
}
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_w);
+
if (format == GL_LUMINANCE || format == GL_RED) {
if (type == GL_FLOAT) {
float *f_rect = (float *)rect;
@@ -660,8 +565,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y * row_w + off_x) * 4);
}
}
-
- glPixelStorei(GL_UNPACK_ROW_LENGTH, old_row_length);
+
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); /* restore default value */
}
}
@@ -672,8 +577,8 @@ void glaDefine2DArea(rcti *screen_rect)
const int sc_w = BLI_rcti_size_x(screen_rect) + 1;
const int sc_h = BLI_rcti_size_y(screen_rect) + 1;
- glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
- glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
+ gpuViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
+ gpuScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
/* The GLA_PIXEL_OFS magic number is to shift the matrix so that
* both raster and vertex integer coordinates fall at pixel
@@ -681,19 +586,19 @@ void glaDefine2DArea(rcti *screen_rect)
* Programming Guide, Appendix H, Correctness Tips.
*/
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0, sc_w, 0.0, sc_h, -1, 1);
- glTranslatef(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0);
+ gpuMatrixMode(GL_PROJECTION);
+ gpuLoadIdentity();
+ gpuOrtho(0.0, sc_w, 0.0, sc_h, -1, 1);
+ gpuTranslate(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuLoadIdentity();
}
#if 0 /* UNUSED */
struct gla2DDrawInfo {
- int orig_vp[4], orig_sc[4];
+ int orig_vp[4], /*orig_sc[4]; Unused*/
float orig_projmat[16], orig_viewmat[16];
rcti screen_rect;
@@ -729,10 +634,9 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
int sc_w, sc_h;
float wo_w, wo_h;
- glGetIntegerv(GL_VIEWPORT, (GLint *)di->orig_vp);
- glGetIntegerv(GL_SCISSOR_BOX, (GLint *)di->orig_sc);
- glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)di->orig_projmat);
- glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)di->orig_viewmat);
+ gpuGetSizeBox(GL_VIEWPORT, (GLint *)di->orig_vp);
+ gpuGetMatrix(GL_PROJECTION_MATRIX, (GLfloat *)di->orig_projmat);
+ gpuGetMatrix(GL_MODELVIEW_MATRIX, (GLfloat *)di->orig_viewmat);
di->screen_rect = *screen_rect;
if (world_rect) {
@@ -771,113 +675,25 @@ void gla2DDrawTranslatePtv(gla2DDrawInfo *di, float world[2], int screen_r[2])
void glaEnd2DDraw(gla2DDrawInfo *di)
{
- glViewport(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
- glScissor(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
- glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(di->orig_projmat);
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(di->orig_viewmat);
+ gpuViewport(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
+ gpuScissor(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
+ gpuMatrixMode(GL_PROJECTION);
+ gpuLoadMatrix(di->orig_projmat);
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuLoadMatrix(di->orig_viewmat);
MEM_freeN(di);
}
#endif
-/* **************** GL_POINT hack ************************ */
-
-static int curmode = 0;
-static int pointhack = 0;
-static GLubyte Squaredot[16] = {0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff};
-
-void bglBegin(int mode)
-{
- curmode = mode;
-
- if (mode == GL_POINTS) {
- float value[4];
- glGetFloatv(GL_POINT_SIZE_RANGE, value);
- if (value[1] < 2.0f) {
- glGetFloatv(GL_POINT_SIZE, value);
- pointhack = floor(value[0] + 0.5f);
- if (pointhack > 4) pointhack = 4;
- }
- else glBegin(mode);
- }
-}
-
-#if 0 /* UNUSED */
-int bglPointHack(void)
-{
- float value[4];
- int pointhack_px;
- glGetFloatv(GL_POINT_SIZE_RANGE, value);
- if (value[1] < 2.0f) {
- glGetFloatv(GL_POINT_SIZE, value);
- pointhack_px = floorf(value[0] + 0.5f);
- if (pointhack_px > 4) pointhack_px = 4;
- return pointhack_px;
- }
- return 0;
-}
-#endif
-
-void bglVertex3fv(const float vec[3])
-{
- switch (curmode) {
- case GL_POINTS:
- if (pointhack) {
- glRasterPos3fv(vec);
- glBitmap(pointhack, pointhack, (float)pointhack / 2.0f, (float)pointhack / 2.0f, 0.0, 0.0, Squaredot);
- }
- else glVertex3fv(vec);
- break;
- }
-}
-
-void bglVertex3f(float x, float y, float z)
-{
- switch (curmode) {
- case GL_POINTS:
- if (pointhack) {
- glRasterPos3f(x, y, z);
- glBitmap(pointhack, pointhack, (float)pointhack / 2.0f, (float)pointhack / 2.0f, 0.0, 0.0, Squaredot);
- }
- else glVertex3f(x, y, z);
- break;
- }
-}
-
-void bglVertex2fv(const float vec[2])
-{
- switch (curmode) {
- case GL_POINTS:
- if (pointhack) {
- glRasterPos2fv(vec);
- glBitmap(pointhack, pointhack, (float)pointhack / 2, pointhack / 2, 0.0, 0.0, Squaredot);
- }
- else glVertex2fv(vec);
- break;
- }
-}
-
-
-void bglEnd(void)
-{
- if (pointhack) pointhack = 0;
- else glEnd();
-
-}
-
/* Uses current OpenGL state to get view matrices for gluProject/gluUnProject */
void bgl_get_mats(bglMats *mats)
{
const double badvalue = 1.0e-6;
- glGetDoublev(GL_MODELVIEW_MATRIX, mats->modelview);
- glGetDoublev(GL_PROJECTION_MATRIX, mats->projection);
- glGetIntegerv(GL_VIEWPORT, (GLint *)mats->viewport);
+ gpuGetMatrix(GL_MODELVIEW_MATRIX, mats->modelview);
+ gpuGetMatrix(GL_PROJECTION_MATRIX, mats->projection);
+ gpuGetSizeBox(GL_VIEWPORT, (GLint *)mats->viewport);
/* Very strange code here - it seems that certain bad values in the
* modelview matrix can cause gluUnProject to give bad results. */
@@ -911,37 +727,25 @@ void bglPolygonOffset(float viewdist, float dist)
// glPolygonOffset(-1.0, -1.0);
/* hack below is to mimic polygon offset */
- glMatrixMode(GL_PROJECTION);
- glGetFloatv(GL_PROJECTION_MATRIX, (float *)winmat);
-
+ gpuMatrixMode(GL_PROJECTION);
+ gpuGetMatrix(GL_PROJECTION_MATRIX, (float *)winmat);
+
/* dist is from camera to center point */
if (winmat[15] > 0.5f) offs = 0.00001f * dist * viewdist; // ortho tweaking
else offs = 0.0005f * dist; // should be clipping value or so...
-
+
winmat[14] -= offs;
offset += offs;
-
- glLoadMatrixf(winmat);
- glMatrixMode(GL_MODELVIEW);
+
+ gpuLoadMatrix(winmat);
+ gpuMatrixMode(GL_MODELVIEW);
}
else {
-
- glMatrixMode(GL_PROJECTION);
+ gpuMatrixMode(GL_PROJECTION);
winmat[14] += offset;
offset = 0.0;
- glLoadMatrixf(winmat);
- glMatrixMode(GL_MODELVIEW);
+ gpuLoadMatrix(winmat);
+ gpuMatrixMode(GL_MODELVIEW);
}
}
-
-#if 0 /* UNUSED */
-void bglFlush(void)
-{
- glFlush();
-#ifdef __APPLE__
-// if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_OFFICIAL))
-// XXX myswapbuffers(); //hack to get mac intel graphics to show frontbuffer
-#endif
-}
-#endif
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 60aad14efcf..52d026c2a89 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -49,7 +49,9 @@
#include "BKE_screen.h"
#include "BKE_scene.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "WM_api.h"
@@ -763,18 +765,18 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir)
}
}
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
for (i = 0; i < 5; i++)
- glVertex2f(points[i].x, points[i].y);
- glEnd();
- glBegin(GL_POLYGON);
+ gpuVertex2f(points[i].x, points[i].y);
+ gpuEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
for (i = 4; i < 8; i++)
- glVertex2f(points[i].x, points[i].y);
- glVertex2f(points[0].x, points[0].y);
- glEnd();
+ gpuVertex2f(points[i].x, points[i].y);
+ gpuVertex2f(points[0].x, points[0].y);
+ gpuEnd();
- glRectf(points[2].x, points[2].y, points[8].x, points[8].y);
- glRectf(points[6].x, points[6].y, points[9].x, points[9].y);
+ gpuDrawFilledRectf(points[2].x, points[2].y, points[8].x, points[8].y);
+ gpuDrawFilledRectf(points[6].x, points[6].y, points[9].x, points[9].y);
}
/* draw vertical shape visualizing future joining (up/down direction) */
@@ -835,35 +837,38 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir)
}
}
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
for (i = 0; i < 5; i++)
- glVertex2f(points[i].x, points[i].y);
- glEnd();
- glBegin(GL_POLYGON);
+ gpuVertex2f(points[i].x, points[i].y);
+ gpuEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
for (i = 4; i < 8; i++)
- glVertex2f(points[i].x, points[i].y);
- glVertex2f(points[0].x, points[0].y);
- glEnd();
+ gpuVertex2f(points[i].x, points[i].y);
+ gpuVertex2f(points[0].x, points[0].y);
+ gpuEnd();
- glRectf(points[2].x, points[2].y, points[8].x, points[8].y);
- glRectf(points[6].x, points[6].y, points[9].x, points[9].y);
+ gpuDrawFilledRectf(points[2].x, points[2].y, points[8].x, points[8].y);
+ gpuDrawFilledRectf(points[6].x, points[6].y, points[9].x, points[9].y);
}
/* draw join shape due to direction of joining */
static void draw_join_shape(ScrArea *sa, char dir)
{
+ gpuImmediateFormat_V2();
+
if (dir == 'u' || dir == 'd')
draw_vertical_join_shape(sa, dir);
else
draw_horizontal_join_shape(sa, dir);
+
+ gpuImmediateUnformat();
}
/* draw screen area darker with arrow (visualization of future joining) */
static void scrarea_draw_shape_dark(ScrArea *sa, char dir)
{
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- glColor4ub(0, 0, 0, 50);
+ gpuCurrentColor4x(CPACK_BLACK, 0.196f);
draw_join_shape(sa, dir);
glDisable(GL_BLEND);
}
@@ -871,33 +876,39 @@ static void scrarea_draw_shape_dark(ScrArea *sa, char dir)
/* draw screen area ligher with arrow shape ("eraser" of previous dark shape) */
static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir))
{
- glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
+ glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); /* non-standard blend function */
glEnable(GL_BLEND);
/* value 181 was hardly computed: 181~105 */
- glColor4ub(255, 255, 255, 50);
+ gpuCurrentColor4x(CPACK_WHITE, 0.196f);
/* draw_join_shape(sa, dir); */
- glRecti(sa->v1->vec.x, sa->v1->vec.y, sa->v3->vec.x, sa->v3->vec.y);
+ gpuSingleFilledRecti(sa->v1->vec.x, sa->v1->vec.y, sa->v3->vec.x, sa->v3->vec.y);
glDisable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
}
static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, short x2, short y2, short a)
{
+ gpuImmediateFormat_V2(); // DOODLE: up to 4 lines, mono
+ gpuBegin(GL_LINES);
+
/* right border area */
if (x2 < sizex - 1)
- sdrawline(x2 + a, y1, x2 + a, y2);
-
+ gpuAppendLinei(x2 + a, y1, x2 + a, y2);
+
/* left border area */
if (x1 > 0) /* otherwise it draws the emboss of window over */
- sdrawline(x1 + a, y1, x1 + a, y2);
-
+ gpuAppendLinei(x1 + a, y1, x1 + a, y2);
+
/* top border area */
if (y2 < sizey - 1)
- sdrawline(x1, y2 + a, x2, y2 + a);
-
+ gpuAppendLinei(x1, y2 + a, x2, y2 + a);
+
/* bottom border area */
if (y1 > 0)
- sdrawline(x1, y1 + a, x2, y1 + a);
-
+ gpuAppendLinei(x1, y1 + a, x2, y1 + a);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
/** screen edges drawing **/
@@ -912,13 +923,13 @@ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center)
rt = 0; // CLAMPIS(G.debug_value, 0, 16);
if (center == 0) {
- cpack(0x505050);
+ gpuCurrentGray3f(0.314f);
for (a = -rt; a <= rt; a++)
if (a != 0)
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, a);
}
else {
- cpack(0x0);
+ gpuCurrentColor3x(CPACK_BLACK);
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
}
}
@@ -1037,19 +1048,26 @@ void ED_screen_draw(wmWindow *win)
/* splitpoint */
if (sa3) {
glEnable(GL_BLEND);
- glColor4ub(255, 255, 255, 100);
-
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: 2 lines, colored
+ gpuBegin(GL_LINES);
+
+ gpuCurrentColor4x(CPACK_WHITE, 0.392f);
+
if (sa3->flag & AREA_FLAG_DRAWSPLIT_H) {
- sdrawline(sa3->totrct.xmin, win->eventstate->y, sa3->totrct.xmax, win->eventstate->y);
- glColor4ub(0, 0, 0, 100);
- sdrawline(sa3->totrct.xmin, win->eventstate->y + 1, sa3->totrct.xmax, win->eventstate->y + 1);
+ gpuAppendLinei(sa3->totrct.xmin, win->eventstate->y, sa3->totrct.xmax, win->eventstate->y);
+ gpuColor4x(CPACK_BLACK, 0.392f);
+ gpuAppendLinei(sa3->totrct.xmin, win->eventstate->y + 1, sa3->totrct.xmax, win->eventstate->y + 1);
}
else {
- sdrawline(win->eventstate->x, sa3->totrct.ymin, win->eventstate->x, sa3->totrct.ymax);
- glColor4ub(0, 0, 0, 100);
- sdrawline(win->eventstate->x + 1, sa3->totrct.ymin, win->eventstate->x + 1, sa3->totrct.ymax);
+ gpuAppendLinei(win->eventstate->x, sa3->totrct.ymin, win->eventstate->x, sa3->totrct.ymax);
+ gpuColor4x(CPACK_BLACK, 0.392f);
+ gpuAppendLinei(win->eventstate->x + 1, sa3->totrct.ymin, win->eventstate->x + 1, sa3->totrct.ymax);
}
-
+
+ gpuEnd();
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index ca85daadf3b..ae5d6ed6152 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -52,7 +52,8 @@
#include "BKE_report.h"
#include "BKE_writeavi.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
+#include "GPU_primitives.h"
#include "BIF_glutil.h"
#include "RNA_access.h"
@@ -410,11 +411,11 @@ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUS
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glColor4ub(0, 0, 0, 32);
- glutil_draw_filled_arc(0.0, M_PI * 2.0, 20, 40);
+ gpuCurrentColor4ub(0, 0, 0, 32);
+ gpuSingleArc(0, 0, 0, 2*M_PI, 20, 20, 40);
- glColor4ub(255, 255, 255, 128);
- glutil_draw_lined_arc(0.0, M_PI * 2.0, 20, 40);
+ gpuCurrentColor4ub(255, 255, 255, 128);
+ gpuSingleArc(0, 0, 0, 2*M_PI, 20, 20, 40);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index ae72dce1415..e00be2902e5 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -56,4 +56,6 @@ set(SRC
sculpt_intern.h
)
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_sculpt_paint "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 5e23a144408..b386d5ff628 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -47,7 +47,8 @@
#include "WM_api.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "ED_view3d.h"
@@ -408,23 +409,23 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
glDepthMask(GL_FALSE);
glDepthFunc(GL_ALWAYS);
- glMatrixMode(GL_TEXTURE);
- glPushMatrix();
- glLoadIdentity();
+ gpuMatrixMode(GL_TEXTURE);
+ gpuPushMatrix();
+ gpuLoadIdentity();
if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
/* brush rotation */
- glTranslatef(0.5, 0.5, 0);
- glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ?
+ gpuTranslate(0.5, 0.5, 0);
+ gpuRotateAxis((double)((brush->flag & BRUSH_RAKE) ?
sd->last_angle : sd->special_rotation),
- 0.0, 0.0, 1.0);
- glTranslatef(-0.5f, -0.5f, 0);
+ 'Z');
+ gpuTranslate(-0.5f, -0.5f, 0);
/* scale based on tablet pressure */
if (sd->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) {
- glTranslatef(0.5f, 0.5f, 0);
- glScalef(1.0f / sd->pressure_value, 1.0f / sd->pressure_value, 1);
- glTranslatef(-0.5f, -0.5f, 0);
+ gpuTranslate(0.5f, 0.5f, 0);
+ gpuScale(1.0f / sd->pressure_value, 1.0f / sd->pressure_value, 1);
+ gpuTranslate(-0.5f, -0.5f, 0);
}
if (sd->draw_anchored) {
@@ -451,24 +452,25 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
}
/* set quad color */
- glColor4f(U.sculpt_paint_overlay_col[0],
- U.sculpt_paint_overlay_col[1],
- U.sculpt_paint_overlay_col[2],
- brush->texture_overlay_alpha / 100.0f);
+ gpuCurrentColor4f(
+ U.sculpt_paint_overlay_col[0],
+ U.sculpt_paint_overlay_col[1],
+ U.sculpt_paint_overlay_col[2],
+ brush->texture_overlay_alpha / 100.0f);
/* draw textured quad */
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0);
- glVertex2f(quad.xmin, quad.ymin);
- glTexCoord2f(1, 0);
- glVertex2f(quad.xmax, quad.ymin);
- glTexCoord2f(1, 1);
- glVertex2f(quad.xmax, quad.ymax);
- glTexCoord2f(0, 1);
- glVertex2f(quad.xmin, quad.ymax);
- glEnd();
-
- glPopMatrix();
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuTexCoord2f(0, 0);
+ gpuVertex2f(quad.xmin, quad.ymin);
+ gpuTexCoord2f(1, 0);
+ gpuVertex2f(quad.xmax, quad.ymin);
+ gpuTexCoord2f(1, 1);
+ gpuVertex2f(quad.xmax, quad.ymax);
+ gpuTexCoord2f(0, 1);
+ gpuVertex2f(quad.xmin, quad.ymax);
+ gpuEnd();
+
+ gpuPopMatrix();
}
glPopAttrib();
@@ -595,12 +597,10 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
glEnable(GL_LINE_SMOOTH);
/* set brush color */
- glColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha);
+ gpuCurrentColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha);
/* draw brush outline */
- glTranslatef(translation[0], translation[1], 0);
- glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius, 40);
- glTranslatef(-translation[0], -translation[1], 0);
+ gpuSingleCircle(translation[0], translation[1], final_radius, 40);
/* restore GL state */
glDisable(GL_BLEND);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 676f033af32..80d49387df7 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -82,7 +82,8 @@
#include "BKE_tessmesh.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "UI_view2d.h"
@@ -5299,7 +5300,7 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
tablet = 0;
pop->s.blend = pop->s.brush->blend;
- if (event->custom == EVT_DATA_TABLET) {
+ if (event->customdatatype == EVT_DATA_TABLET) {
wmtab = event->customdata;
tablet = (wmtab->Active != EVT_TABLET_NONE);
@@ -5471,22 +5472,22 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
alpha *= (pixel_size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
}
- glPushMatrix();
+ gpuPushMatrix();
- glTranslatef((float)x, (float)y, 0.0f);
+ gpuTranslate((float)x, (float)y, 0.0f);
/* No need to scale for uv sculpting, on the contrary it might be useful to keep un-scaled */
if (use_zoom)
- glScalef(zoomx, zoomy, 1.0f);
+ gpuScale(zoomx, zoomy, 1.0f);
- glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha);
+ gpuCurrentColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size, 40);
+ gpuSingleCircle(0, 0, size, 40);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
- glPopMatrix();
+ gpuPopMatrix();
}
#undef PX_SIZE_FADE_MAX
#undef PX_SIZE_FADE_MIN
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 9ebeb61a7bb..0e72aedeb7a 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -49,7 +49,6 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "ED_screen.h"
@@ -57,6 +56,8 @@
#include "paint_intern.h"
+#include "GPU_primitives.h"
+
#include <float.h>
#include <math.h>
@@ -100,22 +101,30 @@ typedef struct PaintStroke {
/*** Cursor ***/
static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata)
{
- Paint *paint = paint_get_active_from_context(C);
- Brush *brush = paint_brush(paint);
PaintStroke *stroke = customdata;
- glColor4ubv(paint->paint_cursor_col);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
+ if (stroke) {
+ Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C)));
- if (stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) {
- ARegion *ar = CTX_wm_region(C);
- sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin,
- (int)stroke->last_mouse_position[1] - ar->winrct.ymin);
- }
+ if (brush && (brush->flag & BRUSH_SMOOTH_STROKE)) {
+ ARegion *ar = CTX_wm_region(C);
+
+ gpuCurrentColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col);
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
+
+ // DOODLE: single line
+ gpuSingleLinei(
+ x,
+ y,
+ (int)stroke->last_mouse_position[0] - ar->winrct.xmin,
+ (int)stroke->last_mouse_position[1] - ar->winrct.ymin);
+
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+ }
+ }
}
/* if this is a tablet event, return tablet pressure and set *pen_flip
@@ -125,7 +134,7 @@ static float event_tablet_data(wmEvent *event, int *pen_flip)
int erasor = 0;
float pressure = 1;
- if (event->custom == EVT_DATA_TABLET) {
+ if (event->customdatatype == EVT_DATA_TABLET) {
wmTabletData *wmtab = event->customdata;
erasor = (wmtab->Active == EVT_TABLET_ERASER);
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index c5eff1a1f0e..ffa5822100a 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -51,10 +51,11 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "BIF_gl.h"
/* TODO: remove once projectf goes away */
#include "BIF_glutil.h"
+#include "GPU_compatibility.h"
+
#include "RE_shader_ext.h"
#include "ED_view3d.h"
@@ -68,6 +69,8 @@
#include "paint_intern.h"
+#include "GPU_compatibility.h"
+
/* Convert the object-space axis-aligned bounding box (expressed as
* its minimum and maximum corners) into a screen-space rectangle,
* returns zero if the result is empty */
@@ -146,12 +149,12 @@ void paint_calc_redraw_planes(float planes[4][4],
* view3d_project_float() */
void projectf(bglMats *mats, const float v[3], float p[2])
{
- double ux, uy, uz;
+ float u[3];
- gluProject(v[0], v[1], v[2], mats->modelview, mats->projection,
- (GLint *)mats->viewport, &ux, &uy, &uz);
- p[0] = ux;
- p[1] = uy;
+ gpuProject(v, mats->modelview, mats->projection,
+ (GLint *)mats->viewport, u);
+ p[0] = u[0];
+ p[1] = u[1];
}
float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
@@ -210,9 +213,9 @@ static void imapaint_tri_weights(Object *ob,
/* compute barycentric coordinates */
/* get the needed opengl matrices */
- glGetIntegerv(GL_VIEWPORT, view);
- glGetFloatv(GL_MODELVIEW_MATRIX, (float *)model);
- glGetFloatv(GL_PROJECTION_MATRIX, (float *)proj);
+ gpuGetSizeBox(GL_VIEWPORT, view);
+ gpuGetMatrix(GL_MODELVIEW_MATRIX, (float *)model);
+ gpuGetMatrix(GL_PROJECTION_MATRIX, (float *)proj);
view[0] = view[1] = 0;
/* project the verts */
diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt
index f53d26d323f..bef98611692 100644
--- a/source/blender/editors/space_action/CMakeLists.txt
+++ b/source/blender/editors/space_action/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -43,4 +44,6 @@ set(SRC
action_intern.h
)
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_action "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 9bd7d2a44ca..3fc504ba02e 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -52,7 +52,8 @@
/* Everything from source (BIF, BDR, BSE) ------------------------------ */
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -244,8 +245,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
case ANIMTYPE_SCENE:
case ANIMTYPE_OBJECT:
{
- if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45);
- else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22);
+ if (sel) gpuCurrentColor4ub(col1b[0], col1b[1], col1b[2], 0x45);
+ else gpuCurrentColor4ub(col1b[0], col1b[1], col1b[2], 0x22);
}
break;
@@ -253,54 +254,66 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
case ANIMTYPE_DSSKEY:
case ANIMTYPE_DSWOR:
{
- if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45);
- else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22);
+ if (sel) gpuCurrentColor4ub(col2b[0], col2b[1], col2b[2], 0x45);
+ else gpuCurrentColor4ub(col2b[0], col2b[1], col2b[2], 0x22);
}
break;
case ANIMTYPE_GROUP:
{
- if (sel) glColor4ub(col1a[0], col1a[1], col1a[2], 0x22);
- else glColor4ub(col2a[0], col2a[1], col2a[2], 0x22);
+ if (sel) gpuCurrentColor4ub(col1a[0], col1a[1], col1a[2], 0x22);
+ else gpuCurrentColor4ub(col2a[0], col2a[1], col2a[2], 0x22);
}
break;
default:
{
- if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22);
- else glColor4ub(col2[0], col2[1], col2[2], 0x22);
+ if (sel) gpuCurrentColor4ub(col1[0], col1[1], col1[2], 0x22);
+ else gpuCurrentColor4ub(col2[0], col2[1], col2[2], 0x22);
}
break;
}
/* draw region twice: firstly backdrop, then the current range */
- glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF);
+ gpuSingleFilledRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF);
if (ac->datatype == ANIMCONT_ACTION)
- glRectf(act_start, (float)y - ACHANNEL_HEIGHT_HALF, act_end, (float)y + ACHANNEL_HEIGHT_HALF);
+ gpuSingleFilledRectf(act_start, (float)y - ACHANNEL_HEIGHT_HALF, act_end, (float)y + ACHANNEL_HEIGHT_HALF);
}
else if (ac->datatype == ANIMCONT_GPENCIL) {
/* frames less than one get less saturated background */
- if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22);
- else glColor4ub(col2[0], col2[1], col2[2], 0x22);
- glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF);
-
+ if (sel)
+ gpuCurrentColor4ub(col1[0], col1[1], col1[2], 0x22);
+ else
+ gpuCurrentColor4ub(col2[0], col2[1], col2[2], 0x22);
+
+ gpuSingleFilledRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF);
+
/* frames one and higher get a saturated background */
- if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44);
- else glColor4ub(col2[0], col2[1], col2[2], 0x44);
- glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF);
+ if (sel)
+ gpuCurrentColor4ub(col1[0], col1[1], col1[2], 0x44);
+ else
+ gpuCurrentColor4ub(col2[0], col2[1], col2[2], 0x44);
+
+ gpuSingleFilledRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF);
}
else if (ac->datatype == ANIMCONT_MASK) {
/* TODO --- this is a copy of gpencil */
/* frames less than one get less saturated background */
- if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22);
- else glColor4ub(col2[0], col2[1], col2[2], 0x22);
- glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF);
+ if (sel)
+ gpuCurrentColor4ub(col1[0], col1[1], col1[2], 0x22);
+ else
+ gpuCurrentColor4ub(col2[0], col2[1], col2[2], 0x22);
+
+ gpuSingleFilledRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF);
/* frames one and higher get a saturated background */
- if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44);
- else glColor4ub(col2[0], col2[1], col2[2], 0x44);
- glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF);
+ if (sel)
+ gpuCurrentColor4ub(col1[0], col1[1], col1[2], 0x44);
+ else
+ gpuCurrentColor4ub(col2[0], col2[1], col2[2], 0x44);
+
+ gpuSingleFilledRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF);
}
}
}
@@ -367,11 +380,11 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* black line marking 'current frame' for Time-Slide transform mode */
if (saction->flag & SACTION_MOVING) {
- glColor3f(0.0f, 0.0f, 0.0f);
-
- glBegin(GL_LINES);
- glVertex2f(saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD);
- glVertex2f(saction->timeslide, v2d->cur.ymax);
- glEnd();
+ gpuCurrentColor3x(CPACK_BLACK);
+
+ gpuBegin(GL_LINES);
+ gpuVertex2f(saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD);
+ gpuVertex2f(saction->timeslide, v2d->cur.ymax);
+ gpuEnd();
}
}
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index c5f3ccee101..812923747d7 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -47,7 +47,7 @@
#include "ED_screen.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -175,7 +175,7 @@ static void action_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
@@ -235,7 +235,7 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt
index 7233d4623d1..7988230c699 100644
--- a/source/blender/editors/space_buttons/CMakeLists.txt
+++ b/source/blender/editors/space_buttons/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -48,4 +49,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_buttons "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 09ad7312123..798fdece79a 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -45,7 +45,7 @@
#include "ED_space_api.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -206,7 +206,7 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar)
{
/* clear */
UI_ThemeClearColor(ED_screen_area_active(C) ? TH_HEADER : TH_HEADERDESEL);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
/* set view2d view matrix for scrolling (without scrollers) */
UI_view2d_view_ortho(&ar->v2d);
diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt
index 75e3d8d5685..7e6c02ca249 100644
--- a/source/blender/editors/space_clip/CMakeLists.txt
+++ b/source/blender/editors/space_clip/CMakeLists.txt
@@ -57,4 +57,6 @@ set(SRC
clip_intern.h
)
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_clip "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index cc1b8d444bc..96e9292c6aa 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -49,7 +49,9 @@
#include "ED_screen.h"
#include "ED_clip.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "WM_types.h"
@@ -89,41 +91,14 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh
{0.0f, -1.0f}, /* bottom vert */
{-1.0f, 0.0f} /* mid-left */
};
- static GLuint displist1 = 0;
- static GLuint displist2 = 0;
- int hsize = STRIP_HEIGHT_HALF;
- /* initialize 2 display lists for diamond shape - one empty, one filled */
- if (displist1 == 0) {
- displist1 = glGenLists(1);
- glNewList(displist1, GL_COMPILE);
-
- glBegin(GL_LINE_LOOP);
- glVertex2fv(_unit_diamond_shape[0]);
- glVertex2fv(_unit_diamond_shape[1]);
- glVertex2fv(_unit_diamond_shape[2]);
- glVertex2fv(_unit_diamond_shape[3]);
- glEnd();
- glEndList();
- }
- if (displist2 == 0) {
- displist2 = glGenLists(1);
- glNewList(displist2, GL_COMPILE);
-
- glBegin(GL_QUADS);
- glVertex2fv(_unit_diamond_shape[0]);
- glVertex2fv(_unit_diamond_shape[1]);
- glVertex2fv(_unit_diamond_shape[2]);
- glVertex2fv(_unit_diamond_shape[3]);
- glEnd();
- glEndList();
- }
+ int hsize = STRIP_HEIGHT_HALF;
- glPushMatrix();
+ gpuPushMatrix();
/* adjust view transform before starting */
- glTranslatef(x, y, 0.0f);
- glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
+ gpuTranslate(x, y, 0.0f);
+ gpuScale(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
/* anti-aliased lines for more consistent appearance */
glEnable(GL_LINE_SMOOTH);
@@ -131,18 +106,28 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh
if (sel)
UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha));
else
- glColor4f(0.91f, 0.91f, 0.91f, alpha);
+ gpuCurrentGray4f(0.910f, alpha);
- glCallList(displist2);
+ gpuBegin(GL_QUADS);
+ gpuVertex2fv(_unit_diamond_shape[0]);
+ gpuVertex2fv(_unit_diamond_shape[1]);
+ gpuVertex2fv(_unit_diamond_shape[2]);
+ gpuVertex2fv(_unit_diamond_shape[3]);
+ gpuEnd();
/* exterior - black frame */
- glColor4f(0.0f, 0.0f, 0.0f, alpha);
- glCallList(displist1);
+ gpuCurrentColor4x(CPACK_BLACK, alpha);
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2fv(_unit_diamond_shape[0]);
+ gpuVertex2fv(_unit_diamond_shape[1]);
+ gpuVertex2fv(_unit_diamond_shape[2]);
+ gpuVertex2fv(_unit_diamond_shape[3]);
+ gpuEnd();
glDisable(GL_LINE_SMOOTH);
/* restore view transform */
- glPopMatrix();
+ gpuPopMatrix();
}
void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
@@ -197,9 +182,9 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
float default_color[4] = {0.8f, 0.93f, 0.8f, 0.3f};
track_channel_color(track, default_color, color);
- glColor4fv(color);
+ gpuCurrentColor4fv(color);
- glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
+ gpuSingleFilledRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF);
}
@@ -211,12 +196,12 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i + 1]);
if (sel)
- glColor4fv(selected_strip);
+ gpuCurrentColor4fv(selected_strip);
else
- glColor4fv(strip);
+ gpuCurrentColor4fv(strip);
if (start_frame != end_frame) {
- glRectf(start_frame, (float) y - STRIP_HEIGHT_HALF,
+ gpuSingleFilledRectf(start_frame, (float) y - STRIP_HEIGHT_HALF,
end_frame, (float) y + STRIP_HEIGHT_HALF);
draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha);
draw_keyframe_shape(end_frame, y, xscale, yscale, sel, alpha);
@@ -304,9 +289,9 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
int sel = track->flag & TRACK_DOPE_SEL;
track_channel_color(track, NULL, color);
- glColor3fv(color);
+ gpuCurrentColor3fv(color);
- glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
+ gpuSingleFilledRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF,
v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF);
if (sel)
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 9cf389c4508..a7ba2b7dbdb 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -57,7 +57,9 @@
#include "ED_mask.h"
#include "ED_gpencil.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "WM_api.h"
@@ -88,7 +90,7 @@ void clip_draw_curfra_label(const int framenr, const float x, const float y)
BLF_width_and_height(fontid, 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);
@@ -101,13 +103,13 @@ static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int wid
int x = (frame - sfra) * framelen;
if (width == 1) {
- glBegin(GL_LINES);
- glVertex2i(x, 0);
- glVertex2i(x, height);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2i(x, 0);
+ gpuVertex2i(x, height);
+ gpuEnd();
}
else {
- glRecti(x, 0, x + width, height);
+ gpuDrawFilledRecti(x, 0, x + width, height);
}
}
@@ -124,13 +126,13 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
glEnable(GL_BLEND);
/* cache background */
- glColor4ub(128, 128, 255, 64);
- glRecti(0, 0, ar->winx, 8);
+ gpuCurrentColor4ub(128, 128, 255, 64);
+ gpuSingleFilledRecti(0, 0, ar->winx, 8);
/* cached segments -- could be usefu lto debug caching strategies */
BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points);
if (totseg) {
- glColor4ub(128, 128, 255, 128);
+ gpuCurrentColor4ub(128, 128, 255, 128);
for (a = 0; a < totseg; a++) {
float x1, x2;
@@ -138,7 +140,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
x1 = (points[a * 2] - sfra) / (efra - sfra + 1) * ar->winx;
x2 = (points[a * 2 + 1] - sfra + 1) / (efra - sfra + 1) * ar->winx;
- glRecti(x1, 0, x2, 8);
+ gpuSingleFilledRecti(x1, 0, x2, 8);
}
}
@@ -169,13 +171,13 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
framenr = marker->framenr;
if (framenr != i)
- glColor4ub(128, 128, 0, 96);
+ gpuCurrentColor4ub(128, 128, 0, 96);
else if ((marker->flag & MARKER_TRACKED) == 0)
- glColor4ub(255, 255, 0, 196);
+ gpuCurrentColor4x(CPACK_YELLOW, 0.769f);
else
- glColor4ub(255, 255, 0, 96);
+ gpuCurrentColor4x(CPACK_YELLOW, 0.376f);
- glRecti((i - sfra + clip->start_frame - 1) * framelen, 0, (i - sfra + clip->start_frame) * framelen, 4);
+ gpuSingleFilledRecti((i - sfra + clip->start_frame - 1) * framelen, 0, (i - sfra + clip->start_frame) * framelen, 4);
}
}
}
@@ -185,7 +187,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
int n = reconstruction->camnr;
MovieReconstructedCamera *cameras = reconstruction->cameras;
- glColor4ub(255, 0, 0, 96);
+ gpuCurrentColor4x(CPACK_RED, 0.376f);
for (i = sfra, a = 0; i <= efra; i++) {
int ok = FALSE;
@@ -203,7 +205,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
}
if (!ok)
- glRecti((i - sfra + clip->start_frame - 1) * framelen, 0, (i - sfra + clip->start_frame) * framelen, 8);
+ gpuSingleFilledRecti((i - sfra + clip->start_frame - 1) * framelen, 0, (i - sfra + clip->start_frame) * framelen, 8);
}
}
@@ -213,14 +215,16 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx;
UI_ThemeColor(TH_CFRAME);
- glRecti(x, 0, x + ceilf(framelen), 8);
+ gpuSingleFilledRecti(x, 0, x + ceilf(framelen), 8);
clip_draw_curfra_label(sc->user.framenr, x, 8.0f);
/* solver keyframes */
- glColor4ub(175, 255, 0, 255);
+ gpuCurrentColor4ub(175, 255, 0, 255);
+ gpuImmediateFormat_V2();
draw_keyframe(act_object->keyframe1 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
draw_keyframe(act_object->keyframe2 + clip->start_frame - 1, CFRA, sfra, framelen, 2);
+ gpuImmediateUnformat();
/* movie clip animation */
if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
@@ -257,8 +261,8 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
if (sc->flag & SC_MUTE_FOOTAGE) {
- glColor3f(0.0f, 0.0f, 0.0f);
- glRectf(x, y, x + zoomx * width, y + zoomy * height);
+ gpuCurrentColor3x(CPACK_BLACK);
+ gpuSingleFilledRectf(x, y, x + zoomx * width, y + zoomy * height);
}
else {
unsigned char *display_buffer;
@@ -271,18 +275,27 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
if (ED_space_clip_texture_buffer_supported(sc)) {
if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) {
- glPushMatrix();
- glTranslatef(x, y, 0.0f);
- glScalef(zoomx, zoomy, 1.0f);
-
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex2f(width, 0.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex2f(width, height);
- glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, height);
- glEnd();
-
- glPopMatrix();
+ gpuPushMatrix();
+ gpuTranslate(x, y, 0.0f);
+ gpuScale(zoomx, zoomy, 1.0f);
+
+ gpuBegin(GL_TRIANGLE_FAN);
+
+ gpuTexCoord2f(0, 0);
+ gpuVertex2f(0, 0);
+
+ gpuTexCoord2f(1, 0);
+ gpuVertex2f(width, 0);
+
+ gpuTexCoord2f(1, 1);
+ gpuVertex2f(width, height);
+
+ gpuTexCoord2f(0, 1);
+ gpuVertex2f(0, height);
+
+ gpuEnd();
+
+ gpuPopMatrix();
ED_space_clip_unload_movieclip_buffer(sc);
@@ -317,26 +330,27 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
/* draw boundary border for frame if stabilization is enabled */
if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
- glColor3f(0.0f, 0.0f, 0.0f);
+ gpuCurrentColor3x(CPACK_BLACK);
+
glLineStipple(3, 0xaaaa);
glEnable(GL_LINE_STIPPLE);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_NOR);
- glPushMatrix();
- glTranslatef(x, y, 0.0f);
+ gpuPushMatrix();
+ gpuTranslate(x, y, 0.0f);
- glScalef(zoomx, zoomy, 1.0f);
- glMultMatrixf(sc->stabmat);
+ gpuScale(zoomx, zoomy, 1.0f);
+ gpuMultMatrix(sc->stabmat);
- glBegin(GL_LINE_LOOP);
- glVertex2f(0.0f, 0.0f);
- glVertex2f(width, 0.0f);
- glVertex2f(width, height);
- glVertex2f(0.0f, height);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(0, 0);
+ gpuVertex2f(width, 0);
+ gpuVertex2f(width, height);
+ gpuVertex2f(0, height);
+ gpuEnd();
- glPopMatrix();
+ gpuPopMatrix();
glDisable(GL_COLOR_LOGIC_OP);
glDisable(GL_LINE_STIPPLE);
@@ -408,19 +422,21 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if (TRACK_VIEW_SELECTED(sc, track)) {
glPointSize(5.0f);
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
for (i = a; i < b; i++) {
- if (i != curindex)
- glVertex2f(path[i][0], path[i][1]);
+ if (i != curindex) {
+ gpuVertex2f(path[i][0], path[i][1]);
+ }
}
- glEnd();
+ gpuEnd();
}
glLineWidth(3.0f);
- glBegin(GL_LINE_STRIP);
- for (i = a; i < b; i++)
- glVertex2f(path[i][0], path[i][1]);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ for (i = a; i < b; i++) {
+ gpuVertex2f(path[i][0], path[i][1]);
+ }
+ gpuEnd();
glLineWidth(1.0f);
}
@@ -428,27 +444,30 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
if (TRACK_VIEW_SELECTED(sc, track)) {
glPointSize(3.0f);
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
for (i = a; i < b; i++) {
- if (i == count + 1)
+ if (i == count + 1) {
UI_ThemeColor(TH_PATH_AFTER);
+ }
- if (i != curindex)
- glVertex2f(path[i][0], path[i][1]);
+ if (i != curindex) {
+ gpuVertex2f(path[i][0], path[i][1]);
+ }
}
- glEnd();
+ gpuEnd();
}
UI_ThemeColor(TH_PATH_BEFORE);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = a; i < b; i++) {
- if (i == count + 1)
+ if (i == count + 1) {
UI_ThemeColor(TH_PATH_AFTER);
+ }
- glVertex2f(path[i][0], path[i][1]);
+ gpuVertex2f(path[i][0], path[i][1]);
}
- glEnd();
+ gpuEnd();
glPointSize(1.0f);
}
@@ -477,59 +496,73 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1],
marker->pattern_corners[2], marker->pattern_corners[3]))
{
- if (tiny) glPointSize(3.0f);
- else glPointSize(4.0f);
- glBegin(GL_POINTS);
- glVertex2f(pos[0], pos[1]);
- glEnd();
+ if (tiny) {
+ glPointSize(3.0f);
+ }
+ else {
+ glPointSize(4.0f);
+ }
+
+ gpuBegin(GL_POINTS);
+ gpuVertex2f(pos[0], pos[1]);
+ gpuEnd();
+
glPointSize(1.0f);
}
else {
- if (!tiny) glLineWidth(3.0f);
- glBegin(GL_LINES);
- glVertex2f(pos[0] + px[0] * 2, pos[1]);
- glVertex2f(pos[0] + px[0] * 8, pos[1]);
-
- glVertex2f(pos[0] - px[0] * 2, pos[1]);
- glVertex2f(pos[0] - px[0] * 8, pos[1]);
-
- glVertex2f(pos[0], pos[1] - px[1] * 2);
- glVertex2f(pos[0], pos[1] - px[1] * 8);
-
- glVertex2f(pos[0], pos[1] + px[1] * 2);
- glVertex2f(pos[0], pos[1] + px[1] * 8);
- glEnd();
- if (!tiny) glLineWidth(1.0f);
+ if (!tiny) {
+ glLineWidth(3.0f);
+ }
+
+ gpuBegin(GL_LINES);
+
+ gpuVertex2f(pos[0] + px[0]*2, pos[1]);
+ gpuVertex2f(pos[0] + px[0]*8, pos[1]);
+
+ gpuVertex2f(pos[0] - px[0]*2, pos[1]);
+ gpuVertex2f(pos[0] - px[0]*8, pos[1]);
+
+ gpuVertex2f(pos[0], pos[1] - px[1]*2);
+ gpuVertex2f(pos[0], pos[1] - px[1]*8);
+
+ gpuVertex2f(pos[0], pos[1] + px[1]*2);
+ gpuVertex2f(pos[0], pos[1] + px[1]*8);
+
+ gpuEnd();
+
+ if (!tiny) {
+ glLineWidth(1.0f);
+ }
}
}
/* pattern and search outline */
- glPushMatrix();
- glTranslatef(marker_pos[0], marker_pos[1], 0);
+ gpuPushMatrix();
+ gpuTranslate(marker_pos[0], marker_pos[1], 0);
if (!tiny)
glLineWidth(3.0f);
if (sc->flag & SC_SHOW_MARKER_PATTERN) {
- glBegin(GL_LINE_LOOP);
- glVertex2fv(marker->pattern_corners[0]);
- glVertex2fv(marker->pattern_corners[1]);
- glVertex2fv(marker->pattern_corners[2]);
- glVertex2fv(marker->pattern_corners[3]);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2fv(marker->pattern_corners[0]);
+ gpuVertex2fv(marker->pattern_corners[1]);
+ gpuVertex2fv(marker->pattern_corners[2]);
+ gpuVertex2fv(marker->pattern_corners[3]);
+ gpuEnd();
}
show_search = TRACK_VIEW_SELECTED(sc, track) &&
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0);
if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {
- glBegin(GL_LINE_LOOP);
- glVertex2f(marker->search_min[0], marker->search_min[1]);
- glVertex2f(marker->search_max[0], marker->search_min[1]);
- glVertex2f(marker->search_max[0], marker->search_max[1]);
- glVertex2f(marker->search_min[0], marker->search_max[1]);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(marker->search_min[0], marker->search_min[1]);
+ gpuVertex2f(marker->search_max[0], marker->search_min[1]);
+ gpuVertex2f(marker->search_max[0], marker->search_max[1]);
+ gpuVertex2f(marker->search_min[0], marker->search_max[1]);
+ gpuEnd();
}
- glPopMatrix();
+ gpuPopMatrix();
if (!tiny)
glLineWidth(1.0f);
@@ -581,9 +614,9 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
else {
if (track->flag & SELECT)
- glColor3fv(scol);
+ gpuCurrentColor3fv(scol);
else
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
}
add_v2_v2v2(pos, marker->pos, track->offset);
@@ -597,38 +630,42 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
if (!tiny)
glPointSize(2.0f);
- glBegin(GL_POINTS);
- glVertex2f(pos[0], pos[1]);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex2f(pos[0], pos[1]);
+ gpuEnd();
if (!tiny)
glPointSize(1.0f);
}
else {
- glBegin(GL_LINES);
- glVertex2f(pos[0] + px[0] * 3, pos[1]);
- glVertex2f(pos[0] + px[0] * 7, pos[1]);
+ gpuBegin(GL_LINES);
+
+ gpuVertex2f(pos[0] + 3*px[0], pos[1]);
+ gpuVertex2f(pos[0] + 7*px[0], pos[1]);
+
+ gpuVertex2f(pos[0] - 3*px[0], pos[1]);
+ gpuVertex2f(pos[0] - 7*px[0], pos[1]);
- glVertex2f(pos[0] - px[0] * 3, pos[1]);
- glVertex2f(pos[0] - px[0] * 7, pos[1]);
+ gpuVertex2f(pos[0], pos[1] - 3*px[1]);
+ gpuVertex2f(pos[0], pos[1] - 7*px[1]);
- glVertex2f(pos[0], pos[1] - px[1] * 3);
- glVertex2f(pos[0], pos[1] - px[1] * 7);
+ gpuVertex2f(pos[0], pos[1] + 3*px[1]);
+ gpuVertex2f(pos[0], pos[1] + 7*px[1]);
+
+ gpuEnd();
- glVertex2f(pos[0], pos[1] + px[1] * 3);
- glVertex2f(pos[0], pos[1] + px[1] * 7);
- glEnd();
+ gpuCurrentColor3x(CPACK_BLACK);
- glColor3f(0.0f, 0.0f, 0.0f);
- glLineStipple(3, 0xaaaa);
glEnable(GL_LINE_STIPPLE);
+ glLineStipple(3, 0xAAAA);
+
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_NOR);
- glBegin(GL_LINES);
- glVertex2fv(pos);
- glVertex2fv(marker_pos);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2fv(pos);
+ gpuVertex2fv(marker_pos);
+ gpuEnd();
glDisable(GL_COLOR_LOGIC_OP);
glDisable(GL_LINE_STIPPLE);
@@ -636,8 +673,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
/* pattern */
- glPushMatrix();
- glTranslatef(marker_pos[0], marker_pos[1], 0);
+ gpuPushMatrix();
+ gpuTranslate(marker_pos[0], marker_pos[1], 0);
if (tiny) {
glLineStipple(3, 0xaaaa);
@@ -661,16 +698,16 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
else {
if (track->pat_flag & SELECT)
- glColor3fv(scol);
- else glColor3fv(col);
+ gpuCurrentColor3fv(scol);
+ else gpuCurrentColor3fv(col);
}
- glBegin(GL_LINE_LOOP);
- glVertex2fv(marker->pattern_corners[0]);
- glVertex2fv(marker->pattern_corners[1]);
- glVertex2fv(marker->pattern_corners[2]);
- glVertex2fv(marker->pattern_corners[3]);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2fv(marker->pattern_corners[0]);
+ gpuVertex2fv(marker->pattern_corners[1]);
+ gpuVertex2fv(marker->pattern_corners[2]);
+ gpuVertex2fv(marker->pattern_corners[3]);
+ gpuEnd();
}
/* search */
@@ -693,23 +730,23 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
}
else {
if (track->search_flag & SELECT)
- glColor3fv(scol);
+ gpuCurrentColor3fv(scol);
else
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
}
- glBegin(GL_LINE_LOOP);
- glVertex2f(marker->search_min[0], marker->search_min[1]);
- glVertex2f(marker->search_max[0], marker->search_min[1]);
- glVertex2f(marker->search_max[0], marker->search_max[1]);
- glVertex2f(marker->search_min[0], marker->search_max[1]);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(marker->search_min[0], marker->search_min[1]);
+ gpuVertex2f(marker->search_max[0], marker->search_min[1]);
+ gpuVertex2f(marker->search_max[0], marker->search_max[1]);
+ gpuVertex2f(marker->search_min[0], marker->search_max[1]);
+ gpuEnd();
}
if (tiny)
glDisable(GL_LINE_STIPPLE);
- glPopMatrix();
+ gpuPopMatrix();
}
static float get_shortest_pattern_side(MovieTrackingMarker *marker)
@@ -742,12 +779,12 @@ static void draw_marker_slide_square(float x, float y, float dx, float dy, int o
tdy += px[1];
}
- glBegin(GL_QUADS);
- glVertex3f(x - tdx, y + tdy, 0.0f);
- glVertex3f(x + tdx, y + tdy, 0.0f);
- glVertex3f(x + tdx, y - tdy, 0.0f);
- glVertex3f(x - tdx, y - tdy, 0.0f);
- glEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuVertex3f(x - tdx, y + tdy, 0.0f);
+ gpuVertex3f(x + tdx, y + tdy, 0.0f);
+ gpuVertex3f(x + tdx, y - tdy, 0.0f);
+ gpuVertex3f(x - tdx, y - tdy, 0.0f);
+ gpuEnd();
}
static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int outline, float px[2])
@@ -762,11 +799,11 @@ static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int
tdy += px[1];
}
- glBegin(GL_TRIANGLES);
- glVertex3f(x, y, 0.0f);
- glVertex3f(x - tdx, y, 0.0f);
- glVertex3f(x, y + tdy, 0.0f);
- glEnd();
+ gpuBegin(GL_TRIANGLES);
+ gpuVertex3f(x, y, 0.0f);
+ gpuVertex3f(x - tdx, y, 0.0f);
+ gpuVertex3f(x, y + tdy, 0.0f);
+ gpuEnd();
}
static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
@@ -789,8 +826,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
UI_ThemeColor(TH_MARKER_OUTLINE);
}
- glPushMatrix();
- glTranslatef(marker_pos[0], marker_pos[1], 0);
+ gpuPushMatrix();
+ gpuTranslate(marker_pos[0], marker_pos[1], 0);
dx = 6.0f / width / sc->zoom;
dy = 6.0f / height / sc->zoom;
@@ -808,9 +845,9 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
if ((sc->flag & SC_SHOW_MARKER_SEARCH) && ((track->search_flag & SELECT) == sel || outline)) {
if (!outline) {
if (track->search_flag & SELECT)
- glColor3fv(scol);
+ gpuCurrentColor3fv(scol);
else
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
}
/* search offset square */
@@ -828,9 +865,9 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
if (!outline) {
if (track->pat_flag & SELECT)
- glColor3fv(scol);
+ gpuCurrentColor3fv(scol);
else
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
}
/* pattern's corners sliding squares */
@@ -845,17 +882,16 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
glEnable(GL_LINE_STIPPLE);
- glLineStipple(3, 0xaaaa);
+ glLineStipple(3, 0xAAAA);
#if 0
/* TODO: disable for now, needs better approach visualizing this */
- glBegin(GL_LINE_LOOP);
- glVertex2f(pat_min[0] - dx, pat_min[1] - dy);
- glVertex2f(pat_max[0] + dx, pat_min[1] - dy);
- glVertex2f(pat_max[0] + dx, pat_max[1] + dy);
- glVertex2f(pat_min[0] - dx, pat_max[1] + dy);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(pat_min[0] - dx, pat_min[1] - dy);
+ gpuVertex2f(pat_max[0] + dx, pat_min[1] - dy);
+ gpuVertex2f(pat_max[0] + dx, pat_max[1] + dy);
+ gpuVertex2f(pat_min[0] - dx, pat_max[1] + dy);
/* marker's offset slider */
draw_marker_slide_square(pat_min[0] - dx, pat_max[1] + dy, patdx, patdy, outline, px);
@@ -864,10 +900,10 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
draw_marker_slide_triangle(pat_max[0] + dx, pat_min[1] - dy, patdx, patdy, outline, px);
#endif
- glBegin(GL_LINES);
- glVertex2f(0.0f, 0.0f);
- glVertex2fv(tilt_ctrl);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(0.0f, 0.0f);
+ gpuVertex2fv(tilt_ctrl);
+ gpuEnd();
glDisable(GL_LINE_STIPPLE);
@@ -876,7 +912,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px);
}
- glPopMatrix();
+ gpuPopMatrix();
if (outline)
glLineWidth(1.0f);
@@ -995,13 +1031,13 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y);
- glPushMatrix();
- glTranslatef(x, y, 0);
+ gpuPushMatrix();
+ gpuTranslate(x, y, 0);
- glPushMatrix();
- glScalef(zoomx, zoomy, 0);
- glMultMatrixf(sc->stabmat);
- glScalef(width, height, 0);
+ gpuPushMatrix();
+ gpuScale(zoomx, zoomy, 0);
+ gpuMultMatrix(sc->stabmat);
+ gpuScale(width, height, 0);
act_track = BKE_tracking_track_get_active(tracking);
@@ -1152,16 +1188,18 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
sub_v2_v2(vec, npos);
if (len_v2(vec) < 3.0f)
- glColor3f(0.0f, 1.0f, 0.0f);
+ gpuCurrentColor3x(CPACK_GREEN);
else
- glColor3f(1.0f, 0.0f, 0.0f);
+ gpuCurrentColor3x(CPACK_RED);
+
+ gpuBegin(GL_POINTS);
- glBegin(GL_POINTS);
if (undistort)
- glVertex3f(pos[0] / width, pos[1] / (height * aspy), 0);
+ gpuVertex3f(pos[0] / width, pos[1] / (height * aspy), 0);
else
- glVertex3f(npos[0] / width, npos[1] / (height * aspy), 0);
- glEnd();
+ gpuVertex3f(npos[0] / width, npos[1] / (height * aspy), 0);
+
+ gpuEnd();
}
}
}
@@ -1173,7 +1211,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
glDisable(GL_POINT_SMOOTH);
}
- glPopMatrix();
+ gpuPopMatrix();
if (sc->flag & SC_SHOW_NAMES) {
/* scaling should be cleared before drawing texts, otherwise font would also be scaled */
@@ -1199,7 +1237,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
}
}
- glPopMatrix();
+ gpuPopMatrix();
if (marker_pos)
MEM_freeN(marker_pos);
@@ -1229,11 +1267,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y);
- glPushMatrix();
- glTranslatef(x, y, 0);
- glScalef(zoomx, zoomy, 0);
- glMultMatrixf(sc->stabmat);
- glScalef(width, height, 0);
+ gpuPushMatrix();
+ gpuTranslate(x, y, 0);
+ gpuScale(zoomx, zoomy, 0);
+ gpuMultMatrix(sc->stabmat);
+ gpuScale(width, height, 0);
/* grid */
if (sc->flag & SC_SHOW_GRID) {
@@ -1305,22 +1343,22 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
pos[1] += dy;
}
- glColor3f(1.0f, 0.0f, 0.0f);
+ gpuCurrentColor3x(CPACK_RED);
for (i = 0; i <= n; i++) {
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (j = 0; j <= n; j++) {
- glVertex2fv(grid[i][j]);
+ gpuVertex2fv(grid[i][j]);
}
- glEnd();
+ gpuEnd();
}
for (j = 0; j <= n; j++) {
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0; i <= n; i++) {
- glVertex2fv(grid[i][j]);
+ gpuVertex2fv(grid[i][j]);
}
- glEnd();
+ gpuEnd();
}
}
@@ -1353,7 +1391,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
continue;
}
- glColor4fv(layer->color);
+ gpuCurrentColor4fv(layer->color);
glLineWidth(layer->thickness);
glPointSize((float)(layer->thickness + 2));
@@ -1363,7 +1401,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
while (stroke) {
if (stroke->flag & GP_STROKE_2DSPACE) {
if (stroke->totpoints > 1) {
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0; i < stroke->totpoints - 1; i++) {
float npos[2], dpos[2], len;
int steps;
@@ -1388,17 +1426,17 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
for (j = 0; j <= steps; j++) {
BKE_tracking_distort_v2(tracking, pos, tpos);
- glVertex2f(tpos[0] / width, tpos[1] / (height * aspy));
+ gpuVertex2f(tpos[0] / width, tpos[1] / (height*aspy));
add_v2_v2(pos, dpos);
}
}
- glEnd();
+ gpuEnd();
}
else if (stroke->totpoints == 1) {
- glBegin(GL_POINTS);
- glVertex2f(stroke->points[0].x + offsx, stroke->points[0].y + offsy);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex2f(stroke->points[0].x + offsx, stroke->points[0].y + offsy);
+ gpuEnd();
}
}
@@ -1415,7 +1453,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
glPointSize(1.0f);
}
- glPopMatrix();
+ gpuPopMatrix();
}
void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
@@ -1499,8 +1537,8 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
/* if manual calibration is used then grease pencil data is already
* drawn in draw_distortion */
if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || sc->mode != SC_MODE_DISTORTION) {
- glPushMatrix();
- glMultMatrixf(sc->unistabmat);
+ gpuPushMatrix();
+ gpuMultMatrix(sc->unistabmat);
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking);
@@ -1509,13 +1547,13 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
int framenr = ED_space_clip_get_clip_frame_number(sc);
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
- glTranslatef(marker->pos[0], marker->pos[1], 0.0f);
+ gpuTranslate(marker->pos[0], marker->pos[1], 0.0f);
}
}
draw_gpencil_2dimage(C);
- glPopMatrix();
+ gpuPopMatrix();
}
}
else {
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 1a62af39600..ac6bb785e72 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -47,6 +47,7 @@
#include "BLI_string.h"
#include "BLI_rect.h"
+#include "GPU_compatibility.h"
#include "GPU_extensions.h"
#include "IMB_imbuf_types.h"
@@ -55,7 +56,6 @@
#include "ED_screen.h"
#include "ED_clip.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "WM_api.h"
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 7b070fde6ba..cab23be85d5 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -46,7 +46,9 @@
#include "ED_screen.h"
#include "ED_clip.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "WM_types.h"
@@ -61,37 +63,20 @@
static void draw_curve_knot(float x, float y, float xscale, float yscale, float hsize)
{
- static GLuint displist = 0;
-
- /* initialize round circle shape */
- if (displist == 0) {
- GLUquadricObj *qobj;
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
- gluDisk(qobj, 0, 0.7, 8, 1);
- gluDeleteQuadric(qobj);
-
- glEndList();
- }
-
- glPushMatrix();
+ gpuPushMatrix();
+ gpuTranslate(x, y, 0.0f);
+ gpuScale(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
- glTranslatef(x, y, 0.0f);
- glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
- glCallList(displist);
+ gpuSingleCircle(0, 0, 0.7, 8);
- glPopMatrix();
+ gpuPopMatrix();
}
static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack *UNUSED(track),
MovieTrackingMarker *UNUSED(marker), int UNUSED(coord),
int scene_framenr, float val)
{
- glVertex2f(scene_framenr, val);
+ gpuVertex2f(scene_framenr, val);
}
static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
@@ -111,14 +96,14 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track,
glLineWidth(1.0f);
}
- glColor4fv(col);
+ gpuCurrentColor4fv(col);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
}
static void tracking_segment_end_cb(void *UNUSED(userdata))
{
- glEnd();
+ gpuEnd();
glLineWidth(1.0f);
}
@@ -186,30 +171,30 @@ static void draw_frame_curves(SpaceClip *sc)
MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking);
int i, lines = 0, prevfra = 0;
- glColor3f(0.0f, 0.0f, 1.0f);
+ gpuColor3x(CPACK_BLUE);
for (i = 0; i < reconstruction->camnr; i++) {
MovieReconstructedCamera *camera = &reconstruction->cameras[i];
int framenr;
if (lines && camera->framenr != prevfra + 1) {
- glEnd();
+ gpuEnd();
lines = 0;
}
if (!lines) {
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
lines = 1;
}
framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, camera->framenr);
- glVertex2f(framenr, camera->error);
+ gpuVertex2f(framenr, camera->error);
prevfra = camera->framenr;
}
if (lines)
- glEnd();
+ gpuEnd();
}
void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index d7a9b1c0cb6..fb0a352a8e0 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -43,7 +43,9 @@
#include "BKE_tracking.h"
#include "BKE_depsgraph.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "WM_api.h"
@@ -241,21 +243,15 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
{
View2D *v2d = &ar->v2d;
float xscale, yscale;
- float vec[2];
+ float c;
/* Draw a light green line to indicate current frame */
- vec[0] = (float)(sc->user.framenr * scene->r.framelen);
+ c = (float)(sc->user.framenr * scene->r.framelen);
UI_ThemeColor(TH_CFRAME);
glLineWidth(2.0);
- glBegin(GL_LINE_STRIP);
- vec[1] = v2d->cur.ymin;
- glVertex2fv(vec);
-
- vec[1] = v2d->cur.ymax;
- glVertex2fv(vec);
- glEnd();
+ gpuSingleLinef(c, v2d->cur.ymin, c, v2d->cur.ymax);
glLineWidth(1.0);
@@ -263,12 +259,12 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
/* because the frame number text is subject to the same scaling as the contents of the view */
UI_view2d_getscale(v2d, &xscale, &yscale);
- glScalef(1.0f / xscale, 1.0f, 1.0f);
+ gpuScale(1.0f / xscale, 1.0f, 1.0f);
clip_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18);
/* restore view transform */
- glScalef(xscale, 1.0, 1.0);
+ gpuScale(xscale, 1.0, 1.0);
}
void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
@@ -276,17 +272,23 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
UI_view2d_view_ortho(v2d);
/* currently clip editor supposes that editing clip length is equal to scene frame range */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
glEnable(GL_BLEND);
- glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+
+ gpuCurrentColor4x(CPACK_BLACK, 0.400f);
+
+ gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+ gpuSingleFilledRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
- glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
glDisable(GL_BLEND);
UI_ThemeColorShade(TH_BACK, -60);
/* thin lines where the actual frames are */
- fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
- fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
+ gpuImmediateFormat_V2(); // DOODLE: pair of mono lines
+ gpuBegin(GL_LINES);
+ gpuAppendLinef((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+ gpuAppendLinef((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
+ gpuEnd();
+ gpuImmediateUnformat();
}
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 77e2a1bb3d3..5f0e4db9dd7 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -59,7 +59,7 @@
#include "IMB_imbuf.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -70,6 +70,8 @@
#include "RNA_access.h"
+#include "GPU_compatibility.h"
+
#include "clip_intern.h" /* own include */
@@ -1119,7 +1121,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
/* data... */
movieclip_main_area_set_view2d(C, ar);
@@ -1196,7 +1198,7 @@ static void graph_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
@@ -1229,7 +1231,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
@@ -1290,7 +1292,7 @@ static void clip_channels_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index b8e162bfb17..1d4262270f5 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -468,7 +468,7 @@ static int do_lasso_select_marker(bContext *C, const int mcords[][2], const shor
static int clip_lasso_select_exec(bContext *C, wmOperator *op)
{
int mcords_tot;
- const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
+ int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
short select;
diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt
index 2f1c3f4a244..0f90841ba12 100644
--- a/source/blender/editors/space_console/CMakeLists.txt
+++ b/source/blender/editors/space_console/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -46,4 +47,6 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_console "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index f19835b7f85..93c6ce472f8 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -41,10 +41,10 @@
#include "BKE_report.h"
-
#include "MEM_guardedalloc.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "ED_datafiles.h"
@@ -179,9 +179,9 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
/* cursor */
UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, fg);
- glColor3ubv(fg);
+ gpuCurrentColor3ubv(fg);
- glRecti((xy[0] + pen[0]) - 1,
+ gpuSingleFilledRecti((xy[0] + pen[0]) - 1,
(xy[1] + pen[1]),
(xy[0] + pen[0]) + 1,
(xy[1] + pen[1] + tvc->lheight)
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 75add570708..4fc9b281854 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -44,7 +44,7 @@
#include "ED_space_api.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "RNA_access.h"
@@ -221,7 +221,7 @@ static void console_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
/* worlks best with no view2d matrix set */
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt
index 98e147413ff..4905701dc31 100644
--- a/source/blender/editors/space_file/CMakeLists.txt
+++ b/source/blender/editors/space_file/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
../../blenlib
../../blenloader
../../imbuf
+ ../../gpu
../../makesdna
../../makesrna
../../render/extern/include
@@ -82,4 +83,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_file "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index fb438ae45fb..8ad1dc23254 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -40,7 +40,9 @@
# include "BLI_winstuff.h"
#endif
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "BKE_context.h"
@@ -361,9 +363,7 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int
dy = (fy + 0.5f - layout->prv_border_y);
xco = sx + (int)dx;
yco = sy - layout->prv_h + (int)dy;
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+
/* shadow */
if (dropshadow)
uiDrawBoxShadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
@@ -371,13 +371,13 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int
glEnable(GL_BLEND);
/* the image */
- glColor4f(1.0, 1.0, 1.0, 1.0);
+ gpuCurrentColor3x(CPACK_WHITE);
glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale);
/* border */
if (dropshadow) {
- glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
- fdrawbox((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
+ gpuCurrentColor4x(CPACK_BLACK, 0.400f);
+ gpuSingleWireRectf((float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
}
/* dragregion */
@@ -423,7 +423,7 @@ static void draw_background(FileLayout *layout, View2D *v2d)
sy = (int)v2d->cur.ymax - i * (layout->tile_h + 2 * layout->tile_border_y) - layout->tile_border_y;
UI_ThemeColorShade(TH_BACK, -7);
- glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y));
+ gpuSingleFilledRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y));
}
}
@@ -436,11 +436,17 @@ static void draw_dividers(FileLayout *layout, View2D *v2d)
sx = (int)v2d->tot.xmin;
while (sx < v2d->cur.xmax) {
sx += (layout->tile_w + 2 * layout->tile_border_x);
-
- UI_ThemeColorShade(TH_BACK, 30);
- sdrawline(sx + 1, (short)(v2d->cur.ymax - layout->tile_border_y), sx + 1, (short)v2d->cur.ymin);
- UI_ThemeColorShade(TH_BACK, -30);
- sdrawline(sx, (short)(v2d->cur.ymax - layout->tile_border_y), sx, (short)v2d->cur.ymin);
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: two theme colored lines
+ gpuBegin(GL_LINES);
+
+ UI_ThemeAppendColorShade(TH_BACK, 30);
+ gpuAppendLinei(sx+1, (short)(v2d->cur.ymax - layout->tile_border_y), sx+1, (short)v2d->cur.ymin);
+ UI_ThemeAppendColorShade(TH_BACK, -30);
+ gpuAppendLinei(sx, (short)(v2d->cur.ymax - layout->tile_border_y), sx, (short)v2d->cur.ymin);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
}
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index a5647c06b92..37ec527e88e 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -509,7 +509,8 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
{
int found = 0;
-#ifdef __linux__
+/* Doesn't yet work with Android */
+#if defined(__linux__) && !defined(WITH_ANDROID)
/* loop over mount points */
struct mntent *mnt;
int len;
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index be037a0d5ba..b5f7b92d09b 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -37,7 +37,7 @@
#include "MEM_guardedalloc.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "BLO_readfile.h"
@@ -322,8 +322,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
- glClearColor(col[0], col[1], col[2], 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuColorAndClearvf(col, 0.0);
/* Allow dynamically sliders to be set, saves notifiers etc. */
if (layout && (layout->flag == FILE_LAYOUT_VER)) {
@@ -534,8 +533,7 @@ static void file_ui_area_draw(const bContext *C, ARegion *ar)
float col[3];
/* clear */
UI_GetThemeColor3fv(TH_PANEL, col);
- glClearColor(col[0], col[1], col[2], 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuColorAndClearvf(col, 0.0);
/* scrolling here is just annoying, disable it */
ar->v2d.cur.ymax = BLI_rctf_size_y(&ar->v2d.cur);
diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt
index 5b39604809c..452e313848c 100644
--- a/source/blender/editors/space_graph/CMakeLists.txt
+++ b/source/blender/editors/space_graph/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -57,4 +58,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_graph "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index f665b979559..096e9ee1116 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -54,8 +54,9 @@
#include "BKE_curve.h"
#include "BKE_fcurve.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "ED_anim_api.h"
@@ -90,40 +91,40 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
FCM_EnvelopeData *fed;
const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
int i;
-
+
/* draw two black lines showing the standard reference levels */
- glColor3f(0.0f, 0.0f, 0.0f);
+ gpuCurrentColor3x(CPACK_BLACK);
setlinestyle(5);
-
- glBegin(GL_LINES);
- glVertex2f(v2d->cur.xmin, env->midval + env->min);
- glVertex2f(v2d->cur.xmax, env->midval + env->min);
-
- glVertex2f(v2d->cur.xmin, env->midval + env->max);
- glVertex2f(v2d->cur.xmax, env->midval + env->max);
- glEnd(); /* GL_LINES */
+
+ gpuBegin(GL_LINES);
+ gpuVertex2f(v2d->cur.xmin, env->midval + env->min);
+ gpuVertex2f(v2d->cur.xmax, env->midval + env->min);
+
+ gpuVertex2f(v2d->cur.xmin, env->midval + env->max);
+ gpuVertex2f(v2d->cur.xmax, env->midval + env->max);
+ gpuEnd(); /* GL_LINES */
setlinestyle(0);
-
+
/* set size of vertices (non-adjustable for now) */
glPointSize(2.0f);
-
+
/* for now, point color is fixed, and is white */
- glColor3f(1.0f, 1.0f, 1.0f);
-
+ gpuCurrentColor3x(CPACK_WHITE);
+
/* we use bgl points not standard gl points, to workaround vertex
* drawing bugs that some drivers have (probably legacy ones only though)
*/
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
for (i = 0, fed = env->data; i < env->totvert; i++, fed++) {
/* only draw if visible
* - min/max here are fixed, not relative
*/
if (IN_RANGE(fed->time, (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) {
- glVertex2f(fed->time, fed->min);
- glVertex2f(fed->time, fed->max);
+ gpuSprite2f(fed->time, fed->min);
+ gpuSprite2f(fed->time, fed->max);
}
}
- bglEnd(); /* GL_POINTS */
+ gpuEndSprites();
glPointSize(1.0f);
}
@@ -143,7 +144,7 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo),
/* we use bgl points not standard gl points, to workaround vertex
* drawing bugs that some drivers have (probably legacy ones only though)
*/
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
for (i = 0; i < fcu->totvert; i++, bezt++) {
/* as an optimization step, only draw those in view
@@ -156,17 +157,17 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo),
* -
*/
if ((bezt->f2 & SELECT) == sel)
- bglVertex3fv(bezt->vec[1]);
+ gpuSprite3fv(bezt->vec[1]);
}
else {
/* no check for selection here, as curve is not editable... */
/* XXX perhaps we don't want to even draw points? maybe add an option for that later */
- bglVertex3fv(bezt->vec[1]);
+ gpuSprite3fv(bezt->vec[1]);
}
}
}
- bglEnd(); /* GL_POINTS */
+ gpuEndSprites();
}
@@ -176,33 +177,16 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo),
*/
static void draw_fcurve_handle_control(float x, float y, float xscale, float yscale, float hsize)
{
- static GLuint displist = 0;
-
- /* initialize round circle shape */
- if (displist == 0) {
- GLUquadricObj *qobj;
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
- gluDisk(qobj, 0, 0.7, 8, 1);
- gluDeleteQuadric(qobj);
-
- glEndList();
- }
-
+ gpuPushMatrix();
+
/* adjust view transform before starting */
- glTranslatef(x, y, 0.0f);
- glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
-
+ gpuTranslate(x, y, 0.0f);
+ gpuScale(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
+
/* draw! */
- glCallList(displist);
-
- /* restore view transform */
- glScalef(xscale / hsize, yscale / hsize, 1.0);
- glTranslatef(-x, -y, 0.0f);
+ gpuSingleCircle(0, 0, 0.7, 8);
+
+ gpuPopMatrix();
}
/* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
@@ -334,7 +318,7 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
* get separate line segments, but which aren't wrapped with GL_LINE_STRIP every time we
* want a single line
*/
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
/* slightly hacky, but we want to draw unselected points before selected ones
* so that selected points are clearly visible
@@ -362,18 +346,18 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
col[3] = fcurve_display_alpha(fcu) * 255;
- glColor4ubv((GLubyte *)col);
+ gpuColor4ubv((GLubyte *)col);
- glVertex2fv(fp); glVertex2fv(fp + 3);
+ gpuVertex2fv(fp); gpuVertex2fv(fp + 3);
}
/* only draw second handle if this segment is bezier */
if (bezt->ipo == BEZT_IPO_BEZ) {
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
col[3] = fcurve_display_alpha(fcu) * 255;
- glColor4ubv((GLubyte *)col);
+ gpuColor4ubv((GLubyte *)col);
- glVertex2fv(fp + 3); glVertex2fv(fp + 6);
+ gpuVertex2fv(fp + 3); gpuVertex2fv(fp + 6);
}
}
else {
@@ -384,9 +368,9 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
fp = bezt->vec[0];
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
col[3] = fcurve_display_alpha(fcu) * 255;
- glColor4ubv((GLubyte *)col);
+ gpuColor4ubv((GLubyte *)col);
- glVertex2fv(fp); glVertex2fv(fp + 3);
+ gpuVertex2fv(fp); gpuVertex2fv(fp + 3);
}
/* only draw second handle if this segment is bezier, and selection is ok */
@@ -396,15 +380,15 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
fp = bezt->vec[1];
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
col[3] = fcurve_display_alpha(fcu) * 255;
- glColor4ubv((GLubyte *)col);
+ gpuColor4ubv((GLubyte *)col);
- glVertex2fv(fp); glVertex2fv(fp + 3);
+ gpuVertex2fv(fp); gpuVertex2fv(fp + 3);
}
}
}
}
- glEnd(); /* GL_LINES */
+ gpuEnd(); /* GL_LINES */
}
/* Samples ---------------- */
@@ -415,34 +399,22 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
*/
static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize)
{
- static GLuint displist = 0;
-
- /* initialize X shape */
- if (displist == 0) {
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- glBegin(GL_LINES);
- glVertex2f(-0.7f, -0.7f);
- glVertex2f(+0.7f, +0.7f);
-
- glVertex2f(-0.7f, +0.7f);
- glVertex2f(+0.7f, -0.7f);
- glEnd(); /* GL_LINES */
-
- glEndList();
- }
-
/* adjust view transform before starting */
- glTranslatef(x, y, 0.0f);
- glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
+ gpuTranslate(x, y, 0.0f);
+ gpuScale(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
/* draw! */
- glCallList(displist);
+ gpuBegin(GL_LINES);
+ gpuVertex2f(-0.7f, -0.7f);
+ gpuVertex2f(+0.7f, +0.7f);
+
+ gpuVertex2f(-0.7f, +0.7f);
+ gpuVertex2f(+0.7f, -0.7f);
+ gpuEnd(); /* GL_LINES */
/* restore view transform */
- glScalef(xscale / hsize, yscale / hsize, 1.0);
- glTranslatef(-x, -y, 0.0f);
+ gpuScale(xscale / hsize, yscale / hsize, 1.0);
+ gpuTranslate(-x, -y, 0.0f);
}
/* helper func - draw keyframe vertices only for an F-Curve */
@@ -529,12 +501,12 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
* - apply the unit correction factor to the calculated values so that
* the displayed values appear correctly in the viewport
*/
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (ctime = stime; ctime <= etime; ctime += samplefreq)
- glVertex2f(ctime, evaluate_fcurve(fcu, ctime) * unitFac);
+ gpuVertex2f(ctime, evaluate_fcurve(fcu, ctime) * unitFac);
- glEnd();
+ gpuEnd();
/* restore driver */
fcu->driver = driver;
@@ -548,7 +520,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
float fac, v[2];
int b = fcu->totvert - 1;
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
/* apply unit mapping */
ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, 0);
@@ -569,18 +541,18 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
- glVertex2fv(v);
+ gpuVertex2fv(v);
}
/* if only one sample, add it now */
if (fcu->totvert == 1)
- glVertex2fv(prevfpt->vec);
+ gpuVertex2fv(prevfpt->vec);
/* loop over samples, drawing segments */
/* draw curve between first and last keyframe (if there are enough to do so) */
while (b--) {
/* Linear interpolation: just add one point (which should add a new line segment) */
- glVertex2fv(prevfpt->vec);
+ gpuVertex2fv(prevfpt->vec);
/* get next pointers */
prevfpt = fpt;
@@ -588,7 +560,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
/* last point? */
if (b == 0)
- glVertex2fv(prevfpt->vec);
+ gpuVertex2fv(prevfpt->vec);
}
/* extrapolate to right? (see code for left-extrapolation above too) */
@@ -608,13 +580,13 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
- glVertex2fv(v);
+ gpuVertex2fv(v);
}
/* unapply unit mapping */
ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, ANIM_UNITCONV_RESTORE);
- glEnd();
+ gpuEnd();
}
/* helper func - draw one repeat of an F-Curve */
@@ -628,7 +600,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
int b = fcu->totvert - 1;
int resol;
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
/* apply unit mapping */
ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, 0);
@@ -656,14 +628,14 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]);
}
- glVertex2fv(v1);
+ gpuVertex2fv(v1);
}
/* if only one keyframe, add it now */
if (fcu->totvert == 1) {
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
- glVertex2fv(v1);
+ gpuVertex2fv(v1);
}
/* draw curve between first and last keyframe (if there are enough to do so) */
@@ -673,17 +645,17 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
/* Constant-Interpolation: draw segment between previous keyframe and next, but holding same value */
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
- glVertex2fv(v1);
+ gpuVertex2fv(v1);
v1[0] = bezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
- glVertex2fv(v1);
+ gpuVertex2fv(v1);
}
else if (prevbezt->ipo == BEZT_IPO_LIN) {
/* Linear interpolation: just add one point (which should add a new line segment) */
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
- glVertex2fv(v1);
+ gpuVertex2fv(v1);
}
else {
/* Bezier-Interpolation: draw curve as series of segments between keyframes
@@ -701,7 +673,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
/* only draw one */
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
- glVertex2fv(v1);
+ gpuVertex2fv(v1);
}
else {
/* clamp resolution to max of 32 */
@@ -724,7 +696,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3);
for (fp = data; resol; resol--, fp += 3)
- glVertex2fv(fp);
+ gpuVertex2fv(fp);
}
}
@@ -736,7 +708,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
if (b == 0) {
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
- glVertex2fv(v1);
+ gpuVertex2fv(v1);
}
}
@@ -763,13 +735,13 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]);
}
- glVertex2fv(v1);
+ gpuVertex2fv(v1);
}
/* unapply unit mapping */
ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, ANIM_UNITCONV_RESTORE);
- glEnd();
+ gpuEnd();
}
/* Public Curve-Drawing API ---------------- */
@@ -795,7 +767,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
* - this is set by the function which creates these
* - draw with a fixed opacity of 2
*/
- glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], 0.5f);
+ gpuCurrentColor4f(fcu->color[0], fcu->color[1], fcu->color[2], 0.5f);
/* simply draw the stored samples */
draw_fcurve_curve_samples(ac, NULL, fcu, &ar->v2d);
@@ -859,7 +831,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
/* set whatever color the curve has set
* - unselected curves draw less opaque to help distinguish the selected ones
*/
- glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], fcurve_display_alpha(fcu));
+ gpuCurrentColor4f(fcu->color[0], fcu->color[1], fcu->color[2], fcurve_display_alpha(fcu));
}
/* draw active F-Curve thicker than the rest to make it stand out */
@@ -996,11 +968,9 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
size_t channel_index = 0;
y = (float)ACHANNEL_FIRST;
-
- /* set blending again, as may not be set in previous step */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
glEnable(GL_BLEND);
-
+
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF);
const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index fa7c6bd472a..84ce12ba9eb 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -53,7 +53,7 @@
#include "ED_anim_api.h"
#include "ED_markers.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -232,8 +232,7 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
- glClearColor(col[0], col[1], col[2], 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuColorAndClearvf(col, 0.0);
UI_view2d_view_ortho(v2d);
@@ -263,22 +262,20 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
/* horizontal component of value-cursor (value line before the current frame line) */
if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) {
- float vec[2];
-
/* Draw a green line to indicate the cursor value */
- vec[1] = sipo->cursorVal;
-
+
UI_ThemeColorShadeAlpha(TH_CFRAME, -10, -50);
glLineWidth(2.0);
-
+
glEnable(GL_BLEND);
- glBegin(GL_LINE_STRIP);
- vec[0] = v2d->cur.xmin;
- glVertex2fv(vec);
-
- vec[0] = v2d->cur.xmax;
- glVertex2fv(vec);
- glEnd(); // GL_LINE_STRIP
+
+ // DOODLE single 2D line
+ gpuSingleLinef(
+ v2d->cur.xmin,
+ sipo->cursorVal,
+ v2d->cur.xmax,
+ sipo->cursorVal);
+
glDisable(GL_BLEND);
}
@@ -289,7 +286,7 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
- draw_markers_time(C, 0);
+ draw_markers_time(C, 0); // DOODLE multiple lines with labels
/* preview range */
UI_view2d_view_ortho(v2d);
@@ -327,8 +324,7 @@ static void graph_channel_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
- glClearColor(col[0], col[1], col[2], 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuColorAndClearvf(col, 0.0);
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt
index 3e3c6adcf8c..12c4d8aa915 100644
--- a/source/blender/editors/space_image/CMakeLists.txt
+++ b/source/blender/editors/space_image/CMakeLists.txt
@@ -26,6 +26,7 @@ set(INC
../../blenloader
../../imbuf
../../bmesh
+ ../../gpu
../../makesdna
../../makesrna
../../render/extern/include
@@ -67,4 +68,6 @@ if(WITH_IMAGE_CINEON)
add_definitions(-DWITH_CINEON)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_image "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index d565e6f9e9a..9f67da768c5 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -58,7 +58,9 @@
#include "BKE_image.h"
#include "BKE_paint.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "BLF_api.h"
@@ -111,17 +113,16 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0;
float col[4], finalcol[4];
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
/* noisy, high contrast make impossible to read if lower alpha is used. */
- glColor4ub(0, 0, 0, 190);
- glRecti(0.0, 0.0, BLI_rcti_size_x(&ar->winrct) + 1, 20);
+ gpuCurrentColor4x(CPACK_BLACK, 0.745f);
+ gpuSingleFilledRecti(0.0, 0.0, BLI_rcti_size_x(&ar->winrct) + 1, 20);
glDisable(GL_BLEND);
BLF_size(blf_mono_font, 11, 72);
- glColor3ub(255, 255, 255);
+ gpuCurrentColor3x(CPACK_WHITE);
BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y);
// UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
BLF_position(blf_mono_font, dx, 6, 0);
@@ -129,14 +130,14 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
dx += BLF_width(blf_mono_font, str);
if (zp) {
- glColor3ub(255, 255, 255);
+ gpuCurrentColor3x(CPACK_WHITE);
BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff));
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
}
if (zpf) {
- glColor3ub(255, 255, 255);
+ gpuCurrentColor3x(CPACK_WHITE);
BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf);
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
@@ -144,7 +145,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
}
if (channels >= 3) {
- glColor3ubv(red);
+ gpuCurrentColor3ubv(red);
if (fp)
BLI_snprintf(str, sizeof(str), " R:%-.4f", fp[0]);
else if (cp)
@@ -155,7 +156,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
- glColor3ubv(green);
+ gpuCurrentColor3ubv(green);
if (fp)
BLI_snprintf(str, sizeof(str), " G:%-.4f", fp[1]);
else if (cp)
@@ -166,7 +167,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
- glColor3ubv(blue);
+ gpuCurrentColor3ubv(blue);
if (fp)
BLI_snprintf(str, sizeof(str), " B:%-.4f", fp[2]);
else if (cp)
@@ -178,7 +179,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
dx += BLF_width(blf_mono_font, str);
if (channels == 4) {
- glColor3ub(255, 255, 255);
+ gpuCurrentColor3x(CPACK_WHITE);
if (fp)
BLI_snprintf(str, sizeof(str), " A:%-.4f", fp[3]);
else if (cp)
@@ -256,27 +257,32 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
}
glDisable(GL_BLEND);
- glColor3fv(finalcol);
+
+ gpuImmediateFormat_C4_V2();
+
+ gpuCurrentColor3fv(finalcol);
dx += 5;
- glBegin(GL_QUADS);
- glVertex2f(dx, 3);
- glVertex2f(dx, 17);
- glVertex2f(dx + 30, 17);
- glVertex2f(dx + 30, 3);
- glEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuVertex2f(dx, 3);
+ gpuVertex2f(dx, 17);
+ gpuVertex2f(dx + 30, 17);
+ gpuVertex2f(dx + 30, 3);
+ gpuEnd();
/* draw outline */
- glColor3ub(128, 128, 128);
- glBegin(GL_LINE_LOOP);
- glVertex2f(dx, 3);
- glVertex2f(dx, 17);
- glVertex2f(dx + 30, 17);
- glVertex2f(dx + 30, 3);
- glEnd();
+ gpuCurrentGray3f(0.500f);
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(dx, 3);
+ gpuVertex2f(dx, 17);
+ gpuVertex2f(dx + 30, 17);
+ gpuVertex2f(dx + 30, 3);
+ gpuEnd();
+
+ gpuImmediateUnformat();
dx += 35;
- glColor3ub(255, 255, 255);
+ gpuCurrentColor3x(CPACK_WHITE);
if (channels == 1) {
if (fp) {
rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val);
@@ -335,13 +341,17 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti)
{
-
/* swap bytes, so alpha is most significant one, then just draw it as luminance int */
- if (ENDIAN_ORDER == B_ENDIAN)
- glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
+
+#if ENDIAN_ORDER == B_ENDIAN
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_TRUE);
+#endif
glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_UNSIGNED_INT, recti);
- glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
+
+#if ENDIAN_ORDER == B_ENDIAN
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); /* restore default value */
+#endif
}
static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, float *rectf)
@@ -449,7 +459,6 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
@@ -590,18 +599,18 @@ void draw_image_sample_line(SpaceImage *sima)
if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) {
Histogram *hist = &sima->sample_line_hist;
- glBegin(GL_LINES);
- glColor3ub(0, 0, 0);
- glVertex2fv(hist->co[0]);
- glVertex2fv(hist->co[1]);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuColor3x(CPACK_BLACK);
+ gpuVertex2fv(hist->co[0]);
+ gpuVertex2fv(hist->co[1]);
+ gpuEnd();
setlinestyle(1);
- glBegin(GL_LINES);
- glColor3ub(255, 255, 255);
- glVertex2fv(hist->co[0]);
- glVertex2fv(hist->co[1]);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuColor3x(CPACK_WHITE);
+ gpuVertex2fv(hist->co[0]);
+ gpuVertex2fv(hist->co[1]);
+ gpuEnd();
setlinestyle(0);
}
@@ -711,7 +720,6 @@ static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scen
glPixelZoom(zoomx, zoomy);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, clonerect);
glDisable(GL_BLEND);
@@ -795,11 +803,11 @@ void draw_image_main(const bContext *C, ARegion *ar)
if (image_preview_active(sa, &xim, &yim)) {
xoffs = scene->r.disprect.xmin;
yoffs = scene->r.disprect.ymin;
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
calc_image_view(sima, 'f');
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
- glRectf(0.0f, 0.0f, 1.0f, 1.0f);
- glLoadIdentity();
+ gpuSingleFilledRectf(0.0f, 0.0f, 1.0f, 1.0f);
+ gpuLoadIdentity();
}
}
#endif
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index ea696772957..7eff00d3882 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -59,7 +59,7 @@
#include "ED_screen.h"
#include "ED_uvedit.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "RNA_access.h"
@@ -642,8 +642,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
- glClearColor(col[0], col[1], col[2], 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuColorAndClearvf(col, 0.0);
/* put scene context variable in iuser */
sima->iuser.scene = scene;
diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt
index 94b40a9f40a..8f8d1aa9309 100644
--- a/source/blender/editors/space_info/CMakeLists.txt
+++ b/source/blender/editors/space_info/CMakeLists.txt
@@ -26,6 +26,7 @@ set(INC
../../blenloader
../../imbuf
../../bmesh
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -52,4 +53,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_info "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 5830c4574df..4de77d1f89a 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -46,10 +46,10 @@
// #include "BKE_suggestions.h"
#include "BKE_report.h"
+#include "GPU_compatibility.h"
#include "MEM_guardedalloc.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "ED_datafiles.h"
@@ -146,8 +146,7 @@ static int report_textview_begin(TextViewContext *tvc)
/* iterator */
tvc->iter = reports->list.last;
- glClearColor(120.0 / 255.0, 120.0 / 255.0, 120.0 / 255.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuColorAndClear(120.0 / 255.0, 120.0 / 255.0, 120.0 / 255.0, 1.0);
#ifdef USE_INFO_NEWLINE
tvc->iter_tmp = 0;
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index cba0a808d63..98aa2ca0a9c 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -48,7 +48,7 @@
#include "ED_space_api.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -153,7 +153,7 @@ static void info_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
/* quick way to avoid drawing if not bug enough */
if (ar->winy < 16)
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index f454b1dbe7d..e7ed566198e 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -36,7 +36,8 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
#include "BIF_glutil.h"
#include "ED_datafiles.h"
@@ -70,10 +71,9 @@ static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(stipple_halftone);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4ub(255, 255, 255, 96);
- glRecti(xy[0] + (cwidth * sta), xy[1] - 2 + lheight, xy[0] + (cwidth * end), xy[1] - 2);
+ gpuCurrentColor4x(CPACK_WHITE, 0.376f);
+ gpuSingleFilledRecti(xy[0] + (cwidth * sta), xy[1] - 2 + lheight, xy[0] + (cwidth * end), xy[1] - 2);
glDisable(GL_POLYGON_STIPPLE);
glDisable(GL_BLEND);
@@ -138,11 +138,11 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
cdc->sel[1] = str_len - sel_orig[0];
if (bg) {
- glColor3ubv(bg);
- glRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, (cdc->xy[1] + (cdc->lheight * tot_lines)) + rct_ofs);
+ gpuCurrentColor3ubv(bg);
+ gpuSingleFilledRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, (cdc->xy[1] + (cdc->lheight * tot_lines)) + rct_ofs);
}
- glColor3ubv(fg);
+ gpuCurrentColor3ubv(fg);
/* last part needs no clipping */
BLF_position(mono, cdc->xy[0], cdc->xy[1], 0);
@@ -150,10 +150,10 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
if (cdc->sel[0] != cdc->sel[1]) {
STEP_SEL(-initial_offset);
- // glColor4ub(255, 0, 0, 96); // debug
+ // gpuCurrentColor4x(CPACK_RED, 0.376f); // debug
console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->lheight);
STEP_SEL(cdc->console_width);
- glColor3ubv(fg);
+ gpuCurrentColor3ubv(fg);
}
cdc->xy[1] += cdc->lheight;
@@ -165,10 +165,10 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
BLF_draw(mono, line_stride, cdc->console_width);
if (cdc->sel[0] != cdc->sel[1]) {
- // glColor4ub(0, 255, 0, 96); // debug
+ // gpuCurrentColor4x(CPACK_GREEN, 0.376f); // debug
console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->lheight);
STEP_SEL(cdc->console_width);
- glColor3ubv(fg);
+ gpuCurrentColor3ubv(fg);
}
cdc->xy[1] += cdc->lheight;
@@ -184,11 +184,11 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
else { /* simple, no wrap */
if (bg) {
- glColor3ubv(bg);
- glRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, cdc->xy[1] + cdc->lheight - rct_ofs);
+ gpuCurrentColor3ubv(bg);
+ gpuSingleFilledRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, cdc->xy[1] + cdc->lheight - rct_ofs);
}
- glColor3ubv(fg);
+ gpuCurrentColor3ubv(fg);
BLF_position(mono, cdc->xy[0], cdc->xy[1], 0);
BLF_draw(mono, str, str_len);
@@ -199,7 +199,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
isel[0] = str_len - cdc->sel[1];
isel[1] = str_len - cdc->sel[0];
- // glColor4ub(255, 255, 0, 96); // debug
+ // gpuCurrentColor4x(CPACK_YELLOW, 0.376f); // debug
console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->lheight);
STEP_SEL(-(str_len + 1));
}
diff --git a/source/blender/editors/space_logic/CMakeLists.txt b/source/blender/editors/space_logic/CMakeLists.txt
index 13e6f9484e8..7cae2cf839f 100644
--- a/source/blender/editors/space_logic/CMakeLists.txt
+++ b/source/blender/editors/space_logic/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -48,6 +49,8 @@ if(WITH_GAMEENGINE)
add_definitions(-DWITH_GAMEENGINE)
endif()
+add_definitions(-DGLEW_STATIC)
+
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 5a8a7cef119..b6b3b5cbd9f 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -62,7 +62,8 @@
#include "WM_types.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
+
#include "BLF_translation.h"
diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c
index 4cd53215697..87b0f8e75f8 100644
--- a/source/blender/editors/space_logic/space_logic.c
+++ b/source/blender/editors/space_logic/space_logic.c
@@ -45,8 +45,7 @@
#include "ED_space_api.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
-
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -251,7 +250,7 @@ static void logic_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt
index aa3598e8e1f..202b6c679e0 100644
--- a/source/blender/editors/space_nla/CMakeLists.txt
+++ b/source/blender/editors/space_nla/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -50,4 +51,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index fd999bf2476..8962b88dbae 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -55,7 +55,9 @@
#include "ED_anim_api.h"
#include "ED_keyframes_draw.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "WM_types.h"
@@ -122,28 +124,28 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, View2D *v2d,
nla_action_get_color(adt, act, color);
color[3] *= 2.5f;
- glColor4fv(color);
+ gpuCurrentColor4fv(color);
/* - draw a rect from the first to the last frame (no extra overlaps for now)
* that is slightly stumpier than the track background (hardcoded 2-units here)
*/
f1 = ((ActKeyColumn *)keys.first)->cfra;
f2 = ((ActKeyColumn *)keys.last)->cfra;
-
- glRectf(f1, ymin + 2, f2, ymax - 2);
-
-
+
+ gpuSingleFilledRectf(f1, ymin + 2, f2, ymax - 2);
+
+
/* get View2D scaling factor */
UI_view2d_getscale(v2d, &xscale, NULL);
-
+
/* for now, color is hardcoded to be black */
- glColor3f(0.0f, 0.0f, 0.0f);
-
+ gpuCurrentColor3x(CPACK_BLACK);
+
/* just draw each keyframe as a simple dot (regardless of the selection status)
* - size is 3.0f which is smaller than the editable keyframes, so that there is a distinction
*/
for (ak = keys.first; ak; ak = ak->next)
draw_keyframe_shape(ak->cfra, y, xscale, 3.0f, 0, ak->key_type, KEYFRAME_SHAPE_FRAME, 1.0f);
-
+
/* free icons */
BLI_dlrbTree_free(&keys);
}
@@ -220,8 +222,8 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc)
/* drawing color is simply a light-gray */
// TODO: is this color suitable?
// XXX nasty hacked color for now... which looks quite bad too...
- glColor3f(0.7f, 0.7f, 0.7f);
-
+ gpuCurrentGray3f(0.700f);
+
/* draw with AA'd line */
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
@@ -232,36 +234,36 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc)
float cfra;
/* plot the curve (over the strip's main region) */
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
/* sample at 1 frame intervals, and draw
* - min y-val is yminc, max is y-maxc, so clamp in those regions
*/
for (cfra = strip->start; cfra <= strip->end; cfra += 1.0f) {
float y = evaluate_fcurve(fcu, cfra); // assume this to be in 0-1 range
- glVertex2f(cfra, ((y * yheight) + yminc));
+ gpuVertex2f(cfra, ((y * yheight) + yminc));
}
- glEnd(); // GL_LINE_STRIP
+ gpuEnd(); // GL_LINE_STRIP
}
else {
/* use blend in/out values only if both aren't zero */
if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f)) == 0) {
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
/* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */
if (IS_EQF(strip->blendin, 0.0f) == 0) {
- glVertex2f(strip->start, yminc);
- glVertex2f(strip->start + strip->blendin, ymaxc);
+ gpuVertex2f(strip->start, yminc);
+ gpuVertex2f(strip->start + strip->blendin, ymaxc);
}
else
- glVertex2f(strip->start, ymaxc);
+ gpuVertex2f(strip->start, ymaxc);
/* end of strip */
if (IS_EQF(strip->blendout, 0.0f) == 0) {
- glVertex2f(strip->end - strip->blendout, ymaxc);
- glVertex2f(strip->end, yminc);
+ gpuVertex2f(strip->end - strip->blendout, ymaxc);
+ gpuVertex2f(strip->end, yminc);
}
else
- glVertex2f(strip->end, ymaxc);
- glEnd(); // GL_LINE_STRIP
+ gpuVertex2f(strip->end, ymaxc);
+ gpuEnd(); // GL_LINE_STRIP
}
}
@@ -287,7 +289,6 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
*/
if ((strip->extendmode != NLASTRIP_EXTEND_NOTHING) && (nonSolo == 0)) {
/* enable transparency... */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
switch (strip->extendmode) {
@@ -298,15 +299,15 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
*/
if (strip->prev == NULL) {
/* set the drawing color to the color of the strip, but with very faint alpha */
- glColor4f(color[0], color[1], color[2], 0.15f);
+ gpuCurrentColor4f(color[0], color[1], color[2], 0.15f);
/* draw the rect to the edge of the screen */
- glBegin(GL_QUADS);
- glVertex2f(v2d->cur.xmin, yminc);
- glVertex2f(v2d->cur.xmin, ymaxc);
- glVertex2f(strip->start, ymaxc);
- glVertex2f(strip->start, yminc);
- glEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuVertex2f(v2d->cur.xmin, yminc);
+ gpuVertex2f(v2d->cur.xmin, ymaxc);
+ gpuVertex2f(strip->start, ymaxc);
+ gpuVertex2f(strip->start, yminc);
+ gpuEnd();
}
/* no break needed... */
@@ -315,22 +316,22 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
/* only need to try and draw if the next strip doesn't occur immediately after */
if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end) == 0)) {
/* set the drawing color to the color of the strip, but this time less faint */
- glColor4f(color[0], color[1], color[2], 0.3f);
+ gpuCurrentColor4f(color[0], color[1], color[2], 0.3f);
/* draw the rect to the next strip or the edge of the screen */
- glBegin(GL_QUADS);
- glVertex2f(strip->end, yminc);
- glVertex2f(strip->end, ymaxc);
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuVertex2f(strip->end, yminc);
+ gpuVertex2f(strip->end, ymaxc);
if (strip->next) {
- glVertex2f(strip->next->start, ymaxc);
- glVertex2f(strip->next->start, yminc);
+ gpuVertex2f(strip->next->start, ymaxc);
+ gpuVertex2f(strip->next->start, yminc);
}
else {
- glVertex2f(v2d->cur.xmax, ymaxc);
- glVertex2f(v2d->cur.xmax, yminc);
+ gpuVertex2f(v2d->cur.xmax, ymaxc);
+ gpuVertex2f(v2d->cur.xmax, yminc);
}
- glEnd();
+ gpuEnd();
}
break;
}
@@ -342,17 +343,17 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
/* draw 'inside' of strip itself */
if (nonSolo == 0) {
/* strip is in normal track */
- glColor3fv(color);
+ gpuCurrentColor3fv(color);
uiSetRoundBox(UI_CNR_ALL); /* all corners rounded */
- uiDrawBoxShade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1);
+ uiDrawBoxShade(GL_TRIANGLE_FAN, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1);
}
else {
/* strip is in disabled track - make less visible */
- glColor4f(color[0], color[1], color[2], 0.1f);
+ gpuCurrentColor4f(color[0], color[1], color[2], 0.1f);
glEnable(GL_BLEND);
- glRectf(strip->start, yminc, strip->end, ymaxc);
+ gpuSingleFilledRectf(strip->start, yminc, strip->end, ymaxc);
glDisable(GL_BLEND);
}
@@ -369,11 +370,11 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
*/
if (strip->flag & NLASTRIP_FLAG_ACTIVE) {
/* strip should appear 'sunken', so draw a light border around it */
- glColor3f(0.9f, 1.0f, 0.9f); // FIXME: hardcoded temp-hack colors
+ gpuCurrentColor3f(0.9f, 1.0f, 0.9f); // FIXME: hardcoded temp-hack colors
}
else {
/* strip should appear to stand out, so draw a dark border around it */
- glColor3f(0.0f, 0.0f, 0.0f);
+ gpuCurrentColor3f(0.0f, 0.0f, 0.0f);
}
/* - line style: dotted for muted */
@@ -382,7 +383,10 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
/* draw outline */
uiDrawBoxShade(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1);
-
+
+ gpuImmediateFormat_V2(); // DOODLE: some number of mono lines
+ gpuBegin(GL_LINES);
+
/* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */
if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f) == 0) {
float repeatLen = (strip->actend - strip->actstart) * strip->scale;
@@ -396,7 +400,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
/* don't draw if line would end up on or after the end of the strip */
if (repeatPos < strip->end)
- fdrawline(repeatPos, yminc + 4, repeatPos, ymaxc - 4);
+ gpuAppendLinef(repeatPos, yminc + 4, repeatPos, ymaxc - 4);
}
}
/* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */
@@ -410,16 +414,19 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
* - on upper half of strip
*/
if ((cs->prev) && IS_EQF(cs->prev->end, cs->start) == 0)
- fdrawline(cs->start, y, cs->start, ymaxc);
+ gpuAppendLinef(cs->start, y, cs->start, ymaxc);
/* draw end-line if not the last strip
* - on lower half of strip
*/
if (cs->next)
- fdrawline(cs->end, yminc, cs->end, y);
+ gpuAppendLinef(cs->end, yminc, cs->end, y);
}
}
-
+
+ gpuEnd();
+ gpuImmediateUnformat();
+
/* reset linestyle */
setlinestyle(0);
}
@@ -575,35 +582,42 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* just draw a semi-shaded rect spanning the width of the viewable area if there's data,
* and a second darker rect within which we draw keyframe indicator dots if there's data
*/
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
/* get colors for drawing */
nla_action_get_color(adt, ale->data, color);
- glColor4fv(color);
+ gpuCurrentColor4fv(color);
/* draw slightly shifted up for greater separation from standard channels,
* but also slightly shorter for some more contrast when viewing the strips
*/
- glRectf(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
+ gpuSingleFilledRectf(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
/* draw keyframes in the action */
nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP);
-
+
+ gpuImmediateFormat_V2(); // DOODLE: thick white line with black thin line on top of it
+
/* draw 'embossed' lines above and below the strip for effect */
/* white base-lines */
glLineWidth(2.0f);
- glColor4f(1.0f, 1.0f, 1.0f, 0.3);
- fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
- fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
-
+ gpuCurrentColor4x(CPACK_WHITE, 0.300f);
+ gpuBegin(GL_LINES);
+ gpuAppendLinef(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
+ gpuAppendLinef(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
+ gpuEnd();
+
/* black top-lines */
glLineWidth(1.0f);
- glColor3f(0.0f, 0.0f, 0.0f);
- fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
- fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
-
+ gpuCurrentColor3x(CPACK_BLACK);
+ gpuBegin(GL_LINES);
+ gpuAppendLinef(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP);
+ gpuAppendLinef(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP);
+ gpuEnd();
+
glDisable(GL_BLEND);
+
+ gpuImmediateUnformat();
}
break;
}
@@ -755,7 +769,6 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
}
/* now, start drawing based on this information */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
/* draw backing strip behind channel name */
@@ -772,11 +785,11 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
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);
+ gpuCurrentColor3fv(color);
}
else {
float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
- glColor4f(color[0], color[1], color[2], alpha);
+ gpuCurrentColor4f(color[0], color[1], color[2], alpha);
}
offset += 7 * indent;
@@ -787,7 +800,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
/* draw slightly shifted up vertically to look like it has more separation from other channels,
* but we then need to slightly shorten it so that it doesn't look like it overlaps
*/
- uiDrawBox(GL_POLYGON, x + offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8);
+ uiDrawBox(GL_TRIANGLE_FAN, x + offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8);
/* clear group value, otherwise we cause errors... */
group = 0;
@@ -798,12 +811,12 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
indent += group;
offset += 7 * indent;
- glBegin(GL_QUADS);
- glVertex2f(x + offset, yminc);
- glVertex2f(x + offset, ymaxc);
- glVertex2f((float)v2d->cur.xmax, ymaxc);
- glVertex2f((float)v2d->cur.xmax, yminc);
- glEnd();
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuVertex2f(x + offset, yminc);
+ gpuVertex2f(x + offset, ymaxc);
+ gpuVertex2f((float)v2d->cur.xmax, ymaxc);
+ gpuVertex2f((float)v2d->cur.xmax, yminc);
+ gpuEnd();
}
/* draw expand/collapse triangle */
@@ -830,11 +843,9 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
/* reset offset - for RHS of panel */
offset = 0;
-
- /* set blending again, as text drawing may clear it */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
glEnable(GL_BLEND);
-
+
/* draw protect 'lock' */
if (protect > -1) {
offset = 16;
@@ -859,23 +870,28 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View
UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_PINNED);
else
UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_UNPINNED);
-
- fdrawline((float)(v2d->cur.xmax - offset), yminc,
- (float)(v2d->cur.xmax - offset), ymaxc);
+
+ // DOODLE: single line
+ gpuSingleLinef(
+ (float)(v2d->cur.xmax - offset), yminc,
+ (float)(v2d->cur.xmax - offset), ymaxc);
+
offset += 16;
-
+
/* 'tweaking action' indicator - not a button */
UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_EDIT);
}
else {
/* XXX firstly draw a little rect to help identify that it's different from the toggles */
- glBegin(GL_LINE_LOOP);
- glVertex2f((float)v2d->cur.xmax - offset - 1, y - 7);
- glVertex2f((float)v2d->cur.xmax - offset - 1, y + 9);
- glVertex2f((float)v2d->cur.xmax - 1, y + 9);
- glVertex2f((float)v2d->cur.xmax - 1, y - 7);
- glEnd(); // GL_LINES
-
+ gpuImmediateFormat_V2(); // DOODLE: a line box
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f((float)v2d->cur.xmax - offset - 1, y - 7);
+ gpuVertex2f((float)v2d->cur.xmax - offset - 1, y + 9);
+ gpuVertex2f((float)v2d->cur.xmax - 1, y + 9);
+ gpuVertex2f((float)v2d->cur.xmax - 1, y - 7);
+ gpuEnd(); // GL_LINES
+ gpuImmediateUnformat();
+
/* 'push down' icon for normal active-actions */
UI_icon_draw((float)v2d->cur.xmax - offset, ydatac, ICON_FREEZE);
}
@@ -931,11 +947,9 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar)
size_t channel_index = 0;
y = (float)(-NLACHANNEL_HEIGHT(snla));
-
- /* set blending again, as may not be set in previous step */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
glEnable(GL_BLEND);
-
+
/* loop through channels, and set up drawing depending on their type */
for (ale = anim_data.first; ale; ale = ale->next) {
const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla));
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 7c9014bd45f..3f375551065 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -52,7 +52,7 @@
#include "ED_markers.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -229,7 +229,7 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
@@ -274,7 +274,7 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt
index 996c6fb530f..0598f72652a 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -66,4 +66,6 @@ if(WITH_COMPOSITOR)
add_definitions(-DWITH_COMPOSITOR)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_node "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 92edac356e6..bd6639c6575 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -49,7 +49,9 @@
#include "BLF_translation.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "MEM_guardedalloc.h"
@@ -73,24 +75,24 @@
static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v)
{
- SpaceNode *snode = snode_v;
+ SpaceNode *snode= snode_v;
- if (snode->treetype == NTREE_SHADER) {
+ if (snode->treetype==NTREE_SHADER) {
nodeShaderSynchronizeID(node_v, 1);
// allqueue(REDRAWBUTSSHADING, 0);
}
}
static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block,
- bNodeTree *UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock,
- const char *UNUSED(name), int x, int y, int width)
+ bNodeTree *UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock,
+ const char *UNUSED(name), int x, int y, int width)
{
uiDefBut(block, LABEL, 0, IFACE_(sock->name), x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
}
static void node_socket_button_default(const bContext *C, uiBlock *block,
- bNodeTree *ntree, bNode *node, bNodeSocket *sock,
- const char *name, int x, int y, int width)
+ bNodeTree *ntree, bNode *node, bNodeSocket *sock,
+ const char *name, int x, int y, int width)
{
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
@@ -101,8 +103,8 @@ static void node_socket_button_default(const bContext *C, uiBlock *block,
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
bt = uiDefButR(block, NUM, B_NODE_EXEC, IFACE_(name),
- x, y + 1, width, NODE_DY - 2,
- &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
+ x, y+1, width, NODE_DY-2,
+ &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
if (node)
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
}
@@ -154,11 +156,11 @@ typedef struct SocketComponentMenuArgs {
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v)
{
- SocketComponentMenuArgs *args = (SocketComponentMenuArgs *)args_v;
+ SocketComponentMenuArgs *args= (SocketComponentMenuArgs*)args_v;
uiBlock *block;
uiLayout *layout;
- block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
+ block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
@@ -169,8 +171,8 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v)
return block;
}
static void node_socket_button_components(const bContext *C, uiBlock *block,
- bNodeTree *ntree, bNode *node, bNodeSocket *sock,
- const char *name, int x, int y, int width)
+ bNodeTree *ntree, bNode *node, bNodeSocket *sock,
+ const char *name, int x, int y, int width)
{
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
@@ -180,7 +182,7 @@ static void node_socket_button_components(const bContext *C, uiBlock *block,
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
- args = MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
+ args= MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
args->ptr = ptr;
args->x = x;
@@ -195,32 +197,32 @@ static void node_socket_button_components(const bContext *C, uiBlock *block,
}
static void node_socket_button_color(const bContext *C, uiBlock *block,
- bNodeTree *ntree, bNode *node, bNodeSocket *sock,
- const char *name, int x, int y, int width)
+ bNodeTree *ntree, bNode *node, bNodeSocket *sock,
+ const char *name, int x, int y, int width)
{
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
node_socket_button_label(C, block, ntree, node, sock, IFACE_(name), x, y, width);
else {
PointerRNA ptr;
uiBut *bt;
- int labelw = width - 40;
+ int labelw= width - 40;
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
bt = uiDefButR(block, COLOR, B_NODE_EXEC, "",
- x, y + 2, (labelw > 0 ? 40 : width), NODE_DY - 2,
- &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
+ x, y+2, (labelw>0 ? 40 : width), NODE_DY-2,
+ &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
if (node)
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
- if (name[0] != '\0' && labelw > 0)
+ if (name[0]!='\0' && labelw>0)
uiDefBut(block, LABEL, 0, IFACE_(name), x + 40, y + 2, labelw, NODE_DY - 2, NULL, 0, 0, 0, 0, "");
}
}
/* standard draw function, display the default input value */
static void node_draw_input_default(const bContext *C, uiBlock *block,
- bNodeTree *ntree, bNode *node, bNodeSocket *sock,
- const char *name, int x, int y, int width)
+ bNodeTree *ntree, bNode *node, bNodeSocket *sock,
+ const char *name, int x, int y, int width)
{
bNodeSocketType *stype = ntreeGetSocketType(sock->type);
if (stype->buttonfunc)
@@ -257,38 +259,38 @@ static void node_draw_output_default(const bContext *C, uiBlock *block,
#if 0 /* UNUSED */
static void node_draw_socket_new(bNodeSocket *sock, float size)
{
- float x = sock->locx, y = sock->locy;
-
+ float x=sock->locx, y=sock->locy;
+
/* 16 values of sin function */
static float si[16] = {
- 0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
- 0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f,
- -0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f,
- -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f
+ 0.00000000f, 0.39435585f, 0.72479278f,0.93775213f,
+ 0.99871650f,0.89780453f,0.65137248f,0.29936312f,
+ -0.10116832f,-0.48530196f,-0.79077573f,-0.96807711f,
+ -0.98846832f,-0.84864425f,-0.57126821f,-0.20129852f
};
/* 16 values of cos function */
- static float co[16] = {
- 1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f,
- -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f,
- -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
- 0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
+ static float co[16] ={
+ 1.00000000f,0.91895781f,0.68896691f,0.34730525f,
+ -0.05064916f,-0.44039415f,-0.75875812f,-0.95413925f,
+ -0.99486932f,-0.87434661f,-0.61210598f,-0.25065253f,
+ 0.15142777f,0.52896401f,0.82076344f,0.97952994f,
};
int a;
-
- glColor3ub(180, 180, 180);
-
- glBegin(GL_POLYGON);
- for (a = 0; a < 16; a++)
- glVertex2f(x + size * si[a], y + size * co[a]);
- glEnd();
-
- glColor4ub(0, 0, 0, 150);
+
+ gpuCurrentGray3f(0.706f);
+
+ gpuBegin(GL_TRIANGLE_FAN);
+ for (a=0; a<16; a++)
+ gpuVertex2f(x+size*si[a], y+size*co[a]);
+ gpuEnd();
+
+ gpuCurrentColor4x(CPACK_BLACK, 0.588f);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
- glBegin(GL_LINE_LOOP);
- for (a = 0; a < 16; a++)
- glVertex2f(x + size * si[a], y + size * co[a]);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ for (a=0; a<16; a++)
+ gpuVertex2f(x+size*si[a], y+size*co[a]);
+ gpuEnd();
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
@@ -327,7 +329,7 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA
{
uiLayout *row, *col;
- bNodeTree *ntree = (bNodeTree *)ptr->id.data;
+ bNodeTree *ntree= (bNodeTree*)ptr->id.data;
col = uiLayoutColumn(layout, FALSE);
row = uiLayoutRow(col, TRUE);
@@ -343,13 +345,13 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt
uiLayout *row;
#if 0
/* XXX no context access here .. */
- bNode *node = ptr->data;
- CurveMapping *cumap = node->storage;
+ bNode *node= ptr->data;
+ CurveMapping *cumap= node->storage;
if (cumap) {
cumap->flag |= CUMA_DRAW_CFRA;
- if (node->custom1 < node->custom2)
- cumap->sample[0] = (float)(CFRA - node->custom1) / (float)(node->custom2 - node->custom1);
+ if (node->custom1<node->custom2)
+ cumap->sample[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1);
}
#endif
@@ -384,8 +386,8 @@ void ED_node_sample_set(const float col[4])
static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
- bNode *node = ptr->data;
- CurveMapping *cumap = node->storage;
+ bNode *node= ptr->data;
+ CurveMapping *cumap= node->storage;
if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
cumap->flag |= CUMA_DRAW_SAMPLE;
@@ -402,7 +404,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
{
bNodeTree *ntree = (bNodeTree*)ptr->id.data;
bNode *node = (bNode*)ptr->data;
- bNodeSocket *sock = node->outputs.first; /* first socket stores normal */
+ bNodeSocket *sock= node->outputs.first; /* first socket stores normal */
PointerRNA sockptr;
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &sockptr);
@@ -411,46 +413,46 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
#if 0 /* not used in 2.5x yet */
static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
{
- Main *bmain = CTX_data_main(C);
- bNodeTree *ntree = ntree_v;
- bNode *node = node_v;
+ Main *bmain= CTX_data_main(C);
+ bNodeTree *ntree= ntree_v;
+ bNode *node= node_v;
Tex *tex;
- if (node->menunr < 1) return;
+ if (node->menunr<1) return;
if (node->id) {
node->id->us--;
- node->id = NULL;
+ node->id= NULL;
}
- tex = BLI_findlink(&bmain->tex, node->menunr - 1);
+ tex= BLI_findlink(&bmain->tex, node->menunr-1);
- node->id = &tex->id;
+ node->id= &tex->id;
id_us_plus(node->id);
- BLI_strncpy(node->name, node->id->name + 2, sizeof(node->name));
+ BLI_strncpy(node->name, node->id->name+2, sizeof(node->name));
nodeSetActive(ntree, node);
- if (ntree->type == NTREE_TEXTURE)
+ if ( ntree->type == NTREE_TEXTURE )
ntreeTexCheckCyclics(ntree);
// allqueue(REDRAWBUTSSHADING, 0);
// allqueue(REDRAWNODE, 0);
NodeTagChanged(ntree, node);
- node->menunr = 0;
+ node->menunr= 0;
}
#endif
static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
- bNode *node = ptr->data;
+ bNode *node= ptr->data;
short multi = (
- node->id &&
- ((Tex *)node->id)->use_nodes &&
- (node->type != CMP_NODE_TEXTURE) &&
- (node->type != TEX_NODE_TEXTURE)
- );
+ node->id &&
+ ((Tex*)node->id)->use_nodes &&
+ (node->type != CMP_NODE_TEXTURE) &&
+ (node->type != TEX_NODE_TEXTURE)
+ );
uiItemR(layout, ptr, "texture", 0, "", ICON_NONE);
@@ -469,9 +471,9 @@ static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt
static int node_resize_area_default(bNode *node, int x, int y)
{
if (node->flag & NODE_HIDDEN) {
- rctf totr = node->totr;
+ rctf totr= node->totr;
/* right part of node */
- totr.xmin = node->totr.xmax - 20.0f;
+ totr.xmin = node->totr.xmax-20.0f;
if (BLI_rctf_isect_pt(&totr, x, y))
return NODE_RESIZE_RIGHT;
else
@@ -479,7 +481,7 @@ static int node_resize_area_default(bNode *node, int x, int y)
}
else {
const float size = 10.0f;
- rctf totr = node->totr;
+ rctf totr= node->totr;
int dir = 0;
if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
@@ -493,7 +495,7 @@ static int node_resize_area_default(bNode *node, int x, int y)
/* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
/* width of socket columns in group display */
-#define NODE_GROUP_FRAME 120
+#define NODE_GROUP_FRAME 120
/* based on settings in node, sets drawing rect info. each redraw! */
/* note: this assumes only 1 group at a time is drawn (linked data) */
@@ -504,11 +506,11 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
node_update_default(C, ntree, gnode);
}
else {
- bNodeTree *ngroup = (bNodeTree *)gnode->id;
+ bNodeTree *ngroup= (bNodeTree *)gnode->id;
bNode *node;
bNodeSocket *sock, *gsock;
float locx, locy;
- rctf *rect = &gnode->totr;
+ rctf *rect= &gnode->totr;
const float dpi_fac = UI_DPI_ICON_FAC;
const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
const float group_header = 26 * dpi_fac;
@@ -524,64 +526,64 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
rect->xmin = rect->xmax = locx;
rect->ymin = rect->ymax = locy;
- counter = 1;
- for (node = ngroup->nodes.first; node; node = node->next) {
+ counter= 1;
+ for (node= ngroup->nodes.first; node; node= node->next) {
if (counter) {
- *rect = node->totr;
- counter = 0;
+ *rect= node->totr;
+ counter= 0;
}
else
BLI_rctf_union(rect, &node->totr);
}
/* add some room for links to group sockets */
- rect->xmin -= 4 * NODE_DY;
- rect->xmax += 4 * NODE_DY;
- rect->ymin -= NODE_DY;
- rect->ymax += NODE_DY;
+ rect->xmin -= 4*NODE_DY;
+ rect->xmax += 4*NODE_DY;
+ rect->ymin-= NODE_DY;
+ rect->ymax+= NODE_DY;
/* input sockets */
dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1));
- gsock = ngroup->inputs.first;
- sock = gnode->inputs.first;
+ gsock=ngroup->inputs.first;
+ sock=gnode->inputs.first;
while (gsock || sock) {
while (sock && !sock->groupsock) {
sock->locx = rect->xmin - node_group_frame;
sock->locy = dy;
/* prevent long socket lists from growing out of the group box */
- if (dy - 3 * NODE_DYS < rect->ymin)
- rect->ymin = dy - 3 * NODE_DYS;
- if (dy + 3 * NODE_DYS > rect->ymax)
- rect->ymax = dy + 3 * NODE_DYS;
- dy -= 2 * NODE_DY;
+ if (dy-3*NODE_DYS < rect->ymin)
+ rect->ymin = dy-3*NODE_DYS;
+ if (dy+3*NODE_DYS > rect->ymax)
+ rect->ymax = dy+3*NODE_DYS;
+ dy -= 2*NODE_DY;
sock = sock->next;
}
- while (gsock && (!sock || sock->groupsock != gsock)) {
+ while (gsock && (!sock || sock->groupsock!=gsock)) {
gsock->locx = rect->xmin;
gsock->locy = dy;
/* prevent long socket lists from growing out of the group box */
- if (dy - 3 * NODE_DYS < rect->ymin)
- rect->ymin = dy - 3 * NODE_DYS;
- if (dy + 3 * NODE_DYS > rect->ymax)
- rect->ymax = dy + 3 * NODE_DYS;
- dy -= 2 * NODE_DY;
+ if (dy-3*NODE_DYS < rect->ymin)
+ rect->ymin = dy-3*NODE_DYS;
+ if (dy+3*NODE_DYS > rect->ymax)
+ rect->ymax = dy+3*NODE_DYS;
+ dy -= 2*NODE_DY;
gsock = gsock->next;
}
- while (sock && gsock && sock->groupsock == gsock) {
+ while (sock && gsock && sock->groupsock==gsock) {
gsock->locx = rect->xmin;
sock->locx = rect->xmin - node_group_frame;
sock->locy = gsock->locy = dy;
/* prevent long socket lists from growing out of the group box */
- if (dy - 3 * NODE_DYS < rect->ymin)
- rect->ymin = dy - 3 * NODE_DYS;
- if (dy + 3 * NODE_DYS > rect->ymax)
- rect->ymax = dy + 3 * NODE_DYS;
- dy -= 2 * NODE_DY;
+ if (dy-3*NODE_DYS < rect->ymin)
+ rect->ymin = dy-3*NODE_DYS;
+ if (dy+3*NODE_DYS > rect->ymax)
+ rect->ymax = dy+3*NODE_DYS;
+ dy -= 2*NODE_DY;
sock = sock->next;
gsock = gsock->next;
@@ -590,46 +592,46 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
/* output sockets */
dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1));
- gsock = ngroup->outputs.first;
- sock = gnode->outputs.first;
+ gsock=ngroup->outputs.first;
+ sock=gnode->outputs.first;
while (gsock || sock) {
while (sock && !sock->groupsock) {
sock->locx = rect->xmax + node_group_frame;
sock->locy = dy - NODE_DYS;
/* prevent long socket lists from growing out of the group box */
- if (dy - 3 * NODE_DYS < rect->ymin)
- rect->ymin = dy - 3 * NODE_DYS;
- if (dy + 3 * NODE_DYS > rect->ymax)
- rect->ymax = dy + 3 * NODE_DYS;
- dy -= 2 * NODE_DY;
+ if (dy-3*NODE_DYS < rect->ymin)
+ rect->ymin = dy-3*NODE_DYS;
+ if (dy+3*NODE_DYS > rect->ymax)
+ rect->ymax = dy+3*NODE_DYS;
+ dy -= 2*NODE_DY;
sock = sock->next;
}
- while (gsock && (!sock || sock->groupsock != gsock)) {
+ while (gsock && (!sock || sock->groupsock!=gsock)) {
gsock->locx = rect->xmax;
gsock->locy = dy - NODE_DYS;
/* prevent long socket lists from growing out of the group box */
- if (dy - 3 * NODE_DYS < rect->ymin)
- rect->ymin = dy - 3 * NODE_DYS;
- if (dy + 3 * NODE_DYS > rect->ymax)
- rect->ymax = dy + 3 * NODE_DYS;
- dy -= 2 * NODE_DY;
+ if (dy-3*NODE_DYS < rect->ymin)
+ rect->ymin = dy-3*NODE_DYS;
+ if (dy+3*NODE_DYS > rect->ymax)
+ rect->ymax = dy+3*NODE_DYS;
+ dy -= 2*NODE_DY;
gsock = gsock->next;
}
- while (sock && gsock && sock->groupsock == gsock) {
+ while (sock && gsock && sock->groupsock==gsock) {
gsock->locx = rect->xmax;
sock->locx = rect->xmax + node_group_frame;
sock->locy = gsock->locy = dy - NODE_DYS;
/* prevent long socket lists from growing out of the group box */
- if (dy - 3 * NODE_DYS < rect->ymin)
- rect->ymin = dy - 3 * NODE_DYS;
- if (dy + 3 * NODE_DYS > rect->ymax)
- rect->ymax = dy + 3 * NODE_DYS;
- dy -= 2 * NODE_DY;
+ if (dy-3*NODE_DYS < rect->ymin)
+ rect->ymin = dy-3*NODE_DYS;
+ if (dy+3*NODE_DYS > rect->ymax)
+ rect->ymax = dy+3*NODE_DYS;
+ dy -= 2*NODE_DY;
sock = sock->next;
gsock = gsock->next;
@@ -640,16 +642,16 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
* Add margin for header and input/output columns.
*/
uiExplicitBoundsBlock(gnode->block,
- rect->xmin - node_group_frame,
- rect->ymin,
- rect->xmax + node_group_frame,
- rect->ymax + group_header);
+ rect->xmin - node_group_frame,
+ rect->ymin,
+ rect->xmax + node_group_frame,
+ rect->ymax + group_header);
}
}
static void update_group_input_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v)
{
- bNodeTree *ngroup = (bNodeTree *)ngroup_v;
+ bNodeTree *ngroup= (bNodeTree*)ngroup_v;
ngroup->update |= NTREE_UPDATE_GROUP_IN;
ntreeUpdateTree(ngroup);
@@ -657,7 +659,7 @@ static void update_group_input_cb(bContext *UNUSED(C), void *UNUSED(snode_v), vo
static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v)
{
- bNodeTree *ngroup = (bNodeTree *)ngroup_v;
+ bNodeTree *ngroup= (bNodeTree*)ngroup_v;
ngroup->update |= NTREE_UPDATE_GROUP_OUT;
ntreeUpdateTree(ngroup);
@@ -672,7 +674,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
but = uiDefBut(gnode->block, TEX, 0, "",
sock->locx + xoffset, sock->locy + 1 + yoffset, width, height,
sock->name, 0, sizeof(sock->name), 0, 0, "");
- if (in_out == SOCK_IN)
+ if (in_out==SOCK_IN)
uiButSetFunc(but, update_group_input_cb, snode, ngroup);
else
uiButSetFunc(but, update_group_output_cb, snode, ngroup);
@@ -689,8 +691,8 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
{
const float dpi_fac = UI_DPI_ICON_FAC;
- bNodeTree *ngroup = (bNodeTree *)gnode->id;
- bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type);
+ bNodeTree *ngroup= (bNodeTree*)gnode->id;
+ bNodeSocketType *stype= ntreeGetSocketType(gsock ? gsock->type : sock->type);
uiBut *bt;
float offset;
int draw_value;
@@ -716,9 +718,9 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
node_socket_circle_draw(ngroup, gsock, socket_size, gsock->flag & SELECT);
/* socket name */
- offset = (in_out == SOCK_IN ? col1 : cor3);
+ offset = (in_out==SOCK_IN ? col1 : cor3);
if (!gsock)
- offset += (in_out == SOCK_IN ? node_group_frame : -node_group_frame);
+ offset += (in_out==SOCK_IN ? node_group_frame : -node_group_frame);
/* draw both name and value button if:
* 1) input: not internal
@@ -726,13 +728,13 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
*/
draw_value = 0;
switch (in_out) {
- case SOCK_IN:
- draw_value = !(gsock && (gsock->flag & SOCK_INTERNAL));
- break;
- case SOCK_OUT:
- if (gnode->typeinfo->flag & NODE_CONST_OUTPUT)
- draw_value = !(gsock && gsock->link);
- break;
+ case SOCK_IN:
+ draw_value = !(gsock && (gsock->flag & SOCK_INTERNAL));
+ break;
+ case SOCK_OUT:
+ if (gnode->typeinfo->flag & NODE_CONST_OUTPUT)
+ draw_value = !(gsock && gsock->link);
+ break;
}
if (draw_value) {
/* both name and value buttons */
@@ -759,17 +761,17 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
if (gsock && (gsock->flag & SOCK_DYNAMIC)) {
/* up/down buttons */
- offset = (in_out == SOCK_IN ? col2 : cor2);
+ offset = (in_out==SOCK_IN ? col2 : cor2);
uiBlockSetDirection(gnode->block, UI_TOP);
uiBlockBeginAlign(gnode->block);
bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP,
- gsock->locx + offset, gsock->locy, arrowbutw, arrowbutw, "");
+ gsock->locx+offset, gsock->locy, arrowbutw, arrowbutw, "");
if (!gsock->prev || !(gsock->prev->flag & SOCK_DYNAMIC))
uiButSetFlag(bt, UI_BUT_DISABLED);
RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN,
- gsock->locx + offset, gsock->locy - arrowbutw, arrowbutw, arrowbutw, "");
+ gsock->locx+offset, gsock->locy-arrowbutw, arrowbutw, arrowbutw, "");
if (!gsock->next || !(gsock->next->flag & SOCK_DYNAMIC))
uiButSetFlag(bt, UI_BUT_DISABLED);
RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
@@ -778,10 +780,10 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
uiBlockSetDirection(gnode->block, 0);
/* remove button */
- offset = (in_out == SOCK_IN ? col3 : cor1);
+ offset = (in_out==SOCK_IN ? col3 : cor1);
uiBlockSetEmboss(gnode->block, UI_EMBOSSN);
bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X,
- gsock->locx + offset, gsock->locy - 0.5f * arrowbutw, arrowbutw, arrowbutw, "");
+ gsock->locx+offset, gsock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, "");
RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
uiBlockSetEmboss(gnode->block, UI_EMBOSS);
@@ -795,11 +797,11 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
node_draw_default(C, ar, snode, ntree, gnode);
}
else {
- bNodeTree *ngroup = (bNodeTree *)gnode->id;
+ bNodeTree *ngroup= (bNodeTree *)gnode->id;
bNodeSocket *sock, *gsock;
uiLayout *layout;
PointerRNA ptr;
- rctf rect = gnode->totr;
+ rctf rect= gnode->totr;
const float dpi_fac = UI_DPI_ICON_FAC;
const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
const float group_header = 26 * dpi_fac;
@@ -810,42 +812,41 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
glEnable(GL_BLEND);
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70);
- uiDrawBox(GL_POLYGON,
+ uiDrawBox(GL_TRIANGLE_FAN,
rect.xmin - node_group_frame, rect.ymax,
rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD);
/* backdrop body */
UI_ThemeColorShadeAlpha(TH_BACK, -8, -70);
uiSetRoundBox(UI_CNR_NONE);
- uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, BASIS_RAD);
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmin, rect.ymin, rect.xmax, rect.ymax, BASIS_RAD);
/* input column */
UI_ThemeColorShadeAlpha(TH_BACK, 10, -50);
uiSetRoundBox(UI_CNR_BOTTOM_LEFT);
- uiDrawBox(GL_POLYGON, rect.xmin - node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD);
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmin-node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD);
/* output column */
UI_ThemeColorShadeAlpha(TH_BACK, 10, -50);
uiSetRoundBox(UI_CNR_BOTTOM_RIGHT);
- uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax + node_group_frame, rect.ymax, BASIS_RAD);
-
+ uiDrawBox(GL_TRIANGLE_FAN, rect.xmax, rect.ymin, rect.xmax+node_group_frame, rect.ymax, BASIS_RAD);
+
+ gpuCurrentGray4f(0.784f, 0.549f);
+
/* input column separator */
- glColor4ub(200, 200, 200, 140);
- glBegin(GL_LINES);
- glVertex2f(rect.xmin, rect.ymin);
- glVertex2f(rect.xmin, rect.ymax);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(rect.xmin, rect.ymin);
+ gpuVertex2f(rect.xmin, rect.ymax);
+ gpuEnd();
/* output column separator */
- glColor4ub(200, 200, 200, 140);
- glBegin(GL_LINES);
- glVertex2f(rect.xmax, rect.ymin);
- glVertex2f(rect.xmax, rect.ymax);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(rect.xmax, rect.ymin);
+ gpuVertex2f(rect.xmax, rect.ymax);
+ gpuEnd();
/* group node outline */
uiSetRoundBox(UI_CNR_ALL);
- glColor4ub(200, 200, 200, 140);
glEnable(GL_LINE_SMOOTH);
uiDrawBox(GL_LINE_LOOP,
rect.xmin - node_group_frame, rect.ymin,
@@ -860,47 +861,47 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
(int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))),
min_ii((int)(BLI_rctf_size_x(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
- uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL);
+ uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL);
uiBlockLayoutResolve(gnode->block, NULL, NULL);
/* draw the internal tree nodes and links */
node_draw_nodetree(C, ar, snode, ngroup);
/* group sockets */
- gsock = ngroup->inputs.first;
- sock = gnode->inputs.first;
+ gsock=ngroup->inputs.first;
+ sock=gnode->inputs.first;
index = 0;
while (gsock || sock) {
while (sock && !sock->groupsock) {
draw_group_socket(C, snode, ntree, gnode, sock, NULL, index, SOCK_IN);
sock = sock->next;
}
- while (gsock && (!sock || sock->groupsock != gsock)) {
+ while (gsock && (!sock || sock->groupsock!=gsock)) {
draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_IN);
gsock = gsock->next;
index++;
}
- while (sock && gsock && sock->groupsock == gsock) {
+ while (sock && gsock && sock->groupsock==gsock) {
draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_IN);
sock = sock->next;
gsock = gsock->next;
index++;
}
}
- gsock = ngroup->outputs.first;
- sock = gnode->outputs.first;
+ gsock=ngroup->outputs.first;
+ sock=gnode->outputs.first;
index = 0;
while (gsock || sock) {
while (sock && !sock->groupsock) {
draw_group_socket(C, snode, ntree, gnode, sock, NULL, index, SOCK_OUT);
sock = sock->next;
}
- while (gsock && (!sock || sock->groupsock != gsock)) {
+ while (gsock && (!sock || sock->groupsock!=gsock)) {
draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_OUT);
gsock = gsock->next;
index++;
}
- while (sock && gsock && sock->groupsock == gsock) {
+ while (sock && gsock && sock->groupsock==gsock) {
draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_OUT);
sock = sock->next;
gsock = gsock->next;
@@ -910,7 +911,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
uiEndBlock(C, gnode->block);
uiDrawBlock(C, gnode->block);
- gnode->block = NULL;
+ gnode->block= NULL;
}
}
@@ -1026,7 +1027,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN
/* body */
if (node->flag & NODE_CUSTOM_COLOR)
- glColor4f(node->color[0], node->color[1], node->color[2], alpha);
+ gpuCurrentColor4f(node->color[0], node->color[1], node->color[2], alpha);
else
UI_ThemeColor4(TH_NODE_FRAME);
glEnable(GL_BLEND);
@@ -1194,13 +1195,13 @@ static void node_common_set_butfunc(bNodeType *ntype)
{
switch (ntype->type) {
case NODE_GROUP:
- ntype->uifunc = node_uifunc_group;
- ntype->drawfunc = node_draw_group;
- ntype->drawupdatefunc = node_update_group;
+ ntype->uifunc= node_uifunc_group;
+ ntype->drawfunc= node_draw_group;
+ ntype->drawupdatefunc= node_update_group;
break;
case NODE_FRAME:
ntype->drawfunc = node_draw_frame;
- ntype->drawupdatefunc = node_update_frame;
+ ntype->drawupdatefunc= node_update_frame;
ntype->uifuncbut = node_buts_frame_details;
ntype->resize_area_func = node_resize_area_frame;
break;
@@ -1256,7 +1257,7 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- bNode *node = ptr->data;
+ bNode *node= ptr->data;
uiLayout *col;
uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL);
@@ -1301,13 +1302,13 @@ static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), Po
static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
+ PointerRNA obptr= CTX_data_pointer_get(C, "active_object");
uiLayout *col;
col = uiLayoutColumn(layout, FALSE);
if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
- PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
+ PointerRNA dataptr= RNA_pointer_get(&obptr, "data");
uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", ICON_NONE);
uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", ICON_NONE);
@@ -1485,73 +1486,73 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_MATERIAL:
case SH_NODE_MATERIAL_EXT:
- ntype->uifunc = node_shader_buts_material;
+ ntype->uifunc= node_shader_buts_material;
break;
case SH_NODE_TEXTURE:
- ntype->uifunc = node_buts_texture;
+ ntype->uifunc= node_buts_texture;
break;
case SH_NODE_NORMAL:
- ntype->uifunc = node_buts_normal;
+ ntype->uifunc= node_buts_normal;
break;
case SH_NODE_CURVE_VEC:
- ntype->uifunc = node_buts_curvevec;
+ ntype->uifunc= node_buts_curvevec;
break;
case SH_NODE_CURVE_RGB:
- ntype->uifunc = node_buts_curvecol;
+ ntype->uifunc= node_buts_curvecol;
break;
case SH_NODE_MAPPING:
- ntype->uifunc = node_shader_buts_mapping;
+ ntype->uifunc= node_shader_buts_mapping;
break;
case SH_NODE_VALUE:
- ntype->uifunc = node_buts_value;
+ ntype->uifunc= node_buts_value;
break;
case SH_NODE_RGB:
- ntype->uifunc = node_buts_rgb;
+ ntype->uifunc= node_buts_rgb;
break;
case SH_NODE_MIX_RGB:
- ntype->uifunc = node_buts_mix_rgb;
+ ntype->uifunc= node_buts_mix_rgb;
break;
case SH_NODE_VALTORGB:
- ntype->uifunc = node_buts_colorramp;
+ ntype->uifunc= node_buts_colorramp;
break;
case SH_NODE_MATH:
- ntype->uifunc = node_buts_math;
+ ntype->uifunc= node_buts_math;
break;
case SH_NODE_VECT_MATH:
- ntype->uifunc = node_shader_buts_vect_math;
+ ntype->uifunc= node_shader_buts_vect_math;
break;
case SH_NODE_GEOMETRY:
- ntype->uifunc = node_shader_buts_geometry;
+ ntype->uifunc= node_shader_buts_geometry;
break;
case SH_NODE_ATTRIBUTE:
- ntype->uifunc = node_shader_buts_attribute;
+ ntype->uifunc= node_shader_buts_attribute;
break;
case SH_NODE_TEX_SKY:
- ntype->uifunc = node_shader_buts_tex_sky;
+ ntype->uifunc= node_shader_buts_tex_sky;
break;
case SH_NODE_TEX_IMAGE:
- ntype->uifunc = node_shader_buts_tex_image;
+ ntype->uifunc= node_shader_buts_tex_image;
break;
case SH_NODE_TEX_ENVIRONMENT:
- ntype->uifunc = node_shader_buts_tex_environment;
+ ntype->uifunc= node_shader_buts_tex_environment;
break;
case SH_NODE_TEX_GRADIENT:
- ntype->uifunc = node_shader_buts_tex_gradient;
+ ntype->uifunc= node_shader_buts_tex_gradient;
break;
case SH_NODE_TEX_MAGIC:
- ntype->uifunc = node_shader_buts_tex_magic;
+ ntype->uifunc= node_shader_buts_tex_magic;
break;
case SH_NODE_TEX_BRICK:
ntype->uifunc = node_shader_buts_tex_brick;
break;
case SH_NODE_TEX_WAVE:
- ntype->uifunc = node_shader_buts_tex_wave;
+ ntype->uifunc= node_shader_buts_tex_wave;
break;
case SH_NODE_TEX_MUSGRAVE:
- ntype->uifunc = node_shader_buts_tex_musgrave;
+ ntype->uifunc= node_shader_buts_tex_musgrave;
break;
case SH_NODE_TEX_VORONOI:
- ntype->uifunc = node_shader_buts_tex_voronoi;
+ ntype->uifunc= node_shader_buts_tex_voronoi;
break;
case SH_NODE_TEX_COORD:
ntype->uifunc = node_shader_buts_tex_coord;
@@ -1565,7 +1566,7 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_BSDF_GLOSSY:
case SH_NODE_BSDF_GLASS:
case SH_NODE_BSDF_REFRACTION:
- ntype->uifunc = node_shader_buts_glossy;
+ ntype->uifunc= node_shader_buts_glossy;
break;
case SH_NODE_SCRIPT:
ntype->uifunc = node_shader_buts_script;
@@ -1578,7 +1579,7 @@ static void node_shader_set_butfunc(bNodeType *ntype)
static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- bNode *node = ptr->data;
+ bNode *node= ptr->data;
PointerRNA imaptr, iuserptr;
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
@@ -1608,13 +1609,13 @@ static void node_composit_buts_image_details(uiLayout *layout, bContext *C, Poin
static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- bNode *node = ptr->data;
+ bNode *node= ptr->data;
uiLayout *col, *row;
PointerRNA op_ptr;
PointerRNA scn_ptr;
PropertyRNA *prop;
const char *layer_name;
- char scene_name[MAX_ID_NAME - 2];
+ char scene_name[MAX_ID_NAME-2];
wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1);
BLI_assert(ot != 0);
@@ -1747,27 +1748,27 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin
uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "quality", 0, "", ICON_NONE);
- if (RNA_enum_get(ptr, "glare_type") != 1) {
+ if (RNA_enum_get(ptr, "glare_type")!= 1) {
uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "glare_type") != 0)
+ if (RNA_enum_get(ptr, "glare_type")!= 0)
uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
}
uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "glare_type") == 2) {
+ if (RNA_enum_get(ptr, "glare_type")== 2) {
uiItemR(layout, ptr, "streaks", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "angle_offset", 0, NULL, ICON_NONE);
}
- if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) {
+ if (RNA_enum_get(ptr, "glare_type")== 0 || RNA_enum_get(ptr, "glare_type")== 2) {
uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "glare_type") == 0)
+ if (RNA_enum_get(ptr, "glare_type")== 0)
uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
}
- if (RNA_enum_get(ptr, "glare_type") == 1) {
+ if (RNA_enum_get(ptr, "glare_type")== 1) {
uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
}
}
@@ -1778,7 +1779,7 @@ static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), Po
col = uiLayoutColumn(layout, FALSE);
uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE);
- if (RNA_enum_get(ptr, "tonemap_type") == 0) {
+ if (RNA_enum_get(ptr, "tonemap_type")== 0) {
uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "gamma", 0, NULL, ICON_NONE);
@@ -1993,7 +1994,7 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C)
col = uiLayoutColumn(layout, FALSE);
uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "limit_method") == 0) {
+ if (RNA_enum_get(ptr, "limit_method")==0) {
uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
row = uiLayoutRow(col, FALSE);
uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -2048,7 +2049,7 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(
col = uiLayoutColumn(layout, FALSE);
uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "limit_method") == 0) {
+ if (RNA_enum_get(ptr, "limit_method")==0) {
uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
row = uiLayoutRow(col, FALSE);
uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -2080,8 +2081,8 @@ static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), Po
/* draw function for file output node sockets, displays only sub-path and format, no value button */
static void node_draw_input_file_output(const bContext *C, uiBlock *block,
- bNodeTree *ntree, bNode *node, bNodeSocket *sock,
- const char *UNUSED(name), int x, int y, int width)
+ bNodeTree *ntree, bNode *node, bNodeSocket *sock,
+ const char *UNUSED(name), int x, int y, int width)
{
uiLayout *layout, *row;
PointerRNA nodeptr, inputptr, imfptr;
@@ -2089,7 +2090,7 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block,
int rx, ry;
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
- layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y + NODE_DY, width, 20, UI_GetStyle());
+ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle());
row = uiLayoutRow(layout, FALSE);
imfptr = RNA_pointer_get(&nodeptr, "format");
@@ -2249,7 +2250,7 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C
uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "correction_method") == 0) {
+ if (RNA_enum_get(ptr, "correction_method")== 0) {
split = uiLayoutSplit(layout, 0.0f, FALSE);
col = uiLayoutColumn(split, FALSE);
@@ -2292,7 +2293,7 @@ static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUS
{
uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "correction_method") == 0) {
+ if (RNA_enum_get(ptr, "correction_method")== 0) {
uiTemplateColorPicker(layout, ptr, "lift", 1, 1, 0, 1);
uiItemR(layout, ptr, "lift", 0, NULL, ICON_NONE);
@@ -2359,7 +2360,7 @@ static void node_composit_buts_movieclip_details(uiLayout *layout, bContext *C,
static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- bNode *node = ptr->data;
+ bNode *node= ptr->data;
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
@@ -2376,7 +2377,7 @@ static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C),
static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- bNode *node = ptr->data;
+ bNode *node= ptr->data;
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
@@ -2527,17 +2528,17 @@ static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNo
if (node->custom1 == 0) {
const float backdropWidth = backdrop->x;
const float backdropHeight = backdrop->y;
- const float cx = x + snode->zoom * backdropWidth * node->custom3;
- const float cy = y + snode->zoom * backdropHeight * node->custom4;
+ const float cx = x+snode->zoom*backdropWidth*node->custom3;
+ const float cy = y+snode->zoom*backdropHeight*node->custom4;
- glColor3f(1.0, 1.0, 1.0);
+ gpuCurrentColor3x(CPACK_WHITE);
- glBegin(GL_LINES);
- glVertex2f(cx - 25, cy - 25);
- glVertex2f(cx + 25, cy + 25);
- glVertex2f(cx + 25, cy - 25);
- glVertex2f(cx - 25, cy + 25);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2f(cx-25, cy-25);
+ gpuVertex2f(cx+25, cy+25);
+ gpuVertex2f(cx+25, cy-25);
+ gpuVertex2f(cx-25, cy+25);
+ gpuEnd();
}
}
@@ -2546,7 +2547,7 @@ static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bN
NodeBoxMask *boxmask = node->storage;
const float backdropWidth = backdrop->x;
const float backdropHeight = backdrop->y;
- const float aspect = backdropWidth / backdropHeight;
+ const float aspect = backdropWidth/backdropHeight;
const float rad = DEG2RADF(-boxmask->rotation);
const float cosine = cosf(rad);
const float sine = sinf(rad);
@@ -2560,31 +2561,31 @@ static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bN
/* keep this, saves us from a version patch */
if (snode->zoom == 0.0f) snode->zoom = 1.0f;
- glColor3f(1.0, 1.0, 1.0);
+ gpuCurrentColor3x(CPACK_WHITE);
- cx = x + snode->zoom * backdropWidth * boxmask->x;
- cy = y + snode->zoom * backdropHeight * boxmask->y;
+ cx = x+snode->zoom*backdropWidth*boxmask->x;
+ cy = y+snode->zoom*backdropHeight*boxmask->y;
- x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
- x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
- x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
- x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
- y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
- y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
- y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
- y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
+ x1 = cx - (cosine*halveBoxWidth+sine*halveBoxHeight)*snode->zoom;
+ x2 = cx - (cosine*-halveBoxWidth+sine*halveBoxHeight)*snode->zoom;
+ x3 = cx - (cosine*-halveBoxWidth+sine*-halveBoxHeight)*snode->zoom;
+ x4 = cx - (cosine*halveBoxWidth+sine*-halveBoxHeight)*snode->zoom;
+ y1 = cy - (-sine*halveBoxWidth + cosine*halveBoxHeight)*snode->zoom;
+ y2 = cy - (-sine*-halveBoxWidth + cosine*halveBoxHeight)*snode->zoom;
+ y3 = cy - (-sine*-halveBoxWidth + cosine*-halveBoxHeight)*snode->zoom;
+ y4 = cy - (-sine*halveBoxWidth + cosine*-halveBoxHeight)*snode->zoom;
- glBegin(GL_LINE_LOOP);
- glVertex2f(x1, y1);
- glVertex2f(x2, y2);
- glVertex2f(x3, y3);
- glVertex2f(x4, y4);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(x1, y1);
+ gpuVertex2f(x2, y2);
+ gpuVertex2f(x3, y3);
+ gpuVertex2f(x4, y4);
+ gpuEnd();
}
static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
{
- NodeEllipseMask *ellipsemask = node->storage;
+ NodeEllipseMask * ellipsemask = node->storage;
const float backdropWidth = backdrop->x;
const float backdropHeight = backdrop->y;
const float aspect = backdropWidth / backdropHeight;
@@ -2601,27 +2602,27 @@ static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop
/* keep this, saves us from a version patch */
if (snode->zoom == 0.0f) snode->zoom = 1.0f;
- glColor3f(1.0, 1.0, 1.0);
+ gpuCurrentColor3x(CPACK_WHITE);
- cx = x + snode->zoom * backdropWidth * ellipsemask->x;
- cy = y + snode->zoom * backdropHeight * ellipsemask->y;
+ cx = x+snode->zoom*backdropWidth*ellipsemask->x;
+ cy = y+snode->zoom*backdropHeight*ellipsemask->y;
- x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
- x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
- x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
- x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
- y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
- y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
- y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
- y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
+ x1 = cx - (cosine*halveBoxWidth+sine*halveBoxHeight)*snode->zoom;
+ x2 = cx - (cosine*-halveBoxWidth+sine*halveBoxHeight)*snode->zoom;
+ x3 = cx - (cosine*-halveBoxWidth+sine*-halveBoxHeight)*snode->zoom;
+ x4 = cx - (cosine*halveBoxWidth+sine*-halveBoxHeight)*snode->zoom;
+ y1 = cy - (-sine*halveBoxWidth + cosine*halveBoxHeight)*snode->zoom;
+ y2 = cy - (-sine*-halveBoxWidth + cosine*halveBoxHeight)*snode->zoom;
+ y3 = cy - (-sine*-halveBoxWidth + cosine*-halveBoxHeight)*snode->zoom;
+ y4 = cy - (-sine*halveBoxWidth + cosine*-halveBoxHeight)*snode->zoom;
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
- glVertex2f(x1, y1);
- glVertex2f(x2, y2);
- glVertex2f(x3, y3);
- glVertex2f(x4, y4);
- glEnd();
+ gpuVertex2f(x1, y1);
+ gpuVertex2f(x2, y2);
+ gpuVertex2f(x3, y3);
+ gpuVertex2f(x4, y4);
+ gpuEnd();
}
static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -2643,7 +2644,7 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C),
uiLayout *col;
uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "tile_order") == 0) {
+ if (RNA_enum_get(ptr, "tile_order")==0) {
col = uiLayoutColumn(layout, TRUE);
uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE);
@@ -2754,50 +2755,50 @@ static void node_composit_set_butfunc(bNodeType *ntype)
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
case CMP_NODE_IMAGE:
- ntype->uifunc = node_composit_buts_image;
+ ntype->uifunc= node_composit_buts_image;
ntype->uifuncbut = node_composit_buts_image_details;
break;
case CMP_NODE_R_LAYERS:
- ntype->uifunc = node_composit_buts_renderlayers;
+ ntype->uifunc= node_composit_buts_renderlayers;
break;
case CMP_NODE_NORMAL:
- ntype->uifunc = node_buts_normal;
+ ntype->uifunc= node_buts_normal;
break;
case CMP_NODE_CURVE_VEC:
- ntype->uifunc = node_buts_curvevec;
+ ntype->uifunc= node_buts_curvevec;
break;
case CMP_NODE_CURVE_RGB:
- ntype->uifunc = node_buts_curvecol;
+ ntype->uifunc= node_buts_curvecol;
break;
case CMP_NODE_VALUE:
- ntype->uifunc = node_buts_value;
+ ntype->uifunc= node_buts_value;
break;
case CMP_NODE_RGB:
- ntype->uifunc = node_buts_rgb;
+ ntype->uifunc= node_buts_rgb;
break;
case CMP_NODE_FLIP:
- ntype->uifunc = node_composit_buts_flip;
+ ntype->uifunc= node_composit_buts_flip;
break;
case CMP_NODE_SPLITVIEWER:
- ntype->uifunc = node_composit_buts_splitviewer;
+ ntype->uifunc= node_composit_buts_splitviewer;
break;
case CMP_NODE_MIX_RGB:
- ntype->uifunc = node_buts_mix_rgb;
+ ntype->uifunc= node_buts_mix_rgb;
break;
case CMP_NODE_VALTORGB:
- ntype->uifunc = node_buts_colorramp;
+ ntype->uifunc= node_buts_colorramp;
break;
case CMP_NODE_CROP:
- ntype->uifunc = node_composit_buts_crop;
+ ntype->uifunc= node_composit_buts_crop;
break;
case CMP_NODE_BLUR:
- ntype->uifunc = node_composit_buts_blur;
+ ntype->uifunc= node_composit_buts_blur;
break;
case CMP_NODE_DBLUR:
- ntype->uifunc = node_composit_buts_dblur;
+ ntype->uifunc= node_composit_buts_dblur;
break;
case CMP_NODE_BILATERALBLUR:
- ntype->uifunc = node_composit_buts_bilateralblur;
+ ntype->uifunc= node_composit_buts_bilateralblur;
break;
case CMP_NODE_DEFOCUS:
ntype->uifunc = node_composit_buts_defocus;
@@ -2812,31 +2813,31 @@ static void node_composit_set_butfunc(bNodeType *ntype)
ntype->uifunc = node_composit_buts_lensdist;
break;
case CMP_NODE_VECBLUR:
- ntype->uifunc = node_composit_buts_vecblur;
+ ntype->uifunc= node_composit_buts_vecblur;
break;
case CMP_NODE_FILTER:
- ntype->uifunc = node_composit_buts_filter;
+ ntype->uifunc= node_composit_buts_filter;
break;
case CMP_NODE_MAP_VALUE:
- ntype->uifunc = node_composit_buts_map_value;
+ ntype->uifunc= node_composit_buts_map_value;
break;
case CMP_NODE_MAP_RANGE:
ntype->uifunc = node_composit_buts_map_range;
break;
case CMP_NODE_TIME:
- ntype->uifunc = node_buts_time;
+ ntype->uifunc= node_buts_time;
break;
case CMP_NODE_ALPHAOVER:
- ntype->uifunc = node_composit_buts_alphaover;
+ ntype->uifunc= node_composit_buts_alphaover;
break;
case CMP_NODE_HUE_SAT:
- ntype->uifunc = node_composit_buts_hue_sat;
+ ntype->uifunc= node_composit_buts_hue_sat;
break;
case CMP_NODE_TEXTURE:
- ntype->uifunc = node_buts_texture;
+ ntype->uifunc= node_buts_texture;
break;
case CMP_NODE_DILATEERODE:
- ntype->uifunc = node_composit_buts_dilateerode;
+ ntype->uifunc= node_composit_buts_dilateerode;
break;
case CMP_NODE_INPAINT:
ntype->uifunc = node_composit_buts_inpaint;
@@ -2845,109 +2846,109 @@ static void node_composit_set_butfunc(bNodeType *ntype)
ntype->uifunc = node_composit_buts_despeckle;
break;
case CMP_NODE_OUTPUT_FILE:
- ntype->uifunc = node_composit_buts_file_output;
- ntype->uifuncbut = node_composit_buts_file_output_details;
+ ntype->uifunc= node_composit_buts_file_output;
+ ntype->uifuncbut= node_composit_buts_file_output_details;
ntype->drawinputfunc = node_draw_input_file_output;
break;
case CMP_NODE_DIFF_MATTE:
- ntype->uifunc = node_composit_buts_diff_matte;
+ ntype->uifunc=node_composit_buts_diff_matte;
break;
case CMP_NODE_DIST_MATTE:
- ntype->uifunc = node_composit_buts_distance_matte;
+ ntype->uifunc=node_composit_buts_distance_matte;
break;
case CMP_NODE_COLOR_SPILL:
- ntype->uifunc = node_composit_buts_color_spill;
+ ntype->uifunc=node_composit_buts_color_spill;
break;
case CMP_NODE_CHROMA_MATTE:
- ntype->uifunc = node_composit_buts_chroma_matte;
+ ntype->uifunc=node_composit_buts_chroma_matte;
break;
case CMP_NODE_COLOR_MATTE:
- ntype->uifunc = node_composit_buts_color_matte;
+ ntype->uifunc=node_composit_buts_color_matte;
break;
case CMP_NODE_SCALE:
- ntype->uifunc = node_composit_buts_scale;
+ ntype->uifunc= node_composit_buts_scale;
break;
case CMP_NODE_ROTATE:
- ntype->uifunc = node_composit_buts_rotate;
+ ntype->uifunc=node_composit_buts_rotate;
break;
case CMP_NODE_CHANNEL_MATTE:
- ntype->uifunc = node_composit_buts_channel_matte;
+ ntype->uifunc= node_composit_buts_channel_matte;
break;
case CMP_NODE_LUMA_MATTE:
- ntype->uifunc = node_composit_buts_luma_matte;
+ ntype->uifunc= node_composit_buts_luma_matte;
break;
case CMP_NODE_MAP_UV:
- ntype->uifunc = node_composit_buts_map_uv;
+ ntype->uifunc= node_composit_buts_map_uv;
break;
case CMP_NODE_ID_MASK:
- ntype->uifunc = node_composit_buts_id_mask;
+ ntype->uifunc= node_composit_buts_id_mask;
break;
case CMP_NODE_DOUBLEEDGEMASK:
- ntype->uifunc = node_composit_buts_double_edge_mask;
+ ntype->uifunc= node_composit_buts_double_edge_mask;
break;
case CMP_NODE_MATH:
- ntype->uifunc = node_buts_math;
+ ntype->uifunc= node_buts_math;
break;
case CMP_NODE_INVERT:
- ntype->uifunc = node_composit_buts_invert;
+ ntype->uifunc= node_composit_buts_invert;
break;
case CMP_NODE_PREMULKEY:
- ntype->uifunc = node_composit_buts_premulkey;
+ ntype->uifunc= node_composit_buts_premulkey;
break;
case CMP_NODE_VIEW_LEVELS:
- ntype->uifunc = node_composit_buts_view_levels;
+ ntype->uifunc=node_composit_buts_view_levels;
break;
case CMP_NODE_COLORBALANCE:
- ntype->uifunc = node_composit_buts_colorbalance;
- ntype->uifuncbut = node_composit_buts_colorbalance_but;
+ ntype->uifunc=node_composit_buts_colorbalance;
+ ntype->uifuncbut=node_composit_buts_colorbalance_but;
break;
case CMP_NODE_HUECORRECT:
- ntype->uifunc = node_composit_buts_huecorrect;
+ ntype->uifunc=node_composit_buts_huecorrect;
break;
case CMP_NODE_ZCOMBINE:
- ntype->uifunc = node_composit_buts_zcombine;
+ ntype->uifunc=node_composit_buts_zcombine;
break;
case CMP_NODE_COMBYCCA:
case CMP_NODE_SEPYCCA:
- ntype->uifunc = node_composit_buts_ycc;
+ ntype->uifunc=node_composit_buts_ycc;
break;
case CMP_NODE_MOVIECLIP:
- ntype->uifunc = node_composit_buts_movieclip;
+ ntype->uifunc= node_composit_buts_movieclip;
ntype->uifuncbut = node_composit_buts_movieclip_details;
break;
case CMP_NODE_STABILIZE2D:
- ntype->uifunc = node_composit_buts_stabilize2d;
+ ntype->uifunc= node_composit_buts_stabilize2d;
break;
case CMP_NODE_TRANSFORM:
- ntype->uifunc = node_composit_buts_transform;
+ ntype->uifunc= node_composit_buts_transform;
break;
case CMP_NODE_MOVIEDISTORTION:
- ntype->uifunc = node_composit_buts_moviedistortion;
+ ntype->uifunc= node_composit_buts_moviedistortion;
break;
case CMP_NODE_COLORCORRECTION:
- ntype->uifunc = node_composit_buts_colorcorrection;
- ntype->uifuncbut = node_composit_buts_colorcorrection_but;
+ ntype->uifunc=node_composit_buts_colorcorrection;
+ ntype->uifuncbut=node_composit_buts_colorcorrection_but;
break;
case CMP_NODE_SWITCH:
- ntype->uifunc = node_composit_buts_switch;
+ ntype->uifunc= node_composit_buts_switch;
break;
case CMP_NODE_MASK_BOX:
- ntype->uifunc = node_composit_buts_boxmask;
+ ntype->uifunc= node_composit_buts_boxmask;
ntype->uibackdropfunc = node_composit_backdrop_boxmask;
break;
case CMP_NODE_MASK_ELLIPSE:
- ntype->uifunc = node_composit_buts_ellipsemask;
+ ntype->uifunc= node_composit_buts_ellipsemask;
ntype->uibackdropfunc = node_composit_backdrop_ellipsemask;
break;
case CMP_NODE_BOKEHIMAGE:
- ntype->uifunc = node_composit_buts_bokehimage;
+ ntype->uifunc= node_composit_buts_bokehimage;
break;
case CMP_NODE_BOKEHBLUR:
ntype->uifunc = node_composit_buts_bokehblur;
break;
case CMP_NODE_VIEWER:
ntype->uifunc = NULL;
- ntype->uifuncbut = node_composit_buts_viewer_but;
+ ntype->uifuncbut= node_composit_buts_viewer_but;
ntype->uibackdropfunc = node_composit_backdrop_viewer;
break;
case CMP_NODE_MASK:
@@ -2963,7 +2964,7 @@ static void node_composit_set_butfunc(bNodeType *ntype)
ntype->uifunc = node_composit_buts_trackpos;
break;
default:
- ntype->uifunc = NULL;
+ ntype->uifunc= NULL;
}
}
@@ -2985,8 +2986,8 @@ static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), Poin
static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
PointerRNA tex_ptr;
- bNode *node = ptr->data;
- ID *id = ptr->id.data;
+ bNode *node= ptr->data;
+ ID *id= ptr->id.data;
Tex *tex = (Tex *)node->storage;
uiLayout *col, *row;
@@ -2994,7 +2995,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe
col = uiLayoutColumn(layout, FALSE);
- switch (tex->type) {
+ switch ( tex->type ) {
case TEX_BLEND:
uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE);
row = uiLayoutRow(col, FALSE);
@@ -3075,47 +3076,47 @@ static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), Poin
/* only once called */
static void node_texture_set_butfunc(bNodeType *ntype)
{
- if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) {
+ if ( ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX ) {
ntype->uifunc = node_texture_buts_proc;
}
else {
switch (ntype->type) {
- case TEX_NODE_MATH:
- ntype->uifunc = node_buts_math;
- break;
+ case TEX_NODE_MATH:
+ ntype->uifunc = node_buts_math;
+ break;
- case TEX_NODE_MIX_RGB:
- ntype->uifunc = node_buts_mix_rgb;
- break;
+ case TEX_NODE_MIX_RGB:
+ ntype->uifunc = node_buts_mix_rgb;
+ break;
- case TEX_NODE_VALTORGB:
- ntype->uifunc = node_buts_colorramp;
- break;
+ case TEX_NODE_VALTORGB:
+ ntype->uifunc = node_buts_colorramp;
+ break;
- case TEX_NODE_CURVE_RGB:
- ntype->uifunc = node_buts_curvecol;
- break;
+ case TEX_NODE_CURVE_RGB:
+ ntype->uifunc= node_buts_curvecol;
+ break;
- case TEX_NODE_CURVE_TIME:
- ntype->uifunc = node_buts_time;
- break;
+ case TEX_NODE_CURVE_TIME:
+ ntype->uifunc = node_buts_time;
+ break;
- case TEX_NODE_TEXTURE:
- ntype->uifunc = node_buts_texture;
- break;
+ case TEX_NODE_TEXTURE:
+ ntype->uifunc = node_buts_texture;
+ break;
- case TEX_NODE_BRICKS:
- ntype->uifunc = node_texture_buts_bricks;
- break;
+ case TEX_NODE_BRICKS:
+ ntype->uifunc = node_texture_buts_bricks;
+ break;
- case TEX_NODE_IMAGE:
- ntype->uifunc = node_texture_buts_image;
- break;
+ case TEX_NODE_IMAGE:
+ ntype->uifunc = node_texture_buts_image;
+ break;
- case TEX_NODE_OUTPUT:
- ntype->uifunc = node_texture_buts_output;
- break;
+ case TEX_NODE_OUTPUT:
+ ntype->uifunc = node_texture_buts_output;
+ break;
}
}
}
@@ -3130,10 +3131,10 @@ void ED_node_init_butfuncs(void)
int i;
/* node type ui functions */
- for (i = 0; i < NUM_NTREE_TYPES; ++i) {
+ for (i=0; i < NUM_NTREE_TYPES; ++i) {
treetype = ntreeGetType(i);
if (treetype) {
- for (ntype = treetype->node_types.first; ntype; ntype = ntype->next) {
+ for (ntype= treetype->node_types.first; ntype; ntype= ntype->next) {
/* default ui functions */
ntype->drawfunc = node_draw_default;
ntype->drawupdatefunc = node_update_default;
@@ -3148,44 +3149,44 @@ void ED_node_init_butfuncs(void)
node_common_set_butfunc(ntype);
switch (i) {
- case NTREE_COMPOSIT:
- node_composit_set_butfunc(ntype);
- break;
- case NTREE_SHADER:
- node_shader_set_butfunc(ntype);
- break;
- case NTREE_TEXTURE:
- node_texture_set_butfunc(ntype);
- break;
+ case NTREE_COMPOSIT:
+ node_composit_set_butfunc(ntype);
+ break;
+ case NTREE_SHADER:
+ node_shader_set_butfunc(ntype);
+ break;
+ case NTREE_TEXTURE:
+ node_texture_set_butfunc(ntype);
+ break;
}
}
}
}
/* socket type ui functions */
- for (i = 0; i < NUM_SOCKET_TYPES; ++i) {
+ for (i=0; i < NUM_SOCKET_TYPES; ++i) {
stype = ntreeGetSocketType(i);
if (stype) {
switch (stype->type) {
- case SOCK_FLOAT:
- case SOCK_INT:
- case SOCK_BOOLEAN:
- stype->buttonfunc = node_socket_button_default;
- break;
+ case SOCK_FLOAT:
+ case SOCK_INT:
+ case SOCK_BOOLEAN:
+ stype->buttonfunc = node_socket_button_default;
+ break;
case SOCK_STRING:
stype->buttonfunc = node_socket_button_string;
break;
- case SOCK_VECTOR:
- stype->buttonfunc = node_socket_button_components;
- break;
- case SOCK_RGBA:
- stype->buttonfunc = node_socket_button_color;
- break;
- case SOCK_SHADER:
- stype->buttonfunc = node_socket_button_label;
- break;
- default:
- stype->buttonfunc = NULL;
+ case SOCK_VECTOR:
+ stype->buttonfunc = node_socket_button_components;
+ break;
+ case SOCK_RGBA:
+ stype->buttonfunc = node_socket_button_color;
+ break;
+ case SOCK_SHADER:
+ stype->buttonfunc = node_socket_button_label;
+ break;
+ default:
+ stype->buttonfunc = NULL;
}
}
}
@@ -3196,22 +3197,22 @@ void ED_node_init_butfuncs(void)
void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
{
- if ((snode->flag & SNODE_BACKDRAW) && snode->treetype == NTREE_COMPOSIT) {
- Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ if ((snode->flag & SNODE_BACKDRAW) && snode->treetype==NTREE_COMPOSIT) {
+ Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
void *lock;
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
+ ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
float x, y;
unsigned char *display_buffer;
void *cache_handle;
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPushMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPushMatrix();
/* keep this, saves us from a version patch */
- if (snode->zoom == 0.0f) snode->zoom = 1.0f;
+ if (snode->zoom==0.0f) snode->zoom= 1.0f;
/* somehow the offset has to be calculated inverse */
@@ -3219,8 +3220,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
/* ortho at pixel level curarea */
wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS);
- x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
- y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
+ x = (ar->winx-snode->zoom*ibuf->x)/2 + snode->xof;
+ y = (ar->winy-snode->zoom*ibuf->y)/2 + snode->yof;
display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
@@ -3240,6 +3241,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
#endif
glPixelZoom(snode->zoom, snode->zoom);
+
/* swap bytes, so alpha is most significant one, then just draw it as luminance int */
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT,
@@ -3256,13 +3258,12 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer);
#ifdef __BIG_ENDIAN__
- glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); /* restore default value */
#endif
glPixelZoom(1.0f, 1.0f);
}
else if (snode->flag & SNODE_USE_ALPHA) {
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPixelZoom(snode->zoom, snode->zoom);
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
@@ -3294,10 +3295,10 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
}
}
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPopMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPopMatrix();
}
BKE_image_release_ibuf(ima, ibuf, lock);
@@ -3312,43 +3313,43 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode)
draw_nodespace_grid(snode);
if (snode->flag & SNODE_BACKDRAW) {
- Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
if (ibuf) {
int x, y;
float zoom = 1.0;
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPushMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPushMatrix();
glaDefine2DArea(&sa->winrct);
if (ibuf->x > sa->winx || ibuf->y > sa->winy) {
float zoomx, zoomy;
- zoomx = (float)sa->winx / ibuf->x;
- zoomy = (float)sa->winy / ibuf->y;
+ zoomx= (float)sa->winx/ibuf->x;
+ zoomy= (float)sa->winy/ibuf->y;
zoom = min_ff(zoomx, zoomy);
}
- x = (sa->winx - zoom * ibuf->x) / 2 + snode->xof;
- y = (sa->winy - zoom * ibuf->y) / 2 + snode->yof;
+ x = (sa->winx-zoom*ibuf->x)/2 + snode->xof;
+ y = (sa->winy-zoom*ibuf->y)/2 + snode->yof;
glPixelZoom(zoom, zoom);
- glColor4f(1.0, 1.0, 1.0, 1.0);
+ gpuCurrentColor3x(CPACK_WHITE);
if (ibuf->rect)
glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
- else if (ibuf->channels == 4)
+ else if (ibuf->channels==4)
glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_FLOAT, ibuf->rect_float);
glPixelZoom(1.0, 1.0);
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPopMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPopMatrix();
BKE_image_release_ibuf(ima, ibuf, NULL);
}
@@ -3364,27 +3365,27 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa
int toreroute, fromreroute;
/* in v0 and v3 we put begin/end points */
if (link->fromsock) {
- vec[0][0] = link->fromsock->locx;
- vec[0][1] = link->fromsock->locy;
+ vec[0][0]= link->fromsock->locx;
+ vec[0][1]= link->fromsock->locy;
fromreroute = (link->fromnode && link->fromnode->type == NODE_REROUTE);
}
else {
- if (snode == NULL) return 0;
+ if (snode==NULL) return 0;
copy_v2_v2(vec[0], snode->cursor);
fromreroute = 0;
}
if (link->tosock) {
- vec[3][0] = link->tosock->locx;
- vec[3][1] = link->tosock->locy;
+ vec[3][0]= link->tosock->locx;
+ vec[3][1]= link->tosock->locy;
toreroute = (link->tonode && link->tonode->type == NODE_REROUTE);
}
else {
- if (snode == NULL) return 0;
+ if (snode==NULL) return 0;
copy_v2_v2(vec[3], snode->cursor);
toreroute = 0;
}
- dist = UI_GetThemeValue(TH_NODE_CURVING) * 0.10f * ABS(vec[0][0] - vec[3][0]);
+ dist= UI_GetThemeValue(TH_NODE_CURVING)*0.10f*ABS(vec[0][0] - vec[3][0]);
deltax = vec[3][0] - vec[0][0];
deltay = vec[3][1] - vec[0][1];
/* check direction later, for top sockets */
@@ -3417,6 +3418,7 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa
vec[2][0] = vec[3][0] - dist;
vec[2][1] = vec[3][1];
}
+
if (v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) {
/* clipped */
}
@@ -3435,13 +3437,13 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa
return 0;
}
-#define LINK_RESOL 24
+#define LINK_RESOL 24
#define LINK_ARROW 12 /* position of arrow on the link, LINK_RESOL/2 */
#define ARROW_SIZE 7
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3)
{
- float coord_array[LINK_RESOL + 1][2];
+ float coord_array[LINK_RESOL+1][2];
if (node_link_bezier_points(v2d, snode, link, coord_array, LINK_RESOL)) {
float dist, spline_step = 0.0f;
@@ -3453,10 +3455,12 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
glGetFloatv(GL_LINE_WIDTH, &linew);
/* we can reuse the dist variable here to increment the GL curve eval amount*/
- dist = 1.0f / (float)LINK_RESOL;
+ dist = 1.0f/(float)LINK_RESOL;
glEnable(GL_LINE_SMOOTH);
-
+
+ gpuImmediateFormat_V2();
+
drawarrow = ((link->tonode && (link->tonode->type == NODE_REROUTE)) &&
(link->fromnode && (link->fromnode->type == NODE_REROUTE)));
@@ -3477,19 +3481,22 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
if (do_triple) {
UI_ThemeColorShadeAlpha(th_col3, -80, -120);
glLineWidth(4.0f);
-
- glBegin(GL_LINE_STRIP);
- for (i = 0; i <= LINK_RESOL; i++) {
- glVertex2fv(coord_array[i]);
+
+ gpuBegin(GL_LINE_STRIP);
+
+ for (i=0; i<=LINK_RESOL; i++) {
+ gpuVertex2fv(coord_array[i]);
}
- glEnd();
+
+ gpuEnd();
+
if (drawarrow) {
- glBegin(GL_LINE_STRIP);
- glVertex2fv(arrow1);
- glVertex2fv(arrow);
- glVertex2fv(arrow);
- glVertex2fv(arrow2);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2fv(arrow1);
+ gpuVertex2fv(arrow);
+ gpuVertex2fv(arrow);
+ gpuVertex2fv(arrow2);
+ gpuEnd();
}
}
@@ -3499,40 +3506,42 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
*/
glLineWidth(1.5f);
if (do_shaded) {
- glBegin(GL_LINES);
- for (i = 0; i < LINK_RESOL; i++) {
- UI_ThemeColorBlend(th_col1, th_col2, spline_step);
- glVertex2fv(coord_array[i]);
+ gpuBegin(GL_LINES);
+ for (i=0; i<LINK_RESOL; i++) {
+ UI_ThemeAppendColorBlend(th_col1, th_col2, spline_step);
+ gpuVertex2fv(coord_array[i]);
- UI_ThemeColorBlend(th_col1, th_col2, spline_step + dist);
- glVertex2fv(coord_array[i + 1]);
+ UI_ThemeAppendColorBlend(th_col1, th_col2, spline_step+dist);
+ gpuVertex2fv(coord_array[i+1]);
spline_step += dist;
}
- glEnd();
+ gpuEnd();
}
else {
UI_ThemeColor(th_col1);
- glBegin(GL_LINE_STRIP);
- for (i = 0; i <= LINK_RESOL; i++) {
- glVertex2fv(coord_array[i]);
+ gpuBegin(GL_LINE_STRIP);
+ for (i=0; i<=LINK_RESOL; i++) {
+ gpuVertex2fv(coord_array[i]);
}
- glEnd();
+ gpuEnd();
}
if (drawarrow) {
- glBegin(GL_LINE_STRIP);
- glVertex2fv(arrow1);
- glVertex2fv(arrow);
- glVertex2fv(arrow);
- glVertex2fv(arrow2);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2fv(arrow1);
+ gpuVertex2fv(arrow);
+ gpuVertex2fv(arrow);
+ gpuVertex2fv(arrow2);
+ gpuEnd();
}
glDisable(GL_LINE_SMOOTH);
/* restore previuos linewidth */
glLineWidth(linew);
+
+ gpuImmediateUnformat();
}
}
@@ -3540,22 +3549,22 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
static void node_link_straight_points(View2D *UNUSED(v2d), SpaceNode *snode, bNodeLink *link, float coord_array[][2])
{
if (link->fromsock) {
- coord_array[0][0] = link->fromsock->locx;
- coord_array[0][1] = link->fromsock->locy;
+ coord_array[0][0]= link->fromsock->locx;
+ coord_array[0][1]= link->fromsock->locy;
}
else {
- if (snode == NULL) return;
- coord_array[0][0] = snode->mx;
- coord_array[0][1] = snode->my;
+ if (snode==NULL) return;
+ coord_array[0][0]= snode->mx;
+ coord_array[0][1]= snode->my;
}
if (link->tosock) {
- coord_array[1][0] = link->tosock->locx;
- coord_array[1][1] = link->tosock->locy;
+ coord_array[1][0]= link->tosock->locx;
+ coord_array[1][1]= link->tosock->locy;
}
else {
- if (snode == NULL) return;
- coord_array[1][0] = snode->mx;
- coord_array[1][1] = snode->my;
+ if (snode==NULL) return;
+ coord_array[1][0]= snode->mx;
+ coord_array[1][1]= snode->my;
}
}
@@ -3577,10 +3586,10 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link,
UI_ThemeColorShadeAlpha(th_col3, -80, -120);
glLineWidth(4.0f);
- glBegin(GL_LINES);
- glVertex2fv(coord_array[0]);
- glVertex2fv(coord_array[1]);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2fv(coord_array[0]);
+ gpuVertex2fv(coord_array[1]);
+ gpuEnd();
}
UI_ThemeColor(th_col1);
@@ -3591,28 +3600,28 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link,
* changing color in begin/end blocks.
*/
if (do_shaded) {
- glBegin(GL_LINES);
- for (i = 0; i < LINK_RESOL - 1; ++i) {
- float t = (float)i / (float)(LINK_RESOL - 1);
+ gpuBegin(GL_LINES);
+ for (i=0; i < LINK_RESOL-1; ++i) {
+ float t= (float)i/(float)(LINK_RESOL-1);
UI_ThemeColorBlend(th_col1, th_col2, t);
- glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
- (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
+ gpuVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
+ (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
- t = (float)(i + 1) / (float)(LINK_RESOL - 1);
+ t= (float)(i+1)/(float)(LINK_RESOL-1);
UI_ThemeColorBlend(th_col1, th_col2, t);
- glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
- (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
+ gpuVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
+ (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
}
- glEnd();
+ gpuEnd();
}
else {
- glBegin(GL_LINE_STRIP);
- for (i = 0; i < LINK_RESOL; ++i) {
- float t = (float)i / (float)(LINK_RESOL - 1);
- glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
- (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
+ gpuBegin(GL_LINE_STRIP);
+ for (i=0; i < LINK_RESOL; ++i) {
+ float t= (float)i/(float)(LINK_RESOL-1);
+ gpuVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
+ (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
}
- glEnd();
+ gpuEnd();
}
glDisable(GL_LINE_SMOOTH);
@@ -3625,10 +3634,10 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link,
/* note; this is used for fake links in groups too */
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
{
- int do_shaded = FALSE, th_col1 = TH_HEADER, th_col2 = TH_HEADER;
- int do_triple = FALSE, th_col3 = TH_WIRE;
+ int do_shaded= FALSE, th_col1= TH_HEADER, th_col2= TH_HEADER;
+ int do_triple= FALSE, th_col3= TH_WIRE;
- if (link->fromsock == NULL && link->tosock == NULL)
+ if (link->fromsock==NULL && link->tosock==NULL)
return;
/* new connection */
@@ -3671,28 +3680,3 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
node_draw_link_bezier(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3);
// node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3);
}
-
-void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border)
-{
- glBegin(GL_LINES);
-
- if (border & (NODE_LEFT | NODE_RIGHT)) {
- glVertex2f(cent[0], v2d->cur.ymin);
- glVertex2f(cent[0], v2d->cur.ymax);
- }
- else {
- glVertex2f(cent[0], cent[1] - size);
- glVertex2f(cent[0], cent[1] + size);
- }
-
- if (border & (NODE_TOP | NODE_BOTTOM)) {
- glVertex2f(v2d->cur.xmin, cent[1]);
- glVertex2f(v2d->cur.xmax, cent[1]);
- }
- else {
- glVertex2f(cent[0] - size, cent[1]);
- glVertex2f(cent[0] + size, cent[1]);
- }
-
- glEnd();
-}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 72461cfb2a8..5e50c9fc287 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -44,7 +44,9 @@
#include "BKE_main.h"
#include "BKE_node.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "WM_api.h"
@@ -537,26 +539,26 @@ static void node_circle_draw(float x, float y, float size, char *col, int highli
};
int a;
- glColor3ub(col[0], col[1], col[2]);
-
- glBegin(GL_POLYGON);
+ gpuCurrentColor3ub(col[0], col[1], col[2]);
+
+ gpuBegin(GL_TRIANGLE_FAN);
for (a = 0; a < 16; a++)
- glVertex2f(x + size * si[a], y + size * co[a]);
- glEnd();
+ gpuVertex2f(x + size*si[a], y + size*co[a]);
+ gpuEnd();
if (highlight) {
UI_ThemeColor(TH_TEXT_HI);
glLineWidth(1.5f);
}
else {
- glColor4ub(0, 0, 0, 150);
+ gpuCurrentColor4x(CPACK_BLACK, 0.588f);
}
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
for (a = 0; a < 16; a++)
- glVertex2f(x + size * si[a], y + size * co[a]);
- glEnd();
+ gpuVertex2f(x + size*si[a], y + size*co[a]);
+ gpuEnd();
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
glLineWidth(1.0f);
@@ -579,10 +581,11 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
float x, y;
/* draw checkerboard backdrop to show alpha */
- glColor3ub(120, 120, 120);
- glRectf(prv->xmin, prv->ymin, prv->xmax, prv->ymax);
- glColor3ub(160, 160, 160);
-
+ gpuCurrentGray3f(0.471f);
+ gpuSingleFilledRectf(prv->xmin, prv->ymin, prv->xmax, prv->ymax);
+
+ gpuCurrentGray3f(0.627f);
+
for (y = prv->ymin; y < prv->ymax; y += tile * 2) {
for (x = prv->xmin; x < prv->xmax; x += tile * 2) {
float tilex = tile, tiley = tile;
@@ -592,7 +595,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
if (y + tile > prv->ymax)
tiley = prv->ymax - y;
- glRectf(x, y, x + tilex, y + tiley);
+ gpuSingleFilledRectf(x, y, x + tilex, y + tiley);
}
}
for (y = prv->ymin + tile; y < prv->ymax; y += tile * 2) {
@@ -604,23 +607,22 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
if (y + tile > prv->ymax)
tiley = prv->ymax - y;
- glRectf(x, y, x + tilex, y + tiley);
+ gpuSingleFilledRectf(x, y, x + tilex, y + tiley);
}
}
glPixelZoom(xscale, yscale);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */
+ glEnable(GL_BLEND); /* premul graphics */
- glColor4f(1.0, 1.0, 1.0, 1.0);
+ gpuCurrentColor3x(CPACK_WHITE);
glaDrawPixelsTex(prv->xmin, prv->ymin, preview->xsize, preview->ysize, GL_UNSIGNED_BYTE, preview->rect);
glDisable(GL_BLEND);
glPixelZoom(1.0f, 1.0f);
UI_ThemeColorShadeAlpha(TH_BACK, -15, +100);
- fdrawbox(prv->xmin, prv->ymin, prv->xmax, prv->ymax);
+ gpuSingleWireRectf(prv->xmin, prv->ymin, prv->xmax, prv->ymax);
}
@@ -645,8 +647,8 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha)
ui_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT);
else {
const float margin = 3.0f;
-
- glColor4f(0.0f, 0.0f, 0.0f, 0.33f);
+
+ gpuCurrentColor4x(CPACK_BLACK, 0.333f);
glEnable(GL_BLEND);
uiRoundBox(rct->xmin - margin, rct->ymin - margin,
rct->xmax + margin, rct->ymax + margin, radius + margin);
@@ -771,7 +773,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
/* body */
if (node->flag & NODE_CUSTOM_COLOR)
- glColor3fv(node->color);
+ gpuCurrentColor3fv(node->color);
else
UI_ThemeColor4(TH_NODE);
glEnable(GL_BLEND);
@@ -799,31 +801,34 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
if (node->flag & NODE_MUTED)
node_draw_mute_line(v2d, snode, node);
-
+ gpuImmediateFormat_C4_V2();
+
/* socket inputs, buttons */
for (sock = node->inputs.first; sock; sock = sock->next) {
if (nodeSocketIsHidden(sock))
continue;
-
+
node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT);
node->typeinfo->drawinputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name),
sock->locx + (NODE_DYS / snode->aspect_sqrt), sock->locy - NODE_DYS,
node->width - NODE_DY);
}
-
+
/* socket outputs */
for (sock = node->outputs.first; sock; sock = sock->next) {
if (nodeSocketIsHidden(sock))
continue;
-
+
node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE, sock->flag & SELECT);
node->typeinfo->drawoutputfunc(C, node->block, ntree, node, sock, IFACE_(sock->name),
sock->locx - node->width + (NODE_DYS / snode->aspect_sqrt), sock->locy - NODE_DYS,
node->width - NODE_DY);
}
-
+
+ gpuImmediateUnformat();
+
/* preview */
if (node->flag & NODE_PREVIEW) {
if (node->preview && node->preview->rect && !BLI_rctf_is_empty(&node->prvr))
@@ -925,16 +930,23 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
NULL, 0, 0, 0, 0, "");
}
+ gpuImmediateFormat_C4_V2(); // DOODLE: 4 theme colored lines
+ gpuBegin(GL_LINES);
+
/* scale widget thing */
- UI_ThemeColorShade(color_id, -10);
+
dx = 10.0f;
- fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f);
- fdrawline(rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f);
-
- UI_ThemeColorShade(color_id, +30);
+ UI_ThemeAppendColorShade(color_id, -10);
+ gpuAppendLinef(rct->xmax - dx, centy - 4.0f, rct->xmax-dx, centy+4.0f);
+ gpuAppendLinef(rct->xmax - dx - 3.0f*snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f*snode->aspect, centy + 4.0f);
+
dx -= snode->aspect;
- fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f);
- fdrawline(rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f);
+ UI_ThemeAppendColorShade(color_id, +30);
+ gpuAppendLinef(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f);
+ gpuAppendLinef(rct->xmax - dx - 3.0f*snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f*snode->aspect, centy + 4.0f);
+
+ gpuEnd();
+ gpuImmediateUnformat();
/* sockets */
for (sock = node->inputs.first; sock; sock = sock->next) {
@@ -1084,7 +1096,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
LinkData *linkdata;
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
@@ -1093,7 +1105,6 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
/* only set once */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_MAP1_VERTEX_3);
/* aspect+font, set each time */
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index a3efa15c54a..1971e3ae101 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -585,7 +585,7 @@ static int do_lasso_select_node(bContext *C, const int mcords[][2], short moves,
static int node_lasso_select_exec(bContext *C, wmOperator *op)
{
int mcords_tot;
- const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
+ int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
short select;
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index 5a7bbc21934..e1a49db0e52 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
../../blenfont
../../blenloader
../../imbuf
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -52,4 +53,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_outliner "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 61d513929ad..6cda8660c5b 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -58,7 +58,9 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "UI_interface.h"
@@ -540,16 +542,22 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex)
UI_ThemeColorShadeAlpha(TH_BACK, -15, -200);
+ gpuImmediateFormat_V2(); // DOODLE: a pair of mono lines
+ gpuBegin(GL_LINES);
+
/* draw column separator lines */
- fdrawline((float)sizex,
+ gpuAppendLinef((float)sizex,
v2d->cur.ymax,
(float)sizex,
miny);
- fdrawline((float)sizex + OL_RNA_COL_SIZEX,
+ gpuAppendLinef((float)sizex + OL_RNA_COL_SIZEX,
v2d->cur.ymax,
(float)sizex + OL_RNA_COL_SIZEX,
miny);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, int sizex, ListBase *lb)
@@ -1219,7 +1227,7 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
float ufac = UI_UNIT_X / 20.0f;
uiSetRoundBox(UI_CNR_ALL);
- glColor4ub(255, 255, 255, 100);
+ gpuCurrentColor4x(CPACK_WHITE, 0.392f);
uiRoundBox((float) *offsx - 0.5f * ufac,
(float)ys - 1.0f * ufac,
(float)*offsx + UI_UNIT_Y - 3.0f * ufac,
@@ -1287,15 +1295,15 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
char col[4];
UI_GetThemeColorType4ubv(TH_MATCH, SPACE_OUTLINER, col);
col[3] = 100;
- glColor4ubv((GLubyte *)col);
- glRecti(startx, *starty + 1, ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1);
+ gpuCurrentColor4ubv((GLubyte *)col);
+ gpuSingleFilledRecti(startx, *starty + 1, ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1);
}
/* colors for active/selected data */
if (tselem->type == 0) {
if (te->idcode == ID_SCE) {
if (tselem->id == (ID *)scene) {
- glColor4ub(255, 255, 255, 100);
+ gpuCurrentColor4x(CPACK_WHITE, 0.392f);
active = 2;
}
}
@@ -1305,7 +1313,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
char col[4];
UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col);
col[3] = 100;
- glColor4ubv((GLubyte *)col);
+ gpuCurrentColor4ubv((GLubyte *)col);
active = 2;
}
@@ -1332,24 +1340,23 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
col[3] = 100;
}
- glColor4ubv((GLubyte *)col);
+ gpuCurrentColor4ubv((GLubyte *)col);
}
-
}
else if (scene->obedit && scene->obedit->data == tselem->id) {
- glColor4ub(255, 255, 255, 100);
+ gpuCurrentColor4x(CPACK_WHITE, 0.392f);
active = 2;
}
else {
if (tree_element_active(C, scene, soops, te, 0)) {
- glColor4ub(220, 220, 255, 100);
+ gpuCurrentColor4ub(220, 220, 255, 100);
active = 2;
}
}
}
else {
if (tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active = 2;
- glColor4ub(220, 220, 255, 100);
+ gpuCurrentColor4ub(220, 220, 255, 100);
}
/* active circle */
@@ -1425,7 +1432,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
/* divider */
UI_ThemeColorShade(TH_BACK, -40);
- glRecti(tempx - 10, *starty + 4, tempx - 8, *starty + UI_UNIT_Y - 4);
+ gpuSingleFilledRecti(tempx - 10, *starty + 4, tempx - 8, *starty + UI_UNIT_Y - 4);
glEnable(GL_BLEND);
glPixelTransferf(GL_ALPHA_SCALE, 0.5);
@@ -1472,7 +1479,7 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx,
/* horizontal line? */
if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE))
- glRecti(startx, *starty, startx + UI_UNIT_X, *starty - 1);
+ gpuSingleFilledRecti(startx, *starty, startx + UI_UNIT_X, *starty - 1);
*starty -= UI_UNIT_Y;
@@ -1486,7 +1493,7 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx,
tselem = TREESTORE(te);
if (tselem->type == 0 && te->idcode == ID_OB) {
- glRecti(startx, y1 + UI_UNIT_Y, startx + 1, y2);
+ gpuSingleFilledRecti(startx, y1 + UI_UNIT_Y, startx + 1, y2);
}
}
}
@@ -1495,22 +1502,34 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
{
TreeElement *te;
TreeStoreElem *tselem;
-
+
+ gpuImmediateFormat_V2(); // DOODLE: struct marks, drawn recursively
+ gpuBegin(GL_LINES);
+
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
/* selection status */
- if (TSELEM_OPEN(tselem, soops))
- if (tselem->type == TSE_RNA_STRUCT)
- glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, *starty + UI_UNIT_Y - 1);
+ if (TSELEM_OPEN(tselem, soops)) {
+ if (tselem->type == TSE_RNA_STRUCT) {
+ gpuEnd();
+ gpuDrawFilledRecti(0, *starty + 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, *starty + UI_UNIT_Y - 1);
+ gpuBegin(GL_LINES);
+ }
+ }
*starty -= UI_UNIT_Y;
+
if (TSELEM_OPEN(tselem, soops)) {
outliner_draw_struct_marks(ar, soops, &te->subtree, starty);
- if (tselem->type == TSE_RNA_STRUCT)
- fdrawline(0, (float)*starty + UI_UNIT_Y, ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (float)*starty + UI_UNIT_Y);
+ if (tselem->type == TSE_RNA_STRUCT) {
+ gpuAppendLinef(0, (float)*starty + UI_UNIT_Y, ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (float)*starty + UI_UNIT_Y);
+ }
}
}
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, int *starty)
@@ -1523,7 +1542,7 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb,
/* selection status */
if (tselem->flag & TSE_SELECTED) {
- glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1);
+ gpuSingleFilledRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1);
}
*starty -= UI_UNIT_Y;
if (TSELEM_OPEN(tselem, soops)) outliner_draw_selection(ar, soops, &te->subtree, starty);
@@ -1536,9 +1555,7 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio
TreeElement *te;
int starty, startx;
float col[3];
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // only once
-
+
if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {
/* struct marks */
UI_ThemeColorShadeAlpha(TH_BACK, -15, -200);
@@ -1549,7 +1566,7 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio
/* always draw selection fill before hierarchy */
UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col);
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
outliner_draw_selection(ar, soops, &soops->tree, &starty);
@@ -1577,7 +1594,7 @@ static void outliner_back(ARegion *ar)
ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET;
while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) {
- glRecti(0, ystart, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, ystart + UI_UNIT_Y);
+ gpuSingleFilledRecti(0, ystart, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, ystart + UI_UNIT_Y);
ystart -= 2 * UI_UNIT_Y;
}
}
@@ -1588,7 +1605,8 @@ static void outliner_draw_restrictcols(ARegion *ar)
/* background underneath */
UI_ThemeColor(TH_BACK);
- glRecti((int)ar->v2d.cur.xmax - OL_TOGW,
+ gpuSingleFilledRecti(
+ (int)ar->v2d.cur.xmax - OL_TOGW,
(int)ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT - 1,
(int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH,
(int)ar->v2d.cur.ymax);
@@ -1598,29 +1616,35 @@ static void outliner_draw_restrictcols(ARegion *ar)
ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET;
while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) {
- glRecti((int)ar->v2d.cur.xmax - OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y);
+ gpuSingleFilledRecti((int)ar->v2d.cur.xmax - OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y);
ystart -= 2 * UI_UNIT_Y;
}
UI_ThemeColorShadeAlpha(TH_BACK, -15, -200);
+ gpuImmediateFormat_V2(); // DOODLE: 3 mono lines
+ gpuBegin(GL_LINES);
+
/* view */
- fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX,
+ gpuAppendLinef(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX,
ar->v2d.cur.ymax,
ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX,
ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT);
/* render */
- fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX,
+ gpuAppendLinef(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX,
ar->v2d.cur.ymax,
ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX,
ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT);
/* render */
- fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX,
+ gpuAppendLinef(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX,
ar->v2d.cur.ymax,
ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX,
ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT);
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
/* ****************************************************** */
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 6cfc3f97b31..c85f6f82ba6 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -49,7 +49,7 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "RNA_access.h"
@@ -241,7 +241,7 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar)
/* clear */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
draw_outliner(C);
diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt
index 00f8df299e2..b41986f83de 100644
--- a/source/blender/editors/space_script/CMakeLists.txt
+++ b/source/blender/editors/space_script/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -51,4 +52,6 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_script "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index 1fbd6f08b34..29f8e80a281 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -45,7 +45,7 @@
#include "ED_space_api.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -147,7 +147,7 @@ static void script_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt
index f108d9f1aaa..558e3dc65d4 100644
--- a/source/blender/editors/space_sequencer/CMakeLists.txt
+++ b/source/blender/editors/space_sequencer/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
../../blenlib
../../blenloader
../../imbuf
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -57,6 +58,8 @@ if(WITH_AUDASPACE)
add_definitions(-DWITH_AUDASPACE)
endif()
+add_definitions(-DGLEW_STATIC)
+
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 5fefafaa54a..7f0ae1d7680 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -55,7 +55,9 @@
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "ED_anim_api.h"
@@ -216,7 +218,7 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x
if (length > floor((waveform->length - startsample) / samplestep))
length = floor((waveform->length - startsample) / samplestep);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0; i < length; i++) {
pos = startsample + i * samplestep;
@@ -227,11 +229,11 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x
value = waveform->data[j * 3];
}
- glVertex2f(x1 + i * stepsize, ymid + value * yscale);
+ gpuVertex2f(x1 + i * stepsize, ymid + value * yscale);
}
- glEnd();
+ gpuEnd();
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0; i < length; i++) {
pos = startsample + i * samplestep;
@@ -242,9 +244,9 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x
value = waveform->data[j * 3 + 1];
}
- glVertex2f(x1 + i * stepsize, ymid + value * yscale);
+ gpuVertex2f(x1 + i * stepsize, ymid + value * yscale);
}
- glEnd();
+ gpuEnd();
}
}
@@ -279,7 +281,6 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
float draw_height;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (seqm->flag & SEQ_MUTE)
drawmeta_stipple(1);
@@ -306,7 +307,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
get_seq_color3ubv(scene, seq, col);
- glColor4ubv(col);
+ gpuCurrentColor4ubv(col);
/* clamp within parent sequence strip bounds */
if (x1_chan < x1) x1_chan = x1;
@@ -315,11 +316,11 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
y1_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSBOTTOM);
y2_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSTOP);
- glRectf(x1_chan, y1_chan, x2_chan, y2_chan);
+ gpuSingleFilledRectf(x1_chan, y1_chan, x2_chan, y2_chan);
UI_GetColorPtrShade3ubv(col, col, -30);
- glColor4ubv(col);
- fdrawbox(x1_chan, y1_chan, x2_chan, y2_chan);
+ gpuCurrentColor4ubv(col);
+ gpuSingleWireRectf(x1_chan, y1_chan, x2_chan, y2_chan);
if ((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE))
drawmeta_stipple(0);
@@ -381,22 +382,30 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
BKE_sequence_effect_get_num_inputs(seq->type) == 0)
{
glEnable(GL_BLEND);
+
+ if (seq->flag & whichsel) {
+ gpuCurrentColor4x(CPACK_BLACK, 0.314f);
+ }
+ else if (seq->flag & SELECT) {
+ gpuCurrentColor4x(CPACK_WHITE, 0.118f);
+ }
+ else {
+ gpuCurrentColor4x(CPACK_BLACK, 0.086f);
+ }
+
+ gpuSingleFilledRectf(rx1, y1, rx2, y2);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- if (seq->flag & whichsel) glColor4ub(0, 0, 0, 80);
- else if (seq->flag & SELECT) glColor4ub(255, 255, 255, 30);
- else glColor4ub(0, 0, 0, 22);
-
- glRectf(rx1, y1, rx2, y2);
-
- if (seq->flag & whichsel) glColor4ub(255, 255, 255, 200);
- else glColor4ub(0, 0, 0, 50);
-
+ if (seq->flag & whichsel) {
+ gpuCurrentColor4x(CPACK_WHITE, 0.784f);
+ }
+ else {
+ gpuCurrentColor4x(CPACK_BLACK, 0.196f);
+ }
+
glEnable(GL_POLYGON_SMOOTH);
- glBegin(GL_TRIANGLES);
- glVertex2fv(v1); glVertex2fv(v2); glVertex2fv(v3);
- glEnd();
+ gpuBegin(GL_TRIANGLES);
+ gpuVertex2fv(v1); gpuVertex2fv(v2); gpuVertex2fv(v3);
+ gpuEnd();
glDisable(GL_POLYGON_SMOOTH);
glDisable(GL_BLEND);
@@ -423,105 +432,111 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq)
float x1, x2, y1, y2, pixely, a;
unsigned char col[3], blendcol[3];
View2D *v2d = &ar->v2d;
-
+
if (seq->type >= SEQ_TYPE_EFFECT) return;
x1 = seq->startdisp;
x2 = seq->enddisp;
-
+
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
-
+
if (pixely <= 0) return; /* can happen when the view is split/resized */
-
+
blendcol[0] = blendcol[1] = blendcol[2] = 120;
+ gpuImmediateFormat_V2(); // DOODLE: sequencer extensions
+
if (seq->startofs) {
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+
get_seq_color3ubv(scene, seq, col);
-
+
if (seq->flag & SELECT) {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
- glColor4ub(col[0], col[1], col[2], 170);
+ gpuCurrentColor4ub(col[0], col[1], col[2], 170);
}
else {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
- glColor4ub(col[0], col[1], col[2], 110);
+ gpuCurrentColor4ub(col[0], col[1], col[2], 110);
}
-
- glRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
-
- if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
- else glColor4ub(col[0], col[1], col[2], 160);
- fdrawbox((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1); //outline
-
+ gpuDrawFilledRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
+
+ if (seq->flag & SELECT) gpuCurrentColor4ub(col[0], col[1], col[2], 255);
+ else gpuCurrentColor4ub(col[0], col[1], col[2], 160);
+
+ gpuDrawWireRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1); //outline
+
glDisable(GL_BLEND);
}
if (seq->endofs) {
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+
get_seq_color3ubv(scene, seq, col);
-
+
if (seq->flag & SELECT) {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
- glColor4ub(col[0], col[1], col[2], 170);
+ gpuCurrentColor4ub(col[0], col[1], col[2], 170);
}
else {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
- glColor4ub(col[0], col[1], col[2], 110);
+ gpuCurrentColor4ub(col[0], col[1], col[2], 110);
}
+
+ gpuDrawFilledRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
- glRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
-
- if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
- else glColor4ub(col[0], col[1], col[2], 160);
+ if (seq->flag & SELECT) gpuCurrentColor4ub(col[0], col[1], col[2], 255);
+ else gpuCurrentColor4ub(col[0], col[1], col[2], 160);
- fdrawbox(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); //outline
+ gpuDrawWireRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); //outline
glDisable(GL_BLEND);
}
if (seq->startstill) {
get_seq_color3ubv(scene, seq, col);
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
- glColor3ubv((GLubyte *)col);
-
+ gpuCurrentColor3ubv((GLubyte *)col);
+
draw_shadedstrip(seq, col, x1, y1, (float)(seq->start), y2);
-
+
/* feint pinstripes, helps see exactly which is extended and which isn't,
* especially when the extension is very small */
if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24);
else UI_GetColorPtrShade3ubv(col, col, -16);
-
- glColor3ubv((GLubyte *)col);
-
+
+ gpuCurrentColor3ubv((GLubyte *)col);
+
+ gpuBegin(GL_LINES);
for (a = y1; a < y2; a += pixely * 2.0f) {
- fdrawline(x1, a, (float)(seq->start), a);
+ gpuAppendLinef(x1, a, (float)(seq->start), a);
}
+ gpuEnd();
}
if (seq->endstill) {
get_seq_color3ubv(scene, seq, col);
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
- glColor3ubv((GLubyte *)col);
-
+ gpuCurrentColor3ubv((GLubyte *)col);
+
draw_shadedstrip(seq, col, (float)(seq->start + seq->len), y1, x2, y2);
-
+
/* feint pinstripes, helps see exactly which is extended and which isn't,
* especially when the extension is very small */
if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, 24);
else UI_GetColorPtrShade3ubv(col, col, -16);
-
- glColor3ubv((GLubyte *)col);
-
+
+ gpuCurrentColor3ubv((GLubyte *)col);
+
+ gpuBegin(GL_LINES);
for (a = y1; a < y2; a += pixely * 2.0f) {
- fdrawline((float)(seq->start + seq->len), a, x2, a);
+ gpuAppendLinef((float)(seq->start + seq->len), a, x2, a);
}
+ gpuEnd();
}
+
+ gpuImmediateUnformat();
}
/* draw info text on a sequence strip */
@@ -632,44 +647,44 @@ static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, floa
ymid2 = (y2 - y1) * 0.65f + y1;
glShadeModel(GL_SMOOTH);
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
if (seq->flag & SEQ_INVALID_EFFECT) { col[0] = 255; col[1] = 0; col[2] = 255; }
else if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -50);
/* else UI_GetColorPtrShade3ubv(col, col, 0); */ /* DO NOTHING */
- glColor3ubv(col);
+ gpuColor3ubv(col);
- glVertex2f(x1, y1);
- glVertex2f(x2, y1);
+ gpuVertex2f(x1, y1);
+ gpuVertex2f(x2, y1);
if (seq->flag & SEQ_INVALID_EFFECT) { col[0] = 255; col[1] = 0; col[2] = 255; }
else if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 5);
else UI_GetColorPtrShade3ubv(col, col, -5);
- glColor3ubv((GLubyte *)col);
+ gpuColor3ubv((GLubyte *)col);
- glVertex2f(x2, ymid1);
- glVertex2f(x1, ymid1);
+ gpuVertex2f(x2, ymid1);
+ gpuVertex2f(x1, ymid1);
- glEnd();
+ gpuEnd();
- glRectf(x1, ymid1, x2, ymid2);
+ gpuSingleFilledRectf(x1, ymid1, x2, ymid2);
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
- glVertex2f(x1, ymid2);
- glVertex2f(x2, ymid2);
+ gpuVertex2f(x1, ymid2);
+ gpuVertex2f(x2, ymid2);
if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -15);
else UI_GetColorPtrShade3ubv(col, col, 25);
- glColor3ubv((GLubyte *)col);
+ gpuColor3ubv((GLubyte *)col);
- glVertex2f(x2, y2);
- glVertex2f(x1, y2);
+ gpuVertex2f(x2, y2);
+ gpuVertex2f(x1, y2);
- glEnd();
+ gpuEnd();
if (seq->flag & SEQ_MUTE) {
glDisable(GL_POLYGON_STIPPLE);
@@ -734,14 +749,14 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
glEnable(GL_BLEND);
/* light stripes */
- glColor4ub(255, 255, 255, 32);
+ gpuCurrentColor4x(CPACK_WHITE, 0.125f);
glPolygonStipple(stipple_diag_stripes_pos);
- glRectf(x1, y1, x2, y2);
+ gpuSingleFilledRectf(x1, y1, x2, y2);
/* dark stripes */
- glColor4ub(0, 0, 0, 32);
+ gpuCurrentColor4x(CPACK_BLACK, 0.125f);
glPolygonStipple(stipple_diag_stripes_neg);
- glRectf(x1, y1, x2, y2);
+ gpuSingleFilledRectf(x1, y1, x2, y2);
glDisable(GL_POLYGON_STIPPLE);
glDisable(GL_BLEND);
@@ -751,7 +766,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
glEnable(GL_POLYGON_STIPPLE);
/* panic! */
- glColor4ub(255, 0, 0, 255);
+ gpuCurrentColor4ub(255, 0, 0, 255);
glPolygonStipple(stipple_diag_stripes_pos);
glRectf(x1, y1, x2, y2);
@@ -769,7 +784,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
else
UI_GetColorPtrShade3ubv(col, col, outline_tint);
- glColor3ubv((GLubyte *)col);
+ gpuCurrentColor3ubv((GLubyte *)col);
if (seq->flag & SEQ_MUTE) {
glEnable(GL_LINE_STIPPLE);
@@ -954,12 +969,11 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col);
- glClearColor(col[0], col[1], col[2], 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuColorAndClearvf(col, 0.0);
}
/* without this colors can flicker from previous opengl state */
- glColor4ub(255, 255, 255, 255);
+ gpuCurrentColor3x(CPACK_WHITE);
UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f);
UI_view2d_curRect_validate(v2d);
@@ -1049,7 +1063,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
if (draw_overlay) {
if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
@@ -1059,25 +1073,25 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
tot_clip.xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax);
tot_clip.ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax);
- glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin);
- glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax);
- glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmax, tot_clip.ymax);
- glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmax, tot_clip.ymin);
+ gpuTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); gpuVertex2f(tot_clip.xmin, tot_clip.ymin);
+ gpuTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); gpuVertex2f(tot_clip.xmin, tot_clip.ymax);
+ gpuTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); gpuVertex2f(tot_clip.xmax, tot_clip.ymax);
+ gpuTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); gpuVertex2f(tot_clip.xmax, tot_clip.ymin);
}
else if (sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
- glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
- glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
- glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
- glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
+ gpuTexCoord2f(0.0f, 0.0f); gpuVertex2f(v2d->tot.xmin, v2d->tot.ymin);
+ gpuTexCoord2f(0.0f, 1.0f); gpuVertex2f(v2d->tot.xmin, v2d->tot.ymax);
+ gpuTexCoord2f(1.0f, 1.0f); gpuVertex2f(v2d->tot.xmax, v2d->tot.ymax);
+ gpuTexCoord2f(1.0f, 0.0f); gpuVertex2f(v2d->tot.xmax, v2d->tot.ymin);
}
}
else {
- glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
- glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
- glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
- glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
+ gpuTexCoord2f(0.0f, 0.0f); gpuVertex2f(v2d->tot.xmin, v2d->tot.ymin);
+ gpuTexCoord2f(0.0f, 1.0f); gpuVertex2f(v2d->tot.xmin, v2d->tot.ymax);
+ gpuTexCoord2f(1.0f, 1.0f); gpuVertex2f(v2d->tot.xmax, v2d->tot.ymax);
+ gpuTexCoord2f(1.0f, 0.0f); gpuVertex2f(v2d->tot.xmax, v2d->tot.ymin);
}
- glEnd();
+ gpuEnd();
glBindTexture(GL_TEXTURE_2D, last_texid);
glDisable(GL_TEXTURE_2D);
glDeleteTextures(1, &texid);
@@ -1094,12 +1108,12 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0);
- glBegin(GL_LINE_LOOP);
- glVertex2f(x1 - 0.5f, y1 - 0.5f);
- glVertex2f(x1 - 0.5f, y2 + 0.5f);
- glVertex2f(x2 + 0.5f, y2 + 0.5f);
- glVertex2f(x2 + 0.5f, y1 - 0.5f);
- glEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(x1 - 0.5f, y1 - 0.5f);
+ gpuVertex2f(x1 - 0.5f, y2 + 0.5f);
+ gpuVertex2f(x2 + 0.5f, y2 + 0.5f);
+ gpuVertex2f(x2 + 0.5f, y1 - 0.5f);
+ gpuEnd();
/* safety border */
if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) {
@@ -1201,40 +1215,44 @@ static void draw_seq_backdrop(View2D *v2d)
int i;
/* darker gray overlay over the view backdrop */
+ gpuImmediateFormat_V2();
+
UI_ThemeColorShade(TH_BACK, -20);
- glRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
+ gpuDrawFilledRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
/* Alternating horizontal stripes */
i = max_ii(1, ((int)v2d->cur.ymin) - 1);
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
while (i < v2d->cur.ymax) {
if (((int)i) & 1)
- UI_ThemeColorShade(TH_BACK, -15);
+ UI_ThemeAppendColorShade(TH_BACK, -15);
else
- UI_ThemeColorShade(TH_BACK, -25);
+ UI_ThemeAppendColorShade(TH_BACK, -25);
- glVertex2f(v2d->cur.xmax, i);
- glVertex2f(v2d->cur.xmin, i);
- glVertex2f(v2d->cur.xmin, i + 1);
- glVertex2f(v2d->cur.xmax, i + 1);
+ gpuVertex2f(v2d->cur.xmax, i);
+ gpuVertex2f(v2d->cur.xmin, i);
+ gpuVertex2f(v2d->cur.xmin, i + 1);
+ gpuVertex2f(v2d->cur.xmax, i + 1);
i += 1.0;
}
- glEnd();
+ gpuEnd();
/* Darker lines separating the horizontal bands */
i = max_ii(1, ((int)v2d->cur.ymin) - 1);
UI_ThemeColor(TH_GRID);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
while (i < v2d->cur.ymax) {
- glVertex2f(v2d->cur.xmax, i);
- glVertex2f(v2d->cur.xmin, i);
+ gpuVertex2f(v2d->cur.xmax, i);
+ gpuVertex2f(v2d->cur.xmin, i);
i += 1.0;
}
- glEnd();
+ gpuEnd();
+
+ gpuImmediateUnformat();
}
/* draw the contents of the sequencer strips view */
@@ -1283,18 +1301,23 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
UI_ThemeColorShadeAlpha(TH_BACK, -25, -100);
if (PSFRA < PEFRA) {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
+ gpuSingleFilledRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
UI_ThemeColorShade(TH_BACK, -60);
/* thin lines where the actual frames are */
- fdrawline((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
-
+
+ gpuImmediateFormat_V2(); // DOODLE: two lines, start frame & end frame (copy paste code)
+ gpuBegin(GL_LINES);
+ gpuAppendLinef((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
+ gpuAppendLinef((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
+ gpuEnd();
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
}
@@ -1312,23 +1335,21 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
if (ed && ed->metastack.first)
- glClearColor(col[0], col[1], col[2] - 0.1f, 0.0f);
+ gpuColorAndClear(col[0], col[1], col[2] - 0.1f, 0.0f);
else
- glClearColor(col[0], col[1], col[2], 0.0f);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuColorAndClearvf(col, 0.0f);
UI_view2d_view_ortho(v2d);
-
-
+
+
/* calculate extents of sequencer strips/data
* NOTE: needed for the scrollers later
*/
boundbox_seq(scene, &v2d->tot);
-
-
+
/* draw backdrop */
draw_seq_backdrop(v2d);
-
+
/* regular grid-pattern over the rest of the view (i.e. 25-frame grid lines) */
// NOTE: the gridlines are currently spaced every 25 frames, which is only fine for 25 fps, but maybe not for 30...
UI_view2d_constant_grid_draw(v2d);
@@ -1343,17 +1364,17 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
/* text draw cached (for sequence names), in pixelspace now */
UI_view2d_text_cache_draw(ar);
}
-
+
/* current frame */
UI_view2d_view_ortho(v2d);
if ((sseq->flag & SEQ_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS;
if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX;
ANIM_draw_cfra(C, v2d, flag);
-
+
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
draw_markers_time(C, DRAW_MARKERS_LINES);
-
+
/* preview range */
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d);
@@ -1361,16 +1382,12 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
/* overlap playhead */
if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs;
- glColor3f(0.2, 0.2, 0.2);
- // glRectf(cfra_over, v2d->cur.ymin, scene->ed->over_ofs + scene->r.cfra + 1, v2d->cur.ymax);
-
- glBegin(GL_LINES);
- glVertex2f(cfra_over, v2d->cur.ymin);
- glVertex2f(cfra_over, v2d->cur.ymax);
- glEnd();
+ gpuCurrentGray3f(0.200f);
+ // gpuSingleFilledRectf(cfra_over, v2d->cur.ymin, scene->ed->over_ofs + scene->r.cfra + 1, v2d->cur.ymax);
+ gpuSingleLinef(cfra_over, v2d->cur.ymin, cfra_over, v2d->cur.ymax);
}
-
+
/* reset view matrix */
UI_view2d_view_restore(C);
@@ -1380,5 +1397,3 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
-
-
diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt
index 9cc407f0604..57bea148048 100644
--- a/source/blender/editors/space_text/CMakeLists.txt
+++ b/source/blender/editors/space_text/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -44,6 +45,8 @@ set(SRC
text_intern.h
)
+add_definitions(-DGLEW_STATIC)
+
if(WITH_PYTHON)
list(APPEND INC
../../python
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index d74e32620af..1f806b78dc8 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -49,7 +49,7 @@
#include "ED_space_api.h"
#include "ED_screen.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -430,7 +430,7 @@ static void text_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
// UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 46ab2d9e688..1818c4a5b31 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -51,7 +51,11 @@
#include "BKE_suggestions.h"
#include "BKE_text.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+#include "GPU_utility.h"
+
+#include "BIF_glutil.h"
#include "ED_datafiles.h"
#include "UI_interface.h"
@@ -92,18 +96,6 @@ static int text_font_draw_character(SpaceText *st, int x, int y, char c)
return st->cwidth;
}
-static int text_font_draw_character_utf8(SpaceText *st, int x, int y, const char *c)
-{
- char str[BLI_UTF8_MAX + 1];
- size_t len = BLI_str_utf8_size_safe(c);
- memcpy(str, c, len);
- str[len] = '\0';
-
- BLF_position(mono, x, y, 0);
- BLF_draw(mono, str, len);
-
- return st->cwidth;
-}
/****************** flatten string **********************/
@@ -147,14 +139,15 @@ int flatten_string(SpaceText *st, FlattenString *fs, const char *in)
fs->accum = fs->fixedaccum;
fs->len = sizeof(fs->fixedbuf);
- for (r = 0, i = 0; *in; r++) {
+ i = 0;
+ for (r = 0; *in; r++) {
if (*in == '\t') {
i = st->tabnumber - (total % st->tabnumber);
total += i;
-
+
while (i--)
flatten_string_append(fs, " ", r, 1);
-
+
in++;
}
else {
@@ -164,7 +157,7 @@ int flatten_string(SpaceText *st, FlattenString *fs, const char *in)
total++;
}
}
-
+
flatten_string_append(fs, "\0", r, 1);
return total;
@@ -721,6 +714,11 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w
for (i = 0, mi = 0; str[mi]; i++, mi += BLI_str_utf8_size_safe(str + mi)) {
if (i - start >= max) {
+ int ox;
+ char last_format;
+ char buffer[BLF_DRAW_STR_DUMMY_MAX];
+ size_t len = 0;
+
/* skip hidden part of line */
if (skip) {
skip--;
@@ -729,11 +727,43 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w
continue;
}
+ if (st->showsyntax && format) {
+ last_format = format[start];
+ format_draw_color(format[start]);
+ }
+
+ ox = x;
+
+ ma = mstart;
+
/* Draw the visible portion of text on the overshot line */
- for (a = start, ma = mstart; a < end; a++, ma += BLI_str_utf8_size_safe(str + ma)) {
- if (st->showsyntax && format) format_draw_color(format[a]);
- x += text_font_draw_character_utf8(st, x, y, str + ma);
+ for (a = start; a < end; a++) {
+ size_t char_len;
+
+ if (st->showsyntax && format && last_format != format[a]) {
+ memcpy(buffer, str + ma - len, len);
+ buffer[len] = '\0';
+ text_font_draw(st, ox, y, buffer);
+
+ ox = x;
+ len = 0;
+
+ format_draw_color(format[a]);
+ last_format = format[a];
+ }
+
+ char_len = BLI_str_utf8_size(str + ma);
+ len += char_len;
+ ma += char_len;
+
+ x += st->cwidth;
}
+
+ /* draw last chunk */
+ memcpy(buffer, str + ma - len, len);
+ buffer[len] = '\0';
+ text_font_draw(st, ox, y, buffer);
+
y -= st->lheight + TXT_LINE_SPACING;
x = basex;
lines++;
@@ -748,11 +778,48 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w
}
/* Draw the remaining text */
- for (a = start, ma = mstart; str[ma] && y > 0; a++, ma += BLI_str_utf8_size_safe(str + ma)) {
- if (st->showsyntax && format)
- format_draw_color(format[a]);
+ if (y > 0) {
+ int ox;
+ char last_format;
+ char buffer[BLF_DRAW_STR_DUMMY_MAX];
+ size_t len = 0;
+ const int showsyntax = st->showsyntax && format;
+
+ if (showsyntax) {
+ last_format = format[start];
+ format_draw_color(format[start]);
+ }
+
+ ox = x;
+
+ ma = mstart;
+
+ for (a = start; str[ma]; a++) {
+ size_t char_len;
+
+ if (showsyntax && last_format != format[a]) {
+ memcpy(buffer, str + ma - len, len);
+ buffer[len] = '\0';
+ text_font_draw(st, ox, y, buffer);
+
+ ox = x;
+ len = 0;
+
+ format_draw_color(format[a]);
+ last_format = format[a];
+ }
+
+ char_len = BLI_str_utf8_size(str + ma);
+ len += char_len;
+ ma += char_len;
+
+ x += st->cwidth;
+ }
- x += text_font_draw_character_utf8(st, x, y, str + ma);
+ /* draw last chunk */
+ memcpy(buffer, str + ma - len, len);
+ buffer[len] = '\0';
+ text_font_draw(st, ox, y, buffer);
}
flatten_string_free(&fs);
@@ -777,17 +844,52 @@ static int text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int dra
w = w - cshift;
if (draw) {
- int amount = maxwidth ? MIN2(w, maxwidth) : w;
-
+ int amount =
+ maxwidth ?
+ MIN3(w, maxwidth, BLF_DRAW_STR_DUMMY_MAX) :
+ MIN2(w, BLF_DRAW_STR_DUMMY_MAX);
+
if (st->showsyntax && format) {
- int a, str_shift = 0;
+ int a;
+ int str_shift = 0;
+ int ox;
+ char last_format;
+ char buffer[BLF_DRAW_STR_DUMMY_MAX];
+ size_t len = 0;
+
format = format + cshift;
+ last_format = format[0];
+ format_draw_color(format[0]);
+
+ ox = x;
+
for (a = 0; a < amount; a++) {
- format_draw_color(format[a]);
- x += text_font_draw_character_utf8(st, x, y, in + str_shift);
- str_shift += BLI_str_utf8_size_safe(in + str_shift);
+ size_t char_len;
+
+ if (last_format != format[a]) {
+ memcpy(buffer, in + str_shift - len, len);
+ buffer[len] = '\0';
+ text_font_draw(st, ox, y, buffer);
+
+ ox = x;
+ len = 0;
+
+ format_draw_color(format[a]);
+ last_format = format[a];
+ }
+
+ char_len = BLI_str_utf8_size(in + str_shift);
+ str_shift += char_len;
+ len += char_len;
+
+ x += st->cwidth;
}
+
+ /* draw last chunk */
+ memcpy(buffer, in + str_shift - len, len);
+ buffer[len] = '\0';
+ text_font_draw(st, ox, y, buffer);
}
else text_font_draw(st, x, y, in);
}
@@ -1193,7 +1295,7 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back)
float rad;
UI_ThemeColor(TH_BACK);
- glRecti(back->xmin, back->ymin, back->xmax, back->ymax);
+ gpuSingleFilledRecti(back->xmin, back->ymin, back->xmax, back->ymax);
uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0);
@@ -1201,7 +1303,7 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back)
rad = 0.4f * min_ii(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll));
UI_GetThemeColor3ubv(TH_HILITE, col);
col[3] = 48;
- glColor4ubv(col);
+ gpuCurrentColor4ubv(col);
glEnable(GL_BLEND);
uiRoundBox(st->txtscroll.xmin + 1, st->txtscroll.ymin, st->txtscroll.xmax - 1, st->txtscroll.ymax, rad);
glDisable(GL_BLEND);
@@ -1243,26 +1345,30 @@ static void draw_documentation(SpaceText *st, ARegion *ar)
/* Draw panel */
UI_ThemeColor(TH_BACK);
- glRecti(x, y, x + boxw, y - boxh);
+ gpuSingleFilledRecti(x, y, x + boxw, y - boxh);
UI_ThemeColor(TH_SHADE1);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, y);
- glVertex2i(x + boxw, y);
- glVertex2i(x + boxw, y - boxh);
- glVertex2i(x, y - boxh);
- glEnd();
- glBegin(GL_LINE_LOOP);
- glVertex2i(x + boxw - 10, y - 7);
- glVertex2i(x + boxw - 4, y - 7);
- glVertex2i(x + boxw - 7, y - 2);
- glEnd();
- glBegin(GL_LINE_LOOP);
- glVertex2i(x + boxw - 10, y - boxh + 7);
- glVertex2i(x + boxw - 4, y - boxh + 7);
- glVertex2i(x + boxw - 7, y - boxh + 2);
- glEnd();
+ gpuImmediateFormat_V2();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2i(x, y);
+ gpuVertex2i(x + boxw, y);
+ gpuVertex2i(x + boxw, y - boxh);
+ gpuVertex2i(x, y - boxh);
+ gpuEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2i(x + boxw - 10, y - 7);
+ gpuVertex2i(x + boxw - 4, y - 7);
+ gpuVertex2i(x + boxw - 7, y - 2);
+ gpuEnd();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2i(x + boxw - 10, y - boxh + 7);
+ gpuVertex2i(x + boxw - 4, y - boxh + 7);
+ gpuVertex2i(x + boxw - 7, y - boxh + 2);
+ gpuEnd();
+ gpuImmediateUnformat();
UI_ThemeColor(TH_TEXT);
+ BLF_draw_lock(mono);
+
i = 0; br = DOC_WIDTH; lines = 0; // XXX -doc_scroll;
for (p = docs; *p; p++) {
if (*p == '\r' && *(++p) != '\n') *(--p) = '\n'; /* Fix line endings */
@@ -1289,6 +1395,8 @@ static void draw_documentation(SpaceText *st, ARegion *ar)
if (lines >= DOC_HEIGHT) break;
}
+ BLF_draw_unlock(mono);
+
if (0 /* XXX doc_scroll*/ > 0 && lines < DOC_HEIGHT) {
// XXX doc_scroll--;
draw_documentation(st, ar);
@@ -1332,9 +1440,11 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
boxh = SUGG_LIST_SIZE * st->lheight + 8;
UI_ThemeColor(TH_SHADE1);
- glRecti(x - 1, y + 1, x + boxw + 1, y - boxh - 1);
+ gpuSingleFilledRecti(x - 1, y + 1, x + boxw + 1, y - boxh - 1);
UI_ThemeColor(TH_BACK);
- glRecti(x, y, x + boxw, y - boxh);
+ gpuSingleFilledRecti(x, y, x + boxw, y - boxh);
+
+ BLF_draw_lock(mono);
/* Set the top 'item' of the visible list */
for (i = 0, item = first; i < *top && item->next; i++, item = item->next) ;
@@ -1349,7 +1459,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
if (item == sel) {
UI_ThemeColor(TH_SHADE2);
- glRecti(x + 16, y - 3, x + 16 + w, y + st->lheight - 3);
+ gpuSingleFilledRecti(x + 16, y - 3, x + 16 + w, y + st->lheight - 3);
}
b = 1; /* b=1 color block, text is default. b=0 no block, color text */
switch (item->type) {
@@ -1360,13 +1470,15 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
case '?': UI_ThemeColor(TH_TEXT); b = 0; break;
}
if (b) {
- glRecti(x + 8, y + 2, x + 11, y + 5);
+ gpuSingleFilledRecti(x + 8, y + 2, x + 11, y + 5);
UI_ThemeColor(TH_TEXT);
}
text_draw(st, str, 0, 0, 1, x + 16, y - 1, NULL);
if (item == last) break;
}
+
+ BLF_draw_unlock(mono);
}
/*********************** draw cursor ************************/
@@ -1399,9 +1511,9 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
if (vcurl == vsell) {
y -= vcurl * lheight;
if (vcurc < vselc)
- glRecti(x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - lheight + TXT_LINE_SPACING);
+ gpuSingleFilledRecti(x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - st->lheight + TXT_LINE_SPACING);
else
- glRecti(x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - lheight + TXT_LINE_SPACING);
+ gpuSingleFilledRecti(x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - st->lheight + TXT_LINE_SPACING);
}
else {
int froml, fromc, tol, toc;
@@ -1416,11 +1528,16 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
}
y -= froml * lheight;
- glRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - lheight); y -= lheight;
+ gpuSingleFilledRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - st->lheight);
+ y -= st->lheight;
for (i = froml + 1; i < tol; i++)
- glRecti(x - 4, y, ar->winx, y - lheight), y -= lheight;
- glRecti(x - 4, y, x + toc * st->cwidth, y - lheight + TXT_LINE_SPACING); y -= lheight;
+ for (i = froml + 1; i < tol; i++) {
+ gpuSingleFilledRecti(x - 4, y, ar->winx, y - st->lheight + TXT_LINE_SPACING);
+ y -= st->lheight;
+ }
+
+ gpuSingleFilledRecti(x - 4, y, x + toc * st->cwidth, y - st->lheight);
}
}
else {
@@ -1456,15 +1573,14 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
x1 = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
x2 = x1 + ar->winx;
- glColor4ub(255, 255, 255, 32);
+ gpuCurrentColor4x(CPACK_WHITE, 0.125f);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- glRecti(x1 - 4, y1, x2, y2 + TXT_LINE_SPACING);
+ gpuSingleFilledRecti(x1 - 4, y1, x2, y2 + TXT_LINE_SPACING);
glDisable(GL_BLEND);
}
}
-
+
if (!hidden) {
/* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */
x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
@@ -1479,11 +1595,11 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
if (ch == '\t') w *= st->tabnumber - (vselc + st->left) % st->tabnumber;
UI_ThemeColor(TH_HILITE);
- glRecti(x, y - lheight - 1, x + w, y - lheight + 1);
+ gpuSingleFilledRecti(x, y - lheight - 1, x + w, y - lheight + 1);
}
else {
UI_ThemeColor(TH_HILITE);
- glRecti(x - 1, y, x + 1, y - lheight + TXT_LINE_SPACING);
+ gpuSingleFilledRecti(x - 1, y, x + 1, y - lheight + TXT_LINE_SPACING);
}
}
}
@@ -1680,7 +1796,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
x = TXT_OFFSET + TEXTXLOC;
UI_ThemeColor(TH_GRID);
- glRecti((TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2);
+ gpuSingleFilledRecti((TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2);
}
else {
st->linenrs_tot = 0; /* not used */
@@ -1695,6 +1811,10 @@ void draw_text_main(SpaceText *st, ARegion *ar)
/* draw the text */
UI_ThemeColor(TH_TEXT);
+ GPU_STRING_MARKER("draw_text_main:begin");
+
+ BLF_draw_lock(mono);
+
for (i = 0; y > 0 && i < st->viewlines && tmp; i++, tmp = tmp->next) {
if (st->showsyntax && !tmp->format)
txt_format_line(st, tmp, 0);
@@ -1726,23 +1846,29 @@ void draw_text_main(SpaceText *st, ARegion *ar)
wrap_skip = 0;
}
-
+
+ BLF_draw_unlock(mono);
+
+ GPU_STRING_MARKER("draw_text_main:end");
+
if (st->flags & ST_SHOW_MARGIN) {
UI_ThemeColor(TH_HILITE);
margin_column_x = x + st->cwidth * (st->margin_column - st->left);
if (margin_column_x >= x) {
- glBegin(GL_LINES);
- glVertex2i(margin_column_x, 0);
- glVertex2i(margin_column_x, ar->winy - 2);
- glEnd();
+ gpuImmediateFormat_V2();
+ gpuBegin(GL_LINES);
+ gpuVertex2i(x + st->cwidth * st->margin_column, 0);
+ gpuVertex2i(x + st->cwidth * st->margin_column, ar->winy - 2);
+ gpuEnd();
+ gpuImmediateUnformat();
}
}
/* draw other stuff */
draw_brackets(st, ar);
- glTranslatef(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0f); /* XXX scroll requires exact pixel space */
+ gpuTranslate(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0f); /* XXX scroll requires exact pixel space */
draw_textscroll(st, &scroll, &back);
draw_documentation(st, ar);
draw_suggestion_list(st, ar);
@@ -1796,7 +1922,9 @@ void text_scroll_to_cursor(SpaceText *st, ScrArea *sa)
st->left = 0;
}
else {
+ BLF_draw_lock(mono);
x = text_draw(st, text->sell->line, st->left, text->selc, 0, 0, 0, NULL);
+ BLF_draw_unlock(mono);
if (x == 0 || x > winx)
st->left = text->curc - 0.5 * winx / st->cwidth;
diff --git a/source/blender/editors/space_time/CMakeLists.txt b/source/blender/editors/space_time/CMakeLists.txt
index 6e51d7829f6..29c1d1aca10 100644
--- a/source/blender/editors/space_time/CMakeLists.txt
+++ b/source/blender/editors/space_time/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -40,4 +41,6 @@ set(SRC
time_intern.h
)
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_space_time "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 13c1938d77c..3dfea56f722 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -53,7 +53,9 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "UI_resources.h"
@@ -71,23 +73,28 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d)
/* draw darkened area outside of active timeline
* frame range used is preview range or scene range
*/
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gpuImmediateFormat_V2(); // DOODLE: two lines, start frame & end frame
+
glEnable(GL_BLEND);
- glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+ gpuCurrentColor4x(CPACK_BLACK, 0.400f);
if (PSFRA < PEFRA) {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ gpuDrawFilledRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
+ gpuDrawFilledRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ gpuDrawFilledRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
glDisable(GL_BLEND);
UI_ThemeColorShade(TH_BACK, -60);
+
/* thin lines where the actual frames are */
- fdrawline((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
+ gpuBegin(GL_LINES);
+ gpuAppendLinef((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
+ gpuAppendLinef((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
+ gpuEnd();
+ gpuImmediateUnformat();
}
#define CACHE_DRAW_HEIGHT 3.0f
@@ -104,6 +111,8 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
+ glEnable(GL_BLEND);
+
/* iterate over pointcaches on the active object,
* add spacetimecache and vertex array for each */
for (pid = pidlist.first; pid; pid = pid->next) {
@@ -167,9 +176,9 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
}
}
- glPushMatrix();
- glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0);
- glScalef(1.0, CACHE_DRAW_HEIGHT, 0.0);
+ gpuPushMatrix();
+ gpuTranslate(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0);
+ gpuScale(1.0, CACHE_DRAW_HEIGHT, 0.0);
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
@@ -198,35 +207,32 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
col[0] = 1.0; col[1] = 0.0; col[2] = 1.0;
col[3] = 0.1;
}
- glColor4fv(col);
-
- glEnable(GL_BLEND);
-
- glRectf((float)sta, 0.0, (float)end, 1.0);
-
+
+
+ gpuCurrentColor4fv(col);
+ gpuSingleFilledRectf((float)sta, 0, (float)end, 1);
+
col[3] = 0.4f;
+
if (pid->cache->flag & PTCACHE_BAKED) {
col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f;
}
else if (pid->cache->flag & PTCACHE_OUTDATED) {
col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f;
}
- glColor4fv(col);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, stc->array);
- glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2);
- glDisableClientState(GL_VERTEX_ARRAY);
-
- glDisable(GL_BLEND);
-
- glPopMatrix();
-
+
+ gpuCurrentColor4fv(col);
+ gpuSingleClientArrays_V2F(GL_QUADS, stc->array, 0, 0, (fp - (stc->array)) / 2);
+
+ gpuPopMatrix();
+
yoffs += CACHE_DRAW_HEIGHT;
stc = stc->next;
}
+ glDisable(GL_BLEND);
+
BLI_freelistN(&pidlist);
/* free excessive caches */
@@ -313,16 +319,14 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
* the first visible keyframe (last one can then be easily checked)
* - draw within a single GL block to be faster
*/
- glBegin(GL_LINES);
for (ak = time_cfra_find_ak(keys.root, v2d->cur.xmin);
(ak) && (ak->cfra <= v2d->cur.xmax);
ak = ak->next)
{
- glVertex2f(ak->cfra, v2d->tot.ymin);
- glVertex2f(ak->cfra, v2d->tot.ymax);
+ gpuVertex2f(ak->cfra, v2d->tot.ymin);
+ gpuVertex2f(ak->cfra, v2d->tot.ymax);
}
- glEnd(); // GL_LINES
-
+
/* free temp stuff */
BLI_dlrbTree_free(&keys);
}
@@ -335,13 +339,16 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar
View2D *v2d = &ar->v2d;
short onlysel = (stime->flag & TIME_ONLYACTSEL);
+ gpuImmediateFormat_C4_V2();
+ gpuBegin(GL_LINES);
+
/* draw scene keyframes first
* - don't try to do this when only drawing active/selected data keyframes,
* since this can become quite slow
*/
if (scene && onlysel == 0) {
/* set draw color */
- glColor3ub(0xDD, 0xA7, 0x00);
+ gpuColor3x(0xDDA700);
time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
}
@@ -350,7 +357,7 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar
* OR the onlysel flag was set, which means that only active object's keyframes should
* be considered
*/
- glColor3ub(0xDD, 0xD7, 0x00);
+ gpuColor3x(0xDDD700);
if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
/* draw keyframes for active object only */
@@ -375,6 +382,9 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar
if (ob && (active_done == 0))
time_draw_idblock_keyframes(v2d, (ID *)ob, 0);
}
+
+ gpuEnd(); // GL_LINES
+ gpuImmediateUnformat();
}
/* ---------------- */
@@ -470,7 +480,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 35dd88c3209..811d391190a 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -31,6 +31,7 @@ set(INC
../../makesrna
../../render/extern/include
../../windowmanager
+ ../../gpu
../../../../intern/guardedalloc
../../../../intern/smoke/extern
)
@@ -47,6 +48,7 @@ set(SRC
drawvolume.c
space_view3d.c
view3d_buttons.c
+ view3d_composite.c
view3d_draw.c
view3d_edit.c
view3d_fly.c
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c
index 0649edc1ac4..5937d5f0988 100644
--- a/source/blender/editors/space_view3d/drawanimviz.c
+++ b/source/blender/editors/space_view3d/drawanimviz.c
@@ -49,7 +49,8 @@
#include "BKE_animsys.h"
#include "BKE_action.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
+
#include "ED_armature.h"
#include "ED_keyframes_draw.h"
@@ -73,8 +74,8 @@ void draw_motion_paths_init(View3D *v3d, ARegion *ar)
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- glPushMatrix();
- glLoadMatrixf(rv3d->viewmat);
+ gpuPushMatrix();
+ gpuLoadMatrix(rv3d->viewmat);
}
/* Draw the given motion path for an Object or a Bone
@@ -88,7 +89,9 @@ void draw_motion_path_instance(Scene *scene,
bMotionPathVert *mpv, *mpv_start;
int i, stepsize = avs->path_step;
int sfra, efra, sind, len;
-
+
+ gpuImmediateFormat_V3();
+
/* get frame ranges */
if (avs->path_type == MOTIONPATH_TYPE_ACFRA) {
/* With "Around Current", we only choose frames from around
@@ -102,7 +105,7 @@ void draw_motion_path_instance(Scene *scene,
sfra = avs->path_sf;
efra = avs->path_ef;
}
-
+
/* no matter what, we can only show what is in the cache and no more
* - abort if whole range is past ends of path
* - otherwise clamp endpoints to extents of path
@@ -115,30 +118,30 @@ void draw_motion_path_instance(Scene *scene,
/* end clamp */
efra = mpath->end_frame;
}
-
+
if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) {
/* whole path is out of bounds */
return;
}
len = efra - sfra;
-
+
if ((len <= 0) || (mpath->points == NULL)) {
return;
}
-
+
/* get pointers to parts of path */
sind = sfra - mpath->start_frame;
mpv_start = (mpath->points + sind);
-
+
/* draw curve-line of path */
glShadeModel(GL_SMOOTH);
-
- glBegin(GL_LINE_STRIP);
+
+ gpuBegin(GL_LINE_STRIP);
for (i = 0, mpv = mpv_start; i < len; i++, mpv++) {
short sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT);
float intensity; /* how faint */
-
+
/* set color
* - more intense for active/selected bones, less intense for unselected bones
* - black for before current frame, green for current frame, blue for after current frame
@@ -155,7 +158,7 @@ void draw_motion_path_instance(Scene *scene,
//intensity = 0.8f;
intensity = SET_INTENSITY(sfra, i, CFRA, 0.68f, 0.92f);
}
- UI_ThemeColorBlend(TH_WIRE, TH_BACK, intensity);
+ UI_ThemeAppendColorBlend(TH_WIRE, TH_BACK, intensity);
}
else if ((sfra + i) > CFRA) {
/* blue - after cfra */
@@ -167,7 +170,7 @@ void draw_motion_path_instance(Scene *scene,
//intensity = 0.8f;
intensity = SET_INTENSITY(CFRA, i, efra, 0.68f, 0.92f);
}
- UI_ThemeColorBlend(TH_BONE_POSE, TH_BACK, intensity);
+ UI_ThemeAppendColorBlend(TH_BONE_POSE, TH_BACK, intensity);
}
else {
/* green - on cfra */
@@ -177,33 +180,33 @@ void draw_motion_path_instance(Scene *scene,
else {
intensity = 0.99f;
}
- UI_ThemeColorBlendShade(TH_CFRAME, TH_BACK, intensity, 10);
+ UI_ThemeAppendColorBlendShade(TH_CFRAME, TH_BACK, intensity, 10);
}
/* draw a vertex with this color */
- glVertex3fv(mpv->co);
+ gpuVertex3fv(mpv->co);
}
-
- glEnd();
+
+ gpuEnd();
glShadeModel(GL_FLAT);
-
+
glPointSize(1.0);
-
+
/* draw little black point at each frame
* NOTE: this is not really visible/noticeable
*/
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
for (i = 0, mpv = mpv_start; i < len; i++, mpv++)
- glVertex3fv(mpv->co);
- glEnd();
-
+ gpuVertex3fv(mpv->co);
+ gpuEnd();
+
/* Draw little white dots at each framestep value */
UI_ThemeColor(TH_TEXT_HI);
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize)
- glVertex3fv(mpv->co);
- glEnd();
-
+ gpuVertex3fv(mpv->co);
+ gpuEnd();
+
/* Draw big green dot where the current frame is
* NOTE: this is only done when keyframes are shown, since this adds similar types of clutter
*/
@@ -213,18 +216,18 @@ void draw_motion_path_instance(Scene *scene,
UI_ThemeColor(TH_CFRAME);
glPointSize(6.0f);
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
mpv = mpv_start + (CFRA - sfra);
- glVertex3fv(mpv->co);
- glEnd();
-
+ gpuVertex3fv(mpv->co);
+ gpuEnd();
+
glPointSize(1.0f);
UI_ThemeColor(TH_TEXT_HI);
}
-
+
/* XXX, this isn't up to date but probably should be kept so. */
invert_m4_m4(ob->imat, ob->obmat);
-
+
/* Draw frame numbers at each framestep value */
if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) {
unsigned char col[4];
@@ -234,7 +237,7 @@ void draw_motion_path_instance(Scene *scene,
for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) {
char numstr[32];
float co[3];
-
+
/* only draw framenum if several consecutive highlighted points don't occur on same point */
if (i == 0) {
sprintf(numstr, "%d", (i + sfra));
@@ -244,7 +247,7 @@ void draw_motion_path_instance(Scene *scene,
else if ((i > stepsize) && (i < len - stepsize)) {
bMotionPathVert *mpvP = (mpv - stepsize);
bMotionPathVert *mpvN = (mpv + stepsize);
-
+
if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) {
sprintf(numstr, "%d", (sfra + i));
mul_v3_m4v3(co, ob->imat, mpv->co);
@@ -253,24 +256,24 @@ void draw_motion_path_instance(Scene *scene,
}
}
}
-
+
/* Keyframes - dots and numbers */
if (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) {
- unsigned char col[4];
-
+ unsigned char col[4];
+
AnimData *adt = BKE_animdata_from_id(&ob->id);
DLRBT_Tree keys;
-
+
/* build list of all keyframes in active action for object or pchan */
BLI_dlrbTree_init(&keys);
-
+
if (adt) {
/* it is assumed that keyframes for bones are all grouped in a single group
* unless an option is set to always use the whole action
*/
if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) {
bActionGroup *agrp = BKE_action_group_find_name(adt->action, pchan->name);
-
+
if (agrp) {
agroup_to_keylist(adt, agrp, &keys, NULL);
BLI_dlrbTree_linkedlist_sync(&keys);
@@ -281,48 +284,50 @@ void draw_motion_path_instance(Scene *scene,
BLI_dlrbTree_linkedlist_sync(&keys);
}
}
-
+
/* Draw slightly-larger yellow dots at each keyframe */
UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col);
col[3] = 255;
-
+
glPointSize(4.0f); // XXX perhaps a bit too big
- glColor3ubv(col);
-
- glBegin(GL_POINTS);
+ gpuCurrentColor3ubv(col);
+
+ gpuBegin(GL_POINTS);
for (i = 0, mpv = mpv_start; i < len; i++, mpv++) {
float mframe = (float)(sfra + i);
-
+
if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe))
- glVertex3fv(mpv->co);
+ gpuVertex3fv(mpv->co);
}
- glEnd();
-
+ gpuEnd();
+
glPointSize(1.0f);
-
+
/* Draw frame numbers of keyframes */
if (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) {
float co[3];
for (i = 0, mpv = mpv_start; i < len; i++, mpv++) {
float mframe = (float)(sfra + i);
-
+
if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) {
char numstr[32];
-
+
sprintf(numstr, "%d", (sfra + i));
mul_v3_m4v3(co, ob->imat, mpv->co);
view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, col);
}
}
}
-
+
BLI_dlrbTree_free(&keys);
}
+
+ gpuImmediateUnformat();
}
/* Clean up drawing environment after drawing motion paths */
void draw_motion_paths_cleanup(View3D *v3d)
{
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- glPopMatrix();
+ gpuPopMatrix();
}
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index beafee335d4..dadb3f3b5f7 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -55,8 +55,9 @@
#include "BKE_modifier.h"
#include "BKE_nla.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "ED_armature.h"
@@ -74,7 +75,7 @@
/* global here is reset before drawing each bone */
static ThemeWireColor *bcolor = NULL;
-/* values of colCode for set_pchan_glcolor */
+/* values of colCode for set_pchan_gpuCurrentColor */
enum {
PCHAN_COLOR_NORMAL = 0, /* normal drawing */
PCHAN_COLOR_SOLID, /* specific case where "solid" color is needed */
@@ -144,7 +145,7 @@ static void cp_shade_color3ub(unsigned char cp[3], const int offset)
}
/* This function sets the gl-color for coloring a certain bone (based on bcolor) */
-static short set_pchan_glColor(short colCode, int boneflag, short constflag)
+static short set_pchan_gpuCurrentColor(short colCode, int boneflag, short constflag)
{
switch (colCode) {
case PCHAN_COLOR_NORMAL:
@@ -167,7 +168,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag)
cp_shade_color3ub(cp, -50);
}
- glColor3ubv(cp);
+ gpuCurrentColor3ubv(cp);
}
else {
if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) {
@@ -191,7 +192,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag)
case PCHAN_COLOR_SOLID:
{
if (bcolor) {
- glColor3ubv((unsigned char *)bcolor->solid);
+ gpuCurrentColor3ubv((unsigned char *)bcolor->solid);
}
else
UI_ThemeColor(TH_BONE_SOLID);
@@ -203,10 +204,10 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag)
case PCHAN_COLOR_CONSTS:
{
if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) {
- if (constflag & PCHAN_HAS_TARGET) glColor4ub(255, 150, 0, 80);
- else if (constflag & PCHAN_HAS_IK) glColor4ub(255, 255, 0, 80);
- else if (constflag & PCHAN_HAS_SPLINEIK) glColor4ub(200, 255, 0, 80);
- else if (constflag & PCHAN_HAS_CONST) glColor4ub(0, 255, 120, 80);
+ if (constflag & PCHAN_HAS_TARGET) gpuCurrentColor4ub(255, 150, 0, 80);
+ else if (constflag & PCHAN_HAS_IK) gpuCurrentColor4ub(255, 255, 0, 80);
+ else if (constflag & PCHAN_HAS_SPLINEIK) gpuCurrentColor4ub(200, 255, 0, 80);
+ else if (constflag & PCHAN_HAS_CONST) gpuCurrentColor4ub(0, 255, 120, 80);
return 1;
}
@@ -230,7 +231,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag)
copy_v3_v3_char((char *)cp, bcolor->solid);
}
- glColor3ubv(cp);
+ gpuCurrentColor3ubv(cp);
}
else {
if (boneflag & BONE_DRAW_ACTIVE) UI_ThemeColorShade(TH_BONE_POSE, 40);
@@ -259,7 +260,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag)
cp_shade_color3ub(cp, -30);
}
- glColor3ubv(cp);
+ gpuCurrentColor3ubv(cp);
}
else {
if (boneflag & BONE_DRAW_ACTIVE) UI_ThemeColorShade(TH_BONE_POSE, 10);
@@ -273,16 +274,16 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag)
{
/* inner part in background color or constraint */
if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) {
- if (constflag & PCHAN_HAS_TARGET) glColor3ub(255, 150, 0);
- else if (constflag & PCHAN_HAS_IK) glColor3ub(255, 255, 0);
- else if (constflag & PCHAN_HAS_SPLINEIK) glColor3ub(200, 255, 0);
- else if (constflag & PCHAN_HAS_CONST) glColor3ub(0, 255, 120);
+ if (constflag & PCHAN_HAS_TARGET) gpuCurrentColor3ub(255, 150, 0);
+ else if (constflag & PCHAN_HAS_IK) gpuCurrentColor3ub(255, 255, 0);
+ else if (constflag & PCHAN_HAS_SPLINEIK) gpuCurrentColor3ub(200, 255, 0);
+ else if (constflag & PCHAN_HAS_CONST) gpuCurrentColor3ub(0, 255, 120);
else if (constflag) UI_ThemeColor(TH_BONE_POSE); /* PCHAN_HAS_ACTION */
}
else {
if (bcolor) {
char *cp = bcolor->solid;
- glColor4ub(cp[0], cp[1], cp[2], 204);
+ gpuCurrentColor4ub(cp[0], cp[1], cp[2], 204);
}
else
UI_ThemeColorShade(TH_BACK, -30);
@@ -296,7 +297,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag)
return 0;
}
-static void set_ebone_glColor(const unsigned int boneflag)
+static void set_ebone_gpuCurrentColor(const unsigned int boneflag)
{
if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) {
UI_ThemeColor(TH_EDGE_SELECT);
@@ -314,245 +315,170 @@ static void set_ebone_glColor(const unsigned int boneflag)
/* *************** Armature drawing, helper calls for parts ******************* */
-/* half the cube, in Y */
-static float cube[8][3] = {
- {-1.0, 0.0, -1.0},
- {-1.0, 0.0, 1.0},
- {-1.0, 1.0, 1.0},
- {-1.0, 1.0, -1.0},
- { 1.0, 0.0, -1.0},
- { 1.0, 0.0, 1.0},
- { 1.0, 1.0, 1.0},
- { 1.0, 1.0, -1.0},
-};
-
-static void drawsolidcube_size(float xsize, float ysize, float zsize)
+static void draw_bonevert(void)
{
- static GLuint displist = 0;
- float n[3] = {0.0f};
-
- glScalef(xsize, ysize, zsize);
-
- if (displist == 0) {
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- glBegin(GL_QUADS);
- n[0] = -1.0;
- glNormal3fv(n);
- glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]);
- n[0] = 0;
- n[1] = -1.0;
- glNormal3fv(n);
- glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[1]);
- n[1] = 0;
- n[0] = 1.0;
- glNormal3fv(n);
- glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glVertex3fv(cube[5]);
- n[0] = 0;
- n[1] = 1.0;
- glNormal3fv(n);
- glVertex3fv(cube[7]); glVertex3fv(cube[3]); glVertex3fv(cube[2]); glVertex3fv(cube[6]);
- n[1] = 0;
- n[2] = 1.0;
- glNormal3fv(n);
- glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]);
- n[2] = -1.0;
- glNormal3fv(n);
- glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]);
- glEnd();
-
- glEndList();
- }
-
- glCallList(displist);
-}
+ gpuPushMatrix();
-static void drawcube_size(float xsize, float ysize, float zsize)
-{
- static GLuint displist = 0;
-
- if (displist == 0) {
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]);
- glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]);
- glVertex3fv(cube[7]); glVertex3fv(cube[4]);
- glEnd();
-
- glBegin(GL_LINES);
- glVertex3fv(cube[1]); glVertex3fv(cube[5]);
- glVertex3fv(cube[2]); glVertex3fv(cube[6]);
- glVertex3fv(cube[3]); glVertex3fv(cube[7]);
- glEnd();
-
- glEndList();
- }
+ gpuImmediateFormat_V2(); // DOODLE: bonevert, 3 orthogonal circles
- glScalef(xsize, ysize, zsize);
- glCallList(displist);
-
-}
+ gpuDrawCircle(0, 0, 0.052, 16);
+ gpuRotateRight('Y');
+ gpuRepeat();
-static void draw_bonevert(void)
-{
- static GLuint displist = 0;
-
- if (displist == 0) {
- GLUquadricObj *qobj;
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- glPushMatrix();
-
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
- gluDisk(qobj, 0.0, 0.05, 16, 1);
-
- glRotatef(90, 0, 1, 0);
- gluDisk(qobj, 0.0, 0.05, 16, 1);
-
- glRotatef(90, 1, 0, 0);
- gluDisk(qobj, 0.0, 0.05, 16, 1);
-
- gluDeleteQuadric(qobj);
-
- glPopMatrix();
- glEndList();
- }
+ gpuRotateRight('X');
+ gpuRepeat();
+
+ gpuImmediateUnformat();
- glCallList(displist);
+ gpuPopMatrix();
}
static void draw_bonevert_solid(void)
{
- static GLuint displist = 0;
-
- if (displist == 0) {
- GLUquadricObj *qobj;
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_FILL);
- glShadeModel(GL_SMOOTH);
- gluSphere(qobj, 0.05, 8, 5);
- glShadeModel(GL_FLAT);
- gluDeleteQuadric(qobj);
-
- glEndList();
+ static GPUimmediate *displist = NULL;
+ static GPUindex* index = NULL;
+
+ glShadeModel(GL_SMOOTH);
+
+ if (!displist) {
+ GPUprim3 prim = GPU_PRIM_MIDFI_SOLID;
+ prim.usegs = 8;
+ prim.vsegs = 5;
+
+ gpuPushImmediate();
+ gpuImmediateMaxVertexCount(48);
+
+ index = gpuNewIndex();
+ gpuImmediateIndex(index);
+ gpuImmediateMaxIndexCount(240);
+
+ gpuSingleSphere(&prim, 0.05f);
+
+ displist = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleRepeatElements(displist);
}
- glCallList(displist);
+ glShadeModel(GL_FLAT);
}
-static float bone_octahedral_verts[6][3] = {
- { 0.0f, 0.0f, 0.0f},
- { 0.1f, 0.1f, 0.1f},
- { 0.1f, 0.1f, -0.1f},
- {-0.1f, 0.1f, -0.1f},
- {-0.1f, 0.1f, 0.1f},
- { 0.0f, 1.0f, 0.0f}
+static float bone_octahedral_verts[8][3] = {
+ { 0.0f, 0.0f, 0.0f}, /* 0 */
+ { 0.1f, 0.1f, 0.1f}, /* 1 */
+ { 0.1f, 0.1f, -0.1f}, /* 2 */
+ {-0.1f, 0.1f, -0.1f}, /* 3 */
+ {-0.1f, 0.1f, 0.1f}, /* 4 */
+ { 0.0f, 1.0f, 0.0f}, /* 5 */
+
+ /* there are more faces (8) than verts (6),
+ so make more (2) so the counts match,
+ otherwise we cannot flat shade */
+ { 0.1f, 0.1f, 0.1f}, /* dup of #1 */
+ {-0.1f, 0.1f, -0.1f}, /* dup of #3 */
};
-static unsigned int bone_octahedral_wire_sides[8] = {0, 1, 5, 3, 0, 4, 5, 2};
-static unsigned int bone_octahedral_wire_square[8] = {1, 2, 3, 4, 1};
+/* Eulerian path over octohedron */
+static unsigned int bone_octahedral_wire[] =
+ {0, 1, 4, 5, 2, 3, 0, 2, 1, 5, 3, 4};
-static unsigned int bone_octahedral_solid_tris[8][3] = {
- {2, 1, 0}, /* bottom */
- {3, 2, 0},
- {4, 3, 0},
- {1, 4, 0},
-
- {5, 1, 2}, /* top */
- {5, 2, 3},
- {5, 3, 4},
- {5, 4, 1}
-};
-
-/* aligned with bone_octahedral_solid_tris */
static float bone_octahedral_solid_normals[8][3] = {
- { 0.70710683f, -0.70710683f, 0.00000000f},
- {-0.00000000f, -0.70710683f, -0.70710683f},
+ {+0.70710683f, -0.70710683f, 0.00000000f},
+ { 0.00000000f, -0.70710683f, +0.70710683f},
+ { 0.00000000f, -0.70710683f, -0.70710683f},
{-0.70710683f, -0.70710683f, 0.00000000f},
- { 0.00000000f, -0.70710683f, 0.70710683f},
- { 0.99388373f, 0.11043154f, -0.00000000f},
- { 0.00000000f, 0.11043154f, -0.99388373f},
- {-0.99388373f, 0.11043154f, 0.00000000f},
- { 0.00000000f, 0.11043154f, 0.99388373f}
+
+ {-0.99388373f, +0.11043154f, 0.00000000f},
+ {+0.99388373f, +0.11043154f, 0.00000000f},
+ { 0.00000000f, +0.11043154f, +0.99388373f},
+ { 0.00000000f, +0.11043154f, -0.99388373f},
+};
+
+static unsigned int bone_octahedral_solid_tris[8][3] = {
+ /* notice that provoking vertex is last in each tri,
+ the normal of that vertex is what is used for lighting */
+
+ {2, 1, 0}, /* bottom */
+ {4, 0, 1},
+ {0, 3, 2},
+ {0, 4, 3},
+
+ {5, 3, 4}, /* top */
+ {1, 2, 5},
+ {5, 4, 6}, /* #6 pos is same as #1 */
+ {5, 2, 7}, /* #7 pos is same as #3 */
};
static void draw_bone_octahedral(void)
{
- static GLuint displist = 0;
-
- if (displist == 0) {
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- /* Section 1, sides */
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, bone_octahedral_verts);
- glDrawElements(GL_LINE_LOOP,
- sizeof(bone_octahedral_wire_sides) / sizeof(*bone_octahedral_wire_sides),
- GL_UNSIGNED_INT,
- bone_octahedral_wire_sides);
-
- /* Section 1, square */
- glDrawElements(GL_LINE_LOOP,
- sizeof(bone_octahedral_wire_square) / sizeof(*bone_octahedral_wire_square),
- GL_UNSIGNED_INT,
- bone_octahedral_wire_square);
- glDisableClientState(GL_VERTEX_ARRAY);
-
- glEndList();
- }
+ static GPUimmediate *displist = NULL;
+ static GPUindex *index = NULL;
+
+ if (!displist) {
+ const GLsizei vertex_count = 6;
+ const GLsizei index_count = 12;
+
+ gpuPushImmediate();
+ gpuImmediateMaxVertexCount(vertex_count);
+
+ index = gpuNewIndex();
+ gpuImmediateIndex(index);
+ gpuImmediateMaxIndexCount(index_count);
+
+ gpuSingleClientRangeElements_V3F(
+ GL_LINE_LOOP,
+ bone_octahedral_verts,
+ 0,
+ 0,
+ 5,
+ index_count,
+ bone_octahedral_wire);
- glCallList(displist);
-}
+ displist = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleRepeatRangeElements(displist);
+ }
+}
static void draw_bone_solid_octahedral(void)
{
- static GLuint displist = 0;
+ static GPUimmediate *displist = NULL;
+ static GPUindex* index = NULL;
- if (displist == 0) {
- int i;
+ glShadeModel(GL_FLAT);
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
+ if (!displist) {
+ const GLsizei index_count = 24;
+ const GLsizei vertex_count = 8; /* 2 extra duplicate verts because or normals */
-#if 1
- glBegin(GL_TRIANGLES);
- for (i = 0; i < 8; i++) {
- glNormal3fv(bone_octahedral_solid_normals[i]);
- glVertex3fv(bone_octahedral_verts[bone_octahedral_solid_tris[i][0]]);
- glVertex3fv(bone_octahedral_verts[bone_octahedral_solid_tris[i][1]]);
- glVertex3fv(bone_octahedral_verts[bone_octahedral_solid_tris[i][2]]);
- }
+ gpuPushImmediate();
+ gpuImmediateMaxVertexCount(vertex_count);
- glEnd();
-
-#else /* not working because each vert needs a different normal */
- glEnableClientState(GL_NORMAL_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
- glNormalPointer(GL_FLOAT, 0, bone_octahedral_solid_normals);
- glVertexPointer(3, GL_FLOAT, 0, bone_octahedral_verts);
- glDrawElements(GL_TRIANGLES, sizeof(bone_octahedral_solid_tris) / sizeof(unsigned int),
- GL_UNSIGNED_INT, bone_octahedral_solid_tris);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
-#endif
+ index = gpuNewIndex();
+ gpuImmediateIndex(index);
+ gpuImmediateMaxIndexCount(index_count);
+
+ gpuSingleClientRangeElements_N3F_V3F(
+ GL_TRIANGLES,
+ bone_octahedral_solid_normals,
+ 0,
+ bone_octahedral_verts,
+ 0,
+ 0,
+ 7,
+ index_count,
+ bone_octahedral_solid_tris);
- glEndList();
+ displist = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleRepeatRangeElements(displist);
}
- glCallList(displist);
-}
+ glShadeModel(GL_SMOOTH);
+}
/* *************** Armature drawing, bones ******************* */
@@ -572,7 +498,7 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag,
}
else {
if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, 0);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_SOLID, boneflag, 0);
else
UI_ThemeColor(TH_BONE_SOLID);
}
@@ -595,17 +521,17 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag,
}
else {
if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, 0);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_SOLID, boneflag, 0);
else
UI_ThemeColor(TH_BONE_SOLID);
}
- glTranslatef(0.0f, 1.0f, 0.0f);
+ gpuTranslate(0.0f, 1.0f, 0.0f);
if (dt > OB_WIRE)
draw_bonevert_solid();
else
draw_bonevert();
- glTranslatef(0.0f, -1.0f, 0.0f);
+ gpuTranslate(0.0f, -1.0f, 0.0f);
}
@@ -706,7 +632,7 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel
//mul_v3_fl(dirvec, head);
cross_v3_v3v3(norvec, dirvec, imat[2]);
- glBegin(GL_QUAD_STRIP);
+ gpuBegin(GL_TRIANGLE_STRIP);
for (a = 0; a < 16; a++) {
vec[0] = -si[a] * dirvec[0] + co[a] * norvec[0];
@@ -716,10 +642,10 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel
madd_v3_v3v3fl(vec1, headvec, vec, head);
madd_v3_v3v3fl(vec2, headvec, vec, head + dist);
- glColor4ub(255, 255, 255, 50);
- glVertex3fv(vec1);
- //glColor4ub(255, 255, 255, 0);
- glVertex3fv(vec2);
+ gpuColor4x(CPACK_WHITE, 0.196f);
+ gpuVertex3fv(vec1);
+ //gpuColor4x(CPACK_WHITE, 0);
+ gpuVertex3fv(vec2);
}
for (a = 15; a >= 0; a--) {
@@ -730,10 +656,10 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel
madd_v3_v3v3fl(vec1, tailvec, vec, tail);
madd_v3_v3v3fl(vec2, tailvec, vec, tail + dist);
- //glColor4ub(255, 255, 255, 50);
- glVertex3fv(vec1);
- //glColor4ub(255, 255, 255, 0);
- glVertex3fv(vec2);
+ //gpuColor4x(CPACK_WHITE, 0.196f);
+ gpuVertex3fv(vec1);
+ //gpuColor4x(CPACK_WHITE, 0);
+ gpuVertex3fv(vec2);
}
/* make it cyclic... */
@@ -744,12 +670,12 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel
madd_v3_v3v3fl(vec1, headvec, vec, head);
madd_v3_v3v3fl(vec2, headvec, vec, head + dist);
- //glColor4ub(255, 255, 255, 50);
- glVertex3fv(vec1);
- //glColor4ub(255, 255, 255, 0);
- glVertex3fv(vec2);
+ //gpuColor4x(CPACK_WHITE, 0.196f);
+ gpuVertex3fv(vec1);
+ //gpuColor4x(CPACK_WHITE, 0);
+ gpuVertex3fv(vec2);
- glEnd();
+ gpuEnd();
}
}
@@ -761,12 +687,14 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4],
{
float head, tail /*, length*/;
float *headvec, *tailvec, dirvec[3];
-
+
+ gpuImmediateFormat_V3(); // DOODLE: sphere bone wire
+
/* figure out the sizes of spheres */
if (ebone) {
/* this routine doesn't call get_matrix_editbone() that calculates it */
ebone->length = len_v3v3(ebone->head, ebone->tail);
-
+
/*length = ebone->length;*/ /*UNUSED*/
tail = ebone->rad_tail;
if (ebone->parent && (boneflag & BONE_CONNECTED))
@@ -786,91 +714,94 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4],
headvec = pchan->pose_head;
tailvec = pchan->pose_tail;
}
-
+
/* sphere root color */
if (armflag & ARM_EDITMODE) {
if (boneflag & BONE_ROOTSEL) UI_ThemeColor(TH_VERTEX_SELECT);
else UI_ThemeColor(TH_VERTEX);
}
else if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
-
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
+
/* Draw root point if we are not connected */
if ((boneflag & BONE_CONNECTED) == 0) {
if (id != -1)
glLoadName(id | BONESEL_ROOT);
- drawcircball(GL_LINE_LOOP, headvec, head, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, headvec, head, imat);
}
-
+
/* Draw tip point */
if (armflag & ARM_EDITMODE) {
if (boneflag & BONE_TIPSEL) UI_ThemeColor(TH_VERTEX_SELECT);
else UI_ThemeColor(TH_VERTEX);
}
-
+
if (id != -1)
glLoadName(id | BONESEL_TIP);
-
- drawcircball(GL_LINE_LOOP, tailvec, tail, imat);
-
+
+ gpuDrawFastBall(GL_LINE_LOOP, tailvec, tail, imat);
+
/* base */
if (armflag & ARM_EDITMODE) {
if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_SELECT);
else UI_ThemeColor(TH_WIRE);
}
-
+
sub_v3_v3v3(dirvec, tailvec, headvec);
-
+
/* move vector to viewspace */
mul_mat3_m4_v3(smat, dirvec);
/* clear zcomp */
dirvec[2] = 0.0f;
/* move vector back */
mul_mat3_m4_v3(imat, dirvec);
-
+
if (0.0f != normalize_v3(dirvec)) {
float norvech[3], norvect[3], vec[3];
-
+
copy_v3_v3(vec, dirvec);
-
+
mul_v3_fl(dirvec, head);
cross_v3_v3v3(norvech, dirvec, imat[2]);
-
+
mul_v3_fl(vec, tail);
cross_v3_v3v3(norvect, vec, imat[2]);
-
+
if (id != -1)
glLoadName(id | BONESEL_BONE);
-
- glBegin(GL_LINES);
+
+ gpuBegin(GL_LINES);
add_v3_v3v3(vec, headvec, norvech);
- glVertex3fv(vec);
+ gpuVertex3fv(vec);
add_v3_v3v3(vec, tailvec, norvect);
- glVertex3fv(vec);
+ gpuVertex3fv(vec);
sub_v3_v3v3(vec, headvec, norvech);
- glVertex3fv(vec);
+ gpuVertex3fv(vec);
sub_v3_v3v3(vec, tailvec, norvect);
- glVertex3fv(vec);
-
- glEnd();
+ gpuVertex3fv(vec);
+
+ gpuEnd();
}
+
+ gpuImmediateUnformat();
}
/* does wire only for outline selecting */
static void draw_sphere_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id,
bPoseChannel *pchan, EditBone *ebone)
{
- GLUquadricObj *qobj;
+ GPUprim3 prim;
float head, tail, length;
float fac1, fac2;
-
- glPushMatrix();
- qobj = gluNewQuadric();
+
+ gpuImmediateFormat_V3();
+
+ gpuPushMatrix();
/* figure out the sizes of spheres */
if (ebone) {
@@ -889,101 +820,133 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
else
head = pchan->bone->rad_head;
}
-
+
/* move to z-axis space */
- glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
+ gpuRotateRight(-'X');
if (dt == OB_SOLID) {
/* set up solid drawing */
- glEnable(GL_COLOR_MATERIAL);
- glEnable(GL_LIGHTING);
-
- gluQuadricDrawStyle(qobj, GLU_FILL);
+ gpuEnableColorMaterial();
+ gpuEnableLighting();
+
glShadeModel(GL_SMOOTH);
+
+ prim = GPU_PRIM_MIDFI_SOLID;
}
else {
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
+ prim = GPU_PRIM_MIDFI_WIRE;
}
-
+
/* sphere root color */
if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_ROOTSEL) UI_ThemeColor(TH_VERTEX_SELECT);
- else UI_ThemeColorShade(TH_BONE_SOLID, -30);
+ if (boneflag & BONE_ROOTSEL) {
+ UI_ThemeColor(TH_VERTEX_SELECT);
+ }
+ else {
+ UI_ThemeColorShade(TH_BONE_SOLID, -30);
+ }
}
- else if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_SPHEREBONE_END, boneflag, constflag);
- else if (dt == OB_SOLID)
+ else if (armflag & ARM_POSEMODE) {
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_SPHEREBONE_END, boneflag, constflag);
+ }
+ else if (dt == OB_SOLID) {
UI_ThemeColorShade(TH_BONE_SOLID, -30);
-
+ }
+
/* Draw root point if we are not connected */
if ((boneflag & BONE_CONNECTED) == 0) {
- if (id != -1)
+ if (id != -1) {
glLoadName(id | BONESEL_ROOT);
- gluSphere(qobj, head, 16, 10);
+ }
+
+ gpuDrawSphere(&prim, head);
+ //GLU Sphere(qobj, head, 16, 10);
}
-
+
/* Draw tip point */
if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_TIPSEL) UI_ThemeColor(TH_VERTEX_SELECT);
- else UI_ThemeColorShade(TH_BONE_SOLID, -30);
+ if (boneflag & BONE_TIPSEL) {
+ UI_ThemeColor(TH_VERTEX_SELECT);
+ }
+ else {
+ UI_ThemeColorShade(TH_BONE_SOLID, -30);
+ }
}
- if (id != -1)
+ if (id != -1) {
glLoadName(id | BONESEL_TIP);
-
- glTranslatef(0.0f, 0.0f, length);
- gluSphere(qobj, tail, 16, 10);
- glTranslatef(0.0f, 0.0f, -length);
-
+ }
+
+ gpuTranslate(0.0f, 0.0f, length);
+ gpuDrawSphere(&prim, tail);
+ //GLU Sphere(qobj, tail, 16, 10);
+ gpuTranslate(0.0f, 0.0f, -length);
+
/* base */
if (armflag & ARM_EDITMODE) {
- if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_SELECT);
- else UI_ThemeColor(TH_BONE_SOLID);
+ if (boneflag & BONE_SELECTED) {
+ UI_ThemeColor(TH_SELECT);
+ }
+ else {
+ UI_ThemeColor(TH_BONE_SOLID);
+ }
}
- else if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_SPHEREBONE_BASE, boneflag, constflag);
- else if (dt == OB_SOLID)
+ else if (armflag & ARM_POSEMODE) {
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_SPHEREBONE_BASE, boneflag, constflag);
+ }
+ else if (dt == OB_SOLID) {
UI_ThemeColor(TH_BONE_SOLID);
-
+ }
+
fac1 = (length - head) / length;
fac2 = (length - tail) / length;
-
+
if (length > (head + tail)) {
- if (id != -1)
+ if (id != -1) {
glLoadName(id | BONESEL_BONE);
-
+ }
+
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -1.0f);
-
- glTranslatef(0.0f, 0.0f, head);
- gluCylinder(qobj, fac1 * head + (1.0f - fac1) * tail, fac2 * tail + (1.0f - fac2) * head, length - head - tail, 16, 1);
- glTranslatef(0.0f, 0.0f, -head);
-
+
+ gpuTranslate(0.0f, 0.0f, head);
+ gpuDrawCylinder(
+ &prim,
+ fac1 * head + (1.0f - fac1) * tail,
+ fac2 * tail + (1.0f - fac2) * head,
+ length - head - tail);
+ //GLU Cylinder(qobj, fac1 * head + (1.0f - fac1) * tail, fac2 * tail + (1.0f - fac2) * head, length - head - tail, 16, 1);
+ gpuTranslate(0.0f, 0.0f, -head);
+
glDisable(GL_POLYGON_OFFSET_FILL);
-
+
/* draw sphere on extrema */
- glTranslatef(0.0f, 0.0f, length - tail);
- gluSphere(qobj, fac2 * tail + (1.0f - fac2) * head, 16, 10);
- glTranslatef(0.0f, 0.0f, -length + tail);
-
- glTranslatef(0.0f, 0.0f, head);
- gluSphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10);
+ gpuTranslate(0.0f, 0.0f, length - tail);
+ gpuDrawSphere(&prim, fac2 * tail + (1.0f - fac2) * head);
+ //GLU Sphere(qobj, fac2 * tail + (1.0f - fac2) * head, 16, 10);
+ gpuTranslate(0.0f, 0.0f, -length + tail);
+
+ gpuTranslate(0.0f, 0.0f, head);
+ gpuDrawSphere(&prim, fac1 * head + (1.0f - fac1) * tail);
+ //GLU Sphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10);
}
else {
/* 1 sphere in center */
- glTranslatef(0.0f, 0.0f, (head + length - tail) / 2.0f);
- gluSphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10);
+ gpuTranslate(0.0f, 0.0f, (head + length - tail) / 2.0f);
+ gpuDrawSphere(&prim, fac1 * head + (1.0f - fac1) * tail);
+ //GLU Sphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10);
}
-
+
/* restore */
if (dt == OB_SOLID) {
glShadeModel(GL_FLAT);
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
+ gpuDisableLighting();
+ gpuDisableColorMaterial();
}
-
- glPopMatrix();
- gluDeleteQuadric(qobj);
+
+ gpuPopMatrix();
+
+ gpuImmediateFormat_V3();
}
static GLubyte bm_dot6[] = {0x0, 0x18, 0x3C, 0x7E, 0x7E, 0x3C, 0x18, 0x0};
@@ -999,20 +962,22 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
float length;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
+
if (pchan)
length = pchan->bone->length;
else
length = ebone->length;
-
- glPushMatrix();
- glScalef(length, length, length);
+
+ gpuImmediateFormat_V3();
+
+ gpuPushMatrix();
+ gpuScale(length, length, length);
/* this chunk not in object mode */
if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) {
glLineWidth(4.0f);
if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
else if (armflag & ARM_EDITMODE) {
UI_ThemeColor(TH_WIRE);
}
@@ -1021,9 +986,9 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
if ((boneflag & BONE_CONNECTED) == 0) {
if (G.f & G_PICKSEL) { /* no bitmap in selection mode, crashes 3d cards... */
glLoadName(id | BONESEL_ROOT);
- glBegin(GL_POINTS);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex3f(0.0f, 0.0f, 0.0f);
+ gpuEnd();
}
else {
glRasterPos3f(0.0f, 0.0f, 0.0f);
@@ -1034,18 +999,18 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
if (id != -1)
glLoadName((GLuint) id | BONESEL_BONE);
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glVertex3f(0.0f, 1.0f, 0.0f);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.0f, 0.0f);
+ gpuVertex3f(0.0f, 1.0f, 0.0f);
+ gpuEnd();
/* tip */
if (G.f & G_PICKSEL) {
/* no bitmap in selection mode, crashes 3d cards... */
glLoadName(id | BONESEL_TIP);
- glBegin(GL_POINTS);
- glVertex3f(0.0f, 1.0f, 0.0f);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex3f(0.0f, 1.0f, 0.0f);
+ gpuEnd();
}
else {
glRasterPos3f(0.0f, 1.0f, 0.0f);
@@ -1057,7 +1022,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
glLoadName(id & 0xFFFF); /* object tag, for bordersel optim */
if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_LINEBONE, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_LINEBONE, boneflag, constflag);
}
glLineWidth(2.0);
@@ -1079,10 +1044,10 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_EDGE_SELECT);
else UI_ThemeColorShade(TH_BACK, -30);
}
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glVertex3f(0.0f, 1.0f, 0.0f);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.0f, 0.0f);
+ gpuVertex3f(0.0f, 1.0f, 0.0f);
+ gpuEnd();
/* tip */
if ((G.f & G_PICKSEL) == 0) {
@@ -1097,7 +1062,11 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
glLineWidth(1.0);
- glPopMatrix();
+ gpuPopMatrix();
+
+ gpuImmediateUnformat();
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4); /* restore default value */
}
static void draw_b_bone_boxes(const short dt, bPoseChannel *pchan, float xwidth, float length, float zwidth)
@@ -1113,18 +1082,34 @@ static void draw_b_bone_boxes(const short dt, bPoseChannel *pchan, float xwidth,
int a;
for (a = 0; a < segments; a++, bbone++) {
- glPushMatrix();
- glMultMatrixf(bbone->mat);
- if (dt == OB_SOLID) drawsolidcube_size(xwidth, dlen, zwidth);
- else drawcube_size(xwidth, dlen, zwidth);
- glPopMatrix();
+ gpuPushMatrix();
+ gpuMultMatrix(bbone->mat);
+ gpuScale(xwidth, dlen, zwidth);
+
+ if (dt == OB_SOLID) {
+ gpuDrawSolidHalfCube();
+ }
+ else {
+ gpuDrawWireHalfCube();
+ }
+
+ gpuPopMatrix();
+
}
}
else {
- glPushMatrix();
- if (dt == OB_SOLID) drawsolidcube_size(xwidth, length, zwidth);
- else drawcube_size(xwidth, length, zwidth);
- glPopMatrix();
+ gpuPushMatrix();
+ gpuScale(xwidth, length, zwidth);
+
+ if (dt == OB_SOLID) {
+ gpuDrawSolidHalfCube();
+ }
+ else {
+ gpuDrawWireHalfCube();
+ }
+
+ gpuPopMatrix();
+
}
}
@@ -1147,23 +1132,23 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl
/* draw points only if... */
if (armflag & ARM_EDITMODE) {
/* move to unitspace */
- glPushMatrix();
- glScalef(length, length, length);
+ gpuPushMatrix();
+ gpuScale(length, length, length);
draw_bone_points(dt, armflag, boneflag, id);
- glPopMatrix();
+ gpuPopMatrix();
length *= 0.95f; /* make vertices visible */
}
/* colors for modes */
if (armflag & ARM_POSEMODE) {
if (dt <= OB_WIRE)
- set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
else
- set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_SOLID, boneflag, constflag);
}
else if (armflag & ARM_EDITMODE) {
if (dt == OB_WIRE) {
- set_ebone_glColor(boneflag);
+ set_ebone_gpuCurrentColor(boneflag);
}
else
UI_ThemeColor(TH_BONE_SOLID);
@@ -1175,26 +1160,26 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl
/* set up solid drawing */
if (dt > OB_WIRE) {
- glEnable(GL_COLOR_MATERIAL);
- glEnable(GL_LIGHTING);
+ gpuEnableColorMaterial();
+ gpuEnableLighting();
if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_SOLID, boneflag, constflag);
else
UI_ThemeColor(TH_BONE_SOLID);
draw_b_bone_boxes(OB_SOLID, pchan, xwidth, length, zwidth);
/* disable solid drawing */
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
+ gpuDisableColorMaterial();
+ gpuDisableLighting();
}
else {
/* wire */
if (armflag & ARM_POSEMODE) {
if (constflag) {
/* set constraint colors */
- if (set_pchan_glColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) {
+ if (set_pchan_gpuCurrentColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) {
glEnable(GL_BLEND);
draw_b_bone_boxes(OB_SOLID, pchan, xwidth, length, zwidth);
@@ -1203,7 +1188,7 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl
}
/* restore colors */
- set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
}
}
@@ -1219,26 +1204,26 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len
int a;
for (a = 0; a < segments; a++, bbone++) {
- glPushMatrix();
- glMultMatrixf(bbone->mat);
+ gpuPushMatrix();
+ gpuMultMatrix(bbone->mat);
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glVertex3f(0.0f, dlen, 0.0f);
- glEnd(); /* GL_LINES */
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.0f, 0.0f);
+ gpuVertex3f(0.0f, dlen, 0.0f);
+ gpuEnd(); /* GL_LINES */
- glPopMatrix();
+ gpuPopMatrix();
}
}
else {
- glPushMatrix();
+ gpuPushMatrix();
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glVertex3f(0.0f, length, 0.0f);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.0f, 0.0f);
+ gpuVertex3f(0.0f, length, 0.0f);
+ gpuEnd();
- glPopMatrix();
+ gpuPopMatrix();
}
}
@@ -1262,10 +1247,10 @@ static void draw_wire_bone(const short dt, int armflag, int boneflag, short cons
/* draw points only if... */
if (armflag & ARM_EDITMODE) {
/* move to unitspace */
- glPushMatrix();
- glScalef(length, length, length);
+ gpuPushMatrix();
+ gpuScale(length, length, length);
draw_bone_points(dt, armflag, boneflag, id);
- glPopMatrix();
+ gpuPopMatrix();
length *= 0.95f; /* make vertices visible */
}
@@ -1283,10 +1268,10 @@ static void draw_wire_bone(const short dt, int armflag, int boneflag, short cons
/* colors for modes */
if (armflag & ARM_POSEMODE) {
- set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
}
else if (armflag & ARM_EDITMODE) {
- set_ebone_glColor(boneflag);
+ set_ebone_gpuCurrentColor(boneflag);
}
/* draw normal */
@@ -1299,21 +1284,21 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag
/* Draw a 3d octahedral bone, we use normalized space based on length,
* for display-lists */
- glScalef(length, length, length);
+ gpuScale(length, length, length);
/* set up solid drawing */
if (dt > OB_WIRE) {
- glEnable(GL_COLOR_MATERIAL);
- glEnable(GL_LIGHTING);
+ gpuEnableColorMaterial();
+ gpuEnableLighting();
UI_ThemeColor(TH_BONE_SOLID);
}
/* colors for posemode */
if (armflag & ARM_POSEMODE) {
if (dt <= OB_WIRE)
- set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
else
- set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_SOLID, boneflag, constflag);
}
@@ -1328,12 +1313,12 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag
if (dt <= OB_WIRE) {
/* colors */
if (armflag & ARM_EDITMODE) {
- set_ebone_glColor(boneflag);
+ set_ebone_gpuCurrentColor(boneflag);
}
else if (armflag & ARM_POSEMODE) {
if (constflag) {
/* draw constraint colors */
- if (set_pchan_glColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) {
+ if (set_pchan_gpuCurrentColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) {
glEnable(GL_BLEND);
draw_bone_solid_octahedral();
@@ -1342,7 +1327,7 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag
}
/* restore colors */
- set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
}
}
draw_bone_octahedral();
@@ -1350,16 +1335,17 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag
else {
/* solid */
if (armflag & ARM_POSEMODE)
- set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_SOLID, boneflag, constflag);
else
UI_ThemeColor(TH_BONE_SOLID);
+
draw_bone_solid_octahedral();
}
/* disable solid drawing */
if (dt > OB_WIRE) {
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
+ gpuDisableColorMaterial();
+ gpuDisableLighting();
}
}
@@ -1368,11 +1354,11 @@ static void draw_custom_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obje
{
if (ob == NULL) return;
- glScalef(length, length, length);
+ gpuScale(length, length, length);
/* colors for posemode */
if (armflag & ARM_POSEMODE) {
- set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, 0);
+ set_pchan_gpuCurrentColor(PCHAN_COLOR_NORMAL, boneflag, 0);
}
if (id != -1) {
@@ -1403,7 +1389,7 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
continue;
setlinestyle(3);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
/* exclude tip from chain? */
if ((data->flag & CONSTRAINT_IK_TIP) == 0)
@@ -1411,7 +1397,7 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
else
parchan = pchan;
- glVertex3fv(parchan->pose_tail);
+ gpuVertex3fv(parchan->pose_tail);
/* Find the chain's root */
while (parchan->parent) {
@@ -1422,9 +1408,9 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
parchan = parchan->parent;
}
if (parchan)
- glVertex3fv(parchan->pose_head);
+ gpuVertex3fv(parchan->pose_head);
- glEnd();
+ gpuEnd();
setlinestyle(0);
}
break;
@@ -1434,10 +1420,10 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
int segcount = 0;
setlinestyle(3);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
parchan = pchan;
- glVertex3fv(parchan->pose_tail);
+ gpuVertex3fv(parchan->pose_tail);
/* Find the chain's root */
while (parchan->parent) {
@@ -1447,9 +1433,9 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
parchan = parchan->parent;
}
if (parchan) /* XXX revise the breaking conditions to only stop at the tail? */
- glVertex3fv(parchan->pose_head);
+ gpuVertex3fv(parchan->pose_head);
- glEnd();
+ gpuEnd();
setlinestyle(0);
}
break;
@@ -1468,7 +1454,7 @@ static void bgl_sphere_project(float ax, float az)
dir[1] = 1.0f - 2.0f * sine;
dir[2] = ax * q3;
- glVertex3fv(dir);
+ gpuVertex3fv(dir);
}
static void draw_dof_ellipse(float ax, float az)
@@ -1487,9 +1473,9 @@ static void draw_dof_ellipse(float ax, float az)
glEnable(GL_BLEND);
glDepthMask(0);
- glColor4ub(70, 70, 70, 50);
+ gpuCurrentGray4f(0.276f, 0.196f);
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
pz = 0.0f;
for (i = 1; i < n; i++) {
z = staticSine[i];
@@ -1499,13 +1485,13 @@ static void draw_dof_ellipse(float ax, float az)
x = staticSine[j];
if (j == n - i) {
- glEnd();
- glBegin(GL_TRIANGLES);
+ gpuEnd();
+ gpuBegin(GL_TRIANGLES);
bgl_sphere_project(ax * px, az * z);
bgl_sphere_project(ax * px, az * pz);
bgl_sphere_project(ax * x, az * pz);
- glEnd();
- glBegin(GL_QUADS);
+ gpuEnd();
+ gpuBegin(GL_QUADS);
}
else {
bgl_sphere_project(ax * x, az * z);
@@ -1518,17 +1504,17 @@ static void draw_dof_ellipse(float ax, float az)
}
pz = z;
}
- glEnd();
+ gpuEnd();
glDisable(GL_BLEND);
glDepthMask(1);
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0; i < n; i++)
bgl_sphere_project(staticSine[n - i - 1] * ax, staticSine[i] * az);
- glEnd();
+ gpuEnd();
}
static void draw_pose_dofs(Object *ob)
@@ -1550,22 +1536,22 @@ static void draw_pose_dofs(Object *ob)
int a, i;
/* in parent-bone pose, but own restspace */
- glPushMatrix();
+ gpuPushMatrix();
copy_v3_v3(posetrans, pchan->pose_mat[3]);
- glTranslatef(posetrans[0], posetrans[1], posetrans[2]);
+ gpuTranslate(posetrans[0], posetrans[1], posetrans[2]);
if (pchan->parent) {
copy_m4_m4(mat, pchan->parent->pose_mat);
mat[3][0] = mat[3][1] = mat[3][2] = 0.0f;
- glMultMatrixf(mat);
+ gpuMultMatrix(mat);
}
copy_m4_m3(mat, pchan->bone->bone_mat);
- glMultMatrixf(mat);
+ gpuMultMatrix(mat);
scale = bone->length * pchan->size[1];
- glScalef(scale, scale, scale);
+ gpuScale(scale, scale, scale);
if (pchan->ikflag & BONE_IK_XLIMIT) {
if (pchan->ikflag & BONE_IK_ZLIMIT) {
@@ -1577,7 +1563,7 @@ static void draw_pose_dofs(Object *ob)
amax[i] = (float)sin(pchan->limitmax[i] * 0.5f);
}
- glScalef(1.0f, -1.0f, 1.0f);
+ gpuScale(1.0f, -1.0f, 1.0f);
if ((amin[0] != 0.0f) && (amin[2] != 0.0f))
draw_dof_ellipse(amin[0], amin[2]);
if ((amin[0] != 0.0f) && (amax[2] != 0.0f))
@@ -1586,18 +1572,18 @@ static void draw_pose_dofs(Object *ob)
draw_dof_ellipse(amax[0], amin[2]);
if ((amax[0] != 0.0f) && (amax[2] != 0.0f))
draw_dof_ellipse(amax[0], amax[2]);
- glScalef(1.0f, -1.0f, 1.0f);
+ gpuScale(1.0f, -1.0f, 1.0f);
}
}
/* arcs */
if (pchan->ikflag & BONE_IK_ZLIMIT) {
/* OpenGL requires rotations in degrees; so we're taking the average angle here */
- theta = RAD2DEGF(0.5f * (pchan->limitmin[2] + pchan->limitmax[2]));
- glRotatef(theta, 0.0f, 0.0f, 1.0f);
+ theta = 0.5f * (pchan->limitmin[2] + pchan->limitmax[2]);
+ gpuRotateAxis(theta, 'Z');
- glColor3ub(50, 50, 255); /* blue, Z axis limit */
- glBegin(GL_LINE_STRIP);
+ gpuCurrentColor3ub(50, 50, 255); /* blue, Z axis limit */
+ gpuBegin(GL_LINE_STRIP);
for (a = -16; a <= 16; a++) {
/* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
float fac = ((float)a) / 16.0f * 0.5f;
@@ -1608,20 +1594,20 @@ static void draw_pose_dofs(Object *ob)
corner[i][0] = (float)sin(phi);
corner[i][1] = (float)cos(phi);
corner[i][2] = 0.0f;
- glVertex3fv(corner[i]);
+ gpuVertex3fv(corner[i]);
}
- glEnd();
+ gpuEnd();
- glRotatef(-theta, 0.0f, 0.0f, 1.0f);
+ gpuRotateAxis(-theta, 'Z');
}
if (pchan->ikflag & BONE_IK_XLIMIT) {
/* OpenGL requires rotations in degrees; so we're taking the average angle here */
theta = RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0]));
- glRotatef(theta, 1.0f, 0.0f, 0.0f);
+ gpuRotateAxis(theta, 'X');
- glColor3ub(255, 50, 50); /* Red, X axis limit */
- glBegin(GL_LINE_STRIP);
+ gpuCurrentColor3ub(255, 50, 50); /* Red, X axis limit */
+ gpuBegin(GL_LINE_STRIP);
for (a = -16; a <= 16; a++) {
/* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */
float fac = ((float)a) / 16.0f * 0.5f;
@@ -1631,15 +1617,15 @@ static void draw_pose_dofs(Object *ob)
corner[i][0] = 0.0f;
corner[i][1] = (float)sin(phi);
corner[i][2] = (float)cos(phi);
- glVertex3fv(corner[i]);
+ gpuVertex3fv(corner[i]);
}
- glEnd();
+ gpuEnd();
- glRotatef(-theta, 1.0f, 0.0f, 0.0f);
+ gpuRotateAxis(-theta, 'X');
}
/* out of cone, out of bone */
- glPopMatrix();
+ gpuPopMatrix();
}
}
}
@@ -1737,13 +1723,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
{
if (bone->layer & arm->layer) {
int use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM);
- glPushMatrix();
+ gpuPushMatrix();
if (use_custom && pchan->custom_tx) {
- glMultMatrixf(pchan->custom_tx->pose_mat);
+ gpuMultMatrix(pchan->custom_tx->pose_mat);
}
else {
- glMultMatrixf(pchan->pose_mat);
+ gpuMultMatrix(pchan->pose_mat);
}
/* catch exception for bone with hidden parent */
@@ -1790,7 +1776,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
draw_bone(OB_SOLID, arm->flag, flag, 0, index, bone->length);
}
- glPopMatrix();
+ gpuPopMatrix();
}
}
@@ -1826,13 +1812,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
if (bone->layer & arm->layer) {
if (pchan->custom) {
if ((dt < OB_SOLID) || (bone->flag & BONE_DRAWWIRE)) {
- glPushMatrix();
+ gpuPushMatrix();
if (pchan->custom_tx) {
- glMultMatrixf(pchan->custom_tx->pose_mat);
+ gpuMultMatrix(pchan->custom_tx->pose_mat);
}
else {
- glMultMatrixf(pchan->pose_mat);
+ gpuMultMatrix(pchan->pose_mat);
}
/* prepare colors */
@@ -1842,7 +1828,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
else if (arm->flag & ARM_POSEMODE)
set_pchan_colorset(ob, pchan);
else {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
/* catch exception for bone with hidden parent */
@@ -1857,7 +1843,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
draw_custom_bone(scene, v3d, rv3d, pchan->custom,
OB_WIRE, arm->flag, flag, index, bone->length);
- glPopMatrix();
+ gpuPopMatrix();
}
}
}
@@ -1911,10 +1897,12 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
UI_ThemeColor(TH_WIRE);
}
setlinestyle(3);
- glBegin(GL_LINES);
- glVertex3fv(pchan->pose_head);
- glVertex3fv(pchan->parent->pose_tail);
- glEnd();
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(pchan->pose_head);
+ gpuVertex3fv(pchan->parent->pose_tail);
+ gpuEnd();
+ gpuImmediateUnformat();
setlinestyle(0);
}
@@ -1924,8 +1912,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
if (arm->flag & ARM_POSEMODE) {
if (constflag & PCHAN_HAS_IK) {
if (bone->flag & BONE_SELECTED) {
- if (constflag & PCHAN_HAS_TARGET) glColor3ub(200, 120, 0);
- else glColor3ub(200, 200, 50); /* add theme! */
+ if (constflag & PCHAN_HAS_TARGET) gpuCurrentColor3ub(200, 120, 0);
+ else gpuCurrentColor3ub(200, 200, 50); /* add theme! */
glLoadName(index & 0xFFFF);
pchan_draw_IK_root_lines(pchan, !(do_dashed & 2));
@@ -1933,7 +1921,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
}
else if (constflag & PCHAN_HAS_SPLINEIK) {
if (bone->flag & BONE_SELECTED) {
- glColor3ub(150, 200, 50); /* add theme! */
+ gpuCurrentColor3ub(150, 200, 50); /* add theme! */
glLoadName(index & 0xFFFF);
pchan_draw_IK_root_lines(pchan, !(do_dashed & 2));
@@ -1942,9 +1930,9 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
}
}
- glPushMatrix();
+ gpuPushMatrix();
if (arm->drawtype != ARM_ENVELOPE)
- glMultMatrixf(pchan->pose_mat);
+ gpuMultMatrix(pchan->pose_mat);
/* catch exception for bone with hidden parent */
flag = bone->flag;
@@ -1981,7 +1969,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
else
draw_bone(OB_WIRE, arm->flag, flag, constflag, index, bone->length);
- glPopMatrix();
+ gpuPopMatrix();
}
}
@@ -2012,13 +2000,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
/* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */
if ((G.f & G_PICKSEL) == 0) {
float vec[3];
-
unsigned char col[4];
if (do_const_color) {
/* so we can draw bone names in current const color */
- float tcol[4];
- glGetFloatv(GL_CURRENT_COLOR, tcol);
- rgb_float_to_uchar(col, tcol);
+ gpuGetCurrentColor4ubv(col);
col[3] = 255;
}
else {
@@ -2027,43 +2012,47 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
col[2] = ob_wire_col[2];
col[3] = 255;
}
-
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
+
+ if (v3d->zbuf) {
+ glDisable(GL_DEPTH_TEST);
+ }
+
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if ((pchan->bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) {
- if (pchan->bone->layer & arm->layer) {
- if (arm->flag & (ARM_EDITMODE | ARM_POSEMODE)) {
- bone = pchan->bone;
- UI_GetThemeColor3ubv((bone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, col);
- }
- else if (dt > OB_WIRE) {
- UI_GetThemeColor3ubv(TH_TEXT, col);
- }
-
- /* Draw names of bone */
- if (arm->flag & ARM_DRAWNAMES) {
- mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail);
- view3d_cached_text_draw_add(vec, pchan->name, 10, 0, col);
- }
-
- /* Draw additional axes on the bone tail */
- if ((arm->flag & ARM_DRAWAXES) && (arm->flag & ARM_POSEMODE)) {
- glPushMatrix();
- copy_m4_m4(bmat, pchan->pose_mat);
- bone_matrix_translate_y(bmat, pchan->bone->length);
- glMultMatrixf(bmat);
-
- glColor3ubv(col);
- drawaxes(pchan->bone->length * 0.25f, OB_ARROWS);
-
- glPopMatrix();
- }
+ if ((pchan->bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0 &&
+ pchan->bone->layer & arm->layer)
+ {
+ if (arm->flag & (ARM_EDITMODE | ARM_POSEMODE)) {
+ bone = pchan->bone;
+ UI_GetThemeColor3ubv((bone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, col);
+ }
+ else if (dt > OB_WIRE) {
+ UI_GetThemeColor3ubv(TH_TEXT, col);
+ }
+
+ /* Draw names of bone */
+ if (arm->flag & ARM_DRAWNAMES) {
+ mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail);
+ view3d_cached_text_draw_add(vec, pchan->name, 10, 0, col);
+ }
+
+ /* Draw additional axes on the bone tail */
+ if ((arm->flag & ARM_DRAWAXES) && (arm->flag & ARM_POSEMODE)) {
+ gpuPushMatrix();
+ copy_m4_m4(bmat, pchan->pose_mat);
+ bone_matrix_translate_y(bmat, pchan->bone->length);
+ gpuMultMatrix(bmat);
+
+ gpuCurrentColor3ubv(col);
+ drawaxes(pchan->bone->length * 0.25f, OB_ARROWS);
+
+ gpuPopMatrix();
}
}
}
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+
+ if (v3d->zbuf) {
+ glEnable(GL_DEPTH_TEST);
+ }
}
}
}
@@ -2129,9 +2118,9 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
for (eBone = arm->edbo->first, index = 0; eBone; eBone = eBone->next, index++) {
if (eBone->layer & arm->layer) {
if ((eBone->flag & BONE_HIDDEN_A) == 0) {
- glPushMatrix();
+ gpuPushMatrix();
get_matrix_editbone(eBone, bmat);
- glMultMatrixf(bmat);
+ gpuMultMatrix(bmat);
/* catch exception for bone with hidden parent */
flag = eBone->flag;
@@ -2153,7 +2142,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
draw_bone(OB_SOLID, arm->flag, flag, 0, index, eBone->length);
}
- glPopMatrix();
+ gpuPopMatrix();
}
}
}
@@ -2191,9 +2180,9 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
draw_sphere_bone_wire(smat, imat, arm->flag, flag, 0, index, NULL, eBone);
}
else {
- glPushMatrix();
+ gpuPushMatrix();
get_matrix_editbone(eBone, bmat);
- glMultMatrixf(bmat);
+ gpuMultMatrix(bmat);
if (arm->drawtype == ARM_LINE)
draw_line_bone(arm->flag, flag, 0, index, NULL, eBone);
@@ -2204,7 +2193,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
else
draw_bone(OB_WIRE, arm->flag, flag, 0, index, eBone->length);
- glPopMatrix();
+ gpuPopMatrix();
}
/* offset to parent */
@@ -2213,10 +2202,10 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
glLoadName(-1); /* -1 here is OK! */
setlinestyle(3);
- glBegin(GL_LINES);
- glVertex3fv(eBone->parent->tail);
- glVertex3fv(eBone->head);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(eBone->parent->tail);
+ gpuVertex3fv(eBone->head);
+ gpuEnd();
setlinestyle(0);
}
@@ -2261,15 +2250,15 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
}
/* Draw additional axes */
if (arm->flag & ARM_DRAWAXES) {
- glPushMatrix();
+ gpuPushMatrix();
get_matrix_editbone(eBone, bmat);
bone_matrix_translate_y(bmat, eBone->length);
- glMultMatrixf(bmat);
+ gpuMultMatrix(bmat);
- glColor3ubv(col);
+ gpuCurrentColor3ubv(col);
drawaxes(eBone->length * 0.25f, OB_ARROWS);
- glPopMatrix();
+ gpuPopMatrix();
}
}
@@ -2589,12 +2578,15 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
if (v3d->flag2 & V3D_RENDER_OVERRIDE)
return 1;
-
+
if (dt > OB_WIRE && !ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
+ static const GLfloat white[4] = { 1, 1, 1, 1 };
+
/* we use color for solid lighting */
- const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gpuMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
+
+ gpuColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); /* only for lighting... */
}
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index f35a844afc9..5d442aff84d 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -58,11 +58,12 @@
#include "BKE_tessmesh.h"
#include "BKE_scene.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "UI_resources.h"
+#include "GPU_compatibility.h"
+#include "GPU_colors.h"
#include "GPU_buffers.h"
#include "GPU_extensions.h"
#include "GPU_draw.h"
@@ -148,12 +149,12 @@ static DMDrawOption draw_mesh_face_select__setHiddenOpts(void *userData, int ind
if (me->drawflag & ME_DRAWEDGES) {
if ((me->drawflag & ME_HIDDENEDGES) || (flags & eEdge_Visible))
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
else
return DM_DRAW_OPTION_SKIP;
}
else if (flags & eEdge_Select)
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
else
return DM_DRAW_OPTION_SKIP;
}
@@ -164,7 +165,7 @@ static DMDrawOption draw_mesh_face_select__setSelectOpts(void *userData, int ind
MEdge *med = &data->me->medge[index];
uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2);
- return (flags & eEdge_Select) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
+ return (flags & eEdge_Select) ? DM_DRAW_OPTION_NORMALLY : DM_DRAW_OPTION_SKIP;
}
/* draws unselected */
@@ -187,31 +188,37 @@ static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
data.eh = get_tface_mesh_marked_edge_info(me);
glEnable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
bglPolygonOffset(rv3d->dist, 1.0);
/* Draw (Hidden) Edges */
setlinestyle(1);
UI_ThemeColor(TH_EDGE_FACESEL);
+ gpuImmediateFormat_C4_V3(); /* XXX: jwilkins, C4 only because CCG age visualization may be enabled */
dm->drawMappedEdges(dm, draw_mesh_face_select__setHiddenOpts, &data);
+ gpuImmediateUnformat();
setlinestyle(0);
/* Draw Selected Faces */
if (me->drawflag & ME_DRAWFACES) {
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* dull unselected faces so as not to get in the way of seeing color */
- glColor4ub(96, 96, 96, 64);
- dm->drawMappedFaces(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, NULL, (void *)me, 0);
+ gpuCurrentGray4f(0.376f, 0.250f);
+ gpuImmediateFormat_V3();
+ /* XXX: jwilkins, drawing without mesh colors, so setDrawOption that turns off color for unselected faces is redundant? */
+ dm->drawMappedFaces(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, NULL, me, 0);
+ gpuImmediateUnformat();
glDisable(GL_BLEND);
}
bglPolygonOffset(rv3d->dist, 1.0);
/* Draw Stippled Outline for selected faces */
- glColor3ub(255, 255, 255);
+ gpuCurrentColor3x(CPACK_WHITE);
setlinestyle(1);
+ gpuImmediateFormat_C4_V3(); /* XXX: jwilkins, C4 only because CCG age visualization may be enabled */
dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data);
+ gpuImmediateUnformat();
setlinestyle(0);
bglPolygonOffset(rv3d->dist, 0.0); /* resets correctly now, even after calling accumulated offsets */
@@ -313,7 +320,10 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m
memcpy(&c_texface, texface, sizeof(c_texface));
}
- if (c_badtex) lit = 0;
+ if (c_badtex) {
+ lit = 0;
+ }
+
if (lit != c_lit || ma != c_ma) {
if (lit) {
float spec[4];
@@ -324,16 +334,17 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m
spec[2] = ma->spec * ma->specb;
spec[3] = 1.0;
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, CLAMPIS(ma->har, 0, 128));
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
+ gpuMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
+ gpuColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gpuMateriali(GL_FRONT_AND_BACK, GL_SHININESS, CLAMPIS(ma->har, 0, 128));
+ gpuEnableLighting();
+ gpuEnableColorMaterial();
}
else {
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
+ gpuDisableLighting();
+ gpuDisableColorMaterial();
}
+
c_lit = lit;
}
@@ -385,7 +396,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
else {
glDisable(GL_CULL_FACE);
}
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
+ gpuLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
}
static void draw_textured_end(void)
@@ -405,10 +416,10 @@ static void draw_textured_end(void)
* of and restored the light settings it changed.
* - zr
*/
- glPushMatrix();
- glLoadIdentity();
+ gpuPushMatrix();
+ gpuLoadIdentity();
GPU_default_lights();
- glPopMatrix();
+ gpuPopMatrix();
}
static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr)
@@ -422,36 +433,40 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int
validtexture = set_draw_settings_cached(0, tface, ma, Gtexdraw);
if (tface && validtexture) {
- glColor3ub(0xFF, 0x00, 0xFF);
+ gpuCurrentColor3x(CPACK_MAGENTA);
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
}
else if (ma && (ma->shade_flag & MA_OBCOLOR)) {
- glColor3ubv(Gtexdraw.obcol);
+ gpuCurrentColor3ubv(Gtexdraw.obcol);
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
}
else if (!has_mcol) {
- if (tface) glColor3f(1.0, 1.0, 1.0);
+ if (tface) {
+ gpuCurrentColor3x(CPACK_WHITE);
+ }
else {
if (ma) {
float col[3];
if (Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r);
else copy_v3_v3(col, &ma->r);
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
+ }
+ else {
+ gpuCurrentColor3x(CPACK_WHITE);
}
- else glColor3f(1.0, 1.0, 1.0);
}
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
}
else {
- return DM_DRAW_OPTION_NORMAL; /* Set color from mcol */
+ return DM_DRAW_OPTION_NORMALLY; /* Set color from mcol */
}
}
static DMDrawOption draw_mcol__set_draw_legacy(MTFace *UNUSED(tface), int has_mcol, int UNUSED(matnr))
{
if (has_mcol)
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
else
return DM_DRAW_OPTION_NO_MCOL;
}
@@ -470,10 +485,10 @@ static DMDrawOption draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr)
}
else if (!has_mcol) {
/* XXX: this return value looks wrong (and doesn't match comment) */
- return DM_DRAW_OPTION_NORMAL; /* Don't set color */
+ return DM_DRAW_OPTION_NORMALLY; /* Don't set color */
}
else {
- return DM_DRAW_OPTION_NORMAL; /* Set color from mcol */
+ return DM_DRAW_OPTION_NORMALLY; /* Set color from mcol */
}
}
@@ -611,13 +626,11 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index)
}
/* when face select is on, use face hidden flag */
-static DMDrawOption wpaint__setSolidDrawOptions_facemask(void *userData, int index)
+static DMDrawOption wpaint__setSolidDrawOptions_facemask(Mesh *me, int index)
{
- Mesh *me = (Mesh *)userData;
MPoly *mp = &me->mpoly[index];
- if (mp->flag & ME_HIDE)
- return DM_DRAW_OPTION_SKIP;
- return DM_DRAW_OPTION_NORMAL;
+
+ return (mp->flag & ME_HIDE) ? DM_DRAW_OPTION_SKIP : DM_DRAW_OPTION_NORMALLY;
}
static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
@@ -736,7 +749,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
normal_tri_v3(nor, v1, v2, v3);
- glNormal3fv(nor);
+ gpuNormal3fv(nor);
}
GPU_render_text(&tmp_tf, mode, string, characters,
@@ -785,7 +798,7 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
/* draw the textured mesh */
draw_textured_begin(scene, v3d, rv3d, ob);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ gpuCurrentColor3x(CPACK_WHITE);
if (ob->mode & OB_MODE_EDIT) {
drawEMTFMapped_userData data;
@@ -799,11 +812,24 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, compareDrawOptionsEm, &data);
}
else if (draw_flags & DRAW_FACE_SELECT) {
- if (ob->mode & OB_MODE_WEIGHT_PAINT)
- dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me,
- DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH);
- else
- dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me);
+ if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+ gpuImmediateFormat_C4_V3();
+ dm->drawMappedFaces(
+ dm,
+ wpaint__setSolidDrawOptions_facemask,
+ GPU_enable_material,
+ NULL,
+ me,
+ DM_DRAW_USE_COLORS|DM_DRAW_ALWAYS_SMOOTH);
+ gpuImmediateUnformat();
+ }
+ else {
+ dm->drawMappedFacesTex(
+ dm,
+ me->mpoly ? draw_tface_mapped__set_draw : NULL,
+ NULL,
+ me);
+ }
}
else {
if (GPU_buffer_legacy(dm)) {
@@ -836,9 +862,6 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
/* reset from negative scale correction */
glFrontFace(GL_CCW);
-
- /* in editmode, the blend mode needs to be set in case it was ADD */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
/************************** NEW SHADING NODES ********************************/
@@ -881,21 +904,21 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs)
/* disable existing material */
GPU_disable_material();
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
- glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
+ gpuMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
+ gpuMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
+ gpuMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
/* bind texture */
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
+ gpuColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gpuEnableColorMaterial();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
- glColor3f(1.0f, 1.0f, 1.0f);
+ gpuCurrentColor3x(CPACK_WHITE);
- glMatrixMode(GL_TEXTURE);
- glLoadMatrixf(texbase->tex_mapping.mat);
- glMatrixMode(GL_MODELVIEW);
+ gpuMatrixMode(GL_TEXTURE);
+ gpuLoadMatrix(texbase->tex_mapping.mat);
+ gpuMatrixMode(GL_MODELVIEW);
/* use active UV texture layer */
memset(gattribs, 0, sizeof(*gattribs));
@@ -910,13 +933,13 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs)
}
if (!texture_set) {
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
+ gpuMatrixMode(GL_TEXTURE);
+ gpuLoadIdentity();
+ gpuMatrixMode(GL_MODELVIEW);
/* disable texture */
glDisable(GL_TEXTURE_2D);
- glDisable(GL_COLOR_MATERIAL);
+ gpuDisableColorMaterial();
/* draw single color */
GPU_enable_material(mat_nr, attribs);
@@ -944,7 +967,7 @@ static int tex_mat_set_face_editmesh_cb(void *userData, int index)
}
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
- Object *ob, DerivedMesh *dm, const int draw_flags)
+ Object *ob, DerivedMesh *dm, int draw_flags)
{
if ((!BKE_scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) {
draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags);
@@ -959,7 +982,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
else glFrontFace(GL_CCW);
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
{
Mesh *me = ob->data;
@@ -990,9 +1013,9 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* draw textured */
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
- glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
+ gpuMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
+ gpuMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
+ gpuMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
dm->drawMappedFacesMat(dm,
tex_mat_set_texture_cb,
@@ -1003,15 +1026,15 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
}
/* reset opengl state */
- glDisable(GL_COLOR_MATERIAL);
+ gpuDisableColorMaterial();
glDisable(GL_TEXTURE_2D);
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
glBindTexture(GL_TEXTURE_2D, 0);
glFrontFace(GL_CCW);
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
+ gpuMatrixMode(GL_TEXTURE);
+ gpuLoadIdentity();
+ gpuMatrixMode(GL_MODELVIEW);
/* faceselect mode drawing over textured mesh */
if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT))
@@ -1021,53 +1044,79 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
/* Vertex Paint and Weight Paint */
void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
- Object *ob, DerivedMesh *dm, const int draw_flags)
+ Object *ob, DerivedMesh *dm, int draw_flags)
{
- DMSetDrawOptions facemask = NULL;
+ DMSetDrawOptions facemask;
Mesh *me = ob->data;
const short do_light = (v3d->drawtype >= OB_SOLID);
/* hide faces in face select mode */
- if (draw_flags & DRAW_FACE_SELECT)
- facemask = wpaint__setSolidDrawOptions_facemask;
+ facemask = (draw_flags & DRAW_FACE_SELECT) ? wpaint__setSolidDrawOptions_facemask : NULL;
if (ob->mode & OB_MODE_WEIGHT_PAINT) {
if (do_light) {
- const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
+ static const GLfloat spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
/* enforce default material settings */
GPU_enable_material(0, NULL);
/* but set default spec */
- glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
+ gpuMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
/* diffuse */
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
+ gpuColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gpuEnableLighting();
+ gpuEnableColorMaterial();
+ }
+
+ if (do_light) {
+ gpuImmediateFormat_C4_N3_V3();
}
+ else {
+ gpuImmediateFormat_C4_V3();
+ }
+
+ dm->drawMappedFaces(
+ dm,
+ facemask,
+ GPU_enable_material,
+ NULL,
+ me,
+ DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH | (do_light ? DM_DRAW_USE_NORMALS : 0));
- dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me,
- DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH);
+ gpuImmediateUnformat();
if (do_light) {
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
+ gpuDisableColorMaterial();
+ gpuDisableLighting();
GPU_disable_material();
}
}
else if (ob->mode & OB_MODE_VERTEX_PAINT) {
if (me->mloopcol) {
- dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me,
- DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH);
+ gpuImmediateFormat_C4_V3();
+ dm->drawMappedFaces(
+ dm,
+ facemask,
+ GPU_enable_material,
+ NULL,
+ me,
+ DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH);
+ gpuImmediateUnformat();
}
else {
- glColor3f(1.0f, 1.0f, 1.0f);
- dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me,
- DM_DRAW_ALWAYS_SMOOTH);
+ gpuCurrentColor3x(CPACK_WHITE);
+ gpuImmediateFormat_V3();
+ dm->drawMappedFaces(
+ dm,
+ facemask,
+ GPU_enable_material,
+ NULL,
+ me,
+ DM_DRAW_ALWAYS_SMOOTH);
+ gpuImmediateUnformat();
}
}
@@ -1084,7 +1133,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
glEnable(GL_BLEND);
- glColor4ub(255, 255, 255, 96);
+ gpuCurrentColor4x(CPACK_WHITE, 0.376f);
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0xAAAA);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 08ba4fb59bc..7cd432db661 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -75,9 +75,10 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
@@ -151,8 +152,6 @@ typedef struct bbsObmodeMeshVerts_userData {
static void draw_bounding_volume(Scene *scene, Object *ob, char type);
-static void drawcube_size(float size);
-static void drawcircle_size(float size);
static void draw_empty_sphere(float size);
static void draw_empty_cone(float size);
@@ -164,7 +163,7 @@ static void ob_wire_color_blend_theme_id(const unsigned char ob_wire_col[4], con
UI_GetThemeColor3fv(theme_id, col_bg);
interp_v3_v3v3(col, col_bg, col_wire, fac);
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
}
/* this condition has been made more complex since editmode can draw textures */
@@ -243,92 +242,6 @@ static unsigned int colortab[24] = {
};
-static float cube[8][3] = {
- {-1.0, -1.0, -1.0},
- {-1.0, -1.0, 1.0},
- {-1.0, 1.0, 1.0},
- {-1.0, 1.0, -1.0},
- { 1.0, -1.0, -1.0},
- { 1.0, -1.0, 1.0},
- { 1.0, 1.0, 1.0},
- { 1.0, 1.0, -1.0},
-};
-
-/* ----------------- OpenGL Circle Drawing - Tables for Optimized Drawing Speed ------------------ */
-/* 32 values of sin function (still same result!) */
-#define CIRCLE_RESOL 32
-
-static const float sinval[CIRCLE_RESOL] = {
- 0.00000000,
- 0.20129852,
- 0.39435585,
- 0.57126821,
- 0.72479278,
- 0.84864425,
- 0.93775213,
- 0.98846832,
- 0.99871650,
- 0.96807711,
- 0.89780453,
- 0.79077573,
- 0.65137248,
- 0.48530196,
- 0.29936312,
- 0.10116832,
- -0.10116832,
- -0.29936312,
- -0.48530196,
- -0.65137248,
- -0.79077573,
- -0.89780453,
- -0.96807711,
- -0.99871650,
- -0.98846832,
- -0.93775213,
- -0.84864425,
- -0.72479278,
- -0.57126821,
- -0.39435585,
- -0.20129852,
- 0.00000000
-};
-
-/* 32 values of cos function (still same result!) */
-static const float cosval[CIRCLE_RESOL] = {
- 1.00000000,
- 0.97952994,
- 0.91895781,
- 0.82076344,
- 0.68896691,
- 0.52896401,
- 0.34730525,
- 0.15142777,
- -0.05064916,
- -0.25065253,
- -0.44039415,
- -0.61210598,
- -0.75875812,
- -0.87434661,
- -0.95413925,
- -0.99486932,
- -0.99486932,
- -0.95413925,
- -0.87434661,
- -0.75875812,
- -0.61210598,
- -0.44039415,
- -0.25065253,
- -0.05064916,
- 0.15142777,
- 0.34730525,
- 0.52896401,
- 0.68896691,
- 0.82076344,
- 0.91895781,
- 0.97952994,
- 1.00000000
-};
-
static void draw_xyz_wire(const float c[3], float size, int axis)
{
float v1[3] = {0.f, 0.f, 0.f}, v2[3] = {0.f, 0.f, 0.f};
@@ -341,7 +254,7 @@ static void draw_xyz_wire(const float c[3], float size, int axis)
switch (axis) {
case 0: /* x axis */
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
/* bottom left to top right */
sub_v3_v3v3(v1, c, dx);
@@ -349,21 +262,21 @@ static void draw_xyz_wire(const float c[3], float size, int axis)
add_v3_v3v3(v2, c, dx);
add_v3_v3(v2, dy);
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
/* top left to bottom right */
mul_v3_fl(dy, 2.f);
add_v3_v3(v1, dy);
sub_v3_v3(v2, dy);
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
- glEnd();
+ gpuEnd();
break;
case 1: /* y axis */
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
/* bottom left to top right */
mul_v3_fl(dx, 0.75f);
@@ -372,44 +285,44 @@ static void draw_xyz_wire(const float c[3], float size, int axis)
add_v3_v3v3(v2, c, dx);
add_v3_v3(v2, dy);
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
/* top left to center */
mul_v3_fl(dy, 2.f);
add_v3_v3(v1, dy);
copy_v3_v3(v2, c);
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
- glEnd();
+ gpuEnd();
break;
case 2: /* z axis */
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
/* start at top left */
sub_v3_v3v3(v1, c, dx);
add_v3_v3v3(v1, c, dz);
- glVertex3fv(v1);
+ gpuVertex3fv(v1);
mul_v3_fl(dx, 2.f);
add_v3_v3(v1, dx);
- glVertex3fv(v1);
+ gpuVertex3fv(v1);
mul_v3_fl(dz, 2.f);
sub_v3_v3(v1, dx);
sub_v3_v3(v1, dz);
- glVertex3fv(v1);
+ gpuVertex3fv(v1);
add_v3_v3(v1, dx);
- glVertex3fv(v1);
+ gpuVertex3fv(v1);
- glEnd();
+ gpuEnd();
break;
}
@@ -421,35 +334,43 @@ void drawaxes(float size, char drawtype)
float v1[3] = {0.0, 0.0, 0.0};
float v2[3] = {0.0, 0.0, 0.0};
float v3[3] = {0.0, 0.0, 0.0};
-
+
switch (drawtype) {
case OB_PLAINAXES:
+ gpuImmediateFormat_V3(); // DOODLE: draw axes
+
for (axis = 0; axis < 3; axis++) {
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
v1[axis] = size;
v2[axis] = -size;
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
/* reset v1 & v2 to zero */
v1[axis] = v2[axis] = 0.0f;
- glEnd();
+ gpuEnd();
}
+
+ gpuImmediateUnformat();
+
break;
+
case OB_SINGLE_ARROW:
- glBegin(GL_LINES);
+ gpuImmediateFormat_V3(); // DOODLE: draw axes
+
+ gpuBegin(GL_LINES);
/* in positive z direction only */
v1[2] = size;
- glVertex3fv(v1);
- glVertex3fv(v2);
- glEnd();
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
+ gpuEnd();
/* square pyramid */
- glBegin(GL_TRIANGLES);
+ gpuBegin(GL_TRIANGLES);
v2[0] = size * 0.035f; v2[1] = size * 0.035f;
v3[0] = size * -0.035f; v3[1] = size * 0.035f;
@@ -465,20 +386,25 @@ void drawaxes(float size, char drawtype)
v3[0] = -v3[0];
}
- glVertex3fv(v1);
- glVertex3fv(v2);
- glVertex3fv(v3);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
+ gpuVertex3fv(v3);
}
- glEnd();
+
+ gpuEnd();
+
+ gpuImmediateUnformat();
break;
+
case OB_CUBE:
- drawcube_size(size);
+ gpuSingleWireCube(size);
+
break;
case OB_CIRCLE:
- drawcircle_size(size);
+ gpuSingleFastCircleXZ(size);
break;
case OB_EMPTY_SPHERE:
@@ -492,25 +418,27 @@ void drawaxes(float size, char drawtype)
case OB_ARROWS:
default:
{
+ gpuImmediateFormat_V3(); // DOODLE: draw axes
+
for (axis = 0; axis < 3; axis++) {
const int arrow_axis = (axis == 0) ? 1 : 0;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
v2[axis] = size;
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
v1[axis] = size * 0.85f;
v1[arrow_axis] = -size * 0.08f;
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
v1[arrow_axis] = size * 0.08f;
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
- glEnd();
+ gpuEnd();
v2[axis] += size * 0.125f;
@@ -520,9 +448,13 @@ void drawaxes(float size, char drawtype)
/* reset v1 & v2 to zero */
v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f;
}
+
+ gpuImmediateUnformat();
+
break;
}
}
+
}
@@ -573,121 +505,109 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
ofs_x = ob->ima_ofs[0] * ima_x;
ofs_y = ob->ima_ofs[1] * ima_y;
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPushMatrix();
/* Make sure we are drawing at the origin */
- glTranslatef(0.0f, 0.0f, 0.0f);
+ gpuTranslate(0.0f, 0.0f, 0.0f);
/* Calculate Image scale */
scale = (ob->empty_drawsize / max_ff((float)ima_x * sca_x, (float)ima_y * sca_y));
/* Set the object scale */
- glScalef(scale * sca_x, scale * sca_y, 1.0f);
+ gpuScale(scale * sca_x, scale * sca_y, 1.0f);
if (ibuf && ibuf->rect) {
/* Setup GL params */
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* Use the object color and alpha */
- glColor4fv(ob->col);
+ gpuCurrentColor4fv(ob->col);
/* Draw the Image on the screen */
glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_UNSIGNED_BYTE, ibuf->rect);
- glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
glDisable(GL_BLEND);
}
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
/* Calculate the outline vertex positions */
- glBegin(GL_LINE_LOOP);
- glVertex2f(ofs_x, ofs_y);
- glVertex2f(ofs_x + ima_x, ofs_y);
- glVertex2f(ofs_x + ima_x, ofs_y + ima_y);
- glVertex2f(ofs_x, ofs_y + ima_y);
- glEnd();
+ gpuImmediateFormat_V2();
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex2f(ofs_x, ofs_y);
+ gpuVertex2f(ofs_x + ima_x, ofs_y);
+ gpuVertex2f(ofs_x + ima_x, ofs_y + ima_y);
+ gpuVertex2f(ofs_x, ofs_y + ima_y);
+ gpuEnd();
+ gpuImmediateUnformat();
}
/* Reset GL settings */
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPopMatrix();
BKE_image_release_ibuf(ima, ibuf, NULL);
}
-static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, float tmat[][4])
-{
- float vx[3], vy[3];
- float *viter = (float *)verts;
- unsigned int a;
-
- mul_v3_v3fl(vx, tmat[0], rad);
- mul_v3_v3fl(vy, tmat[1], rad);
-
- for (a = 0; a < CIRCLE_RESOL; a++, viter += 3) {
- viter[0] = cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0];
- viter[1] = cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1];
- viter[2] = cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2];
- }
-}
-
-void drawcircball(int mode, const float cent[3], float rad, float tmat[][4])
-{
- float verts[CIRCLE_RESOL][3];
-
- circball_array_fill(verts, cent, rad, tmat);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, verts);
- glDrawArrays(mode, 0, CIRCLE_RESOL);
- glDisableClientState(GL_VERTEX_ARRAY);
-}
-
/* circle for object centers, special_color is for library or ob users */
static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], int selstate, int special_color)
{
const float size = ED_view3d_pixel_size(rv3d, co) * (float)U.obcenter_dia * 0.5f;
- float verts[CIRCLE_RESOL][3];
/* using gldepthfunc guarantees that it does write z values,
* but not checks for it, so centers remain visible independent order of drawing */
- if (v3d->zbuf) glDepthFunc(GL_ALWAYS);
+ if (v3d->zbuf) {
+ glDepthFunc(GL_ALWAYS);
+ }
+
glEnable(GL_BLEND);
-
- if (special_color) {
- if (selstate == ACTIVE || selstate == SELECT) glColor4ub(0x88, 0xFF, 0xFF, 155);
- else glColor4ub(0x55, 0xCC, 0xCC, 155);
+ if (special_color) {
+ if (selstate == ACTIVE || selstate == SELECT) {
+ gpuCurrentColor4x(0x88FFFF, 0.608f);
+ }
+ else {
+ gpuCurrentColor4x(0x55CCCC, 0.608f);
+ }
}
else {
- if (selstate == ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -80);
- else if (selstate == SELECT) UI_ThemeColorShadeAlpha(TH_SELECT, 0, -80);
- else if (selstate == DESELECT) UI_ThemeColorShadeAlpha(TH_TRANSFORM, 0, -80);
- }
+ int colorid;
+
+ switch (selstate) {
+ case ACTIVE:
+ colorid = TH_ACTIVE;
+ break;
+
+ case SELECT:
+ colorid = TH_SELECT;
+ break;
+
+ case DESELECT:
+ colorid = TH_TRANSFORM;
+ break;
+ }
- circball_array_fill(verts, co, size, rv3d->viewinv);
+ UI_ThemeColorShadeAlpha(colorid, 0, -80);
+ }
- /* enable vertex array */
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, verts);
+ gpuImmediateFormat_V3();
/* 1. draw filled, blended polygon */
- glDrawArrays(GL_POLYGON, 0, CIRCLE_RESOL);
+ gpuDrawFastBall(GL_TRIANGLE_FAN, co, size, rv3d->viewinv);
/* 2. draw outline */
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -30);
- glDrawArrays(GL_LINE_LOOP, 0, CIRCLE_RESOL);
+ gpuDraw(GL_LINE_LOOP);
- /* finish up */
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuImmediateUnformat();
glDisable(GL_BLEND);
- if (v3d->zbuf) glDepthFunc(GL_LEQUAL);
+ if (v3d->zbuf) {
+ glDepthFunc(GL_LEQUAL);
+ }
}
/* *********** text drawing for object/particles/armature ************* */
@@ -732,6 +652,7 @@ void view3d_cached_text_draw_add(const float co[3],
vos->flag = flag;
vos->str_len = alloc_len - 1;
+
/* allocate past the end */
memcpy(++vos, str, alloc_len);
}
@@ -766,7 +687,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
#if 0
bglMats mats; /* ZBuffer depth vars */
- double ux, uy, uz;
+ float u[3];
float depth;
if (v3d->zbuf)
@@ -776,10 +697,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
ED_view3d_clipping_disable();
}
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPushMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPushMatrix();
ED_region_pixelspace(ar);
if (depth_write) {
@@ -794,7 +715,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
* better to see if we can use the zbuffer while in pixel space - campbell */
#if 0
if (v3d->zbuf && (vos->flag & V3D_CACHE_TEXT_ZBUF)) {
- gluProject(vos->vec[0], vos->vec[1], vos->vec[2], mats.modelview, mats.projection, (GLint *)mats.viewport, &ux, &uy, &uz);
+ gpuProject(vos->vec, mats.modelview, mats.projection, (GLint *)mats.viewport, u);
glReadPixels(ar->winrct.xmin + vos->mval[0] + vos->xoffs, ar->winrct.ymin + vos->mval[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
if (uz > depth)
@@ -805,7 +726,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
const char *str = (char *)(vos + 1);
if (col_pack_prev != vos->col.pack) {
- glColor3ubv(vos->col.ub);
+ gpuCurrentColor3ubv(vos->col.ub);
col_pack_prev = vos->col.pack;
}
@@ -827,10 +748,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
glDepthMask(1);
}
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPopMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPopMatrix();
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_enable();
@@ -845,86 +766,6 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
/* ******************** primitive drawing ******************* */
-static void drawcube(void)
-{
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]);
- glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]);
- glVertex3fv(cube[7]); glVertex3fv(cube[4]);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[1]); glVertex3fv(cube[5]);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[2]); glVertex3fv(cube[6]);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[3]); glVertex3fv(cube[7]);
- glEnd();
-}
-
-/* draws a cube on given the scaling of the cube, assuming that
- * all required matrices have been set (used for drawing empties)
- */
-static void drawcube_size(float size)
-{
- glBegin(GL_LINE_STRIP);
- glVertex3f(-size, -size, -size); glVertex3f(-size, -size, size);
- glVertex3f(-size, size, size); glVertex3f(-size, size, -size);
-
- glVertex3f(-size, -size, -size); glVertex3f(size, -size, -size);
- glVertex3f(size, -size, size); glVertex3f(size, size, size);
-
- glVertex3f(size, size, -size); glVertex3f(size, -size, -size);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3f(-size, -size, size); glVertex3f(size, -size, size);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3f(-size, size, size); glVertex3f(size, size, size);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3f(-size, size, -size); glVertex3f(size, size, -size);
- glEnd();
-}
-
-/* this is an unused (old) cube-drawing function based on a given size */
-#if 0
-static void drawcube_size(const float size[3])
-{
-
- glPushMatrix();
- glScalef(size[0], size[1], size[2]);
-
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]);
- glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]);
- glVertex3fv(cube[7]); glVertex3fv(cube[4]);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[1]); glVertex3fv(cube[5]);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[2]); glVertex3fv(cube[6]);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(cube[3]); glVertex3fv(cube[7]);
- glEnd();
-
- glPopMatrix();
-}
-#endif
static void drawshadbuflimits(Lamp *la, float mat[][4])
{
@@ -936,16 +777,16 @@ static void drawshadbuflimits(Lamp *la, float mat[][4])
madd_v3_v3v3fl(sta, mat[3], lavec, la->clipsta);
madd_v3_v3v3fl(end, mat[3], lavec, la->clipend);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(sta);
- glVertex3fv(end);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(sta);
+ gpuVertex3fv(end);
+ gpuEnd();
glPointSize(3.0);
- bglBegin(GL_POINTS);
- bglVertex3fv(sta);
- bglVertex3fv(end);
- bglEnd();
+ gpuBeginSprites();
+ gpuSprite3fv(sta);
+ gpuSprite3fv(end);
+ gpuEndSprites();
glPointSize(1.0);
}
@@ -1020,15 +861,15 @@ static void draw_spot_cone(Lamp *la, float x, float z)
{
z = fabs(z);
- glBegin(GL_TRIANGLE_FAN);
- glVertex3f(0.0f, 0.0f, -x);
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuVertex3f(0.0f, 0.0f, -x);
if (la->mode & LA_SQUARE) {
- glVertex3f(z, z, 0);
- glVertex3f(-z, z, 0);
- glVertex3f(-z, -z, 0);
- glVertex3f(z, -z, 0);
- glVertex3f(z, z, 0);
+ gpuVertex3f(z, z, 0);
+ gpuVertex3f(-z, z, 0);
+ gpuVertex3f(-z, -z, 0);
+ gpuVertex3f(z, -z, 0);
+ gpuVertex3f(z, z, 0);
}
else {
float angle;
@@ -1036,11 +877,11 @@ static void draw_spot_cone(Lamp *la, float x, float z)
for (a = 0; a < 33; a++) {
angle = a * M_PI * 2 / (33 - 1);
- glVertex3f(z * cosf(angle), z * sinf(angle), 0);
+ gpuVertex3f(z * cosf(angle), z * sinf(angle), 0);
}
}
- glEnd();
+ gpuEnd();
}
static void draw_transp_spot_volume(Lamp *la, float x, float z)
@@ -1052,21 +893,21 @@ static void draw_transp_spot_volume(Lamp *la, float x, float z)
/* draw backside darkening */
glCullFace(GL_FRONT);
- glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
- glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+ glBlendFunc(GL_ZERO, GL_SRC_ALPHA); /* non-standard blend function */
+ gpuCurrentColor4x(CPACK_BLACK, 0.400f);
draw_spot_cone(la, x, z);
/* draw front side lighting */
glCullFace(GL_BACK);
- glBlendFunc(GL_ONE, GL_ONE);
- glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
+ glBlendFunc(GL_ONE, GL_ONE); /* non-standard blend function */
+ gpuCurrentGray3f(0.200f);
draw_spot_cone(la, x, z);
/* restore state */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
glDisable(GL_BLEND);
glDepthMask(1);
glDisable(GL_CULL_FACE);
@@ -1102,8 +943,8 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
}
/* we first draw only the screen aligned & fixed scale stuff */
- glPushMatrix();
- glLoadMatrixf(rv3d->viewmat);
+ gpuPushMatrix();
+ gpuLoadMatrix(rv3d->viewmat);
/* lets calculate the scale: */
lampsize = pixsize * ((float)U.obcenter_dia * 0.5f);
@@ -1122,40 +963,43 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
curcol[1] = ob_wire_col[1];
curcol[2] = ob_wire_col[2];
curcol[3] = 154;
- glColor4ubv(curcol);
+ gpuCurrentColor4ubv(curcol);
}
- if (lampsize > 0.0f) {
+ gpuImmediateFormat_V3();
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if (ob->id.us > 1) {
- if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155);
- else glColor4ub(0x77, 0xCC, 0xCC, 155);
+ if (lampsize > 0.0f) {
+ if (!(dflag & DRAW_CONSTCOLOR) && ob->id.us > 1) {
+ if (ob == OBACT || (ob->flag & SELECT)) {
+ gpuCurrentColor4x(0x88FFFF, 0.608f);
+ }
+ else {
+ gpuCurrentColor4x(0x77CCCC, 0.608f);
}
}
-
+
/* Inner Circle */
glEnable(GL_BLEND);
- drawcircball(GL_LINE_LOOP, vec, lampsize, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, lampsize, imat);
glDisable(GL_BLEND);
- drawcircball(GL_POLYGON, vec, lampsize, imat);
-
+ gpuDrawFastBall(GL_TRIANGLE_FAN, vec, lampsize, imat);
+
/* restore */
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (ob->id.us > 1)
- glColor4ubv(curcol);
+ gpuCurrentColor4ubv(curcol);
}
/* Outer circle */
circrad = 3.0f * lampsize;
setlinestyle(3);
- drawcircball(GL_LINE_LOOP, vec, circrad, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, circrad, imat);
/* draw dashed outer circle if shadow is on. remember some lamps can't have certain shadows! */
if (la->type != LA_HEMI) {
if ((la->mode & LA_SHAD_RAY) || ((la->mode & LA_SHAD_BUF) && (la->type == LA_SPOT))) {
- drawcircball(GL_LINE_LOOP, vec, circrad + 3.0f * pixsize, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, circrad + 3.0f * pixsize, imat);
}
}
}
@@ -1163,46 +1007,46 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
setlinestyle(3);
circrad = 0.0f;
}
-
+
/* draw the pretty sun rays */
if (la->type == LA_SUN) {
float v1[3], v2[3], mat[3][3];
short axis;
-
+
/* setup a 45 degree rotation matrix */
vec_rot_to_mat3(mat, imat[2], (float)M_PI / 4.0f);
-
+
/* vectors */
mul_v3_v3fl(v1, imat[0], circrad * 1.2f);
mul_v3_v3fl(v2, imat[0], circrad * 2.5f);
-
+
/* center */
- glTranslatef(vec[0], vec[1], vec[2]);
-
+ gpuTranslate(vec[0], vec[1], vec[2]);
+
setlinestyle(3);
-
- glBegin(GL_LINES);
+
+ gpuBegin(GL_LINES);
for (axis = 0; axis < 8; axis++) {
- glVertex3fv(v1);
- glVertex3fv(v2);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
mul_m3_v3(mat, v1);
mul_m3_v3(mat, v2);
}
- glEnd();
-
- glTranslatef(-vec[0], -vec[1], -vec[2]);
+ gpuEnd();
+
+ gpuTranslate(-vec[0], -vec[1], -vec[2]);
}
-
+
if (la->type == LA_LOCAL) {
if (la->mode & LA_SPHERE) {
- drawcircball(GL_LINE_LOOP, vec, la->dist, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, la->dist, imat);
}
}
-
- glPopMatrix(); /* back in object space */
+
+ gpuPopMatrix(); /* back in object space */
zero_v3(vec);
-
+
if (is_view) {
/* skip drawing extra info */
}
@@ -1223,17 +1067,17 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
mul_v3_fl(vvec, x);
/* draw the angled sides of the cone */
- glBegin(GL_LINE_STRIP);
- glVertex3fv(vvec);
- glVertex3fv(vec);
- glVertex3fv(lvec);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(vvec);
+ gpuVertex3fv(vec);
+ gpuVertex3fv(lvec);
+ gpuEnd();
z = x * sqrtf(1.0f - y * y);
x *= y;
/* draw the circle/square at the end of the cone */
- glTranslatef(0.0, 0.0, x);
+ gpuTranslate(0.0, 0.0, x);
if (la->mode & LA_SQUARE) {
float tvec[3];
float z_abs = fabs(z);
@@ -1241,18 +1085,18 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
tvec[0] = tvec[1] = z_abs;
tvec[2] = 0.0;
- glBegin(GL_LINE_LOOP);
- glVertex3fv(tvec);
+ gpuBegin(GL_LINE_LOOP);
+ gpuVertex3fv(tvec);
tvec[1] = -z_abs; /* neg */
- glVertex3fv(tvec);
+ gpuVertex3fv(tvec);
tvec[0] = -z_abs; /* neg */
- glVertex3fv(tvec);
+ gpuVertex3fv(tvec);
tvec[1] = z_abs; /* pos */
- glVertex3fv(tvec);
- glEnd();
+ gpuVertex3fv(tvec);
+ gpuEnd();
}
else {
- circ(0.0, 0.0, fabsf(z));
+ gpuDrawFastCircleXY(fabsf(z));
}
/* draw the circle/square representing spotbl */
@@ -1262,14 +1106,14 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
* previously it adjusted to always to show it but that seems
* confusing because it doesn't show the actual blend size */
if (spotblcirc != 0 && spotblcirc != fabsf(z))
- circ(0.0, 0.0, spotblcirc);
+ gpuDrawFastCircleXY(spotblcirc);
}
if (drawcone)
draw_transp_spot_volume(la, x, z);
/* draw clip start, useful for wide cones where its not obvious where the start is */
- glTranslatef(0.0, 0.0, -x); /* reverse translation above */
+ gpuTranslate(0.0, 0.0, -x); /* reverse translation above */
if (la->type == LA_SPOT && (la->mode & LA_SHAD_BUF) ) {
float lvec_clip[3];
float vvec_clip[3];
@@ -1278,22 +1122,22 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
interp_v3_v3v3(lvec_clip, vec, lvec, clipsta_fac);
interp_v3_v3v3(vvec_clip, vec, vvec, clipsta_fac);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(lvec_clip);
- glVertex3fv(vvec_clip);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(lvec_clip);
+ gpuVertex3fv(vvec_clip);
+ gpuEnd();
}
}
else if (ELEM(la->type, LA_HEMI, LA_SUN)) {
-
+
/* draw the line from the circle along the dist */
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
vec[2] = -circrad;
- glVertex3fv(vec);
+ gpuVertex3fv(vec);
vec[2] = -la->dist;
- glVertex3fv(vec);
- glEnd();
-
+ gpuVertex3fv(vec);
+ gpuEnd();
+
if (la->type == LA_HEMI) {
/* draw the hemisphere curves */
short axis, steps, dir;
@@ -1307,7 +1151,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
float v[3] = {0.0, 0.0, 0.0};
zdist = 0.02;
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (steps = 0; steps < 6; steps++) {
if (axis == 0 || axis == 1) { /* x axis up, x axis down */
@@ -1322,12 +1166,12 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
v[2] = v[2] - steps * zdist;
- glVertex3fv(v);
+ gpuVertex3fv(v);
zdist = zdist * mul;
}
- glEnd();
+ gpuEnd();
/* flip the direction */
dir = -dir;
}
@@ -1336,67 +1180,75 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
else if (la->type == LA_AREA) {
setlinestyle(3);
if (la->area_shape == LA_AREA_SQUARE)
- fdrawbox(-la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f);
+ gpuDrawWireRectf(-la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f);
else if (la->area_shape == LA_AREA_RECT)
- fdrawbox(-la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f);
+ gpuDrawWireRectf(-la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f);
- glBegin(GL_LINE_STRIP);
- glVertex3f(0.0, 0.0, -circrad);
- glVertex3f(0.0, 0.0, -la->dist);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3f(0.0, 0.0, -circrad);
+ gpuVertex3f(0.0, 0.0, -la->dist);
+ gpuEnd();
}
-
+
/* and back to viewspace */
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
copy_v3_v3(vec, ob->obmat[3]);
setlinestyle(0);
-
+
if ((la->type == LA_SPOT) && (la->mode & LA_SHAD_BUF) && (is_view == FALSE)) {
drawshadbuflimits(la, ob->obmat);
}
-
+
UI_GetThemeColor4ubv(TH_LAMP, col);
- glColor4ubv(col);
+ gpuCurrentColor4ubv(col);
glEnable(GL_BLEND);
-
- if (vec[2] > 0) vec[2] -= circrad;
- else vec[2] += circrad;
-
- glBegin(GL_LINE_STRIP);
- glVertex3fv(vec);
+
+ if (vec[2] > 0) {
+ vec[2] -= circrad;
+ }
+ else {
+ vec[2] += circrad;
+ }
+
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(vec);
vec[2] = 0;
- glVertex3fv(vec);
- glEnd();
-
+ gpuVertex3fv(vec);
+ gpuEnd();
+
glPointSize(2.0);
- glBegin(GL_POINTS);
- glVertex3fv(vec);
- glEnd();
+
+ gpuBegin(GL_POINTS);
+ gpuVertex3fv(vec);
+ gpuEnd();
+
glPointSize(1.0);
-
+
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
-
+
if ((dflag & DRAW_CONSTCOLOR) == 0) {
/* restore for drawing extra stuff */
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
}
static void draw_limit_line(float sta, float end, unsigned int col)
{
- glBegin(GL_LINES);
- glVertex3f(0.0, 0.0, -sta);
- glVertex3f(0.0, 0.0, -end);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0, 0.0, -sta);
+ gpuVertex3f(0.0, 0.0, -end);
+ gpuEnd();
glPointSize(3.0);
- glBegin(GL_POINTS);
- cpack(col);
- glVertex3f(0.0, 0.0, -sta);
- glVertex3f(0.0, 0.0, -end);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuColor3x(col);
+ gpuVertex3f(0.0, 0.0, -sta);
+ gpuVertex3f(0.0, 0.0, -end);
+ gpuEnd();
glPointSize(1.0);
}
@@ -1405,12 +1257,12 @@ static void draw_limit_line(float sta, float end, unsigned int col)
/* qdn: now also enabled for Blender to set focus point for defocus composite node */
static void draw_focus_cross(float dist, float size)
{
- glBegin(GL_LINES);
- glVertex3f(-size, 0.f, -dist);
- glVertex3f(size, 0.f, -dist);
- glVertex3f(0.f, -size, -dist);
- glVertex3f(0.f, size, -dist);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3f(-size, 0.f, -dist);
+ gpuVertex3f(size, 0.f, -dist);
+ gpuVertex3f(0.f, -size, -dist);
+ gpuVertex3f(0.f, size, -dist);
+ gpuEnd();
}
#ifdef VIEW3D_CAMERA_BORDER_HACK
@@ -1422,25 +1274,23 @@ short view3d_camera_border_hack_test = FALSE;
static void draw_bundle_sphere(void)
{
- static GLuint displist = 0;
+ static GPUimmediate *displist = NULL;
- if (displist == 0) {
- GLUquadricObj *qobj;
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
+ glShadeModel(GL_SMOOTH);
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_FILL);
- glShadeModel(GL_SMOOTH);
- gluSphere(qobj, 0.05, 8, 8);
- glShadeModel(GL_FLAT);
- gluDeleteQuadric(qobj);
+ if (!displist) {
+ GPUprim3 prim = GPU_PRIM_LOFI_SOLID;
- glEndList();
+ gpuPushImmediate();
+ //GLU Sphere(qobj, 0.05, 8, 8);
+ gpuSingleSphere(&prim, 0.05f);
+ displist = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleRepeat(displist);
}
- glCallList(displist);
+ glShadeModel(GL_FLAT);
}
static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D *v3d,
@@ -1460,7 +1310,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
BKE_tracking_get_camera_object_matrix(scene, base->object, mat);
- glPushMatrix();
+ gpuPushMatrix();
if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
/* current ogl matrix is translated in camera space, bundles should
@@ -1468,8 +1318,8 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
* from current ogl matrix */
invert_m4_m4(imat, base->object->obmat);
- glMultMatrixf(imat);
- glMultMatrixf(mat);
+ gpuMultMatrix(imat);
+ gpuMultMatrix(mat);
}
else {
float obmat[4][4];
@@ -1477,7 +1327,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, scene->r.cfra, obmat);
invert_m4_m4(imat, obmat);
- glMultMatrixf(imat);
+ gpuMultMatrix(imat);
}
for (track = tracksbase->first; track; track = track->next) {
@@ -1492,72 +1342,72 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
if (dflag & DRAW_PICKING)
glLoadName(base->selcol + (tracknr << 16));
- glPushMatrix();
- glTranslatef(track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
- glScalef(v3d->bundle_size / 0.05f, v3d->bundle_size / 0.05f, v3d->bundle_size / 0.05f);
+ gpuPushMatrix();
+ gpuTranslate(track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
+ gpuScale(v3d->bundle_size / 0.05f, v3d->bundle_size / 0.05f, v3d->bundle_size / 0.05f);
if (v3d->drawtype == OB_WIRE) {
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (selected && (track->flag & TRACK_CUSTOMCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
else {
- glColor3fv(track->color);
+ gpuCurrentColor3fv(track->color);
}
}
drawaxes(0.05f, v3d->bundle_drawtype);
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
}
else if (v3d->drawtype > OB_WIRE) {
if (v3d->bundle_drawtype == OB_EMPTY_SPHERE) {
/* selection outline */
if (selected) {
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
glLineWidth(2.f);
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
draw_bundle_sphere();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
glLineWidth(1.f);
}
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color);
+ if (track->flag & TRACK_CUSTOMCOLOR) gpuCurrentColor3fv(track->color);
else UI_ThemeColor(TH_BUNDLE_SOLID);
}
draw_bundle_sphere();
}
else {
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (selected) {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
else {
- if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color);
+ if (track->flag & TRACK_CUSTOMCOLOR) gpuCurrentColor3fv(track->color);
else UI_ThemeColor(TH_WIRE);
}
}
drawaxes(0.05f, v3d->bundle_drawtype);
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
}
}
- glPopMatrix();
+ gpuPopMatrix();
if ((dflag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) {
float pos[3];
@@ -1578,23 +1428,23 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
MovieReconstructedCamera *camera = reconstruction->cameras;
int a = 0;
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
UI_ThemeColor(TH_CAMERA_PATH);
glLineWidth(2.0f);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (a = 0; a < reconstruction->camnr; a++, camera++) {
- glVertex3fv(camera->mat[3]);
+ gpuVertex3fv(camera->mat[3]);
}
- glEnd();
+ gpuEnd();
glLineWidth(1.0f);
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
}
}
}
- glPopMatrix();
+ gpuPopMatrix();
*global_track_index = tracknr;
}
@@ -1613,9 +1463,9 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
if (v3d->flag2 & V3D_RENDER_OVERRIDE)
return;
- glEnable(GL_LIGHTING);
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
+ gpuEnableLighting();
+ gpuColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gpuEnableColorMaterial();
glShadeModel(GL_SMOOTH);
tracking_object = tracking->objects.first;
@@ -1628,11 +1478,11 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
/* restore */
glShadeModel(GL_FLAT);
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
+ gpuDisableColorMaterial();
+ gpuDisableLighting();
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
+ if (!(dflag & DRAW_CONSTCOLOR)) {
+ gpuCurrentColor3ubv(ob_wire_col);
}
if (dflag & DRAW_PICKING)
@@ -1661,14 +1511,14 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
#ifdef VIEW3D_CAMERA_BORDER_HACK
if (is_view && !(G.f & G_PICKSEL)) {
- if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ if (!(dflag & DRAW_CONSTCOLOR)) {
view3d_camera_border_hack_col[0] = ob_wire_col[0];
view3d_camera_border_hack_col[1] = ob_wire_col[1];
view3d_camera_border_hack_col[2] = ob_wire_col[2];
}
else {
float col[4];
- glGetFloatv(GL_CURRENT_COLOR, col);
+ gpuGetCurrentColor4fv(col);
rgb_float_to_uchar(view3d_camera_border_hack_col, col);
}
view3d_camera_border_hack_test = TRUE;
@@ -1685,32 +1535,36 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale,
asp, shift, &drawsize, vec);
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
glDisable(GL_CULL_FACE);
+ gpuImmediateFormat_V3(); // DOODLE: camera
+
/* camera frame */
- glBegin(GL_LINE_LOOP);
- glVertex3fv(vec[0]);
- glVertex3fv(vec[1]);
- glVertex3fv(vec[2]);
- glVertex3fv(vec[3]);
- glEnd();
-
- if (is_view)
+ gpuBegin(GL_LINE_STRIP);
+
+ gpuVertex3fv(vec[1]);
+ gpuVertex3fv(vec[2]);
+ gpuVertex3fv(vec[3]);
+ gpuVertex3fv(vec[0]);
+ gpuVertex3fv(vec[1]);
+
+ if (is_view) {
+ gpuEnd();
+ gpuImmediateUnformat();
return;
+ }
zero_v3(tvec);
/* center point to camera frame */
- glBegin(GL_LINE_STRIP);
- glVertex3fv(vec[1]);
- glVertex3fv(tvec);
- glVertex3fv(vec[0]);
- glVertex3fv(vec[3]);
- glVertex3fv(tvec);
- glVertex3fv(vec[2]);
- glEnd();
+ gpuVertex3fv(tvec);
+ gpuVertex3fv(vec[0]);
+ gpuVertex3fv(vec[3]);
+ gpuVertex3fv(tvec);
+ gpuVertex3fv(vec[2]);
+ gpuEnd();
/* arrow on top */
tvec[2] = vec[1][2]; /* copy the depth */
@@ -1720,22 +1574,28 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
* for active cameras. We actually draw both outline+filled
* for active cameras so the wire can be seen side-on */
for (i = 0; i < 2; i++) {
- if (i == 0) glBegin(GL_LINE_LOOP);
- else if (i == 1 && (ob == v3d->camera)) glBegin(GL_TRIANGLES);
- else break;
+ if (i == 0) {
+ gpuBegin(GL_LINE_LOOP);
+ }
+ else if (i == 1 && (ob == v3d->camera)) {
+ gpuBegin(GL_TRIANGLES);
+ }
+ else {
+ break;
+ }
tvec[0] = shift[0] + ((-0.7f * drawsize) * scale[0]);
tvec[1] = shift[1] + ((drawsize * (asp[1] + 0.1f)) * scale[1]);
- glVertex3fv(tvec); /* left */
+ gpuVertex3fv(tvec); /* left */
tvec[0] = shift[0] + ((0.7f * drawsize) * scale[0]);
- glVertex3fv(tvec); /* right */
+ gpuVertex3fv(tvec); /* right */
tvec[0] = shift[0];
tvec[1] = shift[1] + ((1.1f * drawsize * (asp[1] + 0.7f)) * scale[1]);
- glVertex3fv(tvec); /* top */
+ gpuVertex3fv(tvec); /* top */
- glEnd();
+ gpuEnd();
}
if (dflag == 0) {
@@ -1747,23 +1607,25 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
copy_m4_m4(nobmat, ob->obmat);
normalize_m4(nobmat);
- glPushMatrix();
- glLoadMatrixf(rv3d->viewmat);
- glMultMatrixf(nobmat);
+ gpuPushMatrix();
+ gpuLoadMatrix(rv3d->viewmat);
+ gpuMultMatrix(nobmat);
if (cam->flag & CAM_SHOWLIMITS) {
- draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF);
+ draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF); /* CPACK */
/* qdn: was yafray only, now also enabled for Blender to be used with defocus composite node */
draw_focus_cross(BKE_camera_object_dof_distance(ob), cam->drawsize);
}
wrld = scene->world;
if (cam->flag & CAM_SHOWMIST)
- if (wrld) draw_limit_line(wrld->miststa, wrld->miststa + wrld->mistdist, 0xFFFFFF);
+ if (wrld) draw_limit_line(wrld->miststa, wrld->miststa + wrld->mistdist, CPACK_WHITE);
- glPopMatrix();
+ gpuPopMatrix();
}
}
+
+ gpuImmediateUnformat();
}
/* flag similar to draw_object() */
@@ -1777,22 +1639,24 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D
glEnable(GL_BLEND);
+ gpuImmediateFormat_V3();
+
for (j = 0; j < 3; j++) {
vec[2] = 0.25f * j - 0.125f;
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
for (i = 0; i < 16; i++) {
vec[0] = cosf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
vec[1] = sinf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
- glVertex3fv(vec);
+ gpuVertex3fv(vec);
}
- glEnd();
+ gpuEnd();
}
for (j = 0; j < 4; j++) {
vec[0] = (((j + 1) % 2) * (j - 1)) * 0.5f;
vec[1] = ((j % 2) * (j - 2)) * 0.5f;
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
for (i = 0; i < 3; i++) {
if (i == 1) {
vec[0] *= 0.5f;
@@ -1800,11 +1664,13 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D
}
vec[2] = 0.25f * i - 0.125f;
- glVertex3fv(vec);
+ gpuVertex3fv(vec);
}
- glEnd();
+ gpuEnd();
}
+ gpuImmediateUnformat();
+
glDisable(GL_BLEND);
}
@@ -1816,7 +1682,7 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel)
UI_ThemeColor(sel ? TH_VERTEX_SELECT : TH_VERTEX);
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
for (w = 0; w < lt->pntsw; w++) {
int wxt = (w == 0 || w == lt->pntsw - 1);
@@ -1827,7 +1693,7 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel)
if (!(lt->flag & LT_OUTSIDE) || uxt || vxt || wxt) {
if (bp->hide == 0) {
if ((bp->f1 & SELECT) == sel) {
- bglVertex3fv(dl ? co : bp->vec);
+ gpuSprite3fv(dl ? co : bp->vec);
}
}
}
@@ -1836,7 +1702,7 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel)
}
glPointSize(1.0);
- bglEnd();
+ gpuEndSprites();
}
static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, int use_wcol)
@@ -1848,15 +1714,15 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i
MDeformWeight *mdw = defvert_find_index(lt->dvert + index, use_wcol - 1);
weight_to_rgb(col, mdw ? mdw->weight : 0.0f);
- glColor3fv(col);
+ gpuColor3fv(col);
}
if (dl) {
- glVertex3fv(&dl->verts[index * 3]);
+ gpuVertex3fv(&dl->verts[index * 3]);
}
else {
- glVertex3fv(lt->def[index].vec);
+ gpuVertex3fv(lt->def[index].vec);
}
}
@@ -1876,7 +1742,7 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
if (is_edit) {
lt = lt->editlatt->latt;
- cpack(0x004000);
+ gpuCurrentColor3x(0x004000);
if (ob->defbase.first && lt->dvert) {
use_wcol = ob->actdef;
@@ -1884,7 +1750,14 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
}
}
- glBegin(GL_LINES);
+ if (use_wcol) {
+ gpuImmediateFormat_V3();
+ }
+ else {
+ gpuImmediateFormat_C4_V3();
+ }
+
+ gpuBegin(GL_LINES);
for (w = 0; w < lt->pntsw; w++) {
int wxt = (w == 0 || w == lt->pntsw - 1);
for (v = 0; v < lt->pntsv; v++) {
@@ -1907,20 +1780,29 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
}
}
}
- glEnd();
-
+ gpuEnd();
+
+ if (use_wcol) {
+ gpuImmediateUnformat();
+ gpuImmediateFormat_V3();
+ }
+
/* restoration for weight colors */
if (use_wcol)
glShadeModel(GL_FLAT);
if (is_edit) {
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
+ if (v3d->zbuf) {
+ glDisable(GL_DEPTH_TEST);
+ }
+
lattice_draw_verts(lt, dl, 0);
lattice_draw_verts(lt, dl, 1);
-
+
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
+
+ gpuImmediateUnformat();
}
/* ***************** ******************** */
@@ -1936,21 +1818,21 @@ static void drawSelectedVertices__mapFunc(void *userData, int index, const float
/* TODO define selected color */
if (sel) {
- glColor3f(1.0f, 1.0f, 0.0f);
+ gpuColor3x(CPACK_YELLOW);
}
else {
- glColor3f(0.0f, 0.0f, 0.0f);
+ gpuColor3x(CPACK_BLACK);
}
- glVertex3fv(co);
+ gpuVertex3fv(co);
}
}
static void drawSelectedVertices(DerivedMesh *dm, Mesh *me)
{
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
dm->foreachMappedVert(dm, drawSelectedVertices__mapFunc, me->mvert);
- glEnd();
+ gpuEnd();
}
/* ************** DRAW MESH ****************** */
@@ -1989,6 +1871,8 @@ static void draw_dm_face_normals__mapFunc(void *userData, int index, const float
float n[3];
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
+ float p[3];
+
if (!data->uniform_scale) {
mul_v3_m3v3(n, data->tmat, (float *) no);
normalize_v3(n);
@@ -1998,10 +1882,11 @@ static void draw_dm_face_normals__mapFunc(void *userData, int index, const float
copy_v3_v3(n, no);
}
- glVertex3fv(cent);
- glVertex3f(cent[0] + n[0] * data->normalsize,
- cent[1] + n[1] * data->normalsize,
- cent[2] + n[2] * data->normalsize);
+ mul_v3_v3fl(p, n, data->normalsize);
+ add_v3_v3(p, cent);
+
+ gpuVertex3fv(cent);
+ gpuVertex3fv(p);
}
}
@@ -2014,9 +1899,11 @@ static void draw_dm_face_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv
calcDrawDMNormalScale(ob, &data);
- glBegin(GL_LINES);
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINES);
dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, &data);
- glEnd();
+ gpuEnd();
+ gpuImmediateUnformat();
}
static void draw_dm_face_centers__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
@@ -2025,16 +1912,18 @@ static void draw_dm_face_centers__mapFunc(void *userData, int index, const float
int sel = *(((int **)userData)[1]);
if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT) == sel) {
- bglVertex3fv(cent);
+ gpuSprite3fv(cent);
}
}
static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, int sel)
{
void *ptrs[2] = {em, &sel};
- bglBegin(GL_POINTS);
+ gpuImmediateFormat_V3();
+ gpuBeginSprites();
dm->foreachMappedFaceCenter(dm, draw_dm_face_centers__mapFunc, ptrs);
- bglEnd();
+ gpuEndSprites();
+ gpuImmediateUnformat();
}
static void draw_dm_vert_normals__mapFunc(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3])
@@ -2043,15 +1932,15 @@ static void draw_dm_vert_normals__mapFunc(void *userData, int index, const float
BMVert *eve = EDBM_vert_at_index(data->em, index);
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- float no[3], n[3];
+ float no[3], n[3], p[3];
if (no_f) {
copy_v3_v3(no, no_f);
}
else {
- no[0] = no_s[0] / 32767.0f;
- no[1] = no_s[1] / 32767.0f;
- no[2] = no_s[2] / 32767.0f;
+ no[0] = no_s[0] / (float)SHRT_MAX;
+ no[1] = no_s[1] / (float)SHRT_MAX;
+ no[2] = no_s[2] / (float)SHRT_MAX;
}
if (!data->uniform_scale) {
@@ -2063,10 +1952,11 @@ static void draw_dm_vert_normals__mapFunc(void *userData, int index, const float
copy_v3_v3(n, no);
}
- glVertex3fv(co);
- glVertex3f(co[0] + n[0] * data->normalsize,
- co[1] + n[1] * data->normalsize,
- co[2] + n[2] * data->normalsize);
+ mul_v3_v3fl(p, n, data->normalsize);
+ add_v3_v3(p, co);
+
+ gpuVertex3fv(co);
+ gpuVertex3fv(p);
}
}
@@ -2079,9 +1969,11 @@ static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv
calcDrawDMNormalScale(ob, &data);
- glBegin(GL_LINES);
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINES);
dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, &data);
- glEnd();
+ gpuEnd();
+ gpuImmediateUnformat();
}
/* Draw verts with color set based on selection */
@@ -2092,41 +1984,43 @@ static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3],
BMVert *eve = EDBM_vert_at_index(data->em, index);
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT) == data->sel) {
- /* skin nodes: draw a red circle around the root
- * node(s) */
+ /* skin nodes: draw a red circle around the root node(s) */
if (data->has_vskin) {
- const MVertSkin *vs = CustomData_bmesh_get(&data->em->bm->vdata,
- eve->head.data,
- CD_MVERT_SKIN);
+ const MVertSkin *vs =
+ CustomData_bmesh_get(
+ &data->em->bm->vdata,
+ eve->head.data,
+ CD_MVERT_SKIN);
+
if (vs->flag & MVERT_SKIN_ROOT) {
float radius = (vs->radius[0] + vs->radius[1]) * 0.5f;
- bglEnd();
-
- glColor4ubv(data->th_skin_root);
- drawcircball(GL_LINES, co, radius, data->imat);
+ gpuEndSprites();
+
+ gpuCurrentColor4ubv(data->th_skin_root);
+ gpuDrawFastBall(GL_LINES, co, radius, data->imat);
- glColor4ubv(data->sel ? data->th_vertex_select : data->th_vertex);
- bglBegin(GL_POINTS);
+ gpuCurrentColor4ubv(data->sel ? data->th_vertex_select : data->th_vertex);
+ gpuBeginSprites();
}
}
/* draw active larger - need to stop/start point drawing for this :/ */
if (eve == data->eve_act) {
- glColor4ubv(data->th_editmesh_active);
-
- bglEnd();
-
+ gpuColor4ubv(data->th_editmesh_active);
+
+ gpuEndSprites();
+
glPointSize(data->th_vertex_size);
- bglBegin(GL_POINTS);
- bglVertex3fv(co);
- bglEnd();
+ gpuBeginSprites();
+ gpuSprite3fv(co);
+ gpuEndSprites();
- glColor4ubv(data->sel ? data->th_vertex_select : data->th_vertex);
+ gpuCurrentColor4ubv(data->sel ? data->th_vertex_select : data->th_vertex);
glPointSize(data->th_vertex_size);
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
}
else {
- bglVertex3fv(co);
+ gpuSprite3fv(co);
}
}
}
@@ -2152,24 +2046,23 @@ static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, int sel, BMVert *eve_
mult_m4_m4m4(data.imat, rv3d->viewmat, em->ob->obmat);
invert_m4(data.imat);
- bglBegin(GL_POINTS);
+ gpuImmediateFormat_V3();
+ gpuBeginSprites();
dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data);
- bglEnd();
+ gpuEndSprites();
+ gpuImmediateUnformat();
}
/* Draw edges with color set based on selection */
-static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index)
+static DMDrawOption draw_dm_edges_sel__setDrawOptions(drawDMEdgesSel_userData *data, int index)
{
- BMEdge *eed;
- //unsigned char **cols = userData, *col;
- drawDMEdgesSel_userData *data = userData;
- unsigned char *col;
-
- eed = EDBM_edge_at_index(data->em, index);
+ BMEdge* eed = EDBM_edge_at_index(data->em, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
+ unsigned char *col;
+
if (eed == data->eed_act) {
- glColor4ubv(data->actCol);
+ gpuColor4ubv(data->actCol);
}
else {
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
@@ -2178,18 +2071,20 @@ static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index)
else {
col = data->baseCol;
}
+
/* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */
if (col[3] == 0)
return DM_DRAW_OPTION_SKIP;
- glColor4ubv(col);
+ gpuColor4ubv(col);
}
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
}
else {
return DM_DRAW_OPTION_SKIP;
}
}
+
static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
unsigned char *selCol, unsigned char *actCol, BMEdge *eed_act)
{
@@ -2200,7 +2095,10 @@ static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba
data.actCol = actCol;
data.em = em;
data.eed_act = eed_act;
+
+ gpuImmediateFormat_C4_V3();
dm->drawMappedEdges(dm, draw_dm_edges_sel__setDrawOptions, &data);
+ gpuImmediateUnformat();
}
/* Draw edges */
@@ -2209,12 +2107,14 @@ static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index)
if (BM_elem_flag_test(EDBM_edge_at_index(userData, index), BM_ELEM_HIDDEN))
return DM_DRAW_OPTION_SKIP;
else
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
}
static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm)
{
+ gpuImmediateFormat_C4_V3(); /* XXX: jwilkins, C4 only because CCG age visualization may be enabled */
dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em);
+ gpuImmediateUnformat();
}
/* Draw edges with color interpolated based on selection */
@@ -2223,8 +2123,9 @@ static DMDrawOption draw_dm_edges_sel_interp__setDrawOptions(void *userData, int
if (BM_elem_flag_test(EDBM_edge_at_index(((void **)userData)[0], index), BM_ELEM_HIDDEN))
return DM_DRAW_OPTION_SKIP;
else
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
}
+
static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t)
{
BMEdge *eed = EDBM_edge_at_index(((void **)userData)[0], index);
@@ -2232,17 +2133,20 @@ static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int i
unsigned char *col0 = cols[(BM_elem_flag_test(eed->v1, BM_ELEM_SELECT)) ? 2 : 1];
unsigned char *col1 = cols[(BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1];
- glColor4ub(col0[0] + (col1[0] - col0[0]) * t,
- col0[1] + (col1[1] - col0[1]) * t,
- col0[2] + (col1[2] - col0[2]) * t,
- col0[3] + (col1[3] - col0[3]) * t);
+ gpuColor4ub(
+ col0[0] + (col1[0] - col0[0]) * t,
+ col0[1] + (col1[1] - col0[1]) * t,
+ col0[2] + (col1[2] - col0[2]) * t,
+ col0[3] + (col1[3] - col0[3]) * t);
}
static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
{
void *cols[3] = {em, baseCol, selCol};
+ gpuImmediateFormat_C4_V3();
dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols);
+ gpuImmediateUnformat();
}
/* Draw only seam edges */
@@ -2251,14 +2155,16 @@ static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int inde
BMEdge *eed = EDBM_edge_at_index(userData, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SEAM))
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
else
return DM_DRAW_OPTION_SKIP;
}
static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm)
{
+ gpuImmediateFormat_C4_V3(); /* XXX: jwilkins, C4 only because CCG age visualization may be enabled */
dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, em);
+ gpuImmediateUnformat();
}
/* Draw only sharp edges */
@@ -2267,14 +2173,16 @@ static DMDrawOption draw_dm_edges_sharp__setDrawOptions(void *userData, int inde
BMEdge *eed = EDBM_edge_at_index(userData, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && !BM_elem_flag_test(eed, BM_ELEM_SMOOTH))
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
else
return DM_DRAW_OPTION_SKIP;
}
static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm)
{
+ gpuImmediateFormat_C4_V3(); /* XXX: jwilkins, C4 only because CCG age visualization may be enabled */
dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em);
+ gpuImmediateUnformat();
}
@@ -2291,15 +2199,15 @@ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index)
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
if (efa == data->efa_act) {
- glColor4ubv(data->cols[2]);
+ gpuColor4ubv(data->cols[2]);
return DM_DRAW_OPTION_STIPPLE;
}
else {
col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
if (col[3] == 0)
return DM_DRAW_OPTION_SKIP;
- glColor4ubv(col);
- return DM_DRAW_OPTION_NORMAL;
+ gpuColor4ubv(col);
+ return DM_DRAW_OPTION_NORMALLY;
}
}
return DM_DRAW_OPTION_SKIP;
@@ -2353,7 +2261,15 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba
data.orig_index_mf_to_mpoly = data.orig_index_mp_to_orig = NULL;
}
- dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions, &data, 0);
+ gpuImmediateFormat_C4_V3();
+ dm->drawMappedFaces(
+ dm,
+ draw_dm_faces_sel__setDrawOptions,
+ GPU_enable_material,
+ draw_dm_faces_sel__compareDrawOptions,
+ &data,
+ 0);
+ gpuImmediateUnformat();
}
static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index)
@@ -2366,8 +2282,8 @@ static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index)
return DM_DRAW_OPTION_SKIP;
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *crease != 0.0f) {
- UI_ThemeColorBlend(TH_WIRE, TH_EDGE_CREASE, *crease);
- return DM_DRAW_OPTION_NORMAL;
+ UI_ThemeAppendColorBlend(TH_WIRE, TH_EDGE_CREASE, *crease);
+ return DM_DRAW_OPTION_NORMALLY;
}
else {
return DM_DRAW_OPTION_SKIP;
@@ -2376,7 +2292,9 @@ static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index)
static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm)
{
glLineWidth(3.0);
+ gpuImmediateFormat_C4_V3();
dm->drawMappedEdges(dm, draw_dm_creases__setDrawOptions, em);
+ gpuImmediateUnformat();
glLineWidth(1.0);
}
@@ -2384,47 +2302,55 @@ static DMDrawOption draw_dm_bweights__setDrawOptions(void *userData, int index)
{
BMEditMesh *em = userData;
BMEdge *eed = EDBM_edge_at_index(userData, index);
- float *bweight = (float *)CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT);
- if (!bweight)
- return DM_DRAW_OPTION_SKIP;
-
- if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *bweight != 0.0f) {
- UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, *bweight);
- return DM_DRAW_OPTION_NORMAL;
+ float *bweight =
+ CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT);
+
+ if (bweight && *bweight != 0.0f &&
+ !BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
+ {
+ UI_ThemeAppendColorBlend(TH_WIRE, TH_EDGE_SELECT, *bweight);
+ return DM_DRAW_OPTION_NORMALLY;
}
else {
return DM_DRAW_OPTION_SKIP;
}
}
+
static void draw_dm_bweights__mapFunc(void *userData, int index, const float co[3],
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
{
BMEditMesh *em = userData;
BMVert *eve = EDBM_vert_at_index(userData, index);
- float *bweight = (float *)CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_BWEIGHT);
-
- if (!bweight)
- return;
-
- if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && *bweight != 0.0f) {
- UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, *bweight);
- bglVertex3fv(co);
+
+ float *bweight =
+ CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_BWEIGHT);
+
+ if (bweight && *bweight != 0.0f &&
+ !BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
+ {
+ UI_ThemeAppendColorBlend(TH_VERTEX, TH_VERTEX_SELECT, *bweight);
+ gpuSprite3fv(co);
}
}
+
static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm)
{
ToolSettings *ts = scene->toolsettings;
if (ts->selectmode & SCE_SELECT_VERTEX) {
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) + 2);
- bglBegin(GL_POINTS);
+ gpuImmediateFormat_C4_V3();
+ gpuBeginSprites();
dm->foreachMappedVert(dm, draw_dm_bweights__mapFunc, em);
- bglEnd();
+ gpuEndSprites();
+ gpuImmediateUnformat();
}
else {
glLineWidth(3.0);
+ gpuImmediateFormat_C4_V3();
dm->drawMappedEdges(dm, draw_dm_bweights__setDrawOptions, em);
+ gpuImmediateUnformat();
glLineWidth(1.0);
}
}
@@ -2478,13 +2404,13 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit,
if (ts->selectmode & SCE_SELECT_VERTEX) {
glPointSize(size);
- glColor4ubv(col);
+ gpuCurrentColor4ubv(col);
draw_dm_verts(em, cageDM, sel, eve_act, rv3d);
}
if (check_ob_drawface_dot(scene, v3d, obedit->dt)) {
glPointSize(fsize);
- glColor4ubv(fcol);
+ gpuCurrentColor4ubv(fcol);
draw_dm_face_centers(em, cageDM, sel);
}
@@ -2550,7 +2476,7 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d,
}
else {
if (!sel_only) {
- glColor4ubv(wireCol);
+ gpuCurrentColor4ubv(wireCol);
draw_dm_edges(em, cageDM);
}
}
@@ -2793,7 +2719,7 @@ static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index)
if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
GPU_enable_material(efa->mat_nr + 1, NULL);
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
}
else
return DM_DRAW_OPTION_SKIP;
@@ -2806,7 +2732,7 @@ static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
return DM_DRAW_OPTION_SKIP;
else
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
}
static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
@@ -2855,15 +2781,24 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
else {
/* 3 floats for position,
* 3 for normal and times two because the faces may actually be quads instead of triangles */
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
+ gpuLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, GPU_enable_material, NULL, me->edit_btmesh, 0);
+
+ gpuImmediateFormat_N3_V3();
+ finalDM->drawMappedFaces(
+ finalDM,
+ draw_em_fancy__setFaceOpts,
+ GPU_enable_material,
+ NULL,
+ me->edit_btmesh,
+ DM_DRAW_USE_NORMALS);
+ gpuImmediateUnformat();
glFrontFace(GL_CCW);
- glDisable(GL_LIGHTING);
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
+ gpuDisableLighting();
+ gpuLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
}
/* Setup for drawing wire over, disable zbuffer
@@ -2932,7 +2867,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
draw_dm_edges_seams(em, cageDM);
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
glLineWidth(1);
}
@@ -2942,7 +2877,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
draw_dm_edges_sharp(em, cageDM);
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
glLineWidth(1);
}
@@ -3094,7 +3029,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
if (!(draw_flags & DRAW_FACE_SELECT)) {
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
dm->drawLooseEdges(dm);
}
@@ -3107,7 +3042,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
}
else {
- const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
+ static const GLfloat spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
+
/* draw outline */
if ((v3d->flag & V3D_SELECT_OUTLINE) &&
@@ -3123,18 +3059,27 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
GPU_end_object_materials();
GPU_enable_material(0, NULL);
-
+
/* set default spec */
- glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
- /* diffuse */
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
+ gpuMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
- dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, NULL, DM_DRAW_USE_COLORS);
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
+ /* diffuse */
+ gpuColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gpuEnableLighting();
+ gpuEnableColorMaterial();
+
+ gpuImmediateFormat_C4_N3_V3();
+ dm->drawMappedFaces(
+ dm,
+ NULL,
+ GPU_enable_material,
+ NULL,
+ NULL,
+ DM_DRAW_USE_COLORS|DM_DRAW_USE_NORMALS);
+ gpuImmediateUnformat();
+
+ gpuDisableColorMaterial();
+ gpuDisableLighting();
GPU_disable_material();
}
@@ -3151,9 +3096,9 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
draw_mesh_object_outline(v3d, ob, dm);
}
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
+ gpuLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
if (ob->sculpt && (p = paint_get_active(scene))) {
@@ -3177,13 +3122,13 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
GPU_disable_material();
glFrontFace(GL_CCW);
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
+ gpuLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
dm->drawLooseEdges(dm);
}
@@ -3209,7 +3154,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f);
}
else {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
}
@@ -3236,12 +3181,11 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
if (is_obact && paint_vertsel_test(ob)) {
-
- glColor3f(0.0f, 0.0f, 0.0f);
+ gpuCurrentColor3x(CPACK_BLACK);
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
-
+
drawSelectedVertices(dm, ob->data);
-
+
glPointSize(1.0f);
}
dm->release(dm);
@@ -3355,92 +3299,107 @@ static int drawDispListwire(ListBase *dlbase)
{
DispList *dl;
int parts, nr;
- float *data;
- if (dlbase == NULL) return 1;
-
- glEnableClientState(GL_VERTEX_ARRAY);
+ if (dlbase == NULL) {
+ return 1;
+ }
+
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
for (dl = dlbase->first; dl; dl = dl->next) {
- if (dl->parts == 0 || dl->nr == 0)
+ GPUarrays arrays;
+
+ if (dl->parts == 0 || dl->nr == 0) {
continue;
-
- data = dl->verts;
+ }
+
+ arrays = GPU_ARRAYS_V3F;
+ arrays.vertexPointer = dl->verts;
switch (dl->type) {
case DL_SEGM:
- glVertexPointer(3, GL_FLOAT, 0, data);
+ gpuImmediateFormat_V3();
+ for (parts = 0; parts < dl->parts; parts++) {
+ gpuDrawClientArrays(
+ GL_LINE_STRIP,
+ &arrays,
+ parts * dl->nr,
+ dl->nr);
+ }
+ gpuImmediateUnformat();
- for (parts = 0; parts < dl->parts; parts++)
- glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr);
-
break;
- case DL_POLY:
- glVertexPointer(3, GL_FLOAT, 0, data);
+ case DL_POLY:
- for (parts = 0; parts < dl->parts; parts++)
- glDrawArrays(GL_LINE_LOOP, parts * dl->nr, dl->nr);
+ gpuImmediateFormat_V3();
+ for (parts = 0; parts < dl->parts; parts++) {
+ gpuDrawClientArrays(
+ GL_LINE_LOOP,
+ &arrays,
+ parts * dl->nr,
+ dl->nr);
+ }
+ gpuImmediateUnformat();
break;
+
case DL_SURF:
- glVertexPointer(3, GL_FLOAT, 0, data);
+ gpuImmediateFormat_V3();
for (parts = 0; parts < dl->parts; parts++) {
- if (dl->flag & DL_CYCL_U)
- glDrawArrays(GL_LINE_LOOP, parts * dl->nr, dl->nr);
- else
- glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr);
+ gpuDrawClientArrays(
+ (dl->flag & DL_CYCL_U) ? GL_LINE_LOOP : GL_LINE_STRIP,
+ &arrays,
+ parts * dl->nr,
+ dl->nr);
}
+ arrays.vertexStride = 3 * sizeof(float) * dl->nr;
+
for (nr = 0; nr < dl->nr; nr++) {
- int ofs = 3 * dl->nr;
+ arrays.vertexPointer = (dl->verts) + 3 * nr;
- data = (dl->verts) + 3 * nr;
- parts = dl->parts;
+ gpuDrawClientArrays(
+ (dl->flag & DL_CYCL_V) ? GL_LINE_LOOP : GL_LINE_STRIP,
+ &arrays,
+ 0,
+ dl->parts);
+ }
- if (dl->flag & DL_CYCL_V) glBegin(GL_LINE_LOOP);
- else glBegin(GL_LINE_STRIP);
+ gpuImmediateUnformat();
- while (parts--) {
- glVertex3fv(data);
- data += ofs;
- }
- glEnd();
-
-#if 0
- /* (ton) this code crashes for me when resolv is 86 or higher... no clue */
- glVertexPointer(3, GL_FLOAT, sizeof(float) * 3 * dl->nr, data + 3*nr);
- if (dl->flag & DL_CYCL_V)
- glDrawArrays(GL_LINE_LOOP, 0, dl->parts);
- else
- glDrawArrays(GL_LINE_STRIP, 0, dl->parts);
-#endif
- }
break;
case DL_INDEX3:
if (draw_index_wire) {
- glVertexPointer(3, GL_FLOAT, 0, dl->verts);
- glDrawElements(GL_TRIANGLES, 3 * dl->parts, GL_UNSIGNED_INT, dl->index);
+ gpuSingleClientElements_V3F(
+ GL_TRIANGLES,
+ dl->verts,
+ 0,
+ 3 * dl->parts,
+ dl->index);
}
+
break;
case DL_INDEX4:
if (draw_index_wire) {
- glVertexPointer(3, GL_FLOAT, 0, dl->verts);
- glDrawElements(GL_QUADS, 4 * dl->parts, GL_UNSIGNED_INT, dl->index);
+ gpuSingleClientElements_V3F(
+ GL_QUADS, dl->verts,
+ 0,
+ 4 * dl->parts,
+ dl->index);
}
+
break;
}
}
-
- glDisableClientState(GL_VERTEX_ARRAY);
+
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-
+
return 0;
}
@@ -3449,118 +3408,110 @@ static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag,
{
DispList *dl;
GPUVertexAttribs gattribs;
- float *data;
- float *ndata;
-
- if (lb == NULL) return;
- glEnable(GL_LIGHTING);
- glEnableClientState(GL_VERTEX_ARRAY);
-
- if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
- else glFrontFace(GL_CCW);
-
+ GPU_ASSERT(gpuImmediateLockCount() == 0);
+
+ if (lb == NULL) {
+ return;
+ }
+
+ gpuEnableLighting();
+
+ if (ob->transflag & OB_NEG_SCALE) {
+ glFrontFace(GL_CW);
+ }
+ else {
+ glFrontFace(GL_CCW);
+ }
+
if (ob->type == OB_MBALL) { /* mball always smooth shaded */
glShadeModel(GL_SMOOTH);
}
-
+
dl = lb->first;
while (dl) {
- data = dl->verts;
- ndata = dl->nors;
-
switch (dl->type) {
case DL_SEGM:
if (ob->type == OB_SURF) {
- int nr;
-
- glDisable(GL_LIGHTING);
-
- if ((dflag & DRAW_CONSTCOLOR) == 0)
- glColor3ubv(ob_wire_col);
-
- // glVertexPointer(3, GL_FLOAT, 0, dl->verts);
- // glDrawArrays(GL_LINE_STRIP, 0, dl->nr);
-
- glBegin(GL_LINE_STRIP);
- for (nr = dl->nr; nr; nr--, data += 3)
- glVertex3fv(data);
- glEnd();
-
- glEnable(GL_LIGHTING);
+ gpuDisableLighting();
+ gpuCurrentColor3ubv(ob_wire_col);
+ gpuSingleClientArrays_V3F(GL_LINE_STRIP, dl->verts, 0, 0, dl->nr);
+ gpuEnableLighting();
+
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ gpuCurrentColor3ubv(ob_wire_col);
+ }
}
break;
case DL_POLY:
if (ob->type == OB_SURF) {
- int nr;
-
- glDisable(GL_LIGHTING);
-
- /* for some reason glDrawArrays crashes here in half of the platforms (not osx) */
- //glVertexPointer(3, GL_FLOAT, 0, dl->verts);
- //glDrawArrays(GL_LINE_LOOP, 0, dl->nr);
-
- glBegin(GL_LINE_LOOP);
- for (nr = dl->nr; nr; nr--, data += 3)
- glVertex3fv(data);
- glEnd();
-
- glEnable(GL_LIGHTING);
+ gpuDisableLighting();
+ gpuSingleClientArrays_V3F(GL_LINE_LOOP, dl->verts, 0, 0, dl->nr);
+ gpuEnableLighting();
break;
}
case DL_SURF:
if (dl->index) {
- GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
-
- if (dl->rt & CU_SMOOTH) glShadeModel(GL_SMOOTH);
- else glShadeModel(GL_FLAT);
-
- glEnableClientState(GL_NORMAL_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, dl->verts);
- glNormalPointer(GL_FLOAT, 0, dl->nors);
- glDrawElements(GL_QUADS, 4 * dl->totindex, GL_UNSIGNED_INT, dl->index);
- glDisableClientState(GL_NORMAL_ARRAY);
+ GPU_enable_material(dl->col + 1, use_glsl ? &gattribs : NULL);
+
+ glShadeModel((dl->rt & CU_SMOOTH) ? GL_SMOOTH : GL_FLAT);
+
+ gpuSingleClientElements_N3F_V3F(
+ GL_QUADS,
+ dl->nors,
+ 0,
+ dl->verts,
+ 0,
+ 4 * dl->totindex,
+ dl->index);
}
break;
case DL_INDEX3:
- GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
+ GPU_enable_material(dl->col + 1, use_glsl ? &gattribs : NULL);
- glVertexPointer(3, GL_FLOAT, 0, dl->verts);
-
- /* for polys only one normal needed */
if (index3_nors_incr) {
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(GL_FLOAT, 0, dl->nors);
+ gpuSingleClientElements_N3F_V3F(
+ GL_TRIANGLES,
+ dl->nors,
+ 0,
+ dl->verts,
+ 0,
+ 3 * dl->parts,
+ dl->index);
+ }
+ else {
+ gpuCurrentNormal3fv(dl->nors);
+ gpuSingleClientElements_V3F(
+ GL_TRIANGLES,
+ dl->verts,
+ 0,
+ 3 * dl->parts,
+ dl->index);
}
- else
- glNormal3fv(ndata);
-
- glDrawElements(GL_TRIANGLES, 3 * dl->parts, GL_UNSIGNED_INT, dl->index);
-
- if (index3_nors_incr)
- glDisableClientState(GL_NORMAL_ARRAY);
break;
case DL_INDEX4:
- GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
+ GPU_enable_material(dl->col + 1, use_glsl ? &gattribs : NULL);
- glEnableClientState(GL_NORMAL_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, dl->verts);
- glNormalPointer(GL_FLOAT, 0, dl->nors);
- glDrawElements(GL_QUADS, 4 * dl->parts, GL_UNSIGNED_INT, dl->index);
- glDisableClientState(GL_NORMAL_ARRAY);
+ gpuSingleClientElements_N3F_V3F(
+ GL_QUADS,
+ dl->nors,
+ 0,
+ dl->verts,
+ 0,
+ 4 * dl->parts,
+ dl->index);
break;
}
dl = dl->next;
}
- glDisableClientState(GL_VERTEX_ARRAY);
glShadeModel(GL_FLAT);
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
glFrontFace(GL_CCW);
}
@@ -3585,9 +3536,9 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
if (!glsl) {
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
}
else
dm->drawFacesGLSL(dm, GPU_enable_material);
@@ -3655,7 +3606,7 @@ static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d
GPU_end_object_materials();
}
if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) {
- cpack(0);
+ gpuCurrentColor3x(CPACK_BLACK);
draw_index_wire = 0;
drawDispListwire(lb);
draw_index_wire = 1;
@@ -3754,30 +3705,53 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
}
/* *********** drawing for particles ************* */
-static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int select)
+static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int select, void* c, void *n, void *v)
{
- /* draw created data arrays */
- switch (draw_as) {
- case PART_DRAW_AXIS:
- case PART_DRAW_CROSS:
- glDrawArrays(GL_LINES, 0, 6 * totpoint);
- break;
- case PART_DRAW_LINE:
- glDrawArrays(GL_LINES, 0, 2 * totpoint);
- break;
- case PART_DRAW_BB:
- if (ob_dt <= OB_WIRE || select)
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- else
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ if (v) {
+ GLenum mode;
+ GLint count;
- glDrawArrays(GL_QUADS, 0, 4 * totpoint);
- break;
- default:
- glDrawArrays(GL_POINTS, 0, totpoint);
- break;
+ /* draw created data arrays */
+ switch (draw_as) {
+ case PART_DRAW_AXIS:
+ case PART_DRAW_CROSS:
+ mode = GL_LINES;
+ count = 6 * totpoint;
+ break;
+ case PART_DRAW_LINE:
+ mode = GL_LINES;
+ count = 2 * totpoint;
+ break;
+ case PART_DRAW_BB:
+ if (ob_dt <= OB_WIRE || select)
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ else
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ mode = GL_QUADS;
+ count = 4 * totpoint;
+ break;
+ default:
+ mode = GL_POINTS;
+ count = totpoint;
+ break;
+ }
+
+ if (c && n) {
+ gpuSingleClientArrays_C3F_N3F_V3F(mode, c, 0, n, 0, v, 0, 0, count);
+ }
+ else if (c) {
+ gpuSingleClientArrays_C3F_V3F(mode, c, 0, v, 0, 0, count);
+ }
+ else if (n) {
+ gpuSingleClientArrays_N3F_V3F(mode, n, 0, v, 0, 0, count);
+ }
+ else {
+ gpuSingleClientArrays_V3F(mode, v, 0, 0, count);
+ }
}
}
+
static void draw_particle(ParticleKey *state, int draw_as, short draw, float pixsize,
float imat[4][4], float *draw_line, ParticleBillboardData *bb, ParticleDrawData *pdd)
{
@@ -3885,7 +3859,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
}
case PART_DRAW_CIRC:
{
- drawcircball(GL_LINE_LOOP, state->co, pixsize, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, state->co, pixsize, imat);
break;
}
case PART_DRAW_BB:
@@ -4012,14 +3986,14 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
copy_v3_v3(ma_col, &ma->r);
}
- glColor3ubv(tcol);
+ gpuCurrentColor3ubv(tcol);
timestep = psys_get_timestep(&sim);
if ((base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP)) {
float mat[4][4];
mult_m4_m4m4(mat, ob->obmat, psys->imat);
- glMultMatrixf(mat);
+ gpuMultMatrix(mat);
}
/* needed for text display */
@@ -4191,6 +4165,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
totpoint = pdd->totpoint; /* draw data is up to date */
}
else {
+ if (draw_as == PART_DRAW_CIRC) {
+ gpuImmediateFormat_V3();
+ }
+
for (a = 0, pa = pars; a < totpart + totchild; a++, pa++) {
/* setup per particle individual stuff */
if (a < totpart) {
@@ -4341,7 +4319,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if (part->draw & PART_DRAW_SIZE) {
setlinestyle(3);
- drawcircball(GL_LINE_LOOP, state.co, pa_size, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, state.co, pa_size, imat);
setlinestyle(0);
}
@@ -4374,86 +4352,98 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
}
}
}
+
+ if (draw_as == PART_DRAW_CIRC) {
+ gpuImmediateUnformat();
+ }
}
}
/* 6. */
glGetIntegerv(GL_POLYGON_MODE, polygonmode);
- glEnableClientState(GL_VERTEX_ARRAY);
if (draw_as == PART_DRAW_PATH) {
ParticleCacheKey **cache, *path;
- float /* *cd2=NULL, */ /* UNUSED */ *cdata2 = NULL;
+ float* cdata2 = NULL;
/* setup gl flags */
- if (1) { //ob_dt > OB_WIRE) {
- glEnableClientState(GL_NORMAL_ARRAY);
-
- if (part->draw_col == PART_DRAW_COL_MAT)
- glEnableClientState(GL_COLOR_ARRAY);
-
- glEnable(GL_LIGHTING);
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
- }
-#if 0
- else {
- glDisableClientState(GL_NORMAL_ARRAY);
-
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
- UI_ThemeColor(TH_WIRE);
- }
-#endif
+ gpuEnableLighting();
+ gpuColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gpuEnableColorMaterial();
- if (totchild && (part->draw & PART_DRAW_PARENT) == 0)
+ if (totchild && (part->draw & PART_DRAW_PARENT) == 0) {
totpart = 0;
- else if (psys->pathcache == NULL)
+ }
+ else if (psys->pathcache == NULL) {
totpart = 0;
+ }
/* draw actual/parent particles */
cache = psys->pathcache;
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
path = cache[a];
if (path->steps > 0) {
- glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
-
- if (1) { //ob_dt > OB_WIRE) {
- glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
- if (part->draw_col == PART_DRAW_COL_MAT)
- glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+ if (part->draw_col == PART_DRAW_COL_MAT) {
+ gpuSingleClientArrays_C3F_N3F_V3F(
+ GL_LINE_STRIP,
+ path->col,
+ sizeof(ParticleCacheKey),
+ path->vel,
+ sizeof(ParticleCacheKey),
+ path->co,
+ sizeof(ParticleCacheKey),
+ 0,
+ path->steps + 1);
+ }
+ else {
+ gpuSingleClientArrays_N3F_V3F(
+ GL_LINE_STRIP,
+ path->vel,
+ sizeof(ParticleCacheKey),
+ path->co,
+ sizeof(ParticleCacheKey),
+ 0,
+ path->steps + 1);
}
-
- glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
}
}
-
+
/* draw child particles */
cache = psys->childcache;
for (a = 0; a < totchild; a++) {
path = cache[a];
- glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
-
- if (1) { //ob_dt > OB_WIRE) {
- glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
- if (part->draw_col == PART_DRAW_COL_MAT)
- glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+ if (part->draw_col == PART_DRAW_COL_MAT) {
+ gpuSingleClientArrays_C3F_N3F_V3F(
+ GL_LINE_STRIP,
+ path->col,
+ sizeof(ParticleCacheKey),
+ path->vel,
+ sizeof(ParticleCacheKey),
+ path->co,
+ sizeof(ParticleCacheKey),
+ 0,
+ path->steps + 1);
+ }
+ else {
+ gpuSingleClientArrays_N3F_V3F(
+ GL_LINE_STRIP,
+ path->vel,
+ sizeof(ParticleCacheKey),
+ path->co,
+ sizeof(ParticleCacheKey),
+ 0,
+ path->steps + 1);
}
-
- glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
}
-
/* restore & clean up */
- if (1) { //ob_dt > OB_WIRE) {
- if (part->draw_col == PART_DRAW_COL_MAT)
- glDisable(GL_COLOR_ARRAY);
- glDisable(GL_COLOR_MATERIAL);
- }
- if (cdata2)
+ gpuDisableColorMaterial();
+
+ if (cdata2) {
MEM_freeN(cdata2);
- /* cd2 = */ /* UNUSED */ cdata2 = NULL;
+ cdata2 = NULL;
+ }
glLineWidth(1.0f);
@@ -4469,32 +4459,36 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
}
}
}
- else if (pdd && ELEM(draw_as, 0, PART_DRAW_CIRC) == 0) {
- glDisableClientState(GL_COLOR_ARRAY);
+ else if (pdd && !ELEM(draw_as, 0, PART_DRAW_CIRC)) {
+ float* cPtr;
+ float* nPtr;
+ float* vPtr;
/* enable point data array */
if (pdd->vdata) {
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, pdd->vdata);
+ vPtr = pdd->vdata;
+ }
+ else {
+ vPtr = NULL;
}
- else
- glDisableClientState(GL_VERTEX_ARRAY);
if (select) {
UI_ThemeColor(TH_ACTIVE);
- if (part->draw_size)
+ if (part->draw_size) {
glPointSize(part->draw_size + 2);
- else
+ }
+ else {
glPointSize(4.0);
+ }
glLineWidth(3.0);
- draw_particle_arrays(draw_as, totpoint, ob_dt, 1);
+ draw_particle_arrays(draw_as, totpoint, ob_dt, 1, NULL, NULL, vPtr);
}
/* restore from select */
- glColor3fv(ma_col);
+ gpuCurrentColor3fv(ma_col);
glPointSize(part->draw_size ? part->draw_size : 2.0);
glLineWidth(1.0);
@@ -4502,47 +4496,51 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
/* billboards are drawn this way */
if (pdd->ndata && ob_dt > OB_WIRE) {
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(GL_FLOAT, 0, pdd->ndata);
- glEnable(GL_LIGHTING);
+ nPtr = pdd->ndata;
+ gpuEnableLighting();
}
else {
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisable(GL_LIGHTING);
+ nPtr = NULL;
+ gpuDisableLighting();
}
if (pdd->cdata) {
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(3, GL_FLOAT, 0, pdd->cdata);
+ cPtr = pdd->cdata;
+ }
+ else {
+ cPtr = NULL;
}
- draw_particle_arrays(draw_as, totpoint, ob_dt, 0);
+ draw_particle_arrays(draw_as, totpoint, ob_dt, 0, cPtr, nPtr, vPtr);
pdd->flag |= PARTICLE_DRAW_DATA_UPDATED;
pdd->totpoint = totpoint;
}
if (pdd && pdd->vedata) {
- glDisableClientState(GL_COLOR_ARRAY);
- cpack(0xC0C0C0);
-
- glVertexPointer(3, GL_FLOAT, 0, pdd->vedata);
-
- glDrawArrays(GL_LINES, 0, 2 * totve);
+ gpuCurrentGray3f(0.753f);
+
+ draw_particle_arrays(
+ PART_DRAW_LINE,
+ totve,
+ 0,
+ 0,
+ NULL,
+ NULL,
+ pdd->vedata);
}
glPolygonMode(GL_FRONT, polygonmode[0]);
- glPolygonMode(GL_BACK, polygonmode[1]);
+ glPolygonMode(GL_BACK, polygonmode[1]);
/* 7. */
-
- glDisable(GL_LIGHTING);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- if (states)
+ gpuDisableLighting();
+
+ if (states) {
MEM_freeN(states);
+ states = NULL;
+ }
psys->flag &= ~PSYS_DRAWING;
@@ -4563,7 +4561,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
}
if ((base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP)) {
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
}
}
@@ -4609,39 +4607,61 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
pathcol = MEM_callocN(steps * 4 * sizeof(float), "particle path color data");
}
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
-
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
+ gpuColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gpuEnableColorMaterial();
glShadeModel(GL_SMOOTH);
if (pset->brushtype == PE_BRUSH_WEIGHT) {
glLineWidth(2.0f);
- glDisable(GL_LIGHTING);
+ gpuDisableLighting();
}
cache = edit->pathcache;
for (i = 0; i < totpoint; i++) {
+ GLfloat* cPtr;
+ GLint cStride;
+
path = cache[i];
- glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
if (timed) {
for (k = 0, pcol = pathcol, pkey = path; k < steps; k++, pkey++, pcol += 4) {
copy_v3_v3(pcol, pkey->col);
- pcol[3] = 1.0f - fabsf((float)(CFRA) -pkey->time) / (float)pset->fade_frames;
+ pcol[3] = 1.0f - fabsf((float)(CFRA) - pkey->time) / (float)pset->fade_frames;
}
- glColorPointer(4, GL_FLOAT, 4 * sizeof(float), pathcol);
+ cPtr = pathcol;
+ cStride = 0;
+ }
+ else {
+ cPtr = path->col;
+ cStride = sizeof(ParticleCacheKey);
}
- else
- glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
- glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
+ if (timed) {
+ gpuSingleClientArrays_C4F_V3F(
+ GL_LINE_STRIP,
+ cPtr,
+ cStride,
+ path->co,
+ sizeof(ParticleCacheKey),
+ 0,
+ path->steps + 1);
+ }
+ else {
+ gpuSingleClientArrays_C3F_V3F(
+ GL_LINE_STRIP,
+ cPtr,
+ cStride,
+ path->co,
+ sizeof(ParticleCacheKey),
+ 0,
+ path->steps + 1);
+ }
}
- if (pathcol) { MEM_freeN(pathcol); pathcol = pcol = NULL; }
-
+ if (pathcol) {
+ MEM_freeN(pathcol); pathcol = pcol = NULL;
+ }
/* draw edit vertices */
if (pset->selectmode != SCE_SELECT_PATH) {
@@ -4652,17 +4672,22 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
float *cd = NULL, *cdata = NULL;
int totkeys = 0;
- for (i = 0, point = edit->points; i < totpoint; i++, point++)
- if (!(point->flag & PEP_HIDE))
+ for (i = 0, point = edit->points; i < totpoint; i++, point++) {
+ if (!(point->flag & PEP_HIDE)) {
totkeys += point->totkey;
+ }
+ }
- if (edit->points && !(edit->points->keys->flag & PEK_USE_WCO))
+ if (edit->points && !(edit->points->keys->flag & PEK_USE_WCO)) {
pd = pdata = MEM_callocN(totkeys * 3 * sizeof(float), "particle edit point data");
+ }
+
cd = cdata = MEM_callocN(totkeys * (timed ? 4 : 3) * sizeof(float), "particle edit color data");
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
continue;
+ }
for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
if (pd) {
@@ -4677,8 +4702,9 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
copy_v3_v3(cd, nosel_col);
}
- if (timed)
+ if (timed) {
*(cd + 3) = 1.0f - fabsf((float)CFRA - *key->time) / (float)pset->fade_frames;
+ }
cd += (timed ? 4 : 3);
}
@@ -4686,49 +4712,80 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
cd = cdata;
pd = pdata;
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
- if (point->flag & PEP_HIDE || point->totkey == 0)
- continue;
+ GLfloat* vPtr;
+ GLint vStride;
- if (point->keys->flag & PEK_USE_WCO)
- glVertexPointer(3, GL_FLOAT, sizeof(PTCacheEditKey), point->keys->world_co);
- else
- glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), pd);
+ if (point->flag & PEP_HIDE || point->totkey == 0) {
+ continue;
+ }
- glColorPointer((timed ? 4 : 3), GL_FLOAT, (timed ? 4 : 3) * sizeof(float), cd);
+ if (point->keys->flag & PEK_USE_WCO) {
+ vPtr = point->keys->world_co;
+ vStride = sizeof(PTCacheEditKey);
+ }
+ else {
+ vPtr = pd;
+ vStride = 0;
+ }
- glDrawArrays(GL_POINTS, 0, point->totkey);
+ if (timed) {
+ gpuSingleClientArrays_C4F_V3F(
+ GL_POINTS,
+ cd,
+ 0,
+ vPtr,
+ vStride,
+ 0,
+ point->totkey);
+ }
+ else {
+ gpuSingleClientArrays_C3F_V3F(
+ GL_POINTS,
+ cd,
+ 0,
+ vPtr,
+ vStride,
+ 0,
+ point->totkey);
+ }
pd += pd ? 3 * point->totkey : 0;
cd += (timed ? 4 : 3) * point->totkey;
}
- if (pdata) { MEM_freeN(pdata); pd = pdata = NULL; }
- if (cdata) { MEM_freeN(cdata); cd = cdata = NULL; }
+
+ if (pdata) {
+ MEM_freeN(pdata); pd = pdata = NULL;
+ }
+
+ if (cdata) {
+ MEM_freeN(cdata); cd = cdata = NULL;
+ }
}
else if (pset->selectmode == SCE_SELECT_END) {
+ gpuImmediateFormat_C4_V3();
+ gpuBegin(GL_POINTS);
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
if ((point->flag & PEP_HIDE) == 0 && point->totkey) {
key = point->keys + point->totkey - 1;
- if (key->flag & PEK_SELECT)
- glColor3fv(sel_col);
- else
- glColor3fv(nosel_col);
- /* has to be like this.. otherwise selection won't work, have try glArrayElement later..*/
- glBegin(GL_POINTS);
- glVertex3fv(key->flag & PEK_USE_WCO ? key->world_co : key->co);
- glEnd();
+
+ gpuColor3fv(key->flag & PEK_SELECT ? sel_col : nosel_col);
+ gpuVertex3fv(key->flag & PEK_USE_WCO ? key->world_co : key->co);
}
}
+ gpuEnd();
+ gpuImmediateUnformat();
}
}
glDisable(GL_BLEND);
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuDisableLighting();
+ gpuDisableColorMaterial();
glShadeModel(GL_FLAT);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+
+ if (v3d->zbuf) {
+ glEnable(GL_DEPTH_TEST);
+ }
+
glLineWidth(1.0f);
glPointSize(1.0);
}
@@ -4743,156 +4800,160 @@ static void ob_draw_RE_motion(float com[3], float rotscale[3][3], float itw, flo
tw = itw * drw_size;
th = ith * drw_size;
- glColor4ub(0x7F, 0x00, 0x00, 155);
- glBegin(GL_LINES);
+ gpuImmediateFormat_V3();
+
+ gpuCurrentColor4x(0x7F0000, 0.608f);
+ gpuBegin(GL_LINES);
root[1] = root[2] = 0.0f;
root[0] = -drw_size;
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
+ gpuVertex3fv(root);
tip[1] = tip[2] = 0.0f;
tip[0] = drw_size;
mul_m3_v3(tr, tip);
add_v3_v3(tip, com);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(tip);
+ gpuEnd();
root[1] = 0.0f; root[2] = tw;
root[0] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[1] = 0.0f; root[2] = -tw;
root[0] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[1] = tw; root[2] = 0.0f;
root[0] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[1] = -tw; root[2] = 0.0f;
root[0] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
- glColor4ub(0x00, 0x7F, 0x00, 155);
+ gpuCurrentColor4x(0x007F00, 0.608f);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
root[0] = root[2] = 0.0f;
root[1] = -drw_size;
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
+ gpuVertex3fv(root);
tip[0] = tip[2] = 0.0f;
tip[1] = drw_size;
mul_m3_v3(tr, tip);
add_v3_v3(tip, com);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(tip);
+ gpuEnd();
root[0] = 0.0f; root[2] = tw;
root[1] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[0] = 0.0f; root[2] = -tw;
root[1] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[0] = tw; root[2] = 0.0f;
root[1] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[0] = -tw; root[2] = 0.0f;
root[1] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
- glColor4ub(0x00, 0x00, 0x7F, 155);
- glBegin(GL_LINES);
+ gpuCurrentColor4x(0x00007F, 0.608f);
+ gpuBegin(GL_LINES);
root[0] = root[1] = 0.0f;
root[2] = -drw_size;
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
+ gpuVertex3fv(root);
tip[0] = tip[1] = 0.0f;
tip[2] = drw_size;
mul_m3_v3(tr, tip);
add_v3_v3(tip, com);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(tip);
+ gpuEnd();
root[0] = 0.0f; root[1] = tw;
root[2] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[0] = 0.0f; root[1] = -tw;
root[2] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[0] = tw; root[1] = 0.0f;
root[2] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
root[0] = -tw; root[1] = 0.0f;
root[2] = th;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
mul_m3_v3(tr, root);
add_v3_v3(root, com);
- glVertex3fv(root);
- glVertex3fv(tip);
- glEnd();
+ gpuVertex3fv(root);
+ gpuVertex3fv(tip);
+ gpuEnd();
+
+ gpuImmediateUnformat();
}
/*place to add drawers */
@@ -4905,7 +4966,7 @@ static void tekenhandlesN(Nurb *nu, short sel, short hide_handles)
if (nu->hide || hide_handles) return;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
if (nu->type == CU_BEZIER) {
@@ -4925,27 +4986,27 @@ static void tekenhandlesN(Nurb *nu, short sel, short hide_handles)
if ((bezt->f2 & SELECT) == sel) {
fp = bezt->vec[0];
- glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]);
- glVertex3fv(fp);
- glVertex3fv(fp + 3);
+ gpuColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]);
+ gpuVertex3fv(fp);
+ gpuVertex3fv(fp + 3);
- glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]);
- glVertex3fv(fp + 3);
- glVertex3fv(fp + 6);
+ gpuColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]);
+ gpuVertex3fv(fp + 3);
+ gpuVertex3fv(fp + 6);
}
else if ((bezt->f1 & SELECT) == sel) {
fp = bezt->vec[0];
- glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]);
- glVertex3fv(fp);
- glVertex3fv(fp + 3);
+ gpuColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]);
+ gpuVertex3fv(fp);
+ gpuVertex3fv(fp + 3);
}
else if ((bezt->f3 & SELECT) == sel) {
fp = bezt->vec[1];
- glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]);
- glVertex3fv(fp);
- glVertex3fv(fp + 3);
+ gpuColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]);
+ gpuVertex3fv(fp);
+ gpuVertex3fv(fp + 3);
}
}
bezt++;
@@ -4954,7 +5015,7 @@ static void tekenhandlesN(Nurb *nu, short sel, short hide_handles)
#undef TH_HANDLE_COL_TOT
}
- glEnd();
+ gpuEnd();
}
static void tekenhandlesN_active(Nurb *nu)
@@ -4968,7 +5029,7 @@ static void tekenhandlesN_active(Nurb *nu)
UI_ThemeColor(TH_ACTIVE_SPLINE);
glLineWidth(2);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
if (nu->type == CU_BEZIER) {
bezt = nu->bezt;
@@ -4977,18 +5038,18 @@ static void tekenhandlesN_active(Nurb *nu)
if (bezt->hide == 0) {
fp = bezt->vec[0];
- glVertex3fv(fp);
- glVertex3fv(fp + 3);
+ gpuVertex3fv(fp);
+ gpuVertex3fv(fp + 3);
- glVertex3fv(fp + 3);
- glVertex3fv(fp + 6);
+ gpuVertex3fv(fp + 3);
+ gpuVertex3fv(fp + 6);
}
bezt++;
}
}
- glEnd();
+ gpuEnd();
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
glLineWidth(1);
}
@@ -5009,7 +5070,7 @@ static void tekenvertsN(Nurb *nu, short sel, short hide_handles, void *lastsel)
size = UI_GetThemeValuef(TH_VERTEX_SIZE);
glPointSize(size);
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
if (nu->type == CU_BEZIER) {
@@ -5018,23 +5079,23 @@ static void tekenvertsN(Nurb *nu, short sel, short hide_handles, void *lastsel)
while (a--) {
if (bezt->hide == 0) {
if (sel == 1 && bezt == lastsel) {
- UI_ThemeColor(TH_LASTSEL_POINT);
- bglVertex3fv(bezt->vec[1]);
+ UI_ThemeAppendColor(TH_LASTSEL_POINT);
+ gpuSprite3fv(bezt->vec[1]);
if (!hide_handles) {
- if (bezt->f1 & SELECT) bglVertex3fv(bezt->vec[0]);
- if (bezt->f3 & SELECT) bglVertex3fv(bezt->vec[2]);
+ if (bezt->f1 & SELECT) gpuSprite3fv(bezt->vec[0]);
+ if (bezt->f3 & SELECT) gpuSprite3fv(bezt->vec[2]);
}
- UI_ThemeColor(color);
+ UI_ThemeAppendColor(color);
}
else if (hide_handles) {
- if ((bezt->f2 & SELECT) == sel) bglVertex3fv(bezt->vec[1]);
+ if ((bezt->f2 & SELECT) == sel) gpuSprite3fv(bezt->vec[1]);
}
else {
- if ((bezt->f1 & SELECT) == sel) bglVertex3fv(bezt->vec[0]);
- if ((bezt->f2 & SELECT) == sel) bglVertex3fv(bezt->vec[1]);
- if ((bezt->f3 & SELECT) == sel) bglVertex3fv(bezt->vec[2]);
+ if ((bezt->f1 & SELECT) == sel) gpuSprite3fv(bezt->vec[0]);
+ if ((bezt->f2 & SELECT) == sel) gpuSprite3fv(bezt->vec[1]);
+ if ((bezt->f3 & SELECT) == sel) gpuSprite3fv(bezt->vec[2]);
}
}
bezt++;
@@ -5046,19 +5107,19 @@ static void tekenvertsN(Nurb *nu, short sel, short hide_handles, void *lastsel)
while (a--) {
if (bp->hide == 0) {
if (bp == lastsel) {
- UI_ThemeColor(TH_LASTSEL_POINT);
- bglVertex3fv(bp->vec);
- UI_ThemeColor(color);
+ UI_ThemeAppendColor(TH_LASTSEL_POINT);
+ gpuSprite3fv(bp->vec);
+ UI_ThemeAppendColor(color);
}
else {
- if ((bp->f1 & SELECT) == sel) bglVertex3fv(bp->vec);
+ if ((bp->f1 & SELECT) == sel) gpuSprite3fv(bp->vec);
}
}
bp++;
}
}
- bglEnd();
+ gpuEndSprites();
glPointSize(1.0);
}
@@ -5072,17 +5133,17 @@ static void editnurb_draw_active_poly(Nurb *nu)
bp = nu->bp;
for (b = 0; b < nu->pntsv; b++) {
- if (nu->flagu & 1) glBegin(GL_LINE_LOOP);
- else glBegin(GL_LINE_STRIP);
+ if (nu->flagu & 1) gpuBegin(GL_LINE_LOOP);
+ else gpuBegin(GL_LINE_STRIP);
for (a = 0; a < nu->pntsu; a++, bp++) {
- glVertex3fv(bp->vec);
+ gpuVertex3fv(bp->vec);
}
- glEnd();
+ gpuEnd();
}
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
glLineWidth(1);
}
@@ -5094,7 +5155,7 @@ static void editnurb_draw_active_nurbs(Nurb *nu)
UI_ThemeColor(TH_ACTIVE_SPLINE);
glLineWidth(2);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
bp = nu->bp;
for (b = 0; b < nu->pntsv; b++) {
bp1 = bp;
@@ -5102,8 +5163,8 @@ static void editnurb_draw_active_nurbs(Nurb *nu)
for (a = nu->pntsu - 1; a > 0; a--, bp++) {
if (bp->hide == 0 && bp1->hide == 0) {
- glVertex3fv(bp->vec);
- glVertex3fv(bp1->vec);
+ gpuVertex3fv(bp->vec);
+ gpuVertex3fv(bp1->vec);
}
bp1 = bp;
}
@@ -5117,17 +5178,17 @@ static void editnurb_draw_active_nurbs(Nurb *nu)
bp = bp1 + ofs;
for (a = nu->pntsv - 1; a > 0; a--, bp += ofs) {
if (bp->hide == 0 && bp1->hide == 0) {
- glVertex3fv(bp->vec);
- glVertex3fv(bp1->vec);
+ gpuVertex3fv(bp->vec);
+ gpuVertex3fv(bp1->vec);
}
bp1 = bp;
}
}
}
- glEnd();
+ gpuEnd();
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
glLineWidth(1);
}
@@ -5152,14 +5213,14 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
UI_ThemeColor(TH_NURB_ULINE);
bp = nu->bp;
for (b = 0; b < nu->pntsv; b++) {
- if (nu->flagu & 1) glBegin(GL_LINE_LOOP);
- else glBegin(GL_LINE_STRIP);
+ if (nu->flagu & 1) gpuBegin(GL_LINE_LOOP);
+ else gpuBegin(GL_LINE_STRIP);
for (a = 0; a < nu->pntsu; a++, bp++) {
- glVertex3fv(bp->vec);
+ gpuVertex3fv(bp->vec);
}
- glEnd();
+ gpuEnd();
}
break;
case CU_NURBS:
@@ -5178,10 +5239,10 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
UI_ThemeColor(TH_NURB_SEL_ULINE);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(bp->vec);
- glVertex3fv(bp1->vec);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(bp->vec);
+ gpuVertex3fv(bp1->vec);
+ gpuEnd();
}
}
else {
@@ -5191,10 +5252,10 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
else {
UI_ThemeColor(TH_NURB_ULINE);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(bp->vec);
- glVertex3fv(bp1->vec);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(bp->vec);
+ gpuVertex3fv(bp1->vec);
+ gpuEnd();
}
}
}
@@ -5213,10 +5274,10 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
UI_ThemeColor(TH_NURB_SEL_VLINE);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(bp->vec);
- glVertex3fv(bp1->vec);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(bp->vec);
+ gpuVertex3fv(bp1->vec);
+ gpuEnd();
}
}
else {
@@ -5226,10 +5287,10 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
else {
UI_ThemeColor(TH_NURB_VLINE);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(bp->vec);
- glVertex3fv(bp1->vec);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(bp->vec);
+ gpuVertex3fv(bp1->vec);
+ gpuEnd();
}
}
}
@@ -5261,12 +5322,16 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
/* DispList */
UI_GetThemeColor3ubv(TH_WIRE, wire_col);
- glColor3ubv(wire_col);
+ gpuCurrentColor3ubv(wire_col);
drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
+ gpuImmediateFormat_V3();
+
+ if (v3d->zbuf) {
+ glDisable(GL_DEPTH_TEST);
+ }
+
/* first non-selected and active handles */
index = 0;
for (nu = nurb; nu; nu = nu->next) {
@@ -5277,6 +5342,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
}
index++;
}
+
draw_editnurb(ob, nurb, 0);
draw_editnurb(ob, nurb, 1);
/* selected handles */
@@ -5292,12 +5358,14 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
* when at its lowest, don't render normals */
if ((cu->flag & CU_3D) && (ts->normalsize > 0.0015f) && (cu->drawflag & CU_HIDE_NORMALS) == 0) {
+
UI_ThemeColor(TH_WIRE);
+
for (bl = cu->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
BevPoint *bevp = (BevPoint *)(bl + 1);
int nr = bl->nr;
int skip = nu->resolu / 16;
-
+
while (nr-- > 0) { /* accounts for empty bevel lists */
const float fac = bevp->radius * ts->normalsize;
float vec_a[3]; /* Offset perpendicular to the curve */
@@ -5310,7 +5378,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
vec_b[0] = -fac;
vec_b[1] = 0.0f;
vec_b[2] = 0.0f;
-
+
mul_qt_v3(bevp->quat, vec_a);
mul_qt_v3(bevp->quat, vec_b);
add_v3_v3(vec_a, bevp->vec);
@@ -5319,81 +5387,85 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
madd_v3_v3fl(vec_a, bevp->dir, -fac);
madd_v3_v3fl(vec_b, bevp->dir, -fac);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(vec_a);
- glVertex3fv(bevp->vec);
- glVertex3fv(vec_b);
- glEnd();
-
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(vec_a);
+ gpuVertex3fv(bevp->vec);
+ gpuVertex3fv(vec_b);
+ gpuEnd();
+
bevp += skip + 1;
nr -= skip;
}
}
+
+ }
+
+ if (v3d->zbuf) {
+ glDisable(GL_DEPTH_TEST);
}
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
-
for (nu = nurb; nu; nu = nu->next) {
tekenvertsN(nu, 1, hide_handles, cu->lastsel);
}
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+
+ if (v3d->zbuf) {
+ glEnable(GL_DEPTH_TEST);
+ }
+
+ gpuImmediateUnformat();
}
/* draw a sphere for use as an empty drawtype */
static void draw_empty_sphere(float size)
{
- static GLuint displist = 0;
-
- if (displist == 0) {
- GLUquadricObj *qobj;
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
-
- glPushMatrix();
-
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
- gluDisk(qobj, 0.0, 1, 16, 1);
-
- glRotatef(90, 0, 1, 0);
- gluDisk(qobj, 0.0, 1, 16, 1);
-
- glRotatef(90, 1, 0, 0);
- gluDisk(qobj, 0.0, 1, 16, 1);
-
- gluDeleteQuadric(qobj);
-
- glPopMatrix();
- glEndList();
- }
-
- glScalef(size, size, size);
- glCallList(displist);
- glScalef(1.0f / size, 1.0f / size, 1.0f / size);
+ gpuPushMatrix();
+ gpuScale(size, size, size);
+
+ gpuImmediateFormat_V2();
+
+ gpuDrawCircle(0, 0, 1, 16);
+
+ gpuRotateRight('Y');
+ gpuRepeat();
+
+ gpuRotateRight('X');
+ gpuRepeat();
+
+ gpuImmediateUnformat();
+
+ gpuPopMatrix();
}
/* draw a cone for use as an empty drawtype */
static void draw_empty_cone(float size)
{
- float cent = 0;
- float radius;
- GLUquadricObj *qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
-
-
- glPushMatrix();
-
- radius = size;
- glTranslatef(cent, cent, cent);
- glScalef(radius, size * 2.0f, radius);
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1);
+ static GPUimmediate *displist;
+ static GPUindex *index;
- glPopMatrix();
-
- gluDeleteQuadric(qobj);
+ gpuPushMatrix();
+ gpuScale(size, 2.0f * size, size);
+ gpuRotateRight(-'X');
+
+ if (!displist) {
+ GPUprim3 prim = GPU_PRIM_LOFI_WIRE;
+ prim.vsegs = 1;
+
+ gpuPushImmediate();
+ gpuImmediateMaxVertexCount(16);
+
+ index = gpuNewIndex();
+ gpuImmediateIndex(index);
+ gpuImmediateMaxIndexCount(96);
+
+ //GLU Cylinder(qobj, 1.0, 0.0, 1.0, 8, 1);
+ gpuSingleCone(&prim, 1, 1);
+ displist = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleDrawElements(GL_LINES, displist);
+ }
+
+ gpuPopMatrix();
}
/* draw points on curve speed handles */
@@ -5414,144 +5486,59 @@ static void curve_draw_speed(Scene *scene, Object *ob)
return;
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
for (a = 0, bezt = icu->bezt; a < icu->totvert; a++, bezt++) {
if (where_on_path(ob, bezt->vec[1][1], loc, dir)) {
UI_ThemeColor((bezt->f2 & SELECT) && ob == OBACT ? TH_VERTEX_SELECT : TH_VERTEX);
- bglVertex3fv(loc);
+ gpuSprite3fv(loc);
}
}
glPointSize(1.0);
- bglEnd();
+ gpuEndSprites();
}
#endif /* XXX old animation system stuff */
static void draw_textcurs(float textcurs[4][2])
{
- cpack(0);
-
+ gpuImmediateFormat_V3();
+
+ gpuCurrentColor3x(CPACK_BLACK);
set_inverted_drawing(1);
- glBegin(GL_QUADS);
- glVertex2fv(textcurs[0]);
- glVertex2fv(textcurs[1]);
- glVertex2fv(textcurs[2]);
- glVertex2fv(textcurs[3]);
- glEnd();
+ gpuBegin(GL_QUADS);
+ gpuVertex2fv(textcurs[0]);
+ gpuVertex2fv(textcurs[1]);
+ gpuVertex2fv(textcurs[2]);
+ gpuVertex2fv(textcurs[3]);
+ gpuEnd();
set_inverted_drawing(0);
-}
-
-static void drawspiral(const float cent[3], float rad, float tmat[][4], int start)
-{
- float vec[3], vx[3], vy[3];
- const float tot_inv = (1.0f / (float)CIRCLE_RESOL);
- int a;
- char inverse = FALSE;
- float x, y, fac;
-
- if (start < 0) {
- inverse = TRUE;
- start = -start;
- }
-
- mul_v3_v3fl(vx, tmat[0], rad);
- mul_v3_v3fl(vy, tmat[1], rad);
-
- glBegin(GL_LINE_STRIP);
-
- if (inverse == 0) {
- copy_v3_v3(vec, cent);
- glVertex3fv(vec);
-
- for (a = 0; a < CIRCLE_RESOL; a++) {
- if (a + start >= CIRCLE_RESOL)
- start = -a + 1;
-
- fac = (float)a * tot_inv;
- x = sinval[a + start] * fac;
- y = cosval[a + start] * fac;
-
- vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
- vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
- vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
-
- glVertex3fv(vec);
- }
- }
- else {
- fac = (float)(CIRCLE_RESOL - 1) * tot_inv;
- x = sinval[start] * fac;
- y = cosval[start] * fac;
-
- vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
- vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
- vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
-
- glVertex3fv(vec);
-
- for (a = 0; a < CIRCLE_RESOL; a++) {
- if (a + start >= CIRCLE_RESOL)
- start = -a + 1;
-
- fac = (float)(-a + (CIRCLE_RESOL - 1)) * tot_inv;
- x = sinval[a + start] * fac;
- y = cosval[a + start] * fac;
-
- vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
- vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
- vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
- glVertex3fv(vec);
- }
- }
-
- glEnd();
-}
-
-/* draws a circle on x-z plane given the scaling of the circle, assuming that
- * all required matrices have been set (used for drawing empties)
- */
-static void drawcircle_size(float size)
-{
- float x, y;
- short degrees;
-
- glBegin(GL_LINE_LOOP);
-
- /* coordinates are: cos(degrees * 11.25) = x, sin(degrees*11.25) = y, 0.0f = z */
- for (degrees = 0; degrees < CIRCLE_RESOL; degrees++) {
- x = cosval[degrees];
- y = sinval[degrees];
-
- glVertex3f(x * size, 0.0f, y * size);
- }
-
- glEnd();
+ gpuImmediateUnformat();
}
/* needs fixing if non-identity matrice used */
static void drawtube(const float vec[3], float radius, float height, float tmat[][4])
{
float cur[3];
- drawcircball(GL_LINE_LOOP, vec, radius, tmat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, radius, tmat);
copy_v3_v3(cur, vec);
cur[2] += height;
- drawcircball(GL_LINE_LOOP, cur, radius, tmat);
-
- glBegin(GL_LINES);
- glVertex3f(vec[0] + radius, vec[1], vec[2]);
- glVertex3f(cur[0] + radius, cur[1], cur[2]);
- glVertex3f(vec[0] - radius, vec[1], vec[2]);
- glVertex3f(cur[0] - radius, cur[1], cur[2]);
- glVertex3f(vec[0], vec[1] + radius, vec[2]);
- glVertex3f(cur[0], cur[1] + radius, cur[2]);
- glVertex3f(vec[0], vec[1] - radius, vec[2]);
- glVertex3f(cur[0], cur[1] - radius, cur[2]);
- glEnd();
+ gpuDrawFastBall(GL_LINE_LOOP, cur, radius, tmat);
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(vec[0] + radius, vec[1], vec[2]);
+ gpuVertex3f(cur[0] + radius, cur[1], cur[2]);
+ gpuVertex3f(vec[0] - radius, vec[1], vec[2]);
+ gpuVertex3f(cur[0] - radius, cur[1], cur[2]);
+ gpuVertex3f(vec[0], vec[1] + radius, vec[2]);
+ gpuVertex3f(cur[0], cur[1] + radius, cur[2]);
+ gpuVertex3f(vec[0], vec[1] - radius, vec[2]);
+ gpuVertex3f(cur[0], cur[1] - radius, cur[2]);
+ gpuEnd();
}
/* needs fixing if non-identity matrice used */
static void drawcone(const float vec[3], float radius, float height, float tmat[][4])
@@ -5561,19 +5548,20 @@ static void drawcone(const float vec[3], float radius, float height, float tmat[
copy_v3_v3(cur, vec);
cur[2] += height;
- drawcircball(GL_LINE_LOOP, cur, radius, tmat);
-
- glBegin(GL_LINES);
- glVertex3f(vec[0], vec[1], vec[2]);
- glVertex3f(cur[0] + radius, cur[1], cur[2]);
- glVertex3f(vec[0], vec[1], vec[2]);
- glVertex3f(cur[0] - radius, cur[1], cur[2]);
- glVertex3f(vec[0], vec[1], vec[2]);
- glVertex3f(cur[0], cur[1] + radius, cur[2]);
- glVertex3f(vec[0], vec[1], vec[2]);
- glVertex3f(cur[0], cur[1] - radius, cur[2]);
- glEnd();
+ gpuDrawFastBall(GL_LINE_LOOP, cur, radius, tmat);
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(vec[0], vec[1], vec[2]);
+ gpuVertex3f(cur[0] + radius, cur[1], cur[2]);
+ gpuVertex3f(vec[0], vec[1], vec[2]);
+ gpuVertex3f(cur[0] - radius, cur[1], cur[2]);
+ gpuVertex3f(vec[0], vec[1], vec[2]);
+ gpuVertex3f(cur[0], cur[1] + radius, cur[2]);
+ gpuVertex3f(vec[0], vec[1], vec[2]);
+ gpuVertex3f(cur[0], cur[1] - radius, cur[2]);
+ gpuEnd();
}
+
/* return TRUE if nothing was drawn */
static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
const short dt, const short dflag, const unsigned char ob_wire_col[4])
@@ -5583,14 +5571,14 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
MetaElem *ml;
float imat[4][4];
int code = 1;
-
+
mb = ob->data;
if (mb->editelems) {
- if ((G.f & G_PICKSEL) == 0) {
+ if (!(G.f & G_PICKSEL)) {
unsigned char wire_col[4];
UI_GetThemeColor4ubv(TH_WIRE, wire_col);
- glColor3ubv(wire_col);
+ gpuCurrentColor3ubv(wire_col);
drawDispList(scene, v3d, rv3d, base, dt, dflag, wire_col);
}
@@ -5600,6 +5588,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
if ((base->flag & OB_FROMDUPLI) == 0) {
drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
+
ml = mb->elems.first;
}
@@ -5615,9 +5604,11 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
normalize_v3(imat[0]);
normalize_v3(imat[1]);
+ gpuImmediateFormat_V3();
+
if (mb->editelems == NULL) {
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
}
@@ -5626,8 +5617,8 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
/* draw radius */
if (mb->editelems) {
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0);
- else cpack(0x3030A0);
+ if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) gpuCurrentColor3x(0xA0A0F0);
+ else gpuCurrentColor3x(0x3030A0);
}
if (G.f & G_PICKSEL) {
@@ -5635,24 +5626,28 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
glLoadName(code++);
}
}
- drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad, imat);
+
+ gpuDrawFastBall(GL_LINE_LOOP, &(ml->x), ml->rad, imat);
/* draw stiffness */
if (mb->editelems) {
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0);
- else cpack(0x30A030);
+ if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) gpuCurrentColor3x(0xA0F0A0);
+ else gpuCurrentColor3x(0x30A030);
}
if (G.f & G_PICKSEL) {
ml->selcol2 = code;
glLoadName(code++);
}
- drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad * atanf(ml->s) / (float)M_PI_2, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, &(ml->x), ml->rad * atanf(ml->s) / (float)M_PI_2, imat);
}
-
+
ml = ml->next;
}
+
+ gpuImmediateUnformat();
+
return FALSE;
}
@@ -5664,6 +5659,8 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
float vec[3] = {0.0, 0.0, 0.0};
float size;
+ gpuImmediateFormat_V3(); // DOODLE: force field
+
/* scale size of circle etc with the empty drawsize */
if (ob->type == OB_EMPTY) size = ob->empty_drawsize;
else size = 1.0;
@@ -5689,15 +5686,14 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
unit_m4(tmat);
force_val *= 0.1f;
- drawcircball(GL_LINE_LOOP, vec, size, tmat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, size, tmat);
vec[2] = 0.5f * force_val;
- drawcircball(GL_LINE_LOOP, vec, size, tmat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, size, tmat);
vec[2] = 1.0f * force_val;
- drawcircball(GL_LINE_LOOP, vec, size, tmat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, size, tmat);
vec[2] = 1.5f * force_val;
- drawcircball(GL_LINE_LOOP, vec, size, tmat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, size, tmat);
vec[2] = 0.0f; /* reset vec for max dist circle */
-
}
else if (pd->forcefield == PFIELD_FORCE) {
float ffall_val;
@@ -5710,11 +5706,11 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
}
if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f);
- drawcircball(GL_LINE_LOOP, vec, size, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, size, imat);
if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val));
- drawcircball(GL_LINE_LOOP, vec, size * 1.5f, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, size * 1.5f, imat);
if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val));
- drawcircball(GL_LINE_LOOP, vec, size * 2.0f, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, vec, size * 2.0f, imat);
}
else if (pd->forcefield == PFIELD_VORTEX) {
float /*ffall_val,*/ force_val;
@@ -5737,12 +5733,12 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
}
if (force_val < 0) {
- drawspiral(vec, size, tmat, 1);
- drawspiral(vec, size, tmat, 16);
+ gpuDrawSpiral(vec, size, tmat, 1);
+ gpuDrawSpiral(vec, size, tmat, 16);
}
else {
- drawspiral(vec, size, tmat, -1);
- drawspiral(vec, size, tmat, -16);
+ gpuDrawSpiral(vec, size, tmat, -1);
+ gpuDrawSpiral(vec, size, tmat, -16);
}
}
else if (pd->forcefield == PFIELD_GUIDE && ob->type == OB_CURVE) {
@@ -5764,12 +5760,12 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
/*path end*/
setlinestyle(3);
where_on_path(ob, 1.0f, guidevec1, guidevec2, NULL, NULL, NULL);
- drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, guidevec1, mindist, imat);
/*path beginning*/
setlinestyle(0);
where_on_path(ob, 0.0f, guidevec1, guidevec2, NULL, NULL, NULL);
- drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat);
+ gpuDrawFastBall(GL_LINE_LOOP, guidevec1, mindist, imat);
copy_v3_v3(vec, guidevec1); /* max center */
}
@@ -5783,11 +5779,13 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
if (pd->falloff == PFIELD_FALL_SPHERE) {
/* as last, guide curve alters it */
- if (pd->flag & PFIELD_USEMAX)
- drawcircball(GL_LINE_LOOP, vec, pd->maxdist, imat);
+ if (pd->flag & PFIELD_USEMAX) {
+ gpuDrawFastBall(GL_LINE_LOOP, vec, pd->maxdist, imat);
+ }
- if (pd->flag & PFIELD_USEMIN)
- drawcircball(GL_LINE_LOOP, vec, pd->mindist, imat);
+ if (pd->flag & PFIELD_USEMIN) {
+ gpuDrawFastBall(GL_LINE_LOOP, vec, pd->mindist, imat);
+ }
}
else if (pd->falloff == PFIELD_FALL_TUBE) {
float radius, distance;
@@ -5835,21 +5833,27 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
}
}
setlinestyle(0);
+
+ gpuImmediateUnformat();
}
static void draw_box(float vec[8][3])
{
- glBegin(GL_LINE_STRIP);
- glVertex3fv(vec[0]); glVertex3fv(vec[1]); glVertex3fv(vec[2]); glVertex3fv(vec[3]);
- glVertex3fv(vec[0]); glVertex3fv(vec[4]); glVertex3fv(vec[5]); glVertex3fv(vec[6]);
- glVertex3fv(vec[7]); glVertex3fv(vec[4]);
- glEnd();
-
- glBegin(GL_LINES);
- glVertex3fv(vec[1]); glVertex3fv(vec[5]);
- glVertex3fv(vec[2]); glVertex3fv(vec[6]);
- glVertex3fv(vec[3]); glVertex3fv(vec[7]);
- glEnd();
+ gpuImmediateFormat_V3();
+
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(vec[0]); gpuVertex3fv(vec[1]); gpuVertex3fv(vec[2]); gpuVertex3fv(vec[3]);
+ gpuVertex3fv(vec[0]); gpuVertex3fv(vec[4]); gpuVertex3fv(vec[5]); gpuVertex3fv(vec[6]);
+ gpuVertex3fv(vec[7]); gpuVertex3fv(vec[4]);
+ gpuEnd();
+
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(vec[1]); gpuVertex3fv(vec[5]);
+ gpuVertex3fv(vec[2]); gpuVertex3fv(vec[6]);
+ gpuVertex3fv(vec[3]); gpuVertex3fv(vec[7]);
+ gpuEnd();
+
+ gpuImmediateUnformat();
}
/* uses boundbox, function used by Ketsji */
@@ -5877,10 +5881,6 @@ static void get_local_bounds(Object *ob, float center[3], float size[3])
static void draw_bb_quadric(BoundBox *bb, char type)
{
float size[3], cent[3];
- GLUquadricObj *qobj = gluNewQuadric();
-
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
-
size[0] = 0.5f * fabsf(bb->vec[0][0] - bb->vec[4][0]);
size[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]);
size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]);
@@ -5888,28 +5888,92 @@ static void draw_bb_quadric(BoundBox *bb, char type)
cent[0] = 0.5f * (bb->vec[0][0] + bb->vec[4][0]);
cent[1] = 0.5f * (bb->vec[0][1] + bb->vec[2][1]);
cent[2] = 0.5f * (bb->vec[0][2] + bb->vec[1][2]);
-
- glPushMatrix();
+
+ gpuPushMatrix();
+
if (type == OB_BOUND_SPHERE) {
- glTranslatef(cent[0], cent[1], cent[2]);
- glScalef(size[0], size[1], size[2]);
- gluSphere(qobj, 1.0, 8, 5);
+ static GPUimmediate *displist = NULL;
+ static GPUindex *index = NULL;
+
+ gpuTranslate(cent[0], cent[1], cent[2]);
+ gpuScale(size[0], size[1], size[2]);
+
+ if (!displist) {
+ GPUprim3 prim = GPU_PRIM_LOFI_WIRE;
+ prim.usegs = 8;
+ prim.vsegs = 5;
+
+ gpuPushImmediate();
+ gpuImmediateMaxVertexCount(48);
+
+ index = gpuNewIndex();
+ gpuImmediateIndex(index);
+ gpuImmediateMaxIndexCount(176);
+
+ gpuSingleSphere(&prim, 1);
+
+ displist = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleRepeatElements(displist);
+ }
}
else if (type == OB_BOUND_CYLINDER) {
+ static GPUimmediate *displist = NULL;
+ static GPUindex *index = NULL;
+
float radius = size[0] > size[1] ? size[0] : size[1];
- glTranslatef(cent[0], cent[1], cent[2] - size[2]);
- glScalef(radius, radius, 2.0f * size[2]);
- gluCylinder(qobj, 1.0, 1.0, 1.0, 8, 1);
+ gpuTranslate(cent[0], cent[1], cent[2] - size[2]);
+ gpuScale(radius, radius, 2.0f * size[2]);
+
+ if (!displist) {
+ GPUprim3 prim = GPU_PRIM_LOFI_WIRE;
+ prim.vsegs = 1;
+
+ gpuPushImmediate();
+ gpuImmediateMaxVertexCount(16);
+
+ index = gpuNewIndex();
+ gpuImmediateIndex(index);
+ gpuImmediateMaxIndexCount(48);
+
+ //GLU Cylinder(qobj, 1.0, 1.0, 1.0, 8, 1);
+ gpuSingleCylinder(&prim, 1, 1, 1);
+ displist = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleRepeatElements(displist);
+ }
}
else if (type == OB_BOUND_CONE) {
+ static GPUimmediate *displist = NULL;
+ static GPUindex *index = NULL;
+
float radius = size[0] > size[1] ? size[0] : size[1];
- glTranslatef(cent[0], cent[1], cent[2] - size[2]);
- glScalef(radius, radius, 2.0f * size[2]);
- gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1);
+ gpuTranslate(cent[0], cent[1], cent[2] - size[2]);
+ gpuScale(radius, radius, 2.0f * size[2]);
+
+ if (!displist) {
+ GPUprim3 prim = GPU_PRIM_LOFI_WIRE;
+ prim.vsegs = 1;
+
+ gpuPushImmediate();
+ gpuImmediateMaxVertexCount(16);
+
+ index = gpuNewIndex();
+ gpuImmediateIndex(index);
+ gpuImmediateMaxIndexCount(48);
+
+ //GLU Cylinder(qobj, 1.0, 0.0, 1.0, 8, 1);
+ gpuSingleCone(&prim, 1, 1);
+ displist = gpuPopImmediate();
+ }
+ else {
+ gpuImmediateSingleRepeatElements(displist);
+ }
}
- glPopMatrix();
-
- gluDeleteQuadric(qobj);
+
+ gpuPopMatrix();
}
static void draw_bounding_volume(Scene *scene, Object *ob, char type)
@@ -5935,7 +5999,7 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type)
bb = BKE_armature_boundbox_get(ob);
}
else {
- drawcube();
+ gpuSingleWireUnitCube();
return;
}
@@ -6037,7 +6101,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign
UI_ThemeColor(TH_WIRE);
}
else {
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
bglPolygonOffset(rv3d->dist, 1.0);
@@ -6077,6 +6141,8 @@ static void draw_hooks(Object *ob)
ModifierData *md;
float vec[3];
+ gpuImmediateFormat_V3();
+
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Hook) {
HookModifierData *hmd = (HookModifierData *) md;
@@ -6085,20 +6151,22 @@ static void draw_hooks(Object *ob)
if (hmd->object) {
setlinestyle(3);
- glBegin(GL_LINES);
- glVertex3fv(hmd->object->obmat[3]);
- glVertex3fv(vec);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(hmd->object->obmat[3]);
+ gpuVertex3fv(vec);
+ gpuEnd();
setlinestyle(0);
}
glPointSize(3.0);
- bglBegin(GL_POINTS);
- bglVertex3fv(vec);
- bglEnd();
+ gpuBeginSprites();
+ gpuSprite3fv(vec);
+ gpuEndSprites();
glPointSize(1.0);
}
}
+
+ gpuImmediateUnformat();
}
static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const short dflag, unsigned char ob_wire_col[4])
@@ -6117,12 +6185,14 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const short d
copy_v3_v3(v, &data->pivX);
dir[axis] = 1.0f;
- glBegin(GL_LINES);
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINES);
mul_m4_v3(mat, dir);
add_v3_v3(v, dir);
- glVertex3fv(&data->pivX);
- glVertex3fv(v);
- glEnd();
+ gpuVertex3fv(&data->pivX);
+ gpuVertex3fv(v);
+ gpuEnd();
+ gpuImmediateUnformat();
/* when const color is set wirecolor is NULL - we could get the current color but
* with selection and group instancing its not needed to draw the text */
@@ -6221,16 +6291,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
Curve *cu;
RegionView3D *rv3d = ar->regiondata;
float vec1[3], vec2[3];
- unsigned int col = 0;
unsigned char _ob_wire_col[4]; /* dont initialize this */
unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */
int i, selstart, selend, empty_object = 0;
short dt, dtx, zbufoff = 0;
const short is_obact = (ob == OBACT);
- /* only once set now, will be removed too, should become a global standard */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
if (ob != scene->obedit) {
if (ob->restrictflag & OB_RESTRICT_VIEW) {
return;
@@ -6287,7 +6353,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
draw_object_wire_color(scene, base, _ob_wire_col, warning_recursive);
ob_wire_col = _ob_wire_col;
- glColor3ubv(ob_wire_col);
+ gpuCurrentColor3ubv(ob_wire_col);
}
/* maximum drawtype */
@@ -6364,7 +6430,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
draw_textcurs(cu->editfont->textcurs);
if (cu->flag & CU_FAST) {
- cpack(0xFFFFFF);
+ gpuCurrentColor3x(CPACK_WHITE);
set_inverted_drawing(1);
drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
set_inverted_drawing(0);
@@ -6382,10 +6448,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
vec1[1] += cu->linedist * cu->fsize;
vec2[1] -= cu->lines * cu->linedist * cu->fsize;
setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
- glEnd();
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2fv(vec1);
+ gpuVertex2fv(vec2);
+ gpuEnd();
+ gpuImmediateUnformat();
setlinestyle(0);
}
@@ -6396,17 +6464,19 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x;
vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize;
vec1[2] = 0.001;
- glBegin(GL_LINE_STRIP);
- glVertex3fv(vec1);
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(vec1);
vec1[0] += cu->tb[i].w;
- glVertex3fv(vec1);
+ gpuVertex3fv(vec1);
vec1[1] -= cu->tb[i].h;
- glVertex3fv(vec1);
+ gpuVertex3fv(vec1);
vec1[0] -= cu->tb[i].w;
- glVertex3fv(vec1);
+ gpuVertex3fv(vec1);
vec1[1] += cu->tb[i].h;
- glVertex3fv(vec1);
- glEnd();
+ gpuVertex3fv(vec1);
+ gpuEnd();
+ gpuImmediateUnformat();
}
}
setlinestyle(0);
@@ -6415,7 +6485,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) {
float selboxw;
- cpack(0xffffff);
+ gpuCurrentColor3x(CPACK_WHITE);
set_inverted_drawing(1);
for (i = 0; i < (selend - selstart + 1); i++) {
SelBox *sb = &(cu->selboxes[i]);
@@ -6429,12 +6499,15 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
else {
selboxw = sb->w;
}
- glBegin(GL_QUADS);
- glVertex3f(sb->x, sb->y, 0.001);
- glVertex3f(sb->x + selboxw, sb->y, 0.001);
- glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001);
- glVertex3f(sb->x, sb->y + sb->h, 0.001);
- glEnd();
+
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_QUADS);
+ gpuVertex3f(sb->x, sb->y, 0.001);
+ gpuVertex3f(sb->x + selboxw, sb->y, 0.001);
+ gpuVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001);
+ gpuVertex3f(sb->x, sb->y + sb->h, 0.001);
+ gpuEnd();
+ gpuImmediateUnformat();
}
set_inverted_drawing(0);
}
@@ -6497,7 +6570,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
case OB_LAMP:
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
drawlamp(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
- if (dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat);
+ if (dtx || (base->flag & SELECT)) gpuMultMatrix(ob->obmat);
}
break;
case OB_CAMERA:
@@ -6548,12 +6621,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if ((sb = ob->soft)) {
if (sb->solverflags & SBSO_ESTIMATEIPO) {
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
copy_m3_m3(msc, sb->lscale);
copy_m3_m3(mrt, sb->lrot);
mul_m3_m3m3(mtr, mrt, msc);
ob_draw_RE_motion(sb->lcom, mtr, tipw, tiph, drawsize);
- glMultMatrixf(ob->obmat);
+ gpuMultMatrix(ob->obmat);
}
}
}
@@ -6571,10 +6644,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
{
ParticleSystem *psys;
- if (col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */
+ if (ob->flag & SELECT) {
+ gpuCurrentColor3x(CPACK_WHITE); /* for visibility, also while wpaint */
+ }
//glDepthMask(GL_FALSE);
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
view3d_cached_text_draw_begin();
@@ -6591,10 +6666,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
invert_m4_m4(ob->imat, ob->obmat);
view3d_cached_text_draw_end(v3d, ar, 0, NULL);
- glMultMatrixf(ob->obmat);
-
+ gpuMultMatrix(ob->obmat);
+
//glDepthMask(GL_TRUE);
- if (col) cpack(col);
}
/* draw edit particles last so that they can draw over child particles */
@@ -6606,10 +6680,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
PTCacheEdit *edit = PE_create_current(scene, ob);
if (edit) {
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
draw_update_ptcache_edit(scene, ob, edit);
draw_ptcache_edit(scene, v3d, edit);
- glMultMatrixf(ob->obmat);
+ gpuMultMatrix(ob->obmat);
}
}
}
@@ -6625,29 +6699,29 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (scs->points) {
size_t i;
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
- if (col || (ob->flag & SELECT)) cpack(0xFFFFFF);
+ if (ob->flag & SELECT) {
+ gpuCurrentColor3x(CPACK_WHITE);
+ }
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
// glPointSize(3.0);
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
for (i = 0; i < scs->numpoints; i++)
{
- bglVertex3fv(&scs->points[3 * i]);
+ gpuSprite3fv(&scs->points[3 * i]);
}
- bglEnd();
+ gpuEndSprites();
glPointSize(1.0);
- glMultMatrixf(ob->obmat);
+ gpuMultMatrix(ob->obmat);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
- if (col) cpack(col);
-
}
#endif
}
@@ -6658,9 +6732,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
float p0[3], p1[3], viewnormal[3];
BoundBox bb;
- glLoadMatrixf(rv3d->viewmat);
- glMultMatrixf(ob->obmat);
+ gpuLoadMatrix(rv3d->viewmat);
+ gpuMultMatrix(ob->obmat);
+ if (ob->flag & SELECT) {
+ gpuCurrentColor3x(CPACK_WHITE);
+ }
+
/* draw adaptive domain bounds */
if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
/* draw domain max bounds */
@@ -6788,16 +6866,16 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
invert_m4_m4(imat, rv3d->viewmatob);
setlinestyle(2);
- drawcircball(GL_LINE_LOOP, vec, ob->inertia, imat);
+ gpuSingleFastBall(GL_LINE_LOOP, vec, ob->inertia, imat);
setlinestyle(0);
}
}
-
+
/* return warning, this is cached text draw */
invert_m4_m4(ob->imat, ob->obmat);
view3d_cached_text_draw_end(v3d, ar, 1, NULL);
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
if (zbufoff) {
glDisable(GL_DEPTH_TEST);
@@ -6827,9 +6905,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (do_draw_center != -1) {
if (dflag & DRAW_PICKING) {
/* draw a single point for opengl selection */
- glBegin(GL_POINTS);
- glVertex3fv(ob->obmat[3]);
- glEnd();
+ gpuImmediateFormat_V3(); // DOODLE: point for selection
+ gpuBegin(GL_POINTS);
+ gpuVertex3fv(ob->obmat[3]);
+ gpuEnd();
+ gpuImmediateUnformat();
}
else if ((dflag & DRAW_CONSTCOLOR) == 0) {
/* we don't draw centers for duplicators and sets */
@@ -6851,10 +6931,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* help lines and so */
if (ob != scene->obedit && ob->parent && (ob->parent->lay & v3d->lay)) {
setlinestyle(3);
- glBegin(GL_LINES);
- glVertex3fv(ob->obmat[3]);
- glVertex3fv(ob->orig);
- glEnd();
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(ob->obmat[3]);
+ gpuVertex3fv(ob->orig);
+ gpuEnd();
+ gpuImmediateUnformat();
setlinestyle(0);
}
@@ -6868,7 +6950,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
UI_GetThemeColor3ubv(TH_GRID, col1);
UI_make_axis_color(col1, col2, 'Z');
- glColor3ubv(col2);
+ gpuCurrentColor3ubv(col2);
cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
@@ -6897,10 +6979,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (camob) {
setlinestyle(3);
- glBegin(GL_LINES);
- glVertex3fv(camob->obmat[3]);
- glVertex3fv(ob->obmat[3]);
- glEnd();
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(camob->obmat[3]);
+ gpuVertex3fv(ob->obmat[3]);
+ gpuEnd();
+ gpuImmediateUnformat();
setlinestyle(0);
}
}
@@ -6915,10 +6999,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
unit_m4(ct->matrix);
setlinestyle(3);
- glBegin(GL_LINES);
- glVertex3fv(ct->matrix[3]);
- glVertex3fv(ob->obmat[3]);
- glEnd();
+ gpuImmediateFormat_V3();
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(ct->matrix[3]);
+ gpuVertex3fv(ob->obmat[3]);
+ gpuEnd();
+ gpuImmediateUnformat();
setlinestyle(0);
}
@@ -6945,7 +7031,7 @@ static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, const floa
if (!(mv->flag & ME_HIDE)) {
WM_framebuffer_index_set(offset + index);
- bglVertex3fv(co);
+ gpuSprite3fv(co);
}
}
@@ -6957,9 +7043,9 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
data.mvert = mvert;
data.offset = (void *)(intptr_t) offset;
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data);
- bglEnd();
+ gpuEndSprites();
glPointSize(1.0);
}
@@ -6972,63 +7058,85 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3]
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
WM_framebuffer_index_set(offset + index);
- bglVertex3fv(co);
+ gpuSprite3fv(co);
}
}
+
static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
{
void *ptrs[2] = {(void *)(intptr_t) offset, em};
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
- bglBegin(GL_POINTS);
+
+ gpuImmediateFormat_C4_V3();
+
+ gpuBeginSprites();
dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, ptrs);
- bglEnd();
+ gpuEndSprites();
+
+ gpuImmediateUnformat();
+
glPointSize(1.0);
}
-static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index)
+typedef struct mesh_wire_options {
+ BMEditMesh* em;
+ size_t offset;
+} mesh_wire_options;
+
+static DMDrawOption bbs_mesh_wire__setDrawOptions(mesh_wire_options *opts, int index)
{
- void **ptrs = userData;
- int offset = (intptr_t) ptrs[0];
- BMEdge *eed = EDBM_edge_at_index(ptrs[1], index);
+ BMEdge *eed = EDBM_edge_at_index(opts->em, index);
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- WM_framebuffer_index_set(offset + index);
- return DM_DRAW_OPTION_NORMAL;
+ WM_framebuffer_index_set(opts->offset + index);
+ return DM_DRAW_OPTION_NORMALLY;
}
else {
return DM_DRAW_OPTION_SKIP;
}
}
-static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
+
+static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, size_t offset)
{
- void *ptrs[2] = {(void *)(intptr_t) offset, em};
- dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, ptrs);
+ mesh_wire_options opts;
+
+ opts.em = em;
+ opts.offset = offset;
+
+ gpuImmediateFormat_C4_V3();
+ dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, &opts);
+ gpuImmediateUnformat();
}
-static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int index)
+typedef struct mesh_solid_options {
+ BMEditMesh* em;
+ int facecol;
+} mesh_solid_options;
+
+static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(mesh_solid_options *opts, int index)
{
- BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index);
+ BMFace *efa = EDBM_face_at_index(opts->em, index);
if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- if (((void **)userData)[1]) {
+ if (opts->facecol) {
WM_framebuffer_index_set(index + 1);
}
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
}
else {
return DM_DRAW_OPTION_SKIP;
}
}
-static void bbs_mesh_solid__drawCenter(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
+static void bbs_mesh_solid__drawCenter(mesh_solid_options *opts, int index, const float cent[3], const float UNUSED(no[3]))
{
- BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index);
+ BMFace *efa = EDBM_face_at_index(opts->em, index);
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
WM_framebuffer_index_set(index + 1);
- bglVertex3fv(cent);
+ gpuSprite3fv(cent);
}
}
@@ -7036,40 +7144,54 @@ static void bbs_mesh_solid__drawCenter(void *userData, int index, const float ce
static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
Object *ob, DerivedMesh *dm, int facecol)
{
- void *ptrs[2] = {em, NULL}; //second one being null means to draw black
- cpack(0);
+ mesh_solid_options opts;
- if (facecol) {
- ptrs[1] = (void *)(intptr_t) 1;
- dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, GPU_enable_material, NULL, ptrs, 0);
+ opts.em = em;
+ opts.facecol = facecol;
- if (check_ob_drawface_dot(scene, v3d, ob->dt)) {
- glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
+ if (opts.facecol) {
+ gpuImmediateFormat_C4_V3();
+ }
+ else {
+ gpuCurrentColor3x(CPACK_BLACK);
+ gpuImmediateFormat_V3();
+ }
- bglBegin(GL_POINTS);
- dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, ptrs);
- bglEnd();
- }
+ dm->drawMappedFaces(
+ dm,
+ bbs_mesh_solid__setSolidDrawOptions,
+ GPU_enable_material,
+ NULL,
+ &opts,
+ 0);
+ if (!(opts.facecol)) {
+ gpuImmediateUnformat();
+ gpuImmediateFormat_C4_V3();
}
- else {
- dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, GPU_enable_material, NULL, ptrs, 0);
+
+ if (facecol && check_ob_drawface_dot(scene, v3d, ob->dt)) {
+ glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
+
+ gpuBeginSprites();
+ dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, &opts);
+ gpuEndSprites();
}
+
+ gpuImmediateUnformat();
}
static DMDrawOption bbs_mesh_solid__setDrawOpts(void *UNUSED(userData), int index)
{
- WM_framebuffer_index_set(index + 1);
- return DM_DRAW_OPTION_NORMAL;
+ WM_set_framebuffer_index_current_color(index + 1);
+ return DM_DRAW_OPTION_NORMALLY;
}
-static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index)
+static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(Mesh *me, int index)
{
- Mesh *me = userData;
-
if (!(me->mpoly[index].flag & ME_HIDE)) {
- WM_framebuffer_index_set(index + 1);
- return DM_DRAW_OPTION_NORMAL;
+ WM_set_framebuffer_index_current_color(index + 1);
+ return DM_DRAW_OPTION_NORMALLY;
}
else {
return DM_DRAW_OPTION_SKIP;
@@ -7077,12 +7199,10 @@ static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index)
}
/* must have called WM_framebuffer_index_set beforehand */
-static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index)
+static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(Mesh *me, int index)
{
- Mesh *me = userData;
-
if (!(me->mpoly[index].flag & ME_HIDE)) {
- return DM_DRAW_OPTION_NORMAL;
+ return DM_DRAW_OPTION_NORMALLY;
}
else {
return DM_DRAW_OPTION_SKIP;
@@ -7092,14 +7212,16 @@ static void bbs_mesh_solid(Scene *scene, Object *ob)
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
Mesh *me = (Mesh *)ob->data;
-
- glColor3ub(0, 0, 0);
+
+ gpuImmediateFormat_C4_V3();
if ((me->editflag & ME_EDIT_PAINT_MASK))
dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, GPU_enable_material, NULL, me, 0);
else
dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, GPU_enable_material, NULL, me, 0);
+ gpuImmediateUnformat();
+
dm->release(dm);
}
@@ -7107,9 +7229,9 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
{
ToolSettings *ts = scene->toolsettings;
- glMultMatrixf(ob->obmat);
+ gpuMultMatrix(ob->obmat);
- glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT);
+ /*glClearDepth(1.0); */gpuClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
switch (ob->type) {
@@ -7156,10 +7278,11 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
(ob->mode & OB_MODE_WEIGHT_PAINT))
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
- glColor3ub(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
+ gpuImmediateFormat_V3();
dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, GPU_enable_material, NULL, me, 0);
-
+ gpuImmediateUnformat();
bbs_obmode_mesh_verts(ob, dm, 1);
bm_vertoffs = me->totvert + 1;
@@ -7175,7 +7298,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
break;
}
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
}
@@ -7210,22 +7333,25 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
}
else {
- glEnable(GL_COLOR_MATERIAL);
+ gpuEnableColorMaterial();
UI_ThemeColor(TH_BONE_SOLID);
- glDisable(GL_COLOR_MATERIAL);
+ gpuDisableColorMaterial();
}
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- glEnable(GL_LIGHTING);
+ gpuEnableLighting();
if (dm) {
dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
GPU_end_object_materials();
}
- else if (edm)
- edm->drawMappedFaces(edm, NULL, GPU_enable_material, NULL, NULL, 0);
-
- glDisable(GL_LIGHTING);
+ else if (edm) {
+ gpuImmediateFormat_N3_V3();
+ edm->drawMappedFaces(edm, NULL, GPU_enable_material, NULL, NULL, DM_DRAW_USE_NORMALS);
+ gpuImmediateUnformat();
+ }
+
+ gpuDisableLighting();
}
if (edm) edm->release(edm);
diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index ebb48960b80..f60c0ea6075 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -67,8 +67,9 @@
#include "smoke_API.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
+#include "GPU_colors.h"
#include "GPU_extensions.h"
#include "ED_mesh.h"
@@ -264,8 +265,7 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
"CMP result.color, render.r, temp, spec;\n"
"END\n";
- GLuint prog;
-
+ static GLuint prog;
float size[3];
@@ -403,7 +403,7 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
// printf("i: %d\n", i);
// printf("point %f, %f, %f\n", cv[i][0], cv[i][1], cv[i][2]);
- if (GL_TRUE == glewIsSupported("GL_ARB_fragment_program")) {
+ if (prog == 0 && GLEW_ARB_fragment_program) {
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glGenProgramsARB(1, &prog);
@@ -493,30 +493,37 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
}
/* render fire slice */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE); /* non-default blend function */
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, 1.0, 0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glColor3f(1.0, 1.0, 1.0);
+ gpuImmediateFormat_T3_C4_V3();
+ gpuBegin(GL_TRIANGLE_FAN);
+ gpuCurrentColor3x(CPACK_WHITE);
for (i = 0; i < numpoints; i++) {
- glTexCoord3d((points[i * 3 + 0] - min[0]) * cor[0] / size[0],
- (points[i * 3 + 1] - min[1]) * cor[1] / size[1],
- (points[i * 3 + 2] - min[2]) * cor[2] / size[2]);
- glVertex3f(points[i * 3 + 0] / ob->size[0], points[i * 3 + 1] / ob->size[1], points[i * 3 + 2] / ob->size[2]);
+ gpuTexCoord3f(
+ (points[i * 3 + 0] - min[0]) * cor[0] / size[0],
+ (points[i * 3 + 1] - min[1]) * cor[1] / size[1],
+ (points[i * 3 + 2] - min[2]) * cor[2] / size[2]);
+ gpuVertex3f(
+ points[i * 3 + 0] / ob->size[0],
+ points[i * 3 + 1] / ob->size[1],
+ points[i * 3 + 2] / ob->size[2]);
}
- glEnd();
+ gpuEnd();
/* render smoke slice */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, -1.0, 0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glColor3f(1.0, 1.0, 1.0);
+ gpuBegin(GL_POLYGON);
+ gpuColor3f(1.0, 1.0, 1.0);
for (i = 0; i < numpoints; i++) {
- glTexCoord3d((points[i * 3 + 0] - min[0]) * cor[0] / size[0],
- (points[i * 3 + 1] - min[1]) * cor[1] / size[1],
- (points[i * 3 + 2] - min[2]) * cor[2] / size[2]);
- glVertex3f(points[i * 3 + 0] / ob->size[0], points[i * 3 + 1] / ob->size[1], points[i * 3 + 2] / ob->size[2]);
+ gpuTexCoord3f((points[i * 3 + 0] - min[0]) * cor[0] / size[0],
+ (points[i * 3 + 1] - min[1]) * cor[1] / size[1],
+ (points[i * 3 + 2] - min[2]) * cor[2] / size[2]);
+ gpuVertex3f(points[i * 3 + 0] / ob->size[0], points[i * 3 + 1] / ob->size[1], points[i * 3 + 2] / ob->size[2]);
}
- glEnd();
+ gpuEnd();
+ gpuImmediateUnformat();
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* return to default blend function */
}
n++;
}
@@ -538,10 +545,9 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
if (GLEW_ARB_fragment_program) {
glDisable(GL_FRAGMENT_PROGRAM_ARB);
- glDeleteProgramsARB(1, &prog);
+ /* XXX: should eventually delete 'prog' but when and how? */
}
-
MEM_freeN(points);
if (!gl_blend) {
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 4964c0054ac..26eebd16fba 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -50,8 +50,7 @@
#include "ED_screen.h"
#include "ED_object.h"
-#include "BIF_gl.h"
-
+#include "GPU_compatibility.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -64,6 +63,8 @@
#include "view3d_intern.h" /* own include */
+#include "GPU_compatibility.h"
+
/* ******************** manage regions ********************* */
ARegion *view3d_has_buttons_region(ScrArea *sa)
@@ -236,7 +237,7 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d)
/* we have to multiply instead of loading viewmatob to make
* it work with duplis using displists, otherwise it will
* override the dupli-matrix */
- glMultMatrixf(ob->obmat);
+ gpuMultMatrix(ob->obmat);
}
/* ******************** default callbacks for view3d space ***************** */
diff --git a/source/blender/editors/space_view3d/view3d_composite.c b/source/blender/editors/space_view3d/view3d_composite.c
new file mode 100644
index 00000000000..980d14c2fdf
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_composite.c
@@ -0,0 +1,28 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Jason Wilkins
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/view3d_composite.c
+ * \ingroup spview3d
+ */
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index f4547a2ae3b..10480a3872a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -71,7 +71,6 @@
#include "IMB_imbuf.h"
#include "IMB_colormanagement.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "WM_api.h"
@@ -89,6 +88,9 @@
#include "UI_interface_icons.h"
#include "UI_resources.h"
+#include "GPU_colors.h"
+#define GPU_MANGLE_DEPRECATED 0
+#include "GPU_primitives.h"
#include "GPU_draw.h"
#include "GPU_material.h"
#include "GPU_extensions.h"
@@ -108,54 +110,21 @@ extern void bl_debug_draw_edge_add(const float v0[3], const float v1[3]);
static void star_stuff_init_func(void)
{
- cpack(0xFFFFFF);
+ gpuImmediateFormat_V3();
+ gpuCurrentColor3x(CPACK_WHITE);
glPointSize(1.0);
- glBegin(GL_POINTS);
+ gpuBegin(GL_POINTS);
}
static void star_stuff_vertex_func(float *i)
{
- glVertex3fv(i);
+ gpuVertex3fv(i);
}
static void star_stuff_term_func(void)
{
- glEnd();
+ gpuEnd();
+ gpuImmediateUnformat();
}
-void circf(float x, float y, float rad)
-{
- GLUquadricObj *qobj = gluNewQuadric();
-
- gluQuadricDrawStyle(qobj, GLU_FILL);
-
- glPushMatrix();
-
- glTranslatef(x, y, 0.0);
-
- gluDisk(qobj, 0.0, rad, 32, 1);
-
- glPopMatrix();
-
- gluDeleteQuadric(qobj);
-}
-
-void circ(float x, float y, float rad)
-{
- GLUquadricObj *qobj = gluNewQuadric();
-
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
-
- glPushMatrix();
-
- glTranslatef(x, y, 0.0);
-
- gluDisk(qobj, 0.0, rad, 32, 1);
-
- glPopMatrix();
-
- gluDeleteQuadric(qobj);
-}
-
-
/* ********* custom clipping *********** */
static void view3d_draw_clipping(RegionView3D *rv3d)
@@ -163,26 +132,30 @@ static void view3d_draw_clipping(RegionView3D *rv3d)
BoundBox *bb = rv3d->clipbb;
if (bb) {
- static unsigned int clipping_index[6][4] = {
+ static const unsigned int clipping_index[6][4] = {
{0, 1, 2, 3},
{0, 4, 5, 1},
{4, 7, 6, 5},
{7, 3, 2, 6},
{1, 5, 6, 2},
- {7, 4, 0, 3}
+ {7, 4, 0, 3},
};
- /* fill in zero alpha for rendering & re-projection [#31530] */
unsigned char col[4];
+
+ /* fill in zero alpha for rendering & re-projection [#31530] */
UI_GetThemeColorShade3ubv(TH_BACK, -8, col);
col[3] = 0;
- glColor4ubv(col);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, bb->vec);
- glDrawElements(GL_QUADS, sizeof(clipping_index) / sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index);
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuCurrentColor4ubv(col);
+ gpuSingleClientRangeElements_V3F(
+ GL_QUADS,
+ bb->vec,
+ 0,
+ 0,
+ 7,
+ sizeof(clipping_index) / sizeof(unsigned int),
+ clipping_index);
}
}
@@ -242,38 +215,41 @@ int ED_view3d_clipping_test(RegionView3D *rv3d, const float vec[3], const int is
static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, double dx)
-{
- double verts[2][2];
+{
+ float verts[2][2];
x += (wx);
y += (wy);
+ gpuImmediateFormat_V2();
+ gpuBegin(GL_LINES);
+
/* set fixed 'Y' */
verts[0][1] = 0.0f;
- verts[1][1] = (double)ar->winy;
+ verts[1][1] = (float)ar->winy;
/* iter over 'X' */
verts[0][0] = verts[1][0] = x - dx * floor(x / dx);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_DOUBLE, 0, verts);
while (verts[0][0] < ar->winx) {
- glDrawArrays(GL_LINES, 0, 2);
+ gpuAppendLinef(verts[0][0], verts[0][1], verts[1][0], verts[1][1]);
verts[0][0] = verts[1][0] = verts[0][0] + dx;
}
/* set fixed 'X' */
verts[0][0] = 0.0f;
- verts[1][0] = (double)ar->winx;
+ verts[1][0] = (float)ar->winx;
/* iter over 'Y' */
verts[0][1] = verts[1][1] = y - dx * floor(y / dx);
+
while (verts[0][1] < ar->winy) {
- glDrawArrays(GL_LINES, 0, 2);
+ gpuAppendLinef(verts[0][0], verts[0][1], verts[1][0], verts[1][1]);
verts[0][1] = verts[1][1] = verts[0][1] + dx;
}
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuEnd();
+ gpuImmediateUnformat();
}
#define GRID_MIN_PX_D 6.0
@@ -429,23 +405,37 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
UI_GetThemeColor3ubv(TH_GRID, col);
setlinestyle(0);
-
+
+ gpuImmediateFormat_V3(); // DOODLE: grid floor axis, 2 standard colored lines
+ gpuBegin(GL_LINES);
+
/* center cross */
/* horizontal line */
- if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
+ if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) {
UI_make_axis_color(col, col2, 'Y');
- else UI_make_axis_color(col, col2, 'X');
- glColor3ubv(col2);
+ }
+ else {
+ UI_make_axis_color(col, col2, 'X');
+ }
+
+ gpuColor3ubv(col2);
- fdrawline(0.0, y, (float)ar->winx, y);
+ gpuAppendLinef(0.0, y, (float)ar->winx, y);
/* vertical line */
- if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
+ if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) {
UI_make_axis_color(col, col2, 'Y');
- else UI_make_axis_color(col, col2, 'Z');
- glColor3ubv(col2);
+ }
+ else {
+ UI_make_axis_color(col, col2, 'Z');
+ }
+
+ gpuColor3ubv(col2);
- fdrawline(x, 0.0, x, (float)ar->winy);
+ gpuAppendLinef(x, 0.0, x, (float)ar->winy);
+
+ gpuEnd();
+ gpuImmediateUnformat();
glDepthMask(1); /* enable write in zbuffer */
}
@@ -492,7 +482,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
/* draw the Y axis and/or grid lines */
if (v3d->gridflag & V3D_SHOW_FLOOR) {
- float vert[4][3] = {{0.0f}};
+ float vert[4][2];
unsigned char col_bg[3];
unsigned char col_grid_emphasise[3], col_grid_light[3];
int a;
@@ -507,28 +497,30 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
(col_bg[0] + col_bg[1] + col_bg[2])) ? 20 : -10);
/* set fixed axis */
- vert[0][0] = vert[2][1] = grid;
+ vert[0][0] = vert[2][1] = grid;
vert[1][0] = vert[3][1] = -grid;
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, vert);
+ gpuImmediateFormat_C4_V2();
+ gpuBegin(GL_LINES);
for (a = -gridlines; a <= gridlines; a++) {
const float line = a * grid_scale;
const int is_emphasise = (a % 10) == 0;
if (is_emphasise != prev_emphasise) {
- glColor3ubv(is_emphasise ? col_grid_emphasise : col_grid_light);
+ gpuColor3ubv(is_emphasise ? col_grid_emphasise : col_grid_light);
prev_emphasise = is_emphasise;
}
/* set variable axis */
vert[0][1] = vert[1][1] = vert[2][0] = vert[3][0] = line;
- glDrawArrays(GL_LINES, 0, 4);
+ gpuAppendLinef(vert[0][0], vert[0][1], vert[1][0], vert[1][1]);
+ gpuAppendLinef(vert[2][0], vert[2][1], vert[3][0], vert[3][1]);
}
- glDisableClientState(GL_VERTEX_ARRAY);
+ gpuEnd();
+ gpuImmediateUnformat();
GPU_print_error("sdsd");
}
@@ -537,23 +529,28 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
/* check for the 'show Z axis' preference */
if (v3d->gridflag & (V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) {
int axis;
+
+ gpuImmediateFormat_C4_V3();
+ gpuBegin(GL_LINES);
+
for (axis = 0; axis < 3; axis++) {
if (v3d->gridflag & (V3D_SHOW_X << axis)) {
float vert[3];
unsigned char tcol[3];
UI_make_axis_color(col_grid, tcol, 'X' + axis);
- glColor3ubv(tcol);
+ gpuColor3ubv(tcol);
- glBegin(GL_LINE_STRIP);
zero_v3(vert);
vert[axis] = grid;
- glVertex3fv(vert);
+ gpuVertex3fv(vert);
vert[axis] = -grid;
- glVertex3fv(vert);
- glEnd();
+ gpuVertex3fv(vert);
}
}
+
+ gpuEnd();
+ gpuImmediateUnformat();
}
if (v3d->zbuf && scene->obedit) glDepthMask(1);
@@ -565,19 +562,69 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
/* we don't want the clipping for cursor */
if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
+ gpuImmediateFormat_V2(); // DOODLE: view3d cursor, 2 stippled circles, 4 mono lines
+
setlinestyle(0);
- cpack(0xFF);
- circ((float)co[0], (float)co[1], 10.0);
+ gpuCurrentColor3x(CPACK_BLUE);
+ gpuDrawCircle((float)co[0], (float)co[1], 10.0, 32);
+
setlinestyle(4);
- cpack(0xFFFFFF);
- circ((float)co[0], (float)co[1], 10.0);
+ gpuCurrentColor3x(CPACK_WHITE);
+ gpuRepeat();
+
setlinestyle(0);
- cpack(0x0);
-
- sdrawline(co[0] - 20, co[1], co[0] - 5, co[1]);
- sdrawline(co[0] + 5, co[1], co[0] + 20, co[1]);
- sdrawline(co[0], co[1] - 20, co[0], co[1] - 5);
- sdrawline(co[0], co[1] + 5, co[0], co[1] + 20);
+ gpuCurrentColor3x(CPACK_BLACK);
+
+ gpuBegin(GL_LINES);
+ gpuAppendLinei(co[0] - 20, co[1], co[0] - 5, co[1]);
+ gpuAppendLinei(co[0] + 5, co[1], co[0] + 20, co[1]);
+ gpuAppendLinei(co[0], co[1] - 20, co[0], co[1] - 5);
+ gpuAppendLinei(co[0], co[1] + 5, co[0], co[1] + 20);
+ gpuEnd();
+
+ gpuImmediateUnformat();
+ }
+}
+
+static void sort3(int sort[3], float a, float b, float c)
+{
+ if (a < b) {
+ if (a < c) {
+ sort[0] = 0;
+
+ if (b < c) {
+ sort[1] = 1;
+ sort[2] = 2;
+ }
+ else {
+ sort[1] = 2;
+ sort[2] = 1;
+ }
+ }
+ else {
+ sort[0] = 2;
+ sort[1] = 0;
+ sort[2] = 1;
+ }
+ }
+ else {
+ if (b < c) {
+ sort[0] = 1;
+
+ if (a < c) {
+ sort[1] = 0;
+ sort[2] = 2;
+ }
+ else {
+ sort[1] = 2;
+ sort[2] = 0;
+ }
+ }
+ else {
+ sort[0] = 2;
+ sort[1] = 1;
+ sort[2] = 0;
+ }
}
}
@@ -585,81 +632,108 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
* colors copied from transform_manipulator.c, we should keep these matching. */
static void draw_view_axis(RegionView3D *rv3d)
{
- const float k = U.rvisize; /* axis size */
- const float toll = 0.5; /* used to see when view is quasi-orthogonal */
- const float start = k + 1.0f; /* axis center in screen coordinates, x=y */
- float ydisp = 0.0; /* vertical displacement to allow obj info text */
- int bright = 25 * (float)U.rvibright + 5; /* axis alpha (rvibright has range 0-10) */
+ /* axis size */
+ const float k = U.rvisize;
- float vec[3];
- float dx, dy;
-
- /* thickness of lines is proportional to k */
- glLineWidth(2);
+ /* line width is proportional to size */
+ const float size = k/25.0f;
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ /* axis center in screen coordinates, x=y=z */
+ const float start = k + 1.0f;
+ float origin[3] =
+ { start, start, start };
- /* X */
- vec[0] = 1;
- vec[1] = vec[2] = 0;
- mul_qt_v3(rv3d->viewquat, vec);
- dx = vec[0] * k;
- dy = vec[1] * k;
-
- UI_ThemeColorShadeAlpha(TH_AXIS_X, 0, bright);
- glBegin(GL_LINES);
- glVertex2f(start, start + ydisp);
- glVertex2f(start + dx, start + dy + ydisp);
- glEnd();
+ /* used to see when view is quasi-orthogonal */
+ const float toll = 0.5;
- if (fabsf(dx) > toll || fabsf(dy) > toll) {
- BLF_draw_default_ascii(start + dx + 2, start + dy + ydisp + 2, 0.0f, "x", 1);
- }
+ /* axis alpha (rvibright has range 0-10) */
+ const int bright = 25*U.rvibright + U.rvibright/51;
- /* BLF_draw_default disables blending */
- glEnable(GL_BLEND);
+ float axis[3][3] = {
+ { 1, 0, 0 },
+ { 0, 1, 0 },
+ { 0, 0, 1 },
+ };
+
+ float offset[3][3] = {
+ { size, 0, 0 },
+ { 0, size, 0 },
+ { 0, 0, size },
+ };
- /* Y */
- vec[1] = 1;
- vec[0] = vec[2] = 0;
- mul_qt_v3(rv3d->viewquat, vec);
- dx = vec[0] * k;
- dy = vec[1] * k;
+ const unsigned char label[] = "xyz";
+ GLboolean showLabel[3];
+
+ GLubyte color[3][4];
- UI_ThemeColorShadeAlpha(TH_AXIS_Y, 0, bright);
- glBegin(GL_LINES);
- glVertex2f(start, start + ydisp);
- glVertex2f(start + dx, start + dy + ydisp);
- glEnd();
+ const GLfloat jitter[4][3] = {
+ { -size/2, 0, 0 },
+ { 0, -size/2, 0 },
+ { size/2, 0, 0 },
+ { 0, size/2, 0 },
+ };
+
+ int sort[3];
+
+ int i;
+
+ UI_GetThemeColor3ubv(TH_AXIS_X, color[0]);
+ UI_GetThemeColor3ubv(TH_AXIS_Y, color[1]);
+ UI_GetThemeColor3ubv(TH_AXIS_Z, color[2]);
+
+ color[0][3] = color[1][3] = color [2][3] = bright;
+
+ for (i = 0; i < 3; i++) {
+ mul_qt_v3(rv3d->viewquat, axis[i]);
+ mul_qt_v3(rv3d->viewquat, offset[i]);
+ mul_v3_fl(axis[i], k);
+
+ showLabel[i] = fabsf(axis[i][0]) > toll || fabsf(axis[i][1]) > toll;
- if (fabsf(dx) > toll || fabsf(dy) > toll) {
- BLF_draw_default_ascii(start + dx + 2, start + dy + ydisp + 2, 0.0f, "y", 1);
+ add_v3_v3(axis[i], origin);
+ add_v3_v3(offset[i], origin);
}
+ sort3(sort, axis[0][2], axis[1][2], axis[2][2]);
+
+ glLineWidth(size);
glEnable(GL_BLEND);
-
- /* Z */
- vec[2] = 1;
- vec[1] = vec[0] = 0;
- mul_qt_v3(rv3d->viewquat, vec);
- dx = vec[0] * k;
- dy = vec[1] * k;
+ gpuImmediateFormat_C4_V2();
+ gpuBegin(GL_LINES);
+ for (i = 0; i < 3; i++) {
+ if (showLabel[sort[i]]) {
+ int j;
+ GLfloat p0[3], p1[3];
- UI_ThemeColorShadeAlpha(TH_AXIS_Z, 0, bright);
- glBegin(GL_LINES);
- glVertex2f(start, start + ydisp);
- glVertex2f(start + dx, start + dy + ydisp);
- glEnd();
+ gpuColor4ub(color[sort[i]][0], color[sort[i]][1], color[sort[i]][2], bright / 2);
- if (fabsf(dx) > toll || fabsf(dy) > toll) {
- BLF_draw_default_ascii(start + dx + 2, start + dy + ydisp + 2, 0.0f, "z", 1);
- }
+ for (j = 0; j < 4; j++) {
+ add_v3_v3v3(p0, offset[sort[i]], jitter[j]);
+ add_v3_v3v3(p1, axis[sort[i]], jitter[j]);
- /* restore line-width */
-
- glLineWidth(1.0);
+ gpuVertex2fv(p0);
+ gpuVertex2fv(p1);
+ }
+ }
+ }
+ gpuEnd();
+ gpuImmediateUnformat();
glDisable(GL_BLEND);
+ glLineWidth(1.0);
+
+ BLF_draw_default_lock();
+ for (i = 0; i < 3; i++) {
+ if (showLabel[sort[i]]) {
+ gpuCurrentColor4ubv(color[sort[i]]);
+ BLF_draw_default_ascii(
+ axis[sort[i]][0] + size,
+ axis[sort[i]][1] + size,
+ 0,
+ label + sort[i],
+ 1);
+ }
+ }
+ BLF_draw_default_unlock();
}
/* draw center and axis of rotation for ongoing 3D mouse navigation */
@@ -673,7 +747,6 @@ static void draw_rotation_guide(RegionView3D *rv3d)
negate_v3_v3(o, rv3d->ofs);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel(GL_SMOOTH);
glPointSize(5);
glEnable(GL_POINT_SMOOTH);
@@ -686,24 +759,24 @@ static void draw_rotation_guide(RegionView3D *rv3d)
mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale);
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
color[3] = 0.f; /* more transparent toward the ends */
- glColor4fv(color);
+ gpuColor4fv(color);
add_v3_v3v3(end, o, scaled_axis);
- glVertex3fv(end);
+ gpuVertex3fv(end);
// color[3] = 0.2f + fabsf(rv3d->rot_angle); /* modulate opacity with angle */
// ^^ neat idea, but angle is frame-rate dependent, so it's usually close to 0.2
color[3] = 0.5f; /* more opaque toward the center */
- glColor4fv(color);
- glVertex3fv(o);
+ gpuColor4fv(color);
+ gpuVertex3fv(o);
color[3] = 0.f;
- glColor4fv(color);
+ gpuColor4fv(color);
sub_v3_v3v3(end, o, scaled_axis);
- glVertex3fv(end);
- glEnd();
+ gpuVertex3fv(end);
+ gpuEnd();
/* -- draw ring around rotation center -- */
{
@@ -726,8 +799,8 @@ static void draw_rotation_guide(RegionView3D *rv3d)
}
color[3] = 0.25f; /* somewhat faint */
- glColor4fv(color);
- glBegin(GL_LINE_LOOP);
+ gpuCurrentColor4fv(color);
+ gpuBegin(GL_LINE_LOOP);
for (i = 0, angle = 0.f; i < ROT_AXIS_DETAIL; ++i, angle += step) {
float p[3] = {s * cosf(angle), s * sinf(angle), 0.0f};
@@ -736,9 +809,9 @@ static void draw_rotation_guide(RegionView3D *rv3d)
}
add_v3_v3(p, o);
- glVertex3fv(p);
+ gpuVertex3fv(p);
}
- glEnd();
+ gpuEnd();
#undef ROT_AXIS_DETAIL
}
@@ -749,10 +822,10 @@ static void draw_rotation_guide(RegionView3D *rv3d)
color[3] = 0.5f; /* see-through dot */
/* -- draw rotation center -- */
- glColor4fv(color);
- glBegin(GL_POINTS);
- glVertex3fv(o);
- glEnd();
+ gpuCurrentColor4fv(color);
+ gpuBegin(GL_POINTS);
+ gpuVertex3fv(o);
+ gpuEnd();
/* find screen coordinates for rotation center, then draw pretty icon */
#if 0
@@ -779,7 +852,6 @@ static void draw_view_icon(RegionView3D *rv3d)
else return;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UI_icon_draw(5.0, 5.0, icon);
@@ -1002,19 +1074,12 @@ static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float f
x4 = x1 + (1.0f - fac) * (x2 - x1);
y4 = y1 + (1.0f - fac) * (y2 - y1);
- glBegin(GL_LINES);
- glVertex2f(x1, y3);
- glVertex2f(x2, y3);
-
- glVertex2f(x1, y4);
- glVertex2f(x2, y4);
-
- glVertex2f(x3, y1);
- glVertex2f(x3, y2);
-
- glVertex2f(x4, y1);
- glVertex2f(x4, y2);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuAppendLinef(x1, y3, x2, y3);
+ gpuAppendLinef(x1, y4, x2, y4);
+ gpuAppendLinef(x3, y1, x3, y2);
+ gpuAppendLinef(x4, y1, x4, y2);
+ gpuEnd();
}
/* harmonious triangle */
@@ -1024,7 +1089,7 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons
float w = x2 - x1;
float h = y2 - y1;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
if (w > h) {
if (golden) {
ofs = w * (1.0f - (1.0f / 1.61803399f));
@@ -1034,14 +1099,9 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons
}
if (dir == 'B') SWAP(float, y1, y2);
- glVertex2f(x1, y1);
- glVertex2f(x2, y2);
-
- glVertex2f(x2, y1);
- glVertex2f(x1 + (w - ofs), y2);
-
- glVertex2f(x1, y2);
- glVertex2f(x1 + ofs, y1);
+ gpuAppendLinef(x1, y1, x2, y2);
+ gpuAppendLinef(x2, y1, x1 + (w - ofs), y2);
+ gpuAppendLinef(x1, y2, x1 + ofs, y1);
}
else {
if (golden) {
@@ -1052,16 +1112,11 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons
}
if (dir == 'B') SWAP(float, x1, x2);
- glVertex2f(x1, y1);
- glVertex2f(x2, y2);
-
- glVertex2f(x2, y1);
- glVertex2f(x1, y1 + ofs);
-
- glVertex2f(x1, y2);
- glVertex2f(x2, y1 + (h - ofs));
+ gpuAppendLinef(x1, y1, x2, y2);
+ gpuAppendLinef(x2, y1, x1, y1 + ofs);
+ gpuAppendLinef(x1, y2, x2, y1 + (h - ofs));
}
- glEnd();
+ gpuEnd();
}
static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
@@ -1073,19 +1128,21 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
rctf viewborder;
Camera *ca = NULL;
RegionView3D *rv3d = (RegionView3D *)ar->regiondata;
-
+
+ gpuImmediateFormat_V2();
+
if (v3d->camera == NULL)
return;
if (v3d->camera->type == OB_CAMERA)
ca = v3d->camera->data;
-
+
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
/* the offsets */
x1 = viewborder.xmin;
y1 = viewborder.ymin;
x2 = viewborder.xmax;
y2 = viewborder.ymax;
-
+
/* apply offsets so the real 3D camera shows through */
/* note: quite un-scientific but without this bit extra
@@ -1101,38 +1158,35 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
/* passepartout, specified in camera edit buttons */
if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) {
if (ca->passepartalpha == 1.0f) {
- glColor3f(0, 0, 0);
+ gpuCurrentColor3x(CPACK_BLACK);
}
else {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- glColor4f(0, 0, 0, ca->passepartalpha);
+ gpuCurrentColor4f(0, 0, 0, ca->passepartalpha);
}
if (x1i > 0.0f)
- glRectf(0.0, (float)ar->winy, x1i, 0.0);
+ gpuDrawFilledRectf(0.0, (float)ar->winy, x1i, 0.0);
if (x2i < (float)ar->winx)
- glRectf(x2i, (float)ar->winy, (float)ar->winx, 0.0);
+ gpuDrawFilledRectf(x2i, (float)ar->winy, (float)ar->winx, 0.0);
if (y2i < (float)ar->winy)
- glRectf(x1i, (float)ar->winy, x2i, y2i);
+ gpuDrawFilledRectf(x1i, (float)ar->winy, x2i, y2i);
if (y2i > 0.0f)
- glRectf(x1i, y1i, x2i, 0.0);
+ gpuDrawFilledRectf(x1i, y1i, x2i, 0.0);
glDisable(GL_BLEND);
}
/* edge */
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-
setlinestyle(0);
UI_ThemeColor(TH_BACK);
-
- glRectf(x1i, y1i, x2i, y2i);
+
+ gpuDrawWireRectf(x1i, y1i, x2i, y2i);
#ifdef VIEW3D_CAMERA_BORDER_HACK
- if (view3d_camera_border_hack_test == TRUE) {
- glColor3ubv(view3d_camera_border_hack_col);
- glRectf(x1i + 1, y1i + 1, x2i - 1, y2i - 1);
+ if (view3d_camera_border_hack_test) {
+ gpuCurrentColor3ubv(view3d_camera_border_hack_col);
+ gpuDrawWireRectf(x1i + 1, y1i + 1, x2i - 1, y2i - 1);
view3d_camera_border_hack_test = FALSE;
}
#endif
@@ -1142,51 +1196,48 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
/* outer line not to confuse with object selecton */
if (v3d->flag2 & V3D_LOCK_CAMERA) {
UI_ThemeColor(TH_REDALERT);
- glRectf(x1i - 1, y1i - 1, x2i + 1, y2i + 1);
+ gpuDrawWireRectf(x1i - 1, y1i - 1, x2i + 1, y2i + 1);
}
UI_ThemeColor(TH_WIRE);
- glRectf(x1i, y1i, x2i, y2i);
+ gpuDrawWireRectf(x1i, y1i, x2i, y2i);
/* border */
if (scene->r.mode & R_BORDER) {
- cpack(0);
x3 = x1 + scene->r.border.xmin * (x2 - x1);
y3 = y1 + scene->r.border.ymin * (y2 - y1);
x4 = x1 + scene->r.border.xmax * (x2 - x1);
y4 = y1 + scene->r.border.ymax * (y2 - y1);
- cpack(0x4040FF);
- glRectf(x3, y3, x4, y4);
+ gpuCurrentColor3x(0x4040FF);
+ gpuDrawWireRectf(x3, y3, x4, y4);
}
+ gpuImmediateUnformat();
+
/* safety border */
if (ca) {
+ gpuImmediateFormat_V2();
+
if (ca->dtx & CAM_DTX_CENTER) {
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
x3 = x1 + 0.5f * (x2 - x1);
y3 = y1 + 0.5f * (y2 - y1);
- glBegin(GL_LINES);
- glVertex2f(x1, y3);
- glVertex2f(x2, y3);
-
- glVertex2f(x3, y1);
- glVertex2f(x3, y2);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuAppendLinef(x1, y3, x2, y3);
+ gpuAppendLinef(x3, y1, x3, y2);
+ gpuEnd();
}
if (ca->dtx & CAM_DTX_CENTER_DIAG) {
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
- glBegin(GL_LINES);
- glVertex2f(x1, y1);
- glVertex2f(x2, y2);
-
- glVertex2f(x1, y2);
- glVertex2f(x2, y1);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuAppendLinef(x1, y1, x2, y2);
+ gpuAppendLinef(x1, y2, x2, y1);
+ gpuEnd();
}
if (ca->dtx & CAM_DTX_THIRDS) {
@@ -1219,6 +1270,8 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
drawviewborder_triangle(x1, x2, y1, y2, 1, 'B');
}
+ gpuImmediateUnformat();
+
if (ca->flag & CAM_SHOWTITLESAFE) {
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
@@ -1268,7 +1321,6 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
}
setlinestyle(0);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
/* camera name - draw in highlighted text color */
if (ca && (ca->flag & CAM_SHOWNAME)) {
@@ -1335,15 +1387,15 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
glDisable(GL_MULTISAMPLE_ARB);
region_scissor_winrct(ar, &winrct);
- glScissor(winrct.xmin, winrct.ymin, BLI_rcti_size_x(&winrct), BLI_rcti_size_y(&winrct));
+ gpuScissor(winrct.xmin, winrct.ymin, BLI_rcti_size_x(&winrct), BLI_rcti_size_y(&winrct));
- glClearColor(0.0, 0.0, 0.0, 0.0);
+ gpuSetClearColor(0.0, 0.0, 0.0, 0.0);
if (v3d->zbuf) {
glEnable(GL_DEPTH_TEST);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
else {
- glClear(GL_COLOR_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
}
@@ -1743,25 +1795,24 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
glDepthMask(0);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPushMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPushMatrix();
ED_region_pixelspace(ar);
glPixelZoom(zoomx, zoomy);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f - bgpic->blend);
+
+ gpuCurrentColor4x(CPACK_WHITE, 1 - bgpic->blend);
glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
- glPixelZoom(1.0, 1.0);
- glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
+ glPixelZoom(1, 1);
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
+ gpuMatrixMode(GL_PROJECTION);
+ gpuPopMatrix();
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuPopMatrix();
glDisable(GL_BLEND);
@@ -1844,7 +1895,7 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear)
View3DAfter *v3da, *next;
if (clear && v3d->zbuf)
- glClear(GL_DEPTH_BUFFER_BIT);
+ gpuClear(GL_DEPTH_BUFFER_BIT);
v3d->xray = TRUE;
for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) {
@@ -1863,7 +1914,7 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int c
View3DAfter *v3da, *next;
if (clear && v3d->zbuf)
- glClear(GL_DEPTH_BUFFER_BIT);
+ gpuClear(GL_DEPTH_BUFFER_BIT);
v3d->xray = TRUE;
v3d->transp = TRUE;
@@ -1988,10 +2039,10 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
}
}
if (use_displist) {
- glMultMatrixf(dob->mat);
+ gpuMultMatrix(dob->mat);
if (ED_view3d_boundbox_clip(rv3d, dob->mat, &bb))
glCallList(displist);
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
}
else {
copy_m4_m4(dob->ob->obmat, dob->mat);
@@ -2147,9 +2198,9 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
invert_m4_m4(rv3d->persinv, rv3d->persmat);
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
- glClear(GL_DEPTH_BUFFER_BIT);
+ gpuClear(GL_DEPTH_BUFFER_BIT);
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
v3d->zbuf = TRUE;
glEnable(GL_DEPTH_TEST);
@@ -2182,9 +2233,9 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *))
invert_m4_m4(rv3d->persinv, rv3d->persmat);
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
- glClear(GL_DEPTH_BUFFER_BIT);
+ gpuClear(GL_DEPTH_BUFFER_BIT);
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
// persp(PERSP_STORE); /* store correct view for persp(PERSP_VIEW) calls */
if (rv3d->rflag & RV3D_CLIPPING) {
@@ -2505,10 +2556,10 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar,
ED_view3d_update_viewmat(scene, v3d, ar, viewmat, winmat);
/* set for opengl */
- glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(rv3d->winmat);
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(rv3d->viewmat);
+ gpuMatrixMode(GL_PROJECTION);
+ gpuLoadMatrix(rv3d->winmat);
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuLoadMatrix(rv3d->viewmat);
}
void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d)
@@ -2531,7 +2582,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
int bwinx, bwiny;
rcti brect;
- glPushMatrix();
+ gpuPushMatrix();
/* set temporary new size */
bwinx = ar->winx;
@@ -2577,14 +2628,14 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
}
- glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
+ gpuSetClearColorvf(backcol, 0.0);
}
else {
UI_ThemeClearColor(TH_BACK);
}
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat);
@@ -2671,10 +2722,10 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
ar->winy = bwiny;
ar->winrct = brect;
- glPopMatrix();
+ gpuPopMatrix();
/* XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell */
- glColor4ub(255, 255, 255, 255);
+ gpuCurrentColor3x(CPACK_WHITE);
G.f &= ~G_RENDER_OGL;
}
@@ -2909,15 +2960,15 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
cliprct.ymax = CLAMPIS(cliprct.ymax, ar->winrct.ymin, ar->winrct.ymax);
if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) {
- glGetIntegerv(GL_SCISSOR_BOX, scissor);
- glScissor(cliprct.xmin, cliprct.ymin, BLI_rcti_size_x(&cliprct), BLI_rcti_size_y(&cliprct));
+ gpuGetSizeBox(GL_SCISSOR_BOX, scissor);
+ gpuScissor(cliprct.xmin, cliprct.ymin, BLI_rcti_size_x(&cliprct), BLI_rcti_size_y(&cliprct));
}
else
return 0;
}
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gpuSetClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gpuClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (v3d->flag & V3D_DISPBGPICS)
view3d_draw_bgpic(scene, ar, v3d, FALSE, TRUE);
@@ -2933,7 +2984,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
if (draw_border) {
/* restore scissor as it was before */
- glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+ gpuScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
}
return 1;
@@ -2972,12 +3023,12 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings,
&scene->display_settings);
- glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
+ gpuSetClearColorvf(backcol, 0.0);
}
else
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gpuClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
@@ -3023,10 +3074,10 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
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);
}
}
@@ -3148,7 +3199,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
else if (v3d->flag2 & V3D_RENDER_BORDER) {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
setlinestyle(3);
- cpack(0x4040FF);
+ gpuColor3x(0x4040FF);
glRectf(v3d->render_border.xmin * ar->winx, v3d->render_border.ymin * ar->winy,
v3d->render_border.xmax * ar->winx, v3d->render_border.ymax * ar->winy);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index c7ba3378073..ef2b500eec9 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -60,8 +60,8 @@
#include "BKE_armature.h"
#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */
+#include "GPU_compatibility.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "WM_api.h"
@@ -78,6 +78,7 @@
#include "ED_view3d.h"
#include "ED_sculpt.h"
+#include "GPU_compatibility.h"
#include "PIL_time.h" /* smoothview */
@@ -2823,7 +2824,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* ZBuffer depth vars */
bglMats mats;
float depth_close = FLT_MAX;
- double cent[2], p[3];
+ float cent[3], p[3], corner[3];
/* note; otherwise opengl won't work */
view3d_operator_needs_opengl(C);
@@ -2851,24 +2852,26 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
MEM_freeN(depth_temp.depths);
}
- cent[0] = (((double)rect.xmin) + ((double)rect.xmax)) / 2;
- cent[1] = (((double)rect.ymin) + ((double)rect.ymax)) / 2;
+ cent[0] = (((float)rect.xmin) + ((float)rect.xmax)) / 2;
+ cent[1] = (((float)rect.ymin) + ((float)rect.ymax)) / 2;
+
+ corner[0] = rect.xmin;
+ corner[1] = rect.ymin;
if (rv3d->is_persp) {
- double p_corner[3];
+ float p_corner[3];
/* no depths to use, we cant do anything! */
if (depth_close == FLT_MAX) {
BKE_report(op->reports, RPT_ERROR, "Depth too large");
return OPERATOR_CANCELLED;
}
+
+
+ cent[2] = corner[2] = depth_close;
/* convert border to 3d coordinates */
- if ((!gluUnProject(cent[0], cent[1], depth_close,
- mats.modelview, mats.projection, (GLint *)mats.viewport,
- &p[0], &p[1], &p[2])) ||
- (!gluUnProject((double)rect.xmin, (double)rect.ymin, depth_close,
- mats.modelview, mats.projection, (GLint *)mats.viewport,
- &p_corner[0], &p_corner[1], &p_corner[2])))
+ if ( (!gpuUnProject(cent, mats.modelview, mats.projection, (GLint *)mats.viewport, p)) ||
+ (!gpuUnProject(corner, mats.modelview, mats.projection, (GLint *)mats.viewport, p_corner)))
{
return OPERATOR_CANCELLED;
}
@@ -2892,10 +2895,10 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
new_dist = rv3d->dist;
+ cent[2] = depth_close;
/* convert the drawn rectangle into 3d space */
- if (depth_close != FLT_MAX && gluUnProject(cent[0], cent[1], depth_close,
- mats.modelview, mats.projection, (GLint *)mats.viewport,
- &p[0], &p[1], &p[2]))
+ if (depth_close != FLT_MAX &&
+ gpuUnProject(cent, mats.modelview, mats.projection, (GLint *)mats.viewport, p))
{
new_ofs[0] = -p[0];
new_ofs[1] = -p[1];
@@ -3839,31 +3842,21 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3])
{
bglMats mats; /* ZBuffer depth vars */
- float depth_close = FLT_MAX;
- double cent[2], p[3];
+ float cent[3];
/* Get Z Depths, needed for perspective, nice for ortho */
bgl_get_mats(&mats);
draw_depth(scene, ar, v3d, NULL);
- depth_close = view_autodist_depth_margin(ar, mval, 4);
+ cent[2] = view_autodist_depth_margin(ar, mval, 4);
- if (depth_close == FLT_MAX)
+ if (cent[2] == FLT_MAX)
return 0;
- cent[0] = (double)mval[0];
- cent[1] = (double)mval[1];
-
- if (!gluUnProject(cent[0], cent[1], depth_close,
- mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
- {
- return 0;
- }
+ cent[0] = mval[0];
+ cent[1] = mval[1];
- mouse_worldloc[0] = (float)p[0];
- mouse_worldloc[1] = (float)p[1];
- mouse_worldloc[2] = (float)p[2];
- return 1;
+ return gpuUnProject(cent, mats.modelview, mats.projection, (GLint *)mats.viewport, mouse_worldloc);
}
int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode)
@@ -3886,33 +3879,23 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl
int margin, float *force_depth)
{
bglMats mats; /* ZBuffer depth vars, could cache? */
- float depth;
- double cent[2], p[3];
+ float cent[3];
/* Get Z Depths, needed for perspective, nice for ortho */
if (force_depth)
- depth = *force_depth;
+ cent[2] = *force_depth;
else
- depth = view_autodist_depth_margin(ar, mval, margin);
+ cent[2] = view_autodist_depth_margin(ar, mval, margin);
- if (depth == FLT_MAX)
+ if (cent[2] == FLT_MAX)
return 0;
- cent[0] = (double)mval[0];
- cent[1] = (double)mval[1];
+ cent[0] = mval[0];
+ cent[1] = mval[1];
bgl_get_mats(&mats);
- if (!gluUnProject(cent[0], cent[1], depth,
- mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
- {
- return 0;
- }
-
- mouse_worldloc[0] = (float)p[0];
- mouse_worldloc[1] = (float)p[1];
- mouse_worldloc[2] = (float)p[2];
- return 1;
+ return gpuUnProject(cent, mats.modelview, mats.projection, (GLint *)mats.viewport, mouse_worldloc);
}
int ED_view3d_autodist_depth(ARegion *ar, const int mval[2], int margin, float *depth)
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 5aee90f0860..64e72962e13 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -45,7 +45,9 @@
#include "BKE_depsgraph.h" /* for fly mode updating */
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
+#include "GPU_colors.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -231,37 +233,44 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar),
y1 = 0.45f * (float)fly->ar->winy;
x2 = 0.55f * (float)fly->ar->winx;
y2 = 0.55f * (float)fly->ar->winy;
- cpack(0);
- glBegin(GL_LINES);
+ gpuCurrentColor3x(CPACK_BLACK);
+
+ gpuImmediateFormat_V2();
+
+ gpuBegin(GL_LINES);
+
/* bottom left */
- glVertex2f(x1, y1);
- glVertex2f(x1, y1 + 5);
+ gpuVertex2f(x1, y1);
+ gpuVertex2f(x1, y1 + 5);
- glVertex2f(x1, y1);
- glVertex2f(x1 + 5, y1);
+ gpuVertex2f(x1, y1);
+ gpuVertex2f(x1 + 5, y1);
/* top right */
- glVertex2f(x2, y2);
- glVertex2f(x2, y2 - 5);
+ gpuVertex2f(x2, y2);
+ gpuVertex2f(x2, y2 - 5);
- glVertex2f(x2, y2);
- glVertex2f(x2 - 5, y2);
+ gpuVertex2f(x2, y2);
+ gpuVertex2f(x2 - 5, y2);
/* top left */
- glVertex2f(x1, y2);
- glVertex2f(x1, y2 - 5);
+ gpuVertex2f(x1, y2);
+ gpuVertex2f(x1, y2 - 5);
- glVertex2f(x1, y2);
- glVertex2f(x1 + 5, y2);
+ gpuVertex2f(x1, y2);
+ gpuVertex2f(x1 + 5, y2);
/* bottom right */
- glVertex2f(x2, y1);
- glVertex2f(x2, y1 + 5);
+ gpuVertex2f(x2, y1);
+ gpuVertex2f(x2, y1 + 5);
+
+ gpuVertex2f(x2, y1);
+ gpuVertex2f(x2 - 5, y1);
+
+ gpuEnd();
- glVertex2f(x2, y1);
- glVertex2f(x2 - 5, y1);
- glEnd();
+ gpuImmediateUnformat();
}
/* FlyInfo->state */
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 5beeda9f220..0dd3be0e7fc 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -142,9 +142,9 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
/* drawmesh.c */
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
- struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
+ struct Object *ob, struct DerivedMesh *dm, int draw_flags);
void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
- struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
+ struct Object *ob, struct DerivedMesh *dm, int draw_flags);
/* view3d_draw.c */
void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar);
@@ -152,8 +152,6 @@ void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (*func)(void
void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d);
void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag);
-void circf(float x, float y, float rad);
-void circ(float x, float y, float rad);
void view3d_update_depths_rect(struct ARegion *ar, struct ViewDepths *d, struct rcti *rect);
float view3d_depth_near(struct ViewDepths *d);
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index 6ba05abae9a..499f9e286ae 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -35,13 +35,14 @@
#include "BLO_sys_types.h" /* int64_t */
-#include "BIF_gl.h" /* bglMats */
#include "BIF_glutil.h" /* bglMats */
#include "BLI_math_vector.h"
#include "ED_view3d.h" /* own include */
+#include "GPU_compatibility.h"
+
#define BL_NEAR_CLIP 0.001
/* Non Clipping Projection Functions
@@ -482,12 +483,11 @@ void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][
* modelspace */
void ED_view3d_unproject(bglMats *mats, float out[3], const float x, const float y, const float z)
{
- double ux, uy, uz;
+ float w[3];
- gluUnProject(x, y, z, mats->modelview, mats->projection,
- (GLint *)mats->viewport, &ux, &uy, &uz);
+ w[0] = x;
+ w[1] = y;
+ w[2] = z;
- out[0] = ux;
- out[1] = uy;
- out[2] = uz;
+ gpuUnProject(w, mats->modelview, mats->projection, (GLint *)mats->viewport, out);
}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 53f983912ac..1a4d345705b 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -71,8 +71,8 @@
#include "BKE_tessmesh.h"
#include "BKE_tracking.h"
+#include "GPU_compatibility.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "WM_api.h"
@@ -93,6 +93,8 @@
#include "UI_interface.h"
#include "UI_resources.h"
+#include "GPU_compatibility.h"
+
#include "view3d_intern.h" /* own include */
/* TODO: should return whether there is valid context to continue */
@@ -527,7 +529,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m
/* for non zbuf projections, don't change the GL state */
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- glLoadMatrixf(vc->rv3d->viewmat);
+ gpuLoadMatrix(vc->rv3d->viewmat);
bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) {
@@ -931,7 +933,7 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
{
ViewContext vc;
int mcords_tot;
- const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
+ int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
short extend, select;
@@ -1788,7 +1790,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten
/* for non zbuf projections, don't change the GL state */
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- glLoadMatrixf(vc->rv3d->viewmat);
+ gpuLoadMatrix(vc->rv3d->viewmat);
bbsel = EDBM_backbuf_border_init(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
if (ts->selectmode & SCE_SELECT_VERTEX) {
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 714898fed21..62615b82f8a 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -53,9 +53,9 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
-#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "GPU_compatibility.h"
#include "GPU_draw.h"
#include "WM_api.h"
@@ -71,6 +71,8 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "GPU_compatibility.h"
+
#include "view3d_intern.h" /* own include */
/* use this call when executing an operator,
@@ -94,10 +96,11 @@ void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar)
RegionView3D *rv3d = ar->regiondata;
wmSubWindowSet(win, ar->swinid);
- glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(rv3d->winmat);
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(rv3d->viewmat);
+ gpuMatrixMode(GL_PROJECTION);
+ gpuLoadMatrix(rv3d->winmat);
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuLoadMatrix(rv3d->viewmat);
+ gpuMatrixCommit();//change
}
}
@@ -526,7 +529,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect)
{
float modelview[4][4];
- double xs, ys, p[3];
+ float s[3], p[3];
int val, flip_sign, a;
/* near zero floating point values can give issues with gluUnProject
@@ -539,16 +542,19 @@ void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, co
mats->viewport[1] = 0;
/* four clipping planes and bounding volume */
- /* first do the bounding volume */
+ /* first do the bounding volume */
for (val = 0; val < 4; val++) {
- xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax;
- ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax;
+ s[0] = (val == 0 || val == 3) ? rect->xmin : rect->xmax;
+ s[1] = (val == 0 || val == 1) ? rect->ymin : rect->ymax;
+ s[2] = 0;
+
+ gpuUnProject(s, mats->modelview, mats->projection, mats->viewport, p);
+ copy_v3_v3(bb->vec[val], p);
- gluUnProject(xs, ys, 0.0, mats->modelview, mats->projection, mats->viewport, &p[0], &p[1], &p[2]);
- copy_v3fl_v3db(bb->vec[val], p);
+ s[2] = 1.0;
- gluUnProject(xs, ys, 1.0, mats->modelview, mats->projection, mats->viewport, &p[0], &p[1], &p[2]);
- copy_v3fl_v3db(bb->vec[4 + val], p);
+ gpuUnProject(s, mats->modelview, mats->projection, mats->viewport, p);
+ copy_v3_v3(bb->vec[4 + val], p);
}
/* verify if we have negative scale. doing the transform before cross
@@ -702,7 +708,7 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect)
}
/* update matrix in 3d view region */
- glGetFloatv(GL_PROJECTION_MATRIX, (float *)rv3d->winmat);
+ gpuGetMatrix(GL_PROJECTION_MATRIX, (float *)rv3d->winmat);
}
static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short smooth)
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 05a4f6f4ce5..159e3c1c8db 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
../../blenlib
../../blenloader
../../bmesh
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -53,4 +54,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_transform "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 7fbfe8fc719..e69f0695697 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -54,7 +54,8 @@
#include "RNA_access.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "BLF_api.h"
@@ -77,6 +78,7 @@
#include "ED_view3d.h"
#include "ED_mesh.h"
#include "ED_clip.h"
+#include "ED_node.h"
#include "ED_mask.h"
#include "UI_view2d.h"
@@ -1354,6 +1356,7 @@ typedef enum {
LEFT,
RIGHT
} ArrowDirection;
+
static void drawArrow(ArrowDirection d, short offset, short length, short size)
{
switch (d) {
@@ -1361,29 +1364,34 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size)
offset = -offset;
length = -length;
size = -size;
+ /* fall through! */
+
case RIGHT:
- glBegin(GL_LINES);
- glVertex2s(offset, 0);
- glVertex2s(offset + length, 0);
- glVertex2s(offset + length, 0);
- glVertex2s(offset + length - size, -size);
- glVertex2s(offset + length, 0);
- glVertex2s(offset + length - size, size);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2i(offset, 0);
+ gpuVertex2i(offset + length, 0);
+ gpuVertex2i(offset + length, 0);
+ gpuVertex2i(offset + length - size, -size);
+ gpuVertex2i(offset + length, 0);
+ gpuVertex2i(offset + length - size, size);
+ gpuEnd();
break;
+
case DOWN:
offset = -offset;
length = -length;
size = -size;
+ /* fall through! */
+
case UP:
- glBegin(GL_LINES);
- glVertex2s(0, offset);
- glVertex2s(0, offset + length);
- glVertex2s(0, offset + length);
- glVertex2s(-size, offset + length - size);
- glVertex2s(0, offset + length);
- glVertex2s(size, offset + length - size);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2i(0, offset);
+ gpuVertex2i(0, offset + length);
+ gpuVertex2i(0, offset + length);
+ gpuVertex2i(-size, offset + length - size);
+ gpuVertex2i(0, offset + length);
+ gpuVertex2i(size, offset + length - size);
+ gpuEnd();
break;
}
}
@@ -1394,42 +1402,30 @@ static void drawArrowHead(ArrowDirection d, short size)
case LEFT:
size = -size;
case RIGHT:
- glBegin(GL_LINES);
- glVertex2s(0, 0);
- glVertex2s(-size, -size);
- glVertex2s(0, 0);
- glVertex2s(-size, size);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2i(0, 0);
+ gpuVertex2i(-size, -size);
+ gpuVertex2i(0, 0);
+ gpuVertex2i(-size, size);
+ gpuEnd();
break;
+
case DOWN:
size = -size;
+ /* fall through! */
+
case UP:
- glBegin(GL_LINES);
- glVertex2s(0, 0);
- glVertex2s(-size, -size);
- glVertex2s(0, 0);
- glVertex2s(size, -size);
- glEnd();
+ gpuBegin(GL_LINES);
+ gpuVertex2i(0, 0);
+ gpuVertex2i(-size, -size);
+ gpuVertex2i(0, 0);
+ gpuVertex2i(size, -size);
+ gpuEnd();
break;
}
}
-static void drawArc(float size, float angle_start, float angle_end, int segments)
-{
- float delta = (angle_end - angle_start) / segments;
- float angle;
int a;
-
- glBegin(GL_LINE_STRIP);
-
- for (angle = angle_start, a = 0; a < segments; angle += delta, a++) {
- glVertex2f(cosf(angle) * size, sinf(angle) * size);
- }
- glVertex2f(cosf(angle_end) * size, sinf(angle_end) * size);
-
- glEnd();
-}
-
static int helpline_poll(bContext *C)
{
ARegion *ar = CTX_wm_region(C);
@@ -1462,20 +1458,22 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
projectFloatView(t, vecrot, cent); // no overflow in extreme cases
- glPushMatrix();
+ gpuPushMatrix();
+
+ gpuImmediateFormat_V3();
switch (t->helpline) {
case HLP_SPRING:
UI_ThemeColor(TH_WIRE);
setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2iv(t->mval);
- glVertex2fv(cent);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2iv(t->mval);
+ gpuVertex2fv(cent);
+ gpuEnd();
- glTranslatef(mval[0], mval[1], 0);
- glRotatef(-RAD2DEGF(atan2f(cent[0] - t->mval[0], cent[1] - t->mval[1])), 0, 0, 1);
+ gpuTranslate(mval[0], mval[1], 0);
+ gpuRotateAxis(-(atan2f(cent[0] - t->mval[0], cent[1] - t->mval[1])), 'Z');
setlinestyle(0);
glLineWidth(3.0);
@@ -1483,27 +1481,30 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
drawArrow(DOWN, 5, 10, 5);
glLineWidth(1.0);
break;
+
case HLP_HARROW:
UI_ThemeColor(TH_WIRE);
- glTranslatef(mval[0], mval[1], 0);
+ gpuTranslate(mval[0], mval[1], 0);
glLineWidth(3.0);
drawArrow(RIGHT, 5, 10, 5);
drawArrow(LEFT, 5, 10, 5);
glLineWidth(1.0);
break;
+
case HLP_VARROW:
UI_ThemeColor(TH_WIRE);
- glTranslatef(mval[0], mval[1], 0);
+ gpuTranslate(mval[0], mval[1], 0);
glLineWidth(3.0);
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
drawArrow(UP, 5, 10, 5);
drawArrow(DOWN, 5, 10, 5);
glLineWidth(1.0);
break;
+
case HLP_ANGLE:
{
float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
@@ -1514,52 +1515,53 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
UI_ThemeColor(TH_WIRE);
setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2iv(t->mval);
- glVertex2fv(cent);
- glEnd();
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex2iv(t->mval);
+ gpuVertex2fv(cent);
+ gpuEnd();
- glTranslatef(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0);
+ gpuTranslate(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0);
setlinestyle(0);
glLineWidth(3.0);
- drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
- drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
+ gpuDrawArc(0, 0, angle - spacing_angle, delta_angle - spacing_angle, dist, dist, 10);
+ gpuDrawArc(0, 0, angle + spacing_angle, spacing_angle - delta_angle, dist, dist, 10);
- glPushMatrix();
+ gpuPushMatrix();
- glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
- glRotatef(RAD2DEGF(angle - delta_angle), 0, 0, 1);
+ gpuTranslate(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
+ gpuRotateAxis(angle - delta_angle, 'Z');
drawArrowHead(DOWN, 5);
- glPopMatrix();
+ gpuPopMatrix();
- glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
- glRotatef(RAD2DEGF(angle + delta_angle), 0, 0, 1);
+ gpuTranslate(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
+ gpuRotateAxis(angle + delta_angle, 'Z');
drawArrowHead(UP, 5);
glLineWidth(1.0);
break;
}
+
case HLP_TRACKBALL:
{
unsigned char col[3], col2[3];
UI_GetThemeColor3ubv(TH_GRID, col);
- glTranslatef(mval[0], mval[1], 0);
+ gpuTranslate(mval[0], mval[1], 0);
glLineWidth(3.0);
UI_make_axis_color(col, col2, 'X');
- glColor3ubv((GLubyte *)col2);
+ gpuCurrentColor3ubv((GLubyte *)col2);
drawArrow(RIGHT, 5, 10, 5);
drawArrow(LEFT, 5, 10, 5);
UI_make_axis_color(col, col2, 'Y');
- glColor3ubv((GLubyte *)col2);
+ gpuCurrentColor3ubv((GLubyte *)col2);
drawArrow(UP, 5, 10, 5);
drawArrow(DOWN, 5, 10, 5);
@@ -1568,7 +1570,353 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
}
}
- glPopMatrix();
+ gpuImmediateUnformat();
+
+ gpuPopMatrix();
+ }
+}
+
+
+/*----------------- DRAWING CONSTRAINTS -------------------*/
+
+static void drawNonPropEdge(const struct bContext *C, TransInfo *t);
+static void drawConstraint(TransInfo *t);
+static void drawSnapping(const struct bContext *C, TransInfo *t);
+
+void drawConstraintLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)
+{
+ float v1[3], v2[3], v3[3];
+ unsigned char col[3], col2[3];
+
+ if (t->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = t->view;
+
+ copy_v3_v3(v3, dir);
+ mul_v3_fl(v3, v3d->far);
+
+ sub_v3_v3v3(v2, center, v3);
+ add_v3_v3v3(v1, center, v3);
+
+ if (options & DRAWLIGHT) {
+ col[0] = col[1] = col[2] = 220;
+ }
+ else {
+ UI_GetThemeColor3ubv(TH_GRID, col);
+ }
+
+ UI_make_axis_color(col, col2, axis);
+ gpuColor3ubv(col2);
+
+ setlinestyle(0);
+ gpuVertex3fv(v1);
+ gpuVertex3fv(v2);
+ }
+}
+
+static void drawConstraint(TransInfo *t)
+{
+ TransCon *tc = &(t->con);
+
+ if (!ELEM3(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE))
+ return;
+ if (!(tc->mode & CON_APPLY))
+ return;
+ if (t->flag & T_USES_MANIPULATOR)
+ return;
+ if (t->flag & T_NO_CONSTRAINT)
+ return;
+
+ /* nasty exception for Z constraint in camera view */
+ // TRANSFORM_FIX_ME
+// if ((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB)
+// return;
+
+ if (tc->drawExtra) {
+ tc->drawExtra(t);
+ }
+ else {
+ gpuImmediateFormat_C4_V3();
+
+ if (tc->mode & CON_SELECT) {
+ float vec[3];
+ char col2[3] = {255, 255, 255};
+ int depth_test_enabled;
+
+ convertViewVec(t, vec, (t->mval[0] - t->con.imval[0]), (t->mval[1] - t->con.imval[1]));
+ add_v3_v3(vec, tc->center);
+
+ gpuBegin(GL_LINES);
+ drawConstraintLine(t, tc->center, tc->mtx[0], 'X', 0);
+ drawConstraintLine(t, tc->center, tc->mtx[1], 'Y', 0);
+ drawConstraintLine(t, tc->center, tc->mtx[2], 'Z', 0);
+ gpuEnd();
+
+ gpuColor3ubv((GLubyte *)col2);
+
+ depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
+ if (depth_test_enabled)
+ glDisable(GL_DEPTH_TEST);
+
+ setlinestyle(1);
+ gpuBegin(GL_LINE_STRIP);
+ gpuVertex3fv(tc->center);
+ gpuVertex3fv(vec);
+ gpuEnd();
+ setlinestyle(0);
+
+ if (depth_test_enabled)
+ glEnable(GL_DEPTH_TEST);
+ }
+
+ gpuBegin(GL_LINES);
+
+ if (tc->mode & CON_AXIS0) {
+ drawConstraintLine(t, tc->center, tc->mtx[0], 'X', DRAWLIGHT);
+ }
+
+ if (tc->mode & CON_AXIS1) {
+ drawConstraintLine(t, tc->center, tc->mtx[1], 'Y', DRAWLIGHT);
+ }
+
+ if (tc->mode & CON_AXIS2) {
+ drawConstraintLine(t, tc->center, tc->mtx[2], 'Z', DRAWLIGHT);
+ }
+
+ gpuEnd();
+
+ gpuImmediateUnformat();
+ }
+}
+
+static void drawnodesnap(View2D *v2d, const float cent[2], float size, NodeBorder border)
+{
+ gpuBegin(GL_LINES);
+
+ if (border & (NODE_LEFT | NODE_RIGHT)) {
+ gpuVertex2f(cent[0], v2d->cur.ymin);
+ gpuVertex2f(cent[0], v2d->cur.ymax);
+ }
+ else {
+ gpuVertex2f(cent[0], cent[1] - size);
+ gpuVertex2f(cent[0], cent[1] + size);
+ }
+
+ if (border & (NODE_TOP | NODE_BOTTOM)) {
+ gpuVertex2f(v2d->cur.xmin, cent[1]);
+ gpuVertex2f(v2d->cur.xmax, cent[1]);
+ }
+ else {
+ gpuVertex2f(cent[0] - size, cent[1]);
+ gpuVertex2f(cent[0] + size, cent[1]);
+ }
+
+ gpuEnd();
+}
+
+static void drawSnapping(const struct bContext *C, TransInfo *t)
+{
+ if (activeSnap(t)) {
+ unsigned char col[4], selectedCol[4], activeCol[4];
+
+ UI_GetThemeColor3ubv(TH_TRANSFORM, col);
+ col[3]= 128;
+
+ UI_GetThemeColor3ubv(TH_SELECT, selectedCol);
+ selectedCol[3]= 128;
+
+ UI_GetThemeColor3ubv(TH_ACTIVE, activeCol);
+ activeCol[3]= 192;
+
+ gpuImmediateFormat_V3(); // DOODLE: 4 mono lines, commented out
+
+ if (t->spacetype == SPACE_VIEW3D) {
+ if (validSnap(t)) {
+ TransSnapPoint *p;
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ float imat[4][4];
+ float size;
+
+ glDisable(GL_DEPTH_TEST);
+
+ size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
+
+ invert_m4_m4(imat, rv3d->viewmat);
+
+ for (p = t->tsnap.points.first; p; p = p->next) {
+ if (p == t->tsnap.selectedPoint) {
+ gpuCurrentColor4ubv(selectedCol);
+ }
+ else {
+ gpuCurrentColor4ubv(col);
+ }
+
+ gpuDrawFastBall(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat);
+ }
+
+ if (t->tsnap.status & POINT_INIT) {
+ gpuCurrentColor4ubv(activeCol);
+
+ gpuDrawFastBall(GL_LINE_LOOP, t->tsnap.snapPoint, ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat);
+ }
+
+ /* draw normal if needed */
+ if (usingSnappingNormal(t) && validSnappingNormal(t)) {
+ gpuCurrentColor4ubv(activeCol);
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(
+ t->tsnap.snapPoint[0],
+ t->tsnap.snapPoint[1],
+ t->tsnap.snapPoint[2]);
+ gpuVertex3f(
+ t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0],
+ t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1],
+ t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]);
+ gpuEnd();
+ }
+
+ if (v3d->zbuf)
+ glEnable(GL_DEPTH_TEST);
+ }
+ }
+ else if (t->spacetype==SPACE_IMAGE) {
+ /* This will not draw, and Im nor sure why - campbell */
+#if 0
+ float xuser_asp, yuser_asp;
+ int wi, hi;
+ float w, h;
+
+ calc_image_view(G.sima, 'f'); // float
+ myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
+ gpuLoadIdentity();
+
+ ED_space_image_get_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
+ ED_space_image_width(t->sa->spacedata.first, &wi, &hi);
+ w = (((float)wi) / IMAGE_SIZE_FALLBACK) * G.sima->zoom * xuser_asp;
+ h = (((float)hi) / IMAGE_SIZE_FALLBACK) * G.sima->zoom * yuser_asp;
+
+ gpuCurrentColor3x(CPACK_WHITE);
+ gpuTranslate(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], 0.0f);
+
+ //gpuDrawFilledRectf(0, 0, 1, 1);
+
+ setlinestyle(0);
+ gpuCurrentColor3x(CPACK_BLACK);
+
+ gpuBegin(GL_LINES);
+ gpuAppendLinef(-0.020/w, 0, -0.1/w, 0);
+ gpuAppendLinef(0.1/w, 0, .020/w, 0);
+ gpuAppendLinef(0, -0.020/h, 0, -0.1/h);
+ gpuAppendLinef(0, 0.1/h, 0, 0.020/h);
+ gpuEnd();
+
+ gpuTranslate(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f);
+ setlinestyle(0);
+#endif
+ }
+ else if (t->spacetype == SPACE_NODE) {
+ if (validSnap(t)) {
+ ARegion *ar = CTX_wm_region(C);
+ TransSnapPoint *p;
+ float size;
+
+ size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
+
+ glEnable(GL_BLEND);
+
+ for (p = t->tsnap.points.first; p; p = p->next) {
+ if (p == t->tsnap.selectedPoint) {
+ gpuCurrentColor4ubv(selectedCol);
+ }
+ else {
+ gpuCurrentColor4ubv(col);
+ }
+
+ drawnodesnap(&ar->v2d, p->co, size, 0);
+ }
+
+ if (t->tsnap.status & POINT_INIT) {
+ gpuCurrentColor4ubv(activeCol);
+
+ drawnodesnap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder);
+ }
+
+ glDisable(GL_BLEND);
+ }
+ }
+
+ gpuImmediateUnformat();
+ }
+}
+
+static void drawNonPropEdge(const struct bContext *C, TransInfo *t)
+{
+ if (t->flag & TFM_EDGE_SLIDE) {
+ SlideData *sld = (SlideData *)t->customData;
+ /* Non-Prop mode */
+ if (sld && sld->is_proportional == FALSE) {
+ View3D *v3d = CTX_wm_view3d(C);
+ float marker[3];
+ float v1[3], v2[3];
+ float interp_v;
+ TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
+ const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
+ const float guide_size = ctrl_size - 0.5f;
+ const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
+ const int alpha_shade = -30;
+
+ add_v3_v3v3(v1, curr_sv->origvert.co, curr_sv->upvec);
+ add_v3_v3v3(v2, curr_sv->origvert.co, curr_sv->downvec);
+
+ interp_v = (sld->perc + 1.0f) / 2.0f;
+ interp_v3_v3v3(marker, v2, v1, interp_v);
+
+ if (v3d && v3d->zbuf)
+ glDisable(GL_DEPTH_TEST);
+
+ glEnable(GL_BLEND);
+
+ glPushAttrib(GL_CURRENT_BIT | GL_LINE_BIT | GL_POINT_BIT);
+ gpuPushMatrix();
+
+ gpuMultMatrix(t->obedit->obmat);
+
+ glLineWidth(line_size);
+ UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
+ gpuBegin(GL_LINES);
+ gpuVertex3fv(curr_sv->up->co);
+ gpuVertex3fv(curr_sv->origvert.co);
+ gpuVertex3fv(curr_sv->down->co);
+ gpuVertex3fv(curr_sv->origvert.co);
+ gpuEnd();
+
+ UI_ThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade);
+ glPointSize(ctrl_size);
+ gpuBeginSprites();
+ if (sld->flipped_vtx) {
+ gpuSprite3fv(curr_sv->down->co);
+ }
+ else {
+ gpuSprite3fv(curr_sv->up->co);
+ }
+ gpuEndSprites();
+
+ UI_ThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade);
+ glPointSize(guide_size);
+ gpuBeginSprites();
+ gpuSprite3fv(marker);
+ gpuEndSprites();
+
+
+ gpuPopMatrix();
+ glPopAttrib();
+
+ glDisable(GL_BLEND);
+
+ if (v3d && v3d->zbuf)
+ glEnable(GL_DEPTH_TEST);
+ }
}
}
@@ -1819,8 +2167,9 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
/*t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);*/
}
- else
+ else {
unit_m3(t->spacemtx);
+ }
createTransData(C, t); // make TransData structs from selection
@@ -5531,80 +5880,6 @@ int handleEventEdgeSlide(struct TransInfo *t, struct wmEvent *event)
return 0;
}
-void drawNonPropEdge(const struct bContext *C, TransInfo *t)
-{
- if (t->mode == TFM_EDGE_SLIDE) {
- SlideData *sld = (SlideData *)t->customData;
- /* Non-Prop mode */
- if (sld && sld->is_proportional == FALSE) {
- View3D *v3d = CTX_wm_view3d(C);
- float marker[3];
- float v1[3], v2[3];
- float interp_v;
- TransDataSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
- const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
- const float guide_size = ctrl_size - 0.5f;
- const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
- const int alpha_shade = -30;
-
- add_v3_v3v3(v1, curr_sv->origvert.co, curr_sv->upvec);
- add_v3_v3v3(v2, curr_sv->origvert.co, curr_sv->downvec);
-
- interp_v = (sld->perc + 1.0f) / 2.0f;
- interp_v3_v3v3(marker, v2, v1, interp_v);
-
- if (v3d && v3d->zbuf)
- glDisable(GL_DEPTH_TEST);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glPushAttrib(GL_CURRENT_BIT | GL_LINE_BIT | GL_POINT_BIT);
- glPushMatrix();
-
- glMultMatrixf(t->obedit->obmat);
-
- glLineWidth(line_size);
- UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
- glBegin(GL_LINES);
- glVertex3fv(curr_sv->up->co);
- glVertex3fv(curr_sv->origvert.co);
- glVertex3fv(curr_sv->down->co);
- glVertex3fv(curr_sv->origvert.co);
- bglEnd();
-
-
- UI_ThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade);
- glPointSize(ctrl_size);
- if (sld->flipped_vtx) {
- bglBegin(GL_POINTS);
- bglVertex3fv(curr_sv->down->co);
- bglEnd();
- }
- else {
- bglBegin(GL_POINTS);
- bglVertex3fv(curr_sv->up->co);
- bglEnd();
- }
-
- UI_ThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade);
- glPointSize(guide_size);
- bglBegin(GL_POINTS);
- bglVertex3fv(marker);
- bglEnd();
-
-
- glPopMatrix();
- glPopAttrib();
-
- glDisable(GL_BLEND);
-
- if (v3d && v3d->zbuf)
- glEnable(GL_DEPTH_TEST);
- }
- }
-}
-
static int doEdgeSlide(TransInfo *t, float perc)
{
SlideData *sld = t->customData;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index bc959a772d6..cca7917277e 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -590,8 +590,6 @@ void autokeyframe_pose_cb_func(struct bContext *C, struct Scene *scene, struct V
/*********************** Constraints *****************************/
-void drawConstraint(TransInfo *t);
-
void getConstraintMatrix(TransInfo *t);
void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]);
void setLocalConstraint(TransInfo *t, int mode, const char text[]);
@@ -631,7 +629,6 @@ void applyProject(TransInfo *t);
void applySnapping(TransInfo *t, float *vec);
void resetSnapping(TransInfo *t);
int handleSnapping(TransInfo *t, struct wmEvent *event);
-void drawSnapping(const struct bContext *C, TransInfo *t);
int usingSnappingNormal(TransInfo *t);
int validSnappingNormal(TransInfo *t);
@@ -670,9 +667,7 @@ int initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, struc
void postTrans (struct bContext *C, TransInfo *t);
void resetTransRestrictions(TransInfo *t);
-void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options);
-
-void drawNonPropEdge(const struct bContext *C, TransInfo *t);
+void drawConstraintLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options);
/* DRAWLINE options flags */
#define DRAWLIGHT 1
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 947bdf53bee..58d8a06415a 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -48,7 +48,8 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "BKE_context.h"
@@ -628,71 +629,6 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
t->con.mode |= CON_USER;
}
-/*----------------- DRAWING CONSTRAINTS -------------------*/
-
-void drawConstraint(TransInfo *t)
-{
- TransCon *tc = &(t->con);
-
- if (!ELEM3(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE))
- return;
- if (!(tc->mode & CON_APPLY))
- return;
- if (t->flag & T_USES_MANIPULATOR)
- return;
- if (t->flag & T_NO_CONSTRAINT)
- return;
-
- /* nasty exception for Z constraint in camera view */
- // TRANSFORM_FIX_ME
-// if ((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB)
-// return;
-
- if (tc->drawExtra) {
- tc->drawExtra(t);
- }
- else {
- if (tc->mode & CON_SELECT) {
- float vec[3];
- char col2[3] = {255, 255, 255};
- int depth_test_enabled;
-
- convertViewVec(t, vec, (t->mval[0] - t->con.imval[0]), (t->mval[1] - t->con.imval[1]));
- add_v3_v3(vec, tc->center);
-
- drawLine(t, tc->center, tc->mtx[0], 'X', 0);
- drawLine(t, tc->center, tc->mtx[1], 'Y', 0);
- drawLine(t, tc->center, tc->mtx[2], 'Z', 0);
-
- glColor3ubv((GLubyte *)col2);
-
- depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
- if (depth_test_enabled)
- glDisable(GL_DEPTH_TEST);
-
- setlinestyle(1);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(tc->center);
- glVertex3fv(vec);
- glEnd();
- setlinestyle(0);
-
- if (depth_test_enabled)
- glEnable(GL_DEPTH_TEST);
- }
-
- if (tc->mode & CON_AXIS0) {
- drawLine(t, tc->center, tc->mtx[0], 'X', DRAWLIGHT);
- }
- if (tc->mode & CON_AXIS1) {
- drawLine(t, tc->center, tc->mtx[1], 'Y', DRAWLIGHT);
- }
- if (tc->mode & CON_AXIS2) {
- drawLine(t, tc->center, tc->mtx[2], 'Z', DRAWLIGHT);
- }
- }
-}
-
/* called from drawview.c, as an extra per-window draw option */
void drawPropCircle(const struct bContext *C, TransInfo *t)
{
@@ -712,7 +648,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
unit_m4(imat);
}
- glPushMatrix();
+ gpuPushMatrix();
copy_v3_v3(center, t->center);
@@ -729,14 +665,14 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
else {
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
}
- glScalef(1.0f / aspx, 1.0f / aspy, 1.0);
+ gpuScale(1.0f / aspx, 1.0f / aspy, 1.0);
}
set_inverted_drawing(1);
- drawcircball(GL_LINE_LOOP, center, t->prop_size, imat);
+ gpuSingleFastBall(GL_LINE_LOOP, center, t->prop_size, imat);
set_inverted_drawing(0);
- glPopMatrix();
+ gpuPopMatrix();
}
}
@@ -745,6 +681,10 @@ static void drawObjectConstraint(TransInfo *t)
int i;
TransData *td = t->data;
+ gpuImmediateFormat_C4_V3();
+
+ gpuBegin(GL_LINES);
+
/* Draw the first one lighter because that's the one who controls the others.
* Meaning the transformation is projected on that one and just copied on the others
* constraint space.
@@ -752,28 +692,36 @@ static void drawObjectConstraint(TransInfo *t)
* Without drawing the first light, users have little clue what they are doing.
*/
if (t->con.mode & CON_AXIS0) {
- drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', DRAWLIGHT);
+ drawConstraintLine(t, td->ob->obmat[3], td->axismtx[0], 'X', DRAWLIGHT);
}
+
if (t->con.mode & CON_AXIS1) {
- drawLine(t, td->ob->obmat[3], td->axismtx[1], 'Y', DRAWLIGHT);
+ drawConstraintLine(t, td->ob->obmat[3], td->axismtx[1], 'Y', DRAWLIGHT);
}
+
if (t->con.mode & CON_AXIS2) {
- drawLine(t, td->ob->obmat[3], td->axismtx[2], 'Z', DRAWLIGHT);
+ drawConstraintLine(t, td->ob->obmat[3], td->axismtx[2], 'Z', DRAWLIGHT);
}
td++;
for (i = 1; i < t->total; i++, td++) {
if (t->con.mode & CON_AXIS0) {
- drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', 0);
+ drawConstraintLine(t, td->ob->obmat[3], td->axismtx[0], 'X', 0);
}
+
if (t->con.mode & CON_AXIS1) {
- drawLine(t, td->ob->obmat[3], td->axismtx[1], 'Y', 0);
+ drawConstraintLine(t, td->ob->obmat[3], td->axismtx[1], 'Y', 0);
}
+
if (t->con.mode & CON_AXIS2) {
- drawLine(t, td->ob->obmat[3], td->axismtx[2], 'Z', 0);
+ drawConstraintLine(t, td->ob->obmat[3], td->axismtx[2], 'Z', 0);
}
}
+
+ gpuEnd();
+
+ gpuImmediateUnformat();
}
/*--------------------- START / STOP CONSTRAINTS ---------------------- */
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 615bb786071..37dacef4a96 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -58,9 +58,6 @@
#include "RNA_access.h"
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_armature.h"
@@ -948,44 +945,6 @@ void recalcData(TransInfo *t)
}
}
-void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)
-{
- float v1[3], v2[3], v3[3];
- unsigned char col[3], col2[3];
-
- if (t->spacetype == SPACE_VIEW3D) {
- View3D *v3d = t->view;
-
- glPushMatrix();
-
- //if (t->obedit) glLoadMatrixf(t->obedit->obmat); // sets opengl viewing
-
-
- copy_v3_v3(v3, dir);
- mul_v3_fl(v3, v3d->far);
-
- sub_v3_v3v3(v2, center, v3);
- add_v3_v3v3(v1, center, v3);
-
- if (options & DRAWLIGHT) {
- col[0] = col[1] = col[2] = 220;
- }
- else {
- UI_GetThemeColor3ubv(TH_GRID, col);
- }
- UI_make_axis_color(col, col2, axis);
- glColor3ubv(col2);
-
- setlinestyle(0);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(v1);
- glVertex3fv(v2);
- glEnd();
-
- glPopMatrix();
- }
-}
-
void resetTransRestrictions(TransInfo *t)
{
t->flag &= ~T_ALL_RESTRICTIONS;
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index a3f45acc02e..757c99594cc 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -66,7 +66,8 @@
#include "BKE_pointcache.h"
#include "BKE_tessmesh.h"
-#include "BIF_gl.h"
+#include "GPU_primitives.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -640,10 +641,10 @@ static void test_manipulator_axis(const bContext *C)
static float screen_aligned(RegionView3D *rv3d, float mat[][4])
{
- glTranslatef(mat[3][0], mat[3][1], mat[3][2]);
+ gpuTranslate(mat[3][0], mat[3][1], mat[3][2]);
/* sets view screen aligned */
- glRotatef(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]);
+ gpuRotateVector(-2.0f * saacos(rv3d->viewquat[0]), rv3d->viewquat+1);
return len_v3(mat[0]); /* draw scale */
}
@@ -679,7 +680,7 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
sin_theta1 = (float)sin(theta1);
if (do_caps && i == start) { // cap
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
phi = 0.0;
for (j = nsides; j >= 0; j--) {
float cos_phi, sin_phi, dist;
@@ -689,12 +690,12 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
sin_phi = (float)sin(phi);
dist = radhole + radring * cos_phi;
- glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi);
+ gpuVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi);
}
- glEnd();
+ gpuEnd();
}
if (i >= start && i <= end) {
- glBegin(GL_QUAD_STRIP);
+ gpuBegin(GL_TRIANGLE_STRIP);
phi = 0.0;
for (j = nsides; j >= 0; j--) {
float cos_phi, sin_phi, dist;
@@ -704,14 +705,14 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
sin_phi = (float)sin(phi);
dist = radhole + radring * cos_phi;
- glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi);
- glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
+ gpuVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi);
+ gpuVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
}
- glEnd();
+ gpuEnd();
}
if (do_caps && i == end) { // cap
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
phi = 0.0;
for (j = nsides; j >= 0; j--) {
float cos_phi, sin_phi, dist;
@@ -721,9 +722,9 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i
sin_phi = (float)sin(phi);
dist = radhole + radring * cos_phi;
- glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
+ gpuVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
}
- glEnd();
+ gpuEnd();
}
@@ -749,80 +750,107 @@ static char axisBlendAngle(float angle)
* moving: in transform theme color
* else the red/green/blue
*/
-static void manipulator_setcolor(View3D *v3d, char axis, int colcode, unsigned char alpha)
+static void set_manipulator_color(View3D *v3d, char axis, int colcode, unsigned char alpha)
{
- unsigned char col[4] = {0};
- col[3] = alpha;
+ GLubyte col[4];
if (colcode == MAN_GHOST) {
+ col[0] = 0;
+ col[1] = 0;
+ col[2] = 0;
col[3] = 70;
}
else if (colcode == MAN_MOVECOL) {
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
+ col[3] = alpha;
}
else {
switch (axis) {
case 'C':
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
if (v3d->twmode == V3D_MANIP_LOCAL) {
- col[0] = col[0] > 200 ? 255 : col[0] + 55;
- col[1] = col[1] > 200 ? 255 : col[1] + 55;
- col[2] = col[2] > 200 ? 255 : col[2] + 55;
+ col[0] = col[0] > 200 ? 255 : col[0]+55;
+ col[1] = col[1] > 200 ? 255 : col[1]+55;
+ col[2] = col[2] > 200 ? 255 : col[2]+55;
+ col[3] = alpha;
}
else if (v3d->twmode == V3D_MANIP_NORMAL) {
- col[0] = col[0] < 55 ? 0 : col[0] - 55;
- col[1] = col[1] < 55 ? 0 : col[1] - 55;
- col[2] = col[2] < 55 ? 0 : col[2] - 55;
+ col[0] = col[0] < 55 ? 0 : col[0]-55;
+ col[1] = col[1] < 55 ? 0 : col[1]-55;
+ col[2] = col[2] < 55 ? 0 : col[2]-55;
+ col[3] = alpha;
}
break;
case 'X':
UI_GetThemeColor3ubv(TH_AXIS_X, col);
+ col[3] = alpha;
break;
case 'Y':
UI_GetThemeColor3ubv(TH_AXIS_Y, col);
+ col[3] = alpha;
break;
case 'Z':
UI_GetThemeColor3ubv(TH_AXIS_Z, col);
+ col[3] = alpha;
break;
default:
BLI_assert(!"invalid axis arg");
}
}
- glColor4ubv(col);
+ gpuCurrentColor4ubv(col);
}
/* viewmatrix should have been set OK, also no shademode! */
static void draw_manipulator_axes(View3D *v3d, RegionView3D *rv3d, int colcode, int flagx, int flagy, int flagz)
{
-
/* axes */
if (flagx) {
- manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0]));
- if (flagx & MAN_SCALE_X) glLoadName(MAN_SCALE_X);
- else if (flagx & MAN_TRANS_X) glLoadName(MAN_TRANS_X);
- glBegin(GL_LINES);
- glVertex3f(0.2f, 0.0f, 0.0f);
- glVertex3f(1.0f, 0.0f, 0.0f);
- glEnd();
+ set_manipulator_color(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0]));
+
+ if (flagx & MAN_SCALE_X) {
+ glLoadName(MAN_SCALE_X);
+ }
+ else if (flagx & MAN_TRANS_X) {
+ glLoadName(MAN_TRANS_X);
+ }
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.2f, 0.0f, 0.0f);
+ gpuVertex3f(1.0f, 0.0f, 0.0f);
+ gpuEnd();
}
+
if (flagy) {
- if (flagy & MAN_SCALE_Y) glLoadName(MAN_SCALE_Y);
- else if (flagy & MAN_TRANS_Y) glLoadName(MAN_TRANS_Y);
- manipulator_setcolor(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1]));
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.2f, 0.0f);
- glVertex3f(0.0f, 1.0f, 0.0f);
- glEnd();
+ if (flagy & MAN_SCALE_Y) {
+ glLoadName(MAN_SCALE_Y);
+ }
+ else if (flagy & MAN_TRANS_Y) {
+ glLoadName(MAN_TRANS_Y);
+ }
+
+ set_manipulator_color(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1]));
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.2f, 0.0f);
+ gpuVertex3f(0.0f, 1.0f, 0.0f);
+ gpuEnd();
}
+
if (flagz) {
- if (flagz & MAN_SCALE_Z) glLoadName(MAN_SCALE_Z);
- else if (flagz & MAN_TRANS_Z) glLoadName(MAN_TRANS_Z);
- manipulator_setcolor(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2]));
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.0f, 0.2f);
- glVertex3f(0.0f, 0.0f, 1.0f);
- glEnd();
+ if (flagz & MAN_SCALE_Z) {
+ glLoadName(MAN_SCALE_Z);
+ }
+ else if (flagz & MAN_TRANS_Z) {
+ glLoadName(MAN_TRANS_Z);
+ }
+
+ set_manipulator_color(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2]));
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.0f, 0.2f);
+ gpuVertex3f(0.0f, 0.0f, 1.0f);
+ gpuEnd();
}
}
@@ -832,8 +860,8 @@ static void preOrthoFront(int ortho, float twmat[][4], int axis)
float omat[4][4];
copy_m4_m4(omat, twmat);
orthogonalize_m4(omat, axis);
- glPushMatrix();
- glMultMatrixf(omat);
+ gpuPushMatrix();
+ gpuMultMatrix(omat);
glFrontFace(is_negative_m4(omat) ? GL_CW : GL_CCW);
}
}
@@ -841,39 +869,35 @@ static void preOrthoFront(int ortho, float twmat[][4], int axis)
static void postOrtho(int ortho)
{
if (ortho == 0) {
- glPopMatrix();
+ gpuPopMatrix();
}
}
static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo)
{
- GLUquadricObj *qobj;
double plane[4];
float matt[4][4];
- float size, unitmat[4][4];
+ float size;
float cywid = 0.33f * 0.01f * (float)U.tw_handlesize;
float cusize = cywid * 0.65f;
int arcs = (G.debug_value != 2);
int colcode;
int ortho;
- if (moving) colcode = MAN_MOVECOL;
- else colcode = MAN_RGB;
+ colcode = moving ? MAN_MOVECOL : MAN_RGB;
/* when called while moving in mixed mode, do not draw when... */
- if ((drawflags & MAN_ROT_C) == 0) return;
+ if (!(drawflags & MAN_ROT_C)) {
+ return;
+ }
/* Init stuff */
glDisable(GL_DEPTH_TEST);
- unit_m4(unitmat);
-
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_FILL);
/* prepare for screen aligned draw */
size = len_v3(rv3d->twmat[0]);
- glPushMatrix();
- glTranslatef(rv3d->twmat[3][0], rv3d->twmat[3][1], rv3d->twmat[3][2]);
+ gpuPushMatrix();
+ gpuTranslate(rv3d->twmat[3][0], rv3d->twmat[3][1], rv3d->twmat[3][2]);
if (arcs) {
/* clipplane makes nice handles, calc here because of multmatrix but with translate! */
@@ -881,30 +905,34 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
plane[3] = -0.02f * size; // clip just a bit more
glClipPlane(GL_CLIP_PLANE0, plane);
}
+
/* sets view screen aligned */
- glRotatef(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]);
+ gpuRotateVector(-2.0f * saacos(rv3d->viewquat[0]), rv3d->viewquat+1);
/* Screen aligned help circle */
- if (arcs) {
- if ((G.f & G_PICKSEL) == 0) {
- UI_ThemeColorShade(TH_BACK, -30);
- drawcircball(GL_LINE_LOOP, unitmat[3], size, unitmat);
- }
+ if (arcs && !(G.f & G_PICKSEL)) {
+ UI_ThemeColorShade(TH_BACK, -30);
+ gpuDrawFastCircleXY(size);
}
/* Screen aligned trackball rot circle */
if (drawflags & MAN_ROT_T) {
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_T);
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_T);
+ }
UI_ThemeColor(TH_TRANSFORM);
- drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
+ gpuDrawFastCircleXY(0.2f*size);
}
/* Screen aligned view rot circle */
if (drawflags & MAN_ROT_V) {
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V);
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_V);
+ }
+
UI_ThemeColor(TH_TRANSFORM);
- drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f * size, unitmat);
+ gpuDrawFastCircleXY(1.2f*size);
if (moving) {
float vec[3];
@@ -913,102 +941,32 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
vec[2] = 0.0f;
normalize_v3(vec);
mul_v3_fl(vec, 1.2f * size);
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glVertex3fv(vec);
- glEnd();
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.0f, 0.0f);
+ gpuVertex3fv(vec);
+ gpuEnd();
}
}
- glPopMatrix();
+ gpuPopMatrix();
ortho = is_orthogonal_m4(rv3d->twmat);
-
+
/* apply the transform delta */
if (moving) {
copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
// XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat);
if (ortho) {
- glMultMatrixf(matt);
+ gpuMultMatrix(matt);
glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW);
}
}
- else {
- if (ortho) {
- glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW);
- glMultMatrixf(rv3d->twmat);
- }
+ else if (ortho) {
+ glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW:GL_CCW);
+ gpuMultMatrix(rv3d->twmat);
}
- /* axes */
- if (arcs == 0) {
- if (!(G.f & G_PICKSEL)) {
- if ((combo & V3D_MANIP_SCALE) == 0) {
- /* axis */
- if ((drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z))) {
- preOrthoFront(ortho, rv3d->twmat, 2);
- manipulator_setcolor(v3d, 'X', colcode, 255);
- glBegin(GL_LINES);
- glVertex3f(0.2f, 0.0f, 0.0f);
- glVertex3f(1.0f, 0.0f, 0.0f);
- glEnd();
- postOrtho(ortho);
- }
- if ((drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X))) {
- preOrthoFront(ortho, rv3d->twmat, 0);
- manipulator_setcolor(v3d, 'Y', colcode, 255);
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.2f, 0.0f);
- glVertex3f(0.0f, 1.0f, 0.0f);
- glEnd();
- postOrtho(ortho);
- }
- if ((drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y))) {
- preOrthoFront(ortho, rv3d->twmat, 1);
- manipulator_setcolor(v3d, 'Z', colcode, 255);
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.0f, 0.2f);
- glVertex3f(0.0f, 0.0f, 1.0f);
- glEnd();
- postOrtho(ortho);
- }
- }
- }
- }
-
- if (arcs == 0 && moving) {
-
- /* Z circle */
- if (drawflags & MAN_ROT_Z) {
- preOrthoFront(ortho, matt, 2);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
- manipulator_setcolor(v3d, 'Z', colcode, 255);
- drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
- postOrtho(ortho);
- }
- /* X circle */
- if (drawflags & MAN_ROT_X) {
- preOrthoFront(ortho, matt, 0);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
- glRotatef(90.0, 0.0, 1.0, 0.0);
- manipulator_setcolor(v3d, 'X', colcode, 255);
- drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
- glRotatef(-90.0, 0.0, 1.0, 0.0);
- postOrtho(ortho);
- }
- /* Y circle */
- if (drawflags & MAN_ROT_Y) {
- preOrthoFront(ortho, matt, 1);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- manipulator_setcolor(v3d, 'Y', colcode, 255);
- drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
- glRotatef(90.0, 1.0, 0.0, 0.0);
- postOrtho(ortho);
- }
-
- if (arcs) glDisable(GL_CLIP_PLANE0);
- }
// donut arcs
if (arcs) {
glEnable(GL_CLIP_PLANE0);
@@ -1016,87 +974,199 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* Z circle */
if (drawflags & MAN_ROT_Z) {
preOrthoFront(ortho, rv3d->twmat, 2);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
- manipulator_setcolor(v3d, 'Z', colcode, 255);
- partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
+
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_Z);
+ }
+
+ set_manipulator_color(v3d, 'Z', colcode, 255);
+ partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48);
postOrtho(ortho);
}
+
/* X circle */
if (drawflags & MAN_ROT_X) {
preOrthoFront(ortho, rv3d->twmat, 0);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
- glRotatef(90.0, 0.0, 1.0, 0.0);
- manipulator_setcolor(v3d, 'X', colcode, 255);
- partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
- glRotatef(-90.0, 0.0, 1.0, 0.0);
+
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_X);
+ }
+
+ gpuRotateRight('Y');
+ set_manipulator_color(v3d, 'X', colcode, 255);
+ partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48);
+ gpuRotateRight(-'Y');
postOrtho(ortho);
}
+
/* Y circle */
if (drawflags & MAN_ROT_Y) {
preOrthoFront(ortho, rv3d->twmat, 1);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- manipulator_setcolor(v3d, 'Y', colcode, 255);
- partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
- glRotatef(90.0, 1.0, 0.0, 0.0);
+
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_Y);
+ }
+
+ gpuRotateRight(-'X');
+ set_manipulator_color(v3d, 'Y', colcode, 255);
+ partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48);
+ gpuRotateRight('X');
postOrtho(ortho);
}
glDisable(GL_CLIP_PLANE0);
}
+ else /* !arcs */ {
+ /* axes */
+ if (!(G.f & G_PICKSEL) && !(combo & V3D_MANIP_SCALE)) {
+
+ if ( (drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z)) ) {
+ preOrthoFront(ortho, rv3d->twmat, 2);
+ set_manipulator_color(v3d, 'X', colcode, 255);
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.2f, 0.0f, 0.0f);
+ gpuVertex3f(1.0f, 0.0f, 0.0f);
+ gpuEnd();
+
+ postOrtho(ortho);
+ }
+
+ if ( (drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X)) ) {
+ preOrthoFront(ortho, rv3d->twmat, 0);
+ set_manipulator_color(v3d, 'Y', colcode, 255);
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.2f, 0.0f);
+ gpuVertex3f(0.0f, 1.0f, 0.0f);
+ gpuEnd();
+
+ postOrtho(ortho);
+ }
+
+ if ( (drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y)) ) {
+ preOrthoFront(ortho, rv3d->twmat, 1);
+ set_manipulator_color(v3d, 'Z', colcode, 255);
+
+ gpuBegin(GL_LINES);
+ gpuVertex3f(0.0f, 0.0f, 0.2f);
+ gpuVertex3f(0.0f, 0.0f, 1.0f);
+ gpuEnd();
+
+ postOrtho(ortho);
+ }
+ }
+
+ if (moving) {
+ /* Z circle */
+ if (drawflags & MAN_ROT_Z) {
+ preOrthoFront(ortho, matt, 2);
+
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_Z);
+ }
+
+ set_manipulator_color(v3d, 'Z', colcode, 255);
+ gpuDrawFastCircleXY(1);
+ postOrtho(ortho);
+ }
+
+ /* X circle */
+ if (drawflags & MAN_ROT_X) {
+ preOrthoFront(ortho, matt, 0);
+
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_X);
+ }
+
+ gpuPushMatrix();
+ gpuRotateRight('Y');
+ set_manipulator_color(v3d, 'X', colcode, 255);
+ gpuDrawFastCircleXY(1);
+ gpuPopMatrix();
+ postOrtho(ortho);
+ }
+
+ /* Y circle */
+ if (drawflags & MAN_ROT_Y) {
+ preOrthoFront(ortho, matt, 1);
+
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_Y);
+ }
+
+ gpuPushMatrix();
+ gpuRotateRight(-'X');
+ set_manipulator_color(v3d, 'Y', colcode, 255);
+ gpuDrawFastCircleXY(1);
+ gpuPopMatrix();
+ postOrtho(ortho);
+ }
- if (arcs == 0) {
+ if (arcs) {
+ glDisable(GL_CLIP_PLANE0);
+ }
+ }
/* Z handle on X axis */
if (drawflags & MAN_ROT_Z) {
preOrthoFront(ortho, rv3d->twmat, 2);
- glPushMatrix();
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
- manipulator_setcolor(v3d, 'Z', colcode, 255);
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_Z);
+ }
+
+ set_manipulator_color(v3d, 'Z', colcode, 255);
partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64);
- glPopMatrix();
postOrtho(ortho);
}
/* Y handle on X axis */
if (drawflags & MAN_ROT_Y) {
preOrthoFront(ortho, rv3d->twmat, 1);
- glPushMatrix();
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
- manipulator_setcolor(v3d, 'Y', colcode, 255);
- glRotatef(90.0, 1.0, 0.0, 0.0);
- glRotatef(90.0, 0.0, 0.0, 1.0);
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_Y);
+ }
+
+ gpuPushMatrix();
+ gpuRotateRight('X');
+ gpuRotateRight('Z');
+
+ set_manipulator_color(v3d, 'Y', colcode, 255);
partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64);
- glPopMatrix();
+ gpuPopMatrix();
postOrtho(ortho);
}
/* X handle on Z axis */
if (drawflags & MAN_ROT_X) {
preOrthoFront(ortho, rv3d->twmat, 0);
- glPushMatrix();
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
- manipulator_setcolor(v3d, 'X', colcode, 255);
- glRotatef(-90.0, 0.0, 1.0, 0.0);
- glRotatef(90.0, 0.0, 0.0, 1.0);
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_ROT_X);
+ }
+
+ gpuPushMatrix();
+ gpuRotateRight(-'Y');
+ gpuRotateRight('Z');
+
+ set_manipulator_color(v3d, 'X', colcode, 255);
partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64);
- glPopMatrix();
+ gpuPopMatrix();
postOrtho(ortho);
}
-
}
/* restore */
- glLoadMatrixf(rv3d->viewmat);
- gluDeleteQuadric(qobj);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+ gpuLoadMatrix(rv3d->viewmat);
+ if (v3d->zbuf) {
+ glEnable(GL_DEPTH_TEST);
+ }
}
static void drawsolidcube(float size)
@@ -1113,51 +1183,51 @@ static void drawsolidcube(float size)
};
float n[3] = {0.0f};
- glPushMatrix();
- glScalef(size, size, size);
+ gpuPushMatrix();
+ gpuScale(size, size, size);
- glBegin(GL_QUADS);
+ gpuBegin(GL_TRIANGLE_FAN);
n[0] = -1.0;
- glNormal3fv(n);
- glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]);
+ gpuNormal3fv(n);
+ gpuVertex3fv(cube[0]); gpuVertex3fv(cube[1]); gpuVertex3fv(cube[2]); gpuVertex3fv(cube[3]);
n[0] = 0;
- glEnd();
+ gpuEnd();
- glBegin(GL_QUADS);
+ gpuBegin(GL_TRIANGLE_FAN);
n[1] = -1.0;
- glNormal3fv(n);
- glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[1]);
+ gpuNormal3fv(n);
+ gpuVertex3fv(cube[0]); gpuVertex3fv(cube[4]); gpuVertex3fv(cube[5]); gpuVertex3fv(cube[1]);
n[1] = 0;
- glEnd();
+ gpuEnd();
- glBegin(GL_QUADS);
+ gpuBegin(GL_TRIANGLE_FAN);
n[0] = 1.0;
- glNormal3fv(n);
- glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glVertex3fv(cube[5]);
+ gpuNormal3fv(n);
+ gpuVertex3fv(cube[4]); gpuVertex3fv(cube[7]); gpuVertex3fv(cube[6]); gpuVertex3fv(cube[5]);
n[0] = 0;
- glEnd();
+ gpuEnd();
- glBegin(GL_QUADS);
+ gpuBegin(GL_TRIANGLE_FAN);
n[1] = 1.0;
- glNormal3fv(n);
- glVertex3fv(cube[7]); glVertex3fv(cube[3]); glVertex3fv(cube[2]); glVertex3fv(cube[6]);
+ gpuNormal3fv(n);
+ gpuVertex3fv(cube[7]); gpuVertex3fv(cube[3]); gpuVertex3fv(cube[2]); gpuVertex3fv(cube[6]);
n[1] = 0;
- glEnd();
+ gpuEnd();
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
n[2] = 1.0;
- glNormal3fv(n);
- glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]);
+ gpuNormal3fv(n);
+ gpuVertex3fv(cube[1]); gpuVertex3fv(cube[5]); gpuVertex3fv(cube[6]); gpuVertex3fv(cube[2]);
n[2] = 0;
- glEnd();
+ gpuEnd();
- glBegin(GL_QUADS);
+ gpuBegin(GL_QUADS);
n[2] = -1.0;
- glNormal3fv(n);
- glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]);
- glEnd();
+ gpuNormal3fv(n);
+ gpuVertex3fv(cube[7]); gpuVertex3fv(cube[4]); gpuVertex3fv(cube[0]); gpuVertex3fv(cube[3]);
+ gpuEnd();
- glPopMatrix();
+ gpuPopMatrix();
}
@@ -1179,12 +1249,12 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
/* center circle, do not add to selection when shift is pressed (planar constraint) */
if ((G.f & G_PICKSEL) && shift == 0) glLoadName(MAN_SCALE_C);
- manipulator_setcolor(v3d, 'C', colcode, 255);
- glPushMatrix();
+ set_manipulator_color(v3d, 'C', colcode, 255);
+ gpuPushMatrix();
size = screen_aligned(rv3d, rv3d->twmat);
unit_m4(unitmat);
- drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
- glPopMatrix();
+ gpuDrawFastCircleXY(0.2f*size);
+ gpuPopMatrix();
dz = 1.0;
}
@@ -1195,11 +1265,11 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
// XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat);
- glMultMatrixf(matt);
+ gpuMultMatrix(matt);
glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW);
}
else {
- glMultMatrixf(rv3d->twmat);
+ gpuMultMatrix(rv3d->twmat);
glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW);
}
@@ -1209,24 +1279,26 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_SCALE_X, drawflags & MAN_SCALE_Y, drawflags & MAN_SCALE_Z);
/* Z cube */
- glTranslatef(0.0, 0.0, dz);
+ gpuTranslate(0.0, 0.0, dz);
if (drawflags & MAN_SCALE_Z) {
if (G.f & G_PICKSEL) glLoadName(MAN_SCALE_Z);
- manipulator_setcolor(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2]));
+ set_manipulator_color(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2]));
drawsolidcube(cusize);
}
+
/* X cube */
- glTranslatef(dz, 0.0, -dz);
+ gpuTranslate(dz, 0.0, -dz);
if (drawflags & MAN_SCALE_X) {
if (G.f & G_PICKSEL) glLoadName(MAN_SCALE_X);
- manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0]));
+ set_manipulator_color(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0]));
drawsolidcube(cusize);
}
+
/* Y cube */
- glTranslatef(-dz, dz, 0.0);
+ gpuTranslate(-dz, dz, 0.0);
if (drawflags & MAN_SCALE_Y) {
if (G.f & G_PICKSEL) glLoadName(MAN_SCALE_Y);
- manipulator_setcolor(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1]));
+ set_manipulator_color(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1]));
drawsolidcube(cusize);
}
@@ -1235,77 +1307,49 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
int shift = 0; // XXX
if (shift) {
- glTranslatef(0.0, -dz, 0.0);
+ gpuTranslate(0.0, -dz, 0.0);
glLoadName(MAN_SCALE_C);
- glBegin(GL_POINTS);
- glVertex3f(0.0, 0.0, 0.0);
- glEnd();
+ gpuBegin(GL_POINTS);
+ gpuVertex3f(0.0, 0.0, 0.0);
+ gpuEnd();
}
}
/* restore */
- glLoadMatrixf(rv3d->viewmat);
+ gpuLoadMatrix(rv3d->viewmat);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
glFrontFace(GL_CCW);
}
-
-static void draw_cone(GLUquadricObj *qobj, float len, float width)
-{
- glTranslatef(0.0, 0.0, -0.5f * len);
- gluCylinder(qobj, width, 0.0, len, 8, 1);
- gluQuadricOrientation(qobj, GLU_INSIDE);
- gluDisk(qobj, 0.0, width, 8, 1);
- gluQuadricOrientation(qobj, GLU_OUTSIDE);
- glTranslatef(0.0, 0.0, 0.5f * len);
-}
-
-static void draw_cylinder(GLUquadricObj *qobj, float len, float width)
-{
-
- width *= 0.8f; // just for beauty
-
- glTranslatef(0.0, 0.0, -0.5f * len);
- gluCylinder(qobj, width, width, len, 8, 1);
- gluQuadricOrientation(qobj, GLU_INSIDE);
- gluDisk(qobj, 0.0, width, 8, 1);
- gluQuadricOrientation(qobj, GLU_OUTSIDE);
- glTranslatef(0.0, 0.0, len);
- gluDisk(qobj, 0.0, width, 8, 1);
- glTranslatef(0.0, 0.0, -0.5f * len);
-}
-
-
static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUSED(moving), int drawflags, int combo, int colcode)
{
- GLUquadricObj *qobj;
+ GPUprim3 prim = GPU_PRIM_LOFI_SHADELESS;
+
float cylen = 0.01f * (float)U.tw_handlesize;
float cywid = 0.25f * cylen, dz, size;
- float unitmat[4][4];
int shift = 0; // XXX
/* when called while moving in mixed mode, do not draw when... */
if ((drawflags & MAN_TRANS_C) == 0) return;
- // XXX if (moving) glTranslatef(t->vec[0], t->vec[1], t->vec[2]);
+ // XXX if (moving) gpuTranslate(t->vec[0], t->vec[1], t->vec[2]);
glDisable(GL_DEPTH_TEST);
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_FILL);
-
/* center circle, do not add to selection when shift is pressed (planar constraint) */
- if ((G.f & G_PICKSEL) && shift == 0) glLoadName(MAN_TRANS_C);
+ if ( (G.f & G_PICKSEL) && shift==0) {
+ glLoadName(MAN_TRANS_C);
+ }
+
+ set_manipulator_color(v3d, 'C', colcode, 255);
- manipulator_setcolor(v3d, 'C', colcode, 255);
- glPushMatrix();
+ gpuPushMatrix();
size = screen_aligned(rv3d, rv3d->twmat);
- unit_m4(unitmat);
- drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
- glPopMatrix();
+ gpuDrawFastCircleXY(0.2f*size);
+ gpuPopMatrix();
/* and now apply matrix, we move to local matrix drawing */
- glMultMatrixf(rv3d->twmat);
+ gpuMultMatrix(rv3d->twmat);
/* axis */
glLoadName(-1);
@@ -1314,146 +1358,78 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUS
if ((combo & V3D_MANIP_SCALE) == 0 || colcode == MAN_GHOST)
draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_TRANS_X, drawflags & MAN_TRANS_Y, drawflags & MAN_TRANS_Z);
-
/* offset in combo mode, for rotate a bit more */
- if (combo & (V3D_MANIP_ROTATE)) dz = 1.0f + 2.0f * cylen;
- else if (combo & (V3D_MANIP_SCALE)) dz = 1.0f + 0.5f * cylen;
- else dz = 1.0f;
-
- /* Z Cone */
- glTranslatef(0.0, 0.0, dz);
- if (drawflags & MAN_TRANS_Z) {
- if (G.f & G_PICKSEL) glLoadName(MAN_TRANS_Z);
- manipulator_setcolor(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2]));
- draw_cone(qobj, cylen, cywid);
+ if (combo & (V3D_MANIP_ROTATE)) {
+ dz= 1.0f+2.0f*cylen;
}
- /* X Cone */
- glTranslatef(dz, 0.0, -dz);
- if (drawflags & MAN_TRANS_X) {
- if (G.f & G_PICKSEL) glLoadName(MAN_TRANS_X);
- glRotatef(90.0, 0.0, 1.0, 0.0);
- manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0]));
- draw_cone(qobj, cylen, cywid);
- glRotatef(-90.0, 0.0, 1.0, 0.0);
+ else if (combo & (V3D_MANIP_SCALE)) {
+ dz= 1.0f+0.5f*cylen;
}
- /* Y Cone */
- glTranslatef(-dz, dz, 0.0);
- if (drawflags & MAN_TRANS_Y) {
- if (G.f & G_PICKSEL) glLoadName(MAN_TRANS_Y);
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- manipulator_setcolor(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1]));
- draw_cone(qobj, cylen, cywid);
+ else {
+ dz= 1.0f;
}
- gluDeleteQuadric(qobj);
- glLoadMatrixf(rv3d->viewmat);
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+ prim.vsegs = 1;
-}
+ gpuBegin(GL_NOOP);
+ gpuAppendCone(&prim, cywid, cylen);
+ gpuEnd();
-static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
-{
- GLUquadricObj *qobj;
- float size;
- float cylen = 0.01f * (float)U.tw_handlesize;
- float cywid = 0.25f * cylen;
+ /* Z Cone */
- /* when called while moving in mixed mode, do not draw when... */
- if ((drawflags & MAN_ROT_C) == 0) return;
+ gpuTranslate(0.0, 0.0, dz);
- /* prepare for screen aligned draw */
- glPushMatrix();
- size = screen_aligned(rv3d, rv3d->twmat);
+ if (drawflags & MAN_TRANS_Z) {
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_TRANS_Z);
+ }
- glDisable(GL_DEPTH_TEST);
+ set_manipulator_color(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2]));
- qobj = gluNewQuadric();
+ gpuDrawElements(GL_TRIANGLES);
+ }
- /* Screen aligned view rot circle */
- if (drawflags & MAN_ROT_V) {
- float unitmat[4][4] = MAT4_UNITY;
+ /* X Cone */
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V);
- UI_ThemeColor(TH_TRANSFORM);
- drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f * size, unitmat);
+ gpuTranslate(dz, 0.0, -dz);
- if (moving) {
- float vec[3];
- vec[0] = 0; // XXX (float)(t->imval[0] - t->center2d[0]);
- vec[1] = 0; // XXX (float)(t->imval[1] - t->center2d[1]);
- vec[2] = 0.0f;
- normalize_v3(vec);
- mul_v3_fl(vec, 1.2f * size);
- glBegin(GL_LINES);
- glVertex3f(0.0, 0.0, 0.0);
- glVertex3fv(vec);
- glEnd();
+ if (drawflags & MAN_TRANS_X) {
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_TRANS_X);
}
- }
- glPopMatrix();
- /* apply the transform delta */
- if (moving) {
- float matt[4][4];
- copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
- // XXX if (t->flag & T_USES_MANIPULATOR) {
- // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat);
- // XXX }
- glMultMatrixf(matt);
- }
- else {
- glMultMatrixf(rv3d->twmat);
+ set_manipulator_color(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0]));
+
+ gpuPushMatrix();
+ gpuRotateRight('Y');
+ gpuDrawElements(GL_TRIANGLES);
+ gpuPopMatrix();
}
- glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW);
+ /* Y Cone */
- /* axis */
- if ((G.f & G_PICKSEL) == 0) {
+ gpuTranslate(-dz, dz, 0.0);
- // only draw axis when combo didn't draw scale axes
- if ((combo & V3D_MANIP_SCALE) == 0)
- draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_ROT_X, drawflags & MAN_ROT_Y, drawflags & MAN_ROT_Z);
+ if (drawflags & MAN_TRANS_Y) {
+ if (G.f & G_PICKSEL) {
+ glLoadName(MAN_TRANS_Y);
+ }
- /* only has to be set when not in picking */
- gluQuadricDrawStyle(qobj, GLU_FILL);
- }
+ set_manipulator_color(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1]));
- /* Z cyl */
- glTranslatef(0.0, 0.0, 1.0);
- if (drawflags & MAN_ROT_Z) {
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
- manipulator_setcolor(v3d, 'Z', colcode, 255);
- draw_cylinder(qobj, cylen, cywid);
- }
- /* X cyl */
- glTranslatef(1.0, 0.0, -1.0);
- if (drawflags & MAN_ROT_X) {
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
- glRotatef(90.0, 0.0, 1.0, 0.0);
- manipulator_setcolor(v3d, 'X', colcode, 255);
- draw_cylinder(qobj, cylen, cywid);
- glRotatef(-90.0, 0.0, 1.0, 0.0);
- }
- /* Y cylinder */
- glTranslatef(-1.0, 1.0, 0.0);
- if (drawflags & MAN_ROT_Y) {
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- manipulator_setcolor(v3d, 'Y', colcode, 255);
- draw_cylinder(qobj, cylen, cywid);
+ gpuPushMatrix();
+ gpuRotateRight(-'X');
+ gpuDrawElements(GL_TRIANGLES);
+ gpuPopMatrix();
}
- /* restore */
-
- gluDeleteQuadric(qobj);
- glLoadMatrixf(rv3d->viewmat);
-
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+ gpuLoadMatrix(rv3d->viewmat);
+ if (v3d->zbuf) {
+ glEnable(GL_DEPTH_TEST);
+ }
}
-
/* ********************************************* */
/* main call, does calc centers & orientation too */
@@ -1472,12 +1448,18 @@ void BIF_draw_manipulator(const bContext *C)
if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return;
// if (G.moving && (G.moving & G_TRANSFORM_MANIP)==0) return;
+ gpuImmediateFormat_V3(); // draw manipulator
+
// if (G.moving==0) {
{
v3d->twflag &= ~V3D_DRAW_MANIPULATOR;
totsel = calc_manipulator_stats(C);
- if (totsel == 0) return;
+
+ if (totsel==0) {
+ gpuImmediateUnformat();
+ return;
+ }
v3d->twflag |= V3D_DRAW_MANIPULATOR;
@@ -1511,16 +1493,9 @@ void BIF_draw_manipulator(const bContext *C)
if (v3d->twflag & V3D_DRAW_MANIPULATOR) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
if (v3d->twtype & V3D_MANIP_ROTATE) {
-
- if (G.debug_value == 3) {
- if (G.moving) draw_manipulator_rotate_cyl(v3d, rv3d, 1, drawflags, v3d->twtype, MAN_MOVECOL);
- else draw_manipulator_rotate_cyl(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB);
- }
- else
- draw_manipulator_rotate(v3d, rv3d, 0 /* G.moving*/, drawflags, v3d->twtype);
+ draw_manipulator_rotate(v3d, rv3d, 0 /* G.moving*/, drawflags, v3d->twtype);
}
if (v3d->twtype & V3D_MANIP_SCALE) {
draw_manipulator_scale(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB);
@@ -1531,6 +1506,8 @@ void BIF_draw_manipulator(const bContext *C)
glDisable(GL_BLEND);
}
+
+ gpuImmediateUnformat();
}
static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot)
@@ -1559,8 +1536,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
/* do the drawing */
if (v3d->twtype & V3D_MANIP_ROTATE) {
- if (G.debug_value == 3) draw_manipulator_rotate_cyl(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB);
- else draw_manipulator_rotate(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype);
+ draw_manipulator_rotate(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype);
}
if (v3d->twtype & V3D_MANIP_SCALE)
draw_manipulator_scale(v3d, rv3d, 0, MAN_SCALE_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB);
@@ -1629,6 +1605,8 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
/* Force orientation */
RNA_enum_set(op->ptr, "constraint_orientation", v3d->twmode);
+ gpuImmediateFormat_V3(); // DOODLE: do manipulator
+
// find the hotspots first test narrow hotspot
val = manipulator_selectbuf(sa, ar, event->mval, 0.5f * (float)U.tw_hotspot);
if (val) {
@@ -1725,6 +1703,8 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
/* after transform, restore drawflags */
drawflags = 0xFFFF;
+ gpuImmediateUnformat();
+
return val;
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index a6fb7e7ed00..2908df41aa3 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -53,7 +53,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BIF_gl.h"
+#include "GPU_compatibility.h"
#include "BKE_DerivedMesh.h"
#include "BKE_object.h"
@@ -131,134 +131,6 @@ int activeSnap(TransInfo *t)
return (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT;
}
-void drawSnapping(const struct bContext *C, TransInfo *t)
-{
- unsigned char col[4], selectedCol[4], activeCol[4];
-
- if (!activeSnap(t))
- return;
-
- UI_GetThemeColor3ubv(TH_TRANSFORM, col);
- col[3] = 128;
-
- UI_GetThemeColor3ubv(TH_SELECT, selectedCol);
- selectedCol[3] = 128;
-
- UI_GetThemeColor3ubv(TH_ACTIVE, activeCol);
- activeCol[3] = 192;
-
- if (t->spacetype == SPACE_VIEW3D) {
- if (validSnap(t)) {
- TransSnapPoint *p;
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- float imat[4][4];
- float size;
-
- glDisable(GL_DEPTH_TEST);
-
- size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
-
- invert_m4_m4(imat, rv3d->viewmat);
-
- for (p = t->tsnap.points.first; p; p = p->next) {
- if (p == t->tsnap.selectedPoint) {
- glColor4ubv(selectedCol);
- }
- else {
- glColor4ubv(col);
- }
-
- drawcircball(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat);
- }
-
- if (t->tsnap.status & POINT_INIT) {
- glColor4ubv(activeCol);
-
- drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat);
- }
-
- /* draw normal if needed */
- if (usingSnappingNormal(t) && validSnappingNormal(t)) {
- glColor4ubv(activeCol);
-
- glBegin(GL_LINES);
- glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
- glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0],
- t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1],
- t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]);
- glEnd();
- }
-
- if (v3d->zbuf)
- glEnable(GL_DEPTH_TEST);
- }
- }
- else if (t->spacetype == SPACE_IMAGE) {
- if (validSnap(t)) {
- /* This will not draw, and Im nor sure why - campbell */
-#if 0
- float xuser_asp, yuser_asp;
- int wi, hi;
- float w, h;
-
- calc_image_view(G.sima, 'f'); // float
- myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
- glLoadIdentity();
-
- ED_space_image_get_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
- ED_space_image_width(t->sa->spacedata.first, &wi, &hi);
- w = (((float)wi) / IMG_SIZE_FALLBACK) * G.sima->zoom * xuser_asp;
- h = (((float)hi) / IMG_SIZE_FALLBACK) * G.sima->zoom * yuser_asp;
-
- cpack(0xFFFFFF);
- glTranslatef(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], 0.0f);
-
- //glRectf(0, 0, 1, 1);
-
- setlinestyle(0);
- cpack(0x0);
- fdrawline(-0.020 / w, 0, -0.1 / w, 0);
- fdrawline(0.1 / w, 0, 0.020 / w, 0);
- fdrawline(0, -0.020 / h, 0, -0.1 / h);
- fdrawline(0, 0.1 / h, 0, 0.020 / h);
-
- glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f);
- setlinestyle(0);
-#endif
- }
- }
- else if (t->spacetype == SPACE_NODE) {
- if (validSnap(t)) {
- ARegion *ar = CTX_wm_region(C);
- TransSnapPoint *p;
- float size;
-
- size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
-
- glEnable(GL_BLEND);
-
- for (p = t->tsnap.points.first; p; p = p->next) {
- if (p == t->tsnap.selectedPoint) {
- glColor4ubv(selectedCol);
- }
- else {
- glColor4ubv(col);
- }
-
- ED_node_draw_snap(&ar->v2d, p->co, size, 0);
- }
-
- if (t->tsnap.status & POINT_INIT) {
- glColor4ubv(activeCol);
-
- ED_node_draw_snap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder);
- }
-
- glDisable(GL_BLEND);
- }
- }
-}
int handleSnapping(TransInfo *t, wmEvent *event)
{
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index e0991c48fa6..0c94205f537 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -44,7 +44,6 @@ set(SRC
util_intern.h
# general includes
- ../include/BIF_gl.h
../include/BIF_glutil.h
../include/ED_anim_api.h
../include/ED_armature.h
diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt
index 1c69e569aa6..5c7adb62815 100644
--- a/source/blender/editors/uvedit/CMakeLists.txt
+++ b/source/blender/editors/uvedit/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenlib
../../blenloader
../../bmesh
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -47,4 +48,6 @@ set(SRC
uvedit_parametrizer.h
)
+add_definitions(-DGLEW_STATIC)
+
blender_add_lib(bf_editor_uvedit "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 9c2c300c530..a5a8b85b0b5 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -51,7 +51,9 @@
#include "BLI_array.h"
-#include "BIF_gl.h"
+#include "GPU_colors.h"
+#include "GPU_primitives.h"
+
#include "BIF_glutil.h"
#include "ED_util.h"
@@ -74,36 +76,43 @@ void draw_image_cursor(SpaceImage *sima, ARegion *ar)
w = zoomx * width / 256.0f;
h = zoomy * height / 256.0f;
- cpack(0xFFFFFF);
- glTranslatef(sima->cursor[0], sima->cursor[1], 0.0);
- fdrawline(-0.05f / w, 0, 0, 0.05f / h);
- fdrawline(0, 0.05f / h, 0.05f / w, 0.0f);
- fdrawline(0.05f / w, 0.0f, 0.0f, -0.05f / h);
- fdrawline(0.0f, -0.05f / h, -0.05f / w, 0.0f);
+ gpuTranslate(sima->cursor[0], sima->cursor[1], 0.0);
+
+ gpuImmediateFormat_C4_V2(); // DOODLE: uvedit cursor sima, 16 colored lines
+ gpuBegin(GL_LINES);
+
+ gpuColor3x(CPACK_WHITE);
+ gpuAppendLinef(-0.05f / w, 0, 0, 0.05f / h);
+ gpuAppendLinef(0, 0.05f / h, 0.05f / w, 0.0f);
+ gpuAppendLinef(0.05f / w, 0.0f, 0.0f, -0.05f / h);
+ gpuAppendLinef(0.0f, -0.05f / h, -0.05f / w, 0.0f);
setlinestyle(4);
- cpack(0xFF);
- fdrawline(-0.05f / w, 0.0f, 0.0f, 0.05f / h);
- fdrawline(0.0f, 0.05f / h, 0.05f / w, 0.0f);
- fdrawline(0.05f / w, 0.0f, 0.0f, -0.05f / h);
- fdrawline(0.0f, -0.05f / h, -0.05f / w, 0.0f);
+ gpuColor3x(CPACK_BLUE);
+ gpuAppendLinef(-0.05f / w, 0.0f, 0.0f, 0.05f / h);
+ gpuAppendLinef(0.0f, 0.05f / h, 0.05f / w, 0.0f);
+ gpuAppendLinef(0.05f / w, 0.0f, 0.0f, -0.05f / h);
+ gpuAppendLinef(0.0f, -0.05f / h, -0.05f / w, 0.0f);
setlinestyle(0.0f);
- cpack(0x0);
- fdrawline(-0.020f / w, 0.0f, -0.1f / w, 0.0f);
- fdrawline(0.1f / w, 0.0f, 0.020f / w, 0.0f);
- fdrawline(0.0f, -0.020f / h, 0.0f, -0.1f / h);
- fdrawline(0.0f, 0.1f / h, 0.0f, 0.020f / h);
+ gpuColor3x(CPACK_BLACK);
+ gpuAppendLinef(-0.020f / w, 0.0f, -0.1f / w, 0.0f);
+ gpuAppendLinef(0.1f / w, 0.0f, 0.020f / w, 0.0f);
+ gpuAppendLinef(0.0f, -0.020f / h, 0.0f, -0.1f / h);
+ gpuAppendLinef(0.0f, 0.1f / h, 0.0f, 0.020f / h);
setlinestyle(1);
- cpack(0xFFFFFF);
- fdrawline(-0.020f / w, 0.0f, -0.1f / w, 0.0f);
- fdrawline(0.1f / w, 0.0f, 0.020f / w, 0.0f);
- fdrawline(0.0f, -0.020f / h, 0.0f, -0.1f / h);
- fdrawline(0.0f, 0.1f / h, 0.0f, 0.020f / h);
+ gpuColor3x(CPACK_WHITE);
+ gpuAppendLinef(-0.020f / w, 0.0f, -0.1f / w, 0.0f);
+ gpuAppendLinef(0.1f / w, 0.0f, 0.020f / w, 0.0f);
+ gpuAppendLinef(0.0f, -0.020f / h, 0.0f, -0.1f / h);
+ gpuAppendLinef(0.0f, 0.1f / h, 0.0f, 0.020f / h);
- glTranslatef(-sima->cursor[0], -sima->cursor[1], 0.0);
+ gpuEnd();
+ gpuImmediateUnformat();
+
+ gpuTranslate(-sima->cursor[0], -sima->cursor[1], 0.0);
setlinestyle(0);
}
@@ -134,16 +143,16 @@ static void draw_uvs_shadow(Object *obedit)
MLoopUV *luv;
/* draws the gray mesh when painting */
- glColor3ub(112, 112, 112);
+ gpuCurrentGray3f(0.439f);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
}
@@ -152,7 +161,7 @@ static int draw_uvs_dm_shadow(DerivedMesh *dm)
/* draw shadow mesh - this is the mesh with the modifier applied */
if (dm && dm->drawUVEdges && CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) {
- glColor3ub(112, 112, 112);
+ gpuCurrentGray3f(0.439f);
dm->drawUVEdges(dm);
return 1;
}
@@ -217,15 +226,15 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
if (totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) {
col[0] = 1.0;
col[1] = col[2] = 0.0;
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
}
}
@@ -261,14 +270,14 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
areadiff = 1.0f - (area / uvarea);
weight_to_rgb(col, areadiff);
- glColor3fv(col);
+ gpuCurrentColor3fv(col);
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
}
}
@@ -335,15 +344,15 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
ang[i] = angle_normalized_v3v3(av[i], av[(i + 1) % nverts]);
}
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
a = fabsf(uvang[i] - ang[i]) / (float)M_PI;
weight_to_rgb(col, 1.0f - powf((1.0f - a), 2.0f));
- glColor3fv(col);
- glVertex2fv(luv->uv);
+ gpuColor3fv(col);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
else {
if (tf == activetf)
@@ -371,7 +380,7 @@ static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage)
{
Base *base;
- glColor3ub(96, 96, 96);
+ gpuCurrentGray3f(0.376f);
for (base = scene->base.first; base; base = base->next) {
Object *ob = base->object;
@@ -391,13 +400,13 @@ static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage)
for (a = me->totpoly; a > 0; a--, mtpoly++, mpoly++) {
if (mtpoly->tpage == curimage) {
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
mloopuv = me->mloopuv + mpoly->loopstart;
for (b = 0; b < mpoly->totloop; b++, mloopuv++) {
- glVertex2fv(mloopuv->uv);
+ gpuVertex2fv(mloopuv->uv);
}
- glEnd();
+ gpuEnd();
}
}
}
@@ -413,7 +422,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob)
if (sima->flag & SI_DRAW_OTHER)
draw_uvs_other(scene, ob, curimage);
- glColor3ub(112, 112, 112);
+ gpuCurrentGray3f(0.439f);
if (me->mtpoly) {
MPoly *mpoly = me->mpoly;
@@ -423,13 +432,13 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob)
for (a = me->totpoly; a > 0; a--, tface++, mpoly++) {
if (tface->tpage == curimage) {
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
mloopuv = me->mloopuv + mpoly->loopstart;
for (b = 0; b < mpoly->totloop; b++, mloopuv++) {
- glVertex2fv(mloopuv->uv);
+ gpuVertex2fv(mloopuv->uv);
}
- glEnd();
+ gpuEnd();
}
}
}
@@ -453,6 +462,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
int drawfaces, interpedges;
Image *ima = sima->image;
+ gpuImmediateFormat_C4_V2();
+
activetf = EDBM_mtexpoly_active_get(em, &efa_act, FALSE, FALSE); /* will be set to NULL if hidden */
activef = BM_active_face_get(bm, FALSE, FALSE);
ts = scene->toolsettings;
@@ -498,7 +509,6 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* draw transparent faces */
UI_GetThemeColor4ubv(TH_FACE, col1);
UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
@@ -509,16 +519,16 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
if (tf == activetf) continue; /* important the temp boolean is set above */
if (uvedit_face_select_test(scene, em, efa))
- glColor4ubv((GLubyte *)col2);
+ gpuCurrentColor4ubv((GLubyte *)col2);
else
- glColor4ubv((GLubyte *)col1);
+ gpuCurrentColor4ubv((GLubyte *)col1);
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
else {
if (tf == activetf)
@@ -552,18 +562,17 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
tf = CustomData_bmesh_get(&bm->pdata, activef->head.data, CD_MTEXPOLY);
if (uvedit_face_visible_test(scene, ima, activef, tf)) {
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UI_ThemeColor4(TH_EDITMESH_ACTIVE);
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(stipple_quarttone);
- glBegin(GL_POLYGON);
+ gpuBegin(GL_TRIANGLE_FAN);
BM_ITER_ELEM (l, &liter, activef, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
glDisable(GL_POLYGON_STIPPLE);
glDisable(GL_BLEND);
@@ -575,7 +584,6 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
if (sima->flag & SI_SMOOTH_UV) {
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
switch (sima->dt_uv) {
@@ -586,32 +594,32 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY);
if (tf) {
- cpack(0x111111);
+ gpuCurrentGray3f(0.067f);
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
setlinestyle(2);
- cpack(0x909090);
+ gpuCurrentGray3f(0.565f);
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
#if 0
- glBegin(GL_LINE_STRIP);
+ gpuBegin(GL_LINE_STRIP);
luv = CustomData_bmesh_get(&bm->ldata, efa->lbase->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
luv = CustomData_bmesh_get(&bm->ldata, efa->lbase->next->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
- glEnd();
+ gpuVertex2fv(luv->uv);
+ gpuEnd();
#endif
setlinestyle(0);
@@ -620,40 +628,40 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
break;
case SI_UVDT_BLACK: /* black/white */
case SI_UVDT_WHITE:
- if (sima->dt_uv == SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f);
- else glColor3f(0.0f, 0.0f, 0.0f);
+ gpuCurrentColor3x(
+ sima->dt_uv == SI_UVDT_WHITE ? CPACK_WHITE : CPACK_BLACK);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
break;
case SI_UVDT_OUTLINE:
glLineWidth(3);
- cpack(0x0);
+ gpuCurrentColor3x(CPACK_BLACK);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
glLineWidth(1);
col2[0] = col2[1] = col2[2] = 192; col2[3] = 255;
- glColor4ubv((unsigned char *)col2);
+ gpuCurrentColor4ubv((unsigned char *)col2);
if (me->drawflag & ME_DRAWEDGES) {
int sel, lastsel = -1;
@@ -666,15 +674,15 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
sel = (uvedit_uv_select_test(em, scene, l) ? 1 : 0);
- glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2);
+ gpuColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2);
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
glShadeModel(GL_FLAT);
@@ -684,19 +692,19 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- glBegin(GL_LINES);
+ gpuBegin(GL_LINES);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
sel = (uvedit_edge_select_test(em, scene, l) ? 1 : 0);
if (sel != lastsel) {
- glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2);
+ gpuColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2);
lastsel = sel;
}
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
luv = CustomData_bmesh_get(&bm->ldata, l->next->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
}
}
@@ -706,12 +714,12 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- glBegin(GL_LINE_LOOP);
+ gpuBegin(GL_LINE_LOOP);
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- glVertex2fv(luv->uv);
+ gpuVertex2fv(luv->uv);
}
- glEnd();
+ gpuEnd();
}
}
@@ -734,32 +742,32 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* unselected faces */
UI_ThemeColor(TH_WIRE);
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
if (!uvedit_face_select_test(scene, em, efa)) {
uv_poly_center(em, efa, cent);
- bglVertex2fv(cent);
+ gpuSprite2fv(cent);
}
}
- bglEnd();
+ gpuEndSprites();
/* selected faces */
UI_ThemeColor(TH_FACE_DOT);
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
if (uvedit_face_select_test(scene, em, efa)) {
uv_poly_center(em, efa, cent);
- bglVertex2fv(cent);
+ gpuSprite2fv(cent);
}
}
- bglEnd();
+ gpuEndSprites();
}
/* 6. draw uv vertices */
@@ -770,7 +778,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
glPointSize(pointsize);
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
@@ -778,17 +786,17 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
if (!uvedit_uv_select_test(em, scene, l))
- bglVertex2fv(luv->uv);
+ gpuSprite2fv(luv->uv);
}
}
- bglEnd();
-
+ gpuEndSprites();
+
/* pinned uvs */
/* give odd pointsizes odd pin pointsizes */
glPointSize(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0));
- cpack(0xFF);
-
- bglBegin(GL_POINTS);
+ gpuCurrentColor3x(CPACK_BLUE);
+
+ gpuBeginSprites();
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
@@ -797,16 +805,16 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
if (luv->flag & MLOOPUV_PINNED)
- bglVertex2fv(luv->uv);
+ gpuSprite2fv(luv->uv);
}
}
- bglEnd();
+ gpuEndSprites();
/* selected uvs */
UI_ThemeColor(TH_VERTEX_SELECT);
glPointSize(pointsize);
- bglBegin(GL_POINTS);
+ gpuBeginSprites();
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
@@ -815,13 +823,15 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
if (uvedit_uv_select_test(em, scene, l))
- bglVertex2fv(luv->uv);
+ gpuSprite2fv(luv->uv);
}
}
- bglEnd();
+ gpuEndSprites();
}
glPointSize(1.0);
+
+ gpuImmediateUnformat();
}
void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedit, Object *obact)
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 0feaec514d2..c6db7d4896a 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2978,7 +2978,7 @@ static int do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mov
static int uv_lasso_select_exec(bContext *C, wmOperator *op)
{
int mcords_tot;
- const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
+ int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
short select;
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index e10d70d48d1..cd260c4ea77 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -46,8 +46,6 @@
#include "BLI_math_vector.h"
#include "BLI_string.h"
-#include "BIF_gl.h"
-
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_depsgraph.h"
@@ -68,6 +66,8 @@
#include "UI_view2d.h"
#include "UI_resources.h"
+#include "GPU_compatibility.h"
+
#include "uvedit_intern.h"
/* ********************** smart stitch operator *********************** */