summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RELEASE_NOTES3
-rw-r--r--doc/TODO.txt3
-rw-r--r--src/OpenCSGRenderer.cc2
-rw-r--r--src/ThrownTogetherRenderer.cc2
-rw-r--r--src/cgaladv_minkowski2.cc2
-rw-r--r--src/cgalrenderer.cc7
-rw-r--r--src/export.cc23
-rw-r--r--src/openscad.cc11
-rw-r--r--src/polyset.cc278
-rw-r--r--src/transform.cc31
-rw-r--r--tests/OffscreenContext.cc42
-rw-r--r--tests/opencsgtest.cc4
12 files changed, 376 insertions, 32 deletions
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index a95d588..880ba91 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -1,6 +1,9 @@
OpenSCAD 20xx.yy
================
+o The color() statement now supports an alpha parameter, e.g. color(c=[1,0,0], alpha=0.4)
+o The color() statement now supports specifying colors as strings, e.g. color("Red")
+
Bugfixes:
o square() crashed if any of the dimensions were zero
o Flush Caches didn't flush cached USE'd modules
diff --git a/doc/TODO.txt b/doc/TODO.txt
index 751b544..dd9932c 100644
--- a/doc/TODO.txt
+++ b/doc/TODO.txt
@@ -67,7 +67,7 @@ o MDI
and handle_dep.
o 3D View
- OpenGL 2.0 test: What, exactly, is needed from OpenGL 2.0? Can we use 1.x with extensions?
- - Improve mouse rotation
+ - Improve mouse rotation/zoom/pan
- Add modifier key combos to handle pan and zoom on 1 mouse button systems
- Show grid
- Measurement ticks on the axes that look like rulers that one can turn off and on.
@@ -78,6 +78,7 @@ o 3D View
- overlay indicator displaying current view mode
- OpenCSG rendering: Coincident surfaces causes z-buffer fighting. Is this somehow
avoidable tuning the depth tests in OpenCSG?
+ - Make the 10.000 element OpenCSG klimit configurable (Preferences) ?
- Use OpenGL picking to facilitate ray-tracing like features like measuring
thicknesses, distances, slot thicknesses etc.
o Editor wishlist
diff --git a/src/OpenCSGRenderer.cc b/src/OpenCSGRenderer.cc
index 6cbe849..3052c77 100644
--- a/src/OpenCSGRenderer.cc
+++ b/src/OpenCSGRenderer.cc
@@ -92,7 +92,7 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
chain->polysets[j]->render_surface(PolySet::COLORMODE_HIGHLIGHT, PolySet::csgmode_e(csgmode + 20), m, shaderinfo);
} else if (background) {
chain->polysets[j]->render_surface(PolySet::COLORMODE_BACKGROUND, PolySet::csgmode_e(csgmode + 10), m, shaderinfo);
- } else if (m[16] >= 0 || m[17] >= 0 || m[18] >= 0 || m[19] >= 0) {
+ } else if (m[16] >= 0 || m[17] >= 0 || m[18] >= 0) {
// User-defined color from source
glColor4d(m[16], m[17], m[18], m[19]);
if (shaderinfo) {
diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc
index 0a0c9c8..6e0325e 100644
--- a/src/ThrownTogetherRenderer.cc
+++ b/src/ThrownTogetherRenderer.cc
@@ -91,7 +91,7 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
} else {
chain->polysets[i]->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m);
}
- } else if (m[16] >= 0 || m[17] >= 0 || m[18] >= 0 || m[19] >= 0) {
+ } else if (m[16] >= 0 || m[17] >= 0 || m[18] >= 0) {
glColor4d(m[16], m[17], m[18], m[19]);
chain->polysets[i]->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m);
if (showedges) {
diff --git a/src/cgaladv_minkowski2.cc b/src/cgaladv_minkowski2.cc
index b722708..2020ab9 100644
--- a/src/cgaladv_minkowski2.cc
+++ b/src/cgaladv_minkowski2.cc
@@ -92,7 +92,7 @@ CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p)
}
//if (fit != E.faces_begin()) {
if (points.size() != 0) {
- PRINT("WARNING: minkowski() is not implemented for 2d objects with holes!");
+ PRINT("WARNING: minkowski() and hull() is not implemented for 2d objects with holes!");
break;
}
diff --git a/src/cgalrenderer.cc b/src/cgalrenderer.cc
index 687a0f1..d4bdffe 100644
--- a/src/cgalrenderer.cc
+++ b/src/cgalrenderer.cc
@@ -36,11 +36,13 @@ CGALRenderer::CGALRenderer(const CGAL_Nef_polyhedron &root) : root(root)
{
if (root.dim == 2) {
DxfData dd(root);
+ this->polyhedron = NULL;
this->polyset = new PolySet();
this->polyset->is2d = true;
dxf_tesselate(this->polyset, &dd, 0, true, false, 0);
}
else if (root.dim == 3) {
+ this->polyset = NULL;
this->polyhedron = new Polyhedron();
// FIXME: Make independent of Preferences
this->polyhedron->setColor(Polyhedron::CGAL_NEF3_MARKED_FACET_COLOR,
@@ -55,11 +57,16 @@ CGALRenderer::CGALRenderer(const CGAL_Nef_polyhedron &root) : root(root)
CGAL::OGL::Nef3_Converter<CGAL_Nef_polyhedron3>::convert_to_OGLPolyhedron(this->root.p3, this->polyhedron);
this->polyhedron->init();
}
+ else {
+ this->polyhedron = NULL;
+ this->polyset = NULL;
+ }
}
CGALRenderer::~CGALRenderer()
{
if (this->polyset) this->polyset->unlink();
+ delete this->polyhedron;
}
void CGALRenderer::draw(bool showfaces, bool showedges) const
diff --git a/src/export.cc b/src/export.cc
index e46a14f..bb389a0 100644
--- a/src/export.cc
+++ b/src/export.cc
@@ -32,6 +32,7 @@
#include <QProgressDialog>
#include <QTextStream>
#include <errno.h>
+#include <fstream>
#ifdef ENABLE_CGAL
#include "cgal.h"
@@ -52,6 +53,14 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialo
setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output
+ std::ofstream output(filename.toUtf8());
+ if (!output.is_open()) {
+ PRINTA("Can't open STL file \"%1\" for STL export: %2",
+ filename, QString(strerror(errno)));
+ set_output_handler(NULL, NULL);
+ return;
+ }
+
output << "solid OpenSCAD_Model\n";
int facet_count = 0;
@@ -73,10 +82,15 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialo
double x3 = CGAL::to_double(v3.point().x());
double y3 = CGAL::to_double(v3.point().y());
double z3 = CGAL::to_double(v3.point().z());
- QString vs1, vs2, vs3;
- vs1.sprintf("%f %f %f", x1, y1, z1);
- vs2.sprintf("%f %f %f", x2, y2, z2);
- vs3.sprintf("%f %f %f", x3, y3, z3);
+ std::stringstream stream;
+ stream << x1 << " " << y1 << " " << z1;
+ std::string vs1 = stream.str();
+ stream.str("");
+ stream << x2 << " " << y2 << " " << z2;
+ std::string vs2 = stream.str();
+ stream.str("");
+ stream << x3 << " " << y3 << " " << z3;
+ std::string vs3 = stream.str();
if (vs1 != vs2 && vs1 != vs3 && vs2 != vs3) {
double nx = (y1-y2)*(z1-z3) - (z1-z2)*(y1-y3);
@@ -105,6 +119,7 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialo
}
output << "endsolid OpenSCAD_Model\n";
+ output.close();
setlocale(LC_NUMERIC, ""); // Set default locale
}
diff --git a/src/openscad.cc b/src/openscad.cc
index f3aee76..3258820 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -333,6 +333,7 @@ int main(int argc, char **argv)
fclose(fp);
}
+<<<<<<< HEAD
if (stl_output_file) {
QFile file(stl_output_file);
if (!file.open(QIODevice::ReadWrite)) {
@@ -344,6 +345,15 @@ int main(int argc, char **argv)
file.close();
}
}
+=======
+ if (root_N->dim == 3 && !root_N->p3.is_simple()) {
+ fprintf(stderr, "Object isn't a valid 2-manifold! Modify your design.\n");
+ exit(1);
+ }
+
+ if (stl_output_file)
+ export_stl(root_N, stl_output_file, NULL);
+>>>>>>> upstream/master
if (off_output_file) {
QFile file(stl_output_file);
@@ -418,4 +428,3 @@ int main(int argc, char **argv)
return rc;
}
-
diff --git a/src/polyset.cc b/src/polyset.cc
index 19b0bba..6ecf586 100644
--- a/src/polyset.cc
+++ b/src/polyset.cc
@@ -330,5 +330,281 @@ BoundingBox PolySet::getBoundingBox() const
bbox.extend(p);
}
}
- return bbox;
+};
+
+CGAL_Nef_polyhedron PolySet::render_cgal_nef_polyhedron() const
+{
+ if (this->is2d)
+ {
+#if 0
+ // This version of the code causes problems in some cases.
+ // Example testcase: import_dxf("testdata/polygon8.dxf");
+ //
+ typedef std::list<CGAL_Nef_polyhedron2::Point> point_list_t;
+ typedef point_list_t::iterator point_list_it;
+ std::list< point_list_t > pdata_point_lists;
+ std::list < std::pair < point_list_it, point_list_it > > pdata;
+ Grid2d<CGAL_Nef_polyhedron2::Point> grid(GRID_COARSE);
+
+ for (int i = 0; i < this->polygons.size(); i++) {
+ pdata_point_lists.push_back(point_list_t());
+ for (int j = 0; j < this->polygons[i].size(); j++) {
+ double x = this->polygons[i][j].x;
+ double y = this->polygons[i][j].y;
+ CGAL_Nef_polyhedron2::Point p;
+ if (grid.has(x, y)) {
+ p = grid.data(x, y);
+ } else {
+ p = CGAL_Nef_polyhedron2::Point(x, y);
+ grid.data(x, y) = p;
+ }
+ pdata_point_lists.back().push_back(p);
+ }
+ pdata.push_back(std::make_pair(pdata_point_lists.back().begin(),
+ pdata_point_lists.back().end()));
+ }
+
+ CGAL_Nef_polyhedron2 N(pdata.begin(), pdata.end(), CGAL_Nef_polyhedron2::POLYGONS);
+ return CGAL_Nef_polyhedron(N);
+#endif
+#if 0
+ // This version of the code works fine but is pretty slow.
+ //
+ CGAL_Nef_polyhedron2 N;
+ Grid2d<CGAL_Nef_polyhedron2::Point> grid(GRID_COARSE);
+
+ for (int i = 0; i < this->polygons.size(); i++) {
+ std::list<CGAL_Nef_polyhedron2::Point> plist;
+ for (int j = 0; j < this->polygons[i].size(); j++) {
+ double x = this->polygons[i][j].x;
+ double y = this->polygons[i][j].y;
+ CGAL_Nef_polyhedron2::Point p;
+ if (grid.has(x, y)) {
+ p = grid.data(x, y);
+ } else {
+ p = CGAL_Nef_polyhedron2::Point(x, y);
+ grid.data(x, y) = p;
+ }
+ plist.push_back(p);
+ }
+ N += CGAL_Nef_polyhedron2(plist.begin(), plist.end(), CGAL_Nef_polyhedron2::INCLUDED);
+ }
+
+ return CGAL_Nef_polyhedron(N);
+#endif
+#if 1
+ // This version of the code does essentially the same thing as the 2nd
+ // version but merges some triangles before sending them to CGAL. This adds
+ // complexity but speeds up things..
+ //
+ struct PolyReducer
+ {
+ Grid2d<int> grid;
+ QHash< QPair<int,int>, QPair<int,int> > egde_to_poly;
+ QHash< int, CGAL_Nef_polyhedron2::Point > points;
+ QHash< int, QList<int> > polygons;
+ int poly_n;
+
+ void add_edges(int pn)
+ {
+ for (int j = 1; j <= this->polygons[pn].size(); j++) {
+ int a = this->polygons[pn][j-1];
+ int b = this->polygons[pn][j % this->polygons[pn].size()];
+ if (a > b) { a = a^b; b = a^b; a = a^b; }
+ if (this->egde_to_poly[QPair<int,int>(a, b)].first == 0)
+ this->egde_to_poly[QPair<int,int>(a, b)].first = pn;
+ else if (this->egde_to_poly[QPair<int,int>(a, b)].second == 0)
+ this->egde_to_poly[QPair<int,int>(a, b)].second = pn;
+ else
+ abort();
+ }
+ }
+
+ void del_poly(int pn)
+ {
+ for (int j = 1; j <= this->polygons[pn].size(); j++) {
+ int a = this->polygons[pn][j-1];
+ int b = this->polygons[pn][j % this->polygons[pn].size()];
+ if (a > b) { a = a^b; b = a^b; a = a^b; }
+ if (this->egde_to_poly[QPair<int,int>(a, b)].first == pn)
+ this->egde_to_poly[QPair<int,int>(a, b)].first = 0;
+ if (this->egde_to_poly[QPair<int,int>(a, b)].second == pn)
+ this->egde_to_poly[QPair<int,int>(a, b)].second = 0;
+ }
+ this->polygons.remove(pn);
+ }
+
+ PolyReducer(const PolySet *ps) : grid(GRID_COARSE), poly_n(1)
+ {
+ int point_n = 1;
+ for (int i = 0; i < ps->polygons.size(); i++) {
+ for (int j = 0; j < ps->polygons[i].size(); j++) {
+ double x = ps->polygons[i][j].x;
+ double y = ps->polygons[i][j].y;
+ if (this->grid.has(x, y)) {
+ int idx = this->grid.data(x, y);
+ // Filter away two vertices with the same index (due to grid)
+ // This could be done in a more general way, but we'd rather redo the entire
+ // grid concept instead.
+ if (this->polygons[this->poly_n].indexOf(idx) == -1) {
+ this->polygons[this->poly_n].append(this->grid.data(x, y));
+ }
+ } else {
+ this->grid.align(x, y) = point_n;
+ this->polygons[this->poly_n].append(point_n);
+ this->points[point_n] = CGAL_Nef_polyhedron2::Point(x, y);
+ point_n++;
+ }
+ }
+ if (this->polygons[this->poly_n].size() >= 3) {
+ add_edges(this->poly_n);
+ this->poly_n++;
+ }
+ else {
+ this->polygons.remove(this->poly_n);
+ }
+ }
+ }
+
+ int merge(int p1, int p1e, int p2, int p2e)
+ {
+ for (int i = 1; i < this->polygons[p1].size(); i++) {
+ int j = (p1e + i) % this->polygons[p1].size();
+ this->polygons[this->poly_n].append(this->polygons[p1][j]);
+ }
+ for (int i = 1; i < this->polygons[p2].size(); i++) {
+ int j = (p2e + i) % this->polygons[p2].size();
+ this->polygons[this->poly_n].append(this->polygons[p2][j]);
+ }
+ del_poly(p1);
+ del_poly(p2);
+ add_edges(this->poly_n);
+ return this->poly_n++;
+ }
+
+ void reduce()
+ {
+ QList<int> work_queue;
+ QHashIterator< int, QList<int> > it(polygons);
+ while (it.hasNext()) {
+ it.next();
+ work_queue.append(it.key());
+ }
+ while (!work_queue.isEmpty()) {
+ int poly1_n = work_queue.first();
+ work_queue.removeFirst();
+ if (!this->polygons.contains(poly1_n))
+ continue;
+ for (int j = 1; j <= this->polygons[poly1_n].size(); j++) {
+ int a = this->polygons[poly1_n][j-1];
+ int b = this->polygons[poly1_n][j % this->polygons[poly1_n].size()];
+ if (a > b) { a = a^b; b = a^b; a = a^b; }
+ if (this->egde_to_poly[QPair<int,int>(a, b)].first != 0 &&
+ this->egde_to_poly[QPair<int,int>(a, b)].second != 0) {
+ int poly2_n = this->egde_to_poly[QPair<int,int>(a, b)].first +
+ this->egde_to_poly[QPair<int,int>(a, b)].second - poly1_n;
+ int poly2_edge = -1;
+ for (int k = 1; k <= this->polygons[poly2_n].size(); k++) {
+ int c = this->polygons[poly2_n][k-1];
+ int d = this->polygons[poly2_n][k % this->polygons[poly2_n].size()];
+ if (c > d) { c = c^d; d = c^d; c = c^d; }
+ if (a == c && b == d) {
+ poly2_edge = k-1;
+ continue;
+ }
+ int poly3_n = this->egde_to_poly[QPair<int,int>(c, d)].first +
+ this->egde_to_poly[QPair<int,int>(c, d)].second - poly2_n;
+ if (poly3_n < 0)
+ continue;
+ if (poly3_n == poly1_n)
+ goto next_poly1_edge;
+ }
+ work_queue.append(merge(poly1_n, j-1, poly2_n, poly2_edge));
+ goto next_poly1;
+ }
+ next_poly1_edge:;
+ }
+ next_poly1:;
+ }
+ }
+
+ CGAL_Nef_polyhedron2 toNef()
+ {
+ CGAL_Nef_polyhedron2 N;
+
+ QHashIterator< int, QList<int> > it(polygons);
+ while (it.hasNext()) {
+ it.next();
+ std::list<CGAL_Nef_polyhedron2::Point> plist;
+ for (int j = 0; j < it.value().size(); j++) {
+ int p = it.value()[j];
+ plist.push_back(points[p]);
+ }
+ N += CGAL_Nef_polyhedron2(plist.begin(), plist.end(), CGAL_Nef_polyhedron2::INCLUDED);
+ }
+
+ return N;
+ }
+ };
+
+ PolyReducer pr(this);
+ // printf("Number of polygons before reduction: %d\n", pr.polygons.size());
+ pr.reduce();
+ // printf("Number of polygons after reduction: %d\n", pr.polygons.size());
+ return CGAL_Nef_polyhedron(pr.toNef());
+#endif
+#if 0
+ // This is another experimental version. I should run faster than the above,
+ // is a lot simpler and has only one known weakness: Degenerate polygons, which
+ // get repaired by GLUTess, might trigger a CGAL crash here. The only
+ // known case for this is triangle-with-duplicate-vertex.dxf
+ // FIXME: If we just did a projection, we need to recreate the border!
+ if (this->polygons.size() > 0) assert(this->borders.size() > 0);
+ CGAL_Nef_polyhedron2 N;
+ Grid2d<CGAL_Nef_polyhedron2::Point> grid(GRID_COARSE);
+
+ for (int i = 0; i < this->borders.size(); i++) {
+ std::list<CGAL_Nef_polyhedron2::Point> plist;
+ for (int j = 0; j < this->borders[i].size(); j++) {
+ double x = this->borders[i][j].x;
+ double y = this->borders[i][j].y;
+ CGAL_Nef_polyhedron2::Point p;
+ if (grid.has(x, y)) {
+ p = grid.data(x, y);
+ } else {
+ p = CGAL_Nef_polyhedron2::Point(x, y);
+ grid.data(x, y) = p;
+ }
+ plist.push_back(p);
+ }
+ // FIXME: If a border (path) has a duplicate vertex in dxf,
+ // the CGAL_Nef_polyhedron2 constructor will crash.
+ N ^= CGAL_Nef_polyhedron2(plist.begin(), plist.end(), CGAL_Nef_polyhedron2::INCLUDED);
+ }
+
+ return CGAL_Nef_polyhedron(N);
+
+#endif
+ }
+ else // not (this->is2d)
+ {
+ CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
+ try {
+ CGAL_Polyhedron P;
+ CGAL_Build_PolySet builder(this);
+ P.delegate(builder);
+#if 0
+ std::cout << P;
+#endif
+ CGAL_Nef_polyhedron3 N(P);
+ return CGAL_Nef_polyhedron(N);
+ }
+ catch (CGAL::Assertion_exception e) {
+ PRINTF("CGAL error: %s", e.what());
+ CGAL::set_error_behaviour(old_behaviour);
+ return CGAL_Nef_polyhedron();
+ }
+ CGAL::set_error_behaviour(old_behaviour);
+ }
+ return CGAL_Nef_polyhedron();
}
diff --git a/src/transform.cc b/src/transform.cc
index 7459765..b55a1c3 100644
--- a/src/transform.cc
+++ b/src/transform.cc
@@ -85,9 +85,10 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti
TransformNode *node = new TransformNode(inst);
for (int i = 0; i < 16; i++)
- node->matrix[i] = i % 5 == 0 ? 1.0 : 0.0;
- for (int i = 16; i < 20; i++)
- node->matrix[i] = -1;
+ node->m[i] = i % 5 == 0 ? 1.0 : 0.0;
+ for (int i = 16; i < 19; i++)
+ node->m[i] = -1;
+ node->m[19] = 1;
QVector<QString> argnames;
QVector<Expression*> argexpr;
@@ -267,9 +268,7 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti
// FIXME: Only lookup alpha if color was set
Value alpha = c.lookup_variable("alpha");
if (alpha.type == Value::NUMBER) {
- node->matrix[16+3] = alpha.num;
- } else {
- node->matrix[16+3] = 1.0;
+ node->m[16+3] = alpha.num;
}
}
@@ -309,7 +308,27 @@ string TransformNode::toString() const
string TransformNode::name() const
{
+<<<<<<< HEAD
return "transform";
+=======
+ if (dump_cache.isEmpty()) {
+ QString text;
+ if (m[16] >= 0 || m[17] >= 0 || m[18] >= 0)
+ text.sprintf("n%d: color([%g, %g, %g, %g])", idx,
+ m[16], m[17], m[18], m[19]);
+ else
+ text.sprintf("n%d: multmatrix([[%g, %g, %g, %g], [%g, %g, %g, %g], "
+ "[%g, %g, %g, %g], [%g, %g, %g, %g]])", idx,
+ m[0], m[4], m[ 8], m[12],
+ m[1], m[5], m[ 9], m[13],
+ m[2], m[6], m[10], m[14],
+ m[3], m[7], m[11], m[15]);
+ text = indent + text + " {\n";
+ foreach (AbstractNode *v, children)
+ text += v->dump(indent + QString("\t"));
+ ((AbstractNode*)this)->dump_cache = text + indent + "}\n";
+ }
+ return dump_cache;
}
void register_builtin_transform()
diff --git a/tests/OffscreenContext.cc b/tests/OffscreenContext.cc
index f2a7e9c..0795fe7 100644
--- a/tests/OffscreenContext.cc
+++ b/tests/OffscreenContext.cc
@@ -1,7 +1,15 @@
#include "OffscreenContext.h"
+// see http://www.gamedev.net/topic/552607-conflict-between-glew-and-sdl/
+#define NO_SDL_GLEXT
+#include <GL/glew.h>
+
+#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
-#include <GL/glu.h> // for gluCheckExtension
+#include <GL/glext.h>
+
+//#include <GL/gl.h>
+//#include <GL/glu.h> // for gluCheckExtension
#include <SDL.h>
// Simple error reporting macros to help keep the sample code clean
@@ -26,18 +34,27 @@ OffscreenContext *create_offscreen_context(int w, int h)
// dummy window
SDL_Init(SDL_INIT_VIDEO);
- SDL_SetVideoMode(10,10,32,SDL_OPENGL);
+ SDL_SetVideoMode(256,256,32,SDL_OPENGL);
- /*
- * Test if framebuffer objects are supported
- */
+ // must come after openGL context init (done by dummy window)
+ // but must also come before various EXT calls
+ glewInit();
+
+/*
+ // Test if framebuffer objects are supported
const GLubyte* strExt = glGetString(GL_EXTENSIONS);
GLboolean fboSupported = gluCheckExtension((const GLubyte*)"GL_EXT_framebuffer_object", strExt);
if (!fboSupported)
REPORT_ERROR_AND_EXIT("Your system does not support framebuffer extension - unable to render scene");
- /*
- * Create an FBO
- */
+
+ printf("%i\n", (int)glGenFramebuffersEXT);
+ GLuint fbo;
+ //ctx->fbo = 0;
+ glGenFramebuffersEXT(1, &fbo);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+ REPORTGLERROR("binding framebuffer");
+
+
GLuint renderBuffer = 0;
GLuint depthBuffer = 0;
// Depth buffer to use for depth testing - optional if you're not using depth testing
@@ -51,10 +68,6 @@ OffscreenContext *create_offscreen_context(int w, int h)
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, w, h);
REPORTGLERROR("creating color render buffer");
- ctx->fbo = 0;
- glGenFramebuffersEXT(1, &ctx->fbo);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ctx->fbo);
- REPORTGLERROR("binding framebuffer");
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, renderBuffer);
@@ -71,6 +84,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) !=
GL_FRAMEBUFFER_COMPLETE_EXT)
REPORT_ERROR_AND_EXIT("Problem with OpenGL framebuffer after specifying depth render buffer.");
+*/
return ctx;
}
@@ -78,7 +92,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
bool teardown_offscreen_context(OffscreenContext *ctx)
{
// "un"bind my FBO
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
/*
* Cleanup
@@ -121,5 +135,5 @@ bool save_framebuffer(OffscreenContext *ctx, const char *filename)
void bind_offscreen_context(OffscreenContext *ctx)
{
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ctx->fbo);
+// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ctx->fbo);
}
diff --git a/tests/opencsgtest.cc b/tests/opencsgtest.cc
index 026978d..6d92312 100644
--- a/tests/opencsgtest.cc
+++ b/tests/opencsgtest.cc
@@ -241,8 +241,8 @@ int main(int argc, char *argv[])
OpenCSGRenderer opencsgRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo);
ThrownTogetherRenderer thrownTogetherRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain);
-// csgInfo.glview->setRenderer(&thrownTogetherRenderer);
- csgInfo.glview->setRenderer(&opencsgRenderer);
+ csgInfo.glview->setRenderer(&thrownTogetherRenderer);
+// csgInfo.glview->setRenderer(&opencsgRenderer);
csgInfo.glview->paintGL();
contact: Jan Huwald // Impressum