[Bf-blender-cvs] [587a163] blender2.8: Gawain: add immRect utility functions (replaces legacy glRect)
Mike Erwin
noreply at git.blender.org
Mon Oct 10 18:52:31 CEST 2016
Commit: 587a16352a331cd8e54faca241e2f723e4c8be2d
Author: Mike Erwin
Date: Mon Oct 10 12:30:55 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB587a16352a331cd8e54faca241e2f723e4c8be2d
Gawain: add immRect utility functions (replaces legacy glRect)
Caller is responsible for setting up vertex format, binding a shader program, and setting the color *before* calling immRect.
===================================================================
M source/blender/gpu/CMakeLists.txt
M source/blender/gpu/GPU_immediate.h
A source/blender/gpu/gawain/imm_util.c
A source/blender/gpu/gawain/imm_util.h
===================================================================
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 6b23bfc..668a948 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -72,6 +72,8 @@ set(SRC
gawain/element.h
gawain/immediate.c
gawain/immediate.h
+ gawain/imm_util.c
+ gawain/imm_util.h
gawain/vertex_buffer.c
gawain/vertex_buffer.h
gawain/vertex_format.c
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 7c4b161..8e7f91b 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -31,6 +31,7 @@
#pragma once
#include "gawain/immediate.h"
+#include "gawain/imm_util.h"
#include "GPU_shader.h"
/* Extend immBindProgram to use Blender’s library of built-in shader programs.
diff --git a/source/blender/gpu/gawain/imm_util.c b/source/blender/gpu/gawain/imm_util.c
new file mode 100644
index 0000000..0f253fe
--- /dev/null
+++ b/source/blender/gpu/gawain/imm_util.c
@@ -0,0 +1,46 @@
+
+// Gawain immediate mode drawing utilities
+//
+// This code is part of the Gawain library, with modifications
+// specific to integration with Blender.
+//
+// Copyright 2016 Mike Erwin
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
+// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+#include "imm_util.h"
+#include "immediate.h"
+
+
+void immRectf(unsigned pos, float x1, float y1, float x2, float y2)
+{
+ immBegin(GL_TRIANGLE_FAN, 4);
+ immVertex2f(pos, x1, y1);
+ immVertex2f(pos, x2, y1);
+ immVertex2f(pos, x2, y2);
+ immVertex2f(pos, x1, y2);
+ immEnd();
+}
+
+void immRecti(unsigned pos, int x1, int y1, int x2, int y2)
+{
+ immBegin(GL_TRIANGLE_FAN, 4);
+ immVertex2i(pos, x1, y1);
+ immVertex2i(pos, x2, y1);
+ immVertex2i(pos, x2, y2);
+ immVertex2i(pos, x1, y2);
+ immEnd();
+}
+
+#if 0 // more complete version in case we want that
+void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
+{
+ VertexFormat *format = immVertexFormat();
+ unsigned pos = add_attrib(format, "pos", GL_INT, 2, CONVERT_INT_TO_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4fv(color);
+ immRecti(pos, x1, y1, x2, y2);
+ immUnbindProgram();
+}
+#endif
diff --git a/source/blender/gpu/gawain/imm_util.h b/source/blender/gpu/gawain/imm_util.h
new file mode 100644
index 0000000..730bd7c
--- /dev/null
+++ b/source/blender/gpu/gawain/imm_util.h
@@ -0,0 +1,18 @@
+
+// Gawain immediate mode drawing utilities
+//
+// This code is part of the Gawain library, with modifications
+// specific to integration with Blender.
+//
+// Copyright 2016 Mike Erwin
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
+// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+#pragma once
+
+
+// Draw 2D rectangles (replaces glRect functions)
+// caller is reponsible for vertex format & shader
+void immRectf(unsigned pos, float x1, float y1, float x2, float y2);
+void immRecti(unsigned pos, int x1, int y1, int x2, int y2);
More information about the Bf-blender-cvs
mailing list