summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GLView.h11
-rw-r--r--src/OffscreenView.cc55
2 files changed, 62 insertions, 4 deletions
diff --git a/src/GLView.h b/src/GLView.h
index aefcfcb..2c5779d 100644
--- a/src/GLView.h
+++ b/src/GLView.h
@@ -1,8 +1,15 @@
#ifndef GLVIEW_H_
#define GLVIEW_H_
-// A basic OpenGL viewing rectangle.
-// Inherited by QGLview (for QT) and OffscreenView (non-QT)
+/* GLView: A basic OpenGL rectangle for rendering images.
+
+Inherited by QGLview (for QT GUI) and OffscreenView.
+
+There are two different types of cameras. A 'gimbal' based camera set
+using position & euler-angles (object_trans/object_rot/distance) and a
+'plain' camera set using eye-position, 'look at' center point, and 'up'
+
+*/
#include <Eigen/Core>
#include <Eigen/Geometry>
diff --git a/src/OffscreenView.cc b/src/OffscreenView.cc
index e499bb0..1b53082 100644
--- a/src/OffscreenView.cc
+++ b/src/OffscreenView.cc
@@ -40,8 +40,54 @@ void OffscreenView::enable_opencsg_shaders()
openscad_disable_gl20_env = NULL;
}
- if (glewIsSupported("GL_VERSION_2_0") && openscad_disable_gl20_env == NULL )
- {
+ // All OpenGL 2 contexts are OpenCSG capable
+ if (GLEW_VERSION_2_0) {
+ if (!openscad_disable_gl20_env) {
+ this->is_opencsg_capable = true;
+ this->has_shaders = true;
+ }
+ }
+
+ // If OpenGL < 2, check for extensions
+ else {
+ if (GLEW_ARB_framebuffer_object) this->is_opencsg_capable = true;
+ else if (GLEW_EXT_framebuffer_object && GLEW_EXT_packed_depth_stencil) {
+ this->is_opencsg_capable = true;
+ }
+#ifdef WIN32
+ else if (WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format) this->is_opencsg_capable = true;
+#elif !defined(__APPLE__)
+ else if (GLXEW_SGIX_pbuffer && GLXEW_SGIX_fbconfig) this->is_opencsg_capable = true;
+#endif
+ }
+
+ if (!GLEW_VERSION_2_0 || !this->is_opencsg_capable) {
+ fprintf(stderr, "OpenSCAD recommended OpenGL version is 2.0. \n");
+ }
+
+ if (opencsg_support && this->has_shaders) {
+ /*
+ Uniforms:
+ 1 color1 - face color
+ 2 color2 - edge color
+ 7 xscale
+ 8 yscale
+
+ Attributes:
+ 3 trig
+ 4 pos_b
+ 5 pos_c
+ 6 mask
+
+ Other:
+ 9 width
+ 10 height
+
+ Outputs:
+ tp
+ tr
+ shading
+ */
const char *vs_source =
"uniform float xscale, yscale;\n"
"attribute vec3 pos_b, pos_c;\n"
@@ -67,6 +113,11 @@ void OffscreenView::enable_opencsg_shaders()
" shading = abs(dot(normal, lightDir));\n"
"}\n";
+ /*
+ Inputs:
+ tp && tr - if any components of tp < tr, use color2 (edge color)
+ shading - multiplied by color1. color2 is is without lighting
+ */
const char *fs_source =
"uniform vec4 color1, color2;\n"
"varying vec3 tp, tr, tmp;\n"
contact: Jan Huwald // Impressum