mirror of https://github.com/vitalif/openscad
obj_rot + obj_trans -> Eigen::Vector. simplify glinfo dialog box.
parent
fc2d9341fa
commit
e3ecf26d45
|
@ -87,7 +87,7 @@ private:
|
||||||
void loadViewSettings();
|
void loadViewSettings();
|
||||||
void loadDesignSettings();
|
void loadDesignSettings();
|
||||||
|
|
||||||
class QMessageBox *openglbox;
|
class QDialog *openglbox;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void actionNew();
|
void actionNew();
|
||||||
|
|
|
@ -62,7 +62,6 @@ OffscreenContext *create_offscreen_context_common(OffscreenContext *ctx)
|
||||||
std::cerr << "Unable to init GLEW: " << glewGetErrorString(err) << "\n";
|
std::cerr << "Unable to init GLEW: " << glewGetErrorString(err) << "\n";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
//cerr << glew_dump(0);
|
|
||||||
|
|
||||||
ctx->fbo = fbo_new();
|
ctx->fbo = fbo_new();
|
||||||
if (!fbo_init(ctx->fbo, ctx->width, ctx->height)) {
|
if (!fbo_init(ctx->fbo, ctx->width, ctx->height)) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
|
||||||
std::cerr << "Unable to init GLEW: " << glewGetErrorString(err) << std::endl;
|
std::cerr << "Unable to init GLEW: " << glewGetErrorString(err) << std::endl;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
glew_dump(false);
|
glew_dump();
|
||||||
|
|
||||||
ctx->fbo = fbo_new();
|
ctx->fbo = fbo_new();
|
||||||
if (!fbo_init(ctx->fbo, w, h)) {
|
if (!fbo_init(ctx->fbo, w, h)) {
|
||||||
|
|
|
@ -150,18 +150,8 @@ bool OffscreenView::save(std::ostream &output)
|
||||||
const std::string &OffscreenView::getRendererInfo()
|
const std::string &OffscreenView::getRendererInfo()
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
GLint rbits, gbits, bbits, abits, dbits, sbits;
|
|
||||||
glGetIntegerv(GL_RED_BITS, &rbits);
|
|
||||||
glGetIntegerv(GL_GREEN_BITS, &gbits);
|
|
||||||
glGetIntegerv(GL_BLUE_BITS, &bbits);
|
|
||||||
glGetIntegerv(GL_ALPHA_BITS, &abits);
|
|
||||||
glGetIntegerv(GL_DEPTH_BITS, &dbits);
|
|
||||||
glGetIntegerv(GL_STENCIL_BITS, &sbits);
|
|
||||||
|
|
||||||
out << glew_dump(false)
|
out << glew_dump()
|
||||||
<< "FBO: RGBA(" << rbits << gbits << bbits << abits
|
|
||||||
<< "), depth(" << dbits
|
|
||||||
<< "), stencil(" << sbits << ")\n"
|
|
||||||
<< offscreen_context_getinfo(this->ctx);
|
<< offscreen_context_getinfo(this->ctx);
|
||||||
|
|
||||||
return out.str();
|
return out.str();
|
||||||
|
|
|
@ -942,7 +942,7 @@ void MainWindow::pasteViewportTranslation()
|
||||||
{
|
{
|
||||||
QTextCursor cursor = editor->textCursor();
|
QTextCursor cursor = editor->textCursor();
|
||||||
QString txt;
|
QString txt;
|
||||||
txt.sprintf("[ %.2f, %.2f, %.2f ]", -this->qglview->object_trans_x, -this->qglview->object_trans_y, -this->qglview->object_trans_z);
|
txt.sprintf("[ %.2f, %.2f, %.2f ]", -this->qglview->object_trans.x(), -this->qglview->object_trans.y(), -this->qglview->object_trans.z());
|
||||||
cursor.insertText(txt);
|
cursor.insertText(txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,7 +951,7 @@ void MainWindow::pasteViewportRotation()
|
||||||
QTextCursor cursor = editor->textCursor();
|
QTextCursor cursor = editor->textCursor();
|
||||||
QString txt;
|
QString txt;
|
||||||
txt.sprintf("[ %.2f, %.2f, %.2f ]",
|
txt.sprintf("[ %.2f, %.2f, %.2f ]",
|
||||||
fmodf(360 - this->qglview->object_rot_x + 90, 360), fmodf(360 - this->qglview->object_rot_y, 360), fmodf(360 - this->qglview->object_rot_z, 360));
|
fmodf(360 - this->qglview->object_rot.x() + 90, 360), fmodf(360 - this->qglview->object_rot.y(), 360), fmodf(360 - this->qglview->object_rot.z(), 360));
|
||||||
cursor.insertText(txt);
|
cursor.insertText(txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,15 +960,15 @@ void MainWindow::updateTemporalVariables()
|
||||||
this->root_ctx.set_variable("$t", Value(this->e_tval->text().toDouble()));
|
this->root_ctx.set_variable("$t", Value(this->e_tval->text().toDouble()));
|
||||||
|
|
||||||
Value::VectorType vpt;
|
Value::VectorType vpt;
|
||||||
vpt.push_back(Value(-this->qglview->object_trans_x));
|
vpt.push_back(Value(-this->qglview->object_trans.x()));
|
||||||
vpt.push_back(Value(-this->qglview->object_trans_y));
|
vpt.push_back(Value(-this->qglview->object_trans.y()));
|
||||||
vpt.push_back(Value(-this->qglview->object_trans_z));
|
vpt.push_back(Value(-this->qglview->object_trans.z()));
|
||||||
this->root_ctx.set_variable("$vpt", Value(vpt));
|
this->root_ctx.set_variable("$vpt", Value(vpt));
|
||||||
|
|
||||||
Value::VectorType vpr;
|
Value::VectorType vpr;
|
||||||
vpr.push_back(Value(fmodf(360 - this->qglview->object_rot_x + 90, 360)));
|
vpr.push_back(Value(fmodf(360 - this->qglview->object_rot.x() + 90, 360)));
|
||||||
vpr.push_back(Value(fmodf(360 - this->qglview->object_rot_y, 360)));
|
vpr.push_back(Value(fmodf(360 - this->qglview->object_rot.y(), 360)));
|
||||||
vpr.push_back(Value(fmodf(360 - this->qglview->object_rot_z, 360)));
|
vpr.push_back(Value(fmodf(360 - this->qglview->object_rot.z(), 360)));
|
||||||
root_ctx.set_variable("$vpr", Value(vpr));
|
root_ctx.set_variable("$vpr", Value(vpr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1595,65 +1595,65 @@ void MainWindow::animateUpdate()
|
||||||
|
|
||||||
void MainWindow::viewAngleTop()
|
void MainWindow::viewAngleTop()
|
||||||
{
|
{
|
||||||
this->qglview->object_rot_x = 90;
|
this->qglview->object_rot.x() = 90;
|
||||||
this->qglview->object_rot_y = 0;
|
this->qglview->object_rot.y() = 0;
|
||||||
this->qglview->object_rot_z = 0;
|
this->qglview->object_rot.z() = 0;
|
||||||
this->qglview->updateGL();
|
this->qglview->updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::viewAngleBottom()
|
void MainWindow::viewAngleBottom()
|
||||||
{
|
{
|
||||||
this->qglview->object_rot_x = 270;
|
this->qglview->object_rot.x() = 270;
|
||||||
this->qglview->object_rot_y = 0;
|
this->qglview->object_rot.y() = 0;
|
||||||
this->qglview->object_rot_z = 0;
|
this->qglview->object_rot.z() = 0;
|
||||||
this->qglview->updateGL();
|
this->qglview->updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::viewAngleLeft()
|
void MainWindow::viewAngleLeft()
|
||||||
{
|
{
|
||||||
this->qglview->object_rot_x = 0;
|
this->qglview->object_rot.x() = 0;
|
||||||
this->qglview->object_rot_y = 0;
|
this->qglview->object_rot.y() = 0;
|
||||||
this->qglview->object_rot_z = 90;
|
this->qglview->object_rot.z() = 90;
|
||||||
this->qglview->updateGL();
|
this->qglview->updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::viewAngleRight()
|
void MainWindow::viewAngleRight()
|
||||||
{
|
{
|
||||||
this->qglview->object_rot_x = 0;
|
this->qglview->object_rot.x() = 0;
|
||||||
this->qglview->object_rot_y = 0;
|
this->qglview->object_rot.y() = 0;
|
||||||
this->qglview->object_rot_z = 270;
|
this->qglview->object_rot.z() = 270;
|
||||||
this->qglview->updateGL();
|
this->qglview->updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::viewAngleFront()
|
void MainWindow::viewAngleFront()
|
||||||
{
|
{
|
||||||
this->qglview->object_rot_x = 0;
|
this->qglview->object_rot.x() = 0;
|
||||||
this->qglview->object_rot_y = 0;
|
this->qglview->object_rot.y() = 0;
|
||||||
this->qglview->object_rot_z = 0;
|
this->qglview->object_rot.z() = 0;
|
||||||
this->qglview->updateGL();
|
this->qglview->updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::viewAngleBack()
|
void MainWindow::viewAngleBack()
|
||||||
{
|
{
|
||||||
this->qglview->object_rot_x = 0;
|
this->qglview->object_rot.x() = 0;
|
||||||
this->qglview->object_rot_y = 0;
|
this->qglview->object_rot.y() = 0;
|
||||||
this->qglview->object_rot_z = 180;
|
this->qglview->object_rot.z() = 180;
|
||||||
this->qglview->updateGL();
|
this->qglview->updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::viewAngleDiagonal()
|
void MainWindow::viewAngleDiagonal()
|
||||||
{
|
{
|
||||||
this->qglview->object_rot_x = 35;
|
this->qglview->object_rot.x() = 35;
|
||||||
this->qglview->object_rot_y = 0;
|
this->qglview->object_rot.y() = 0;
|
||||||
this->qglview->object_rot_z = -25;
|
this->qglview->object_rot.z() = -25;
|
||||||
this->qglview->updateGL();
|
this->qglview->updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::viewCenter()
|
void MainWindow::viewCenter()
|
||||||
{
|
{
|
||||||
this->qglview->object_trans_x = 0;
|
this->qglview->object_trans.x() = 0;
|
||||||
this->qglview->object_trans_y = 0;
|
this->qglview->object_trans.y() = 0;
|
||||||
this->qglview->object_trans_z = 0;
|
this->qglview->object_trans.z() = 0;
|
||||||
this->qglview->updateGL();
|
this->qglview->updateGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1745,14 +1745,16 @@ void MainWindow::helpLibrary()
|
||||||
qVersion());
|
qVersion());
|
||||||
|
|
||||||
if (!this->openglbox) {
|
if (!this->openglbox) {
|
||||||
this->openglbox = new QMessageBox(QMessageBox::Information,
|
this->openglbox = new QDialog( this );
|
||||||
"OpenGL Info", "Detailed Library Info",
|
QVBoxLayout *ql = new QVBoxLayout( openglbox );
|
||||||
QMessageBox::Ok, this);
|
QTextEdit *qte = new QTextEdit( openglbox );
|
||||||
|
ql->addWidget( qte );
|
||||||
}
|
}
|
||||||
|
QTextEdit *qte = openglbox->findChild<QTextEdit *>();
|
||||||
this->openglbox->setDetailedText(libinfo + QString(this->qglview->getRendererInfo()));
|
qte->setText(libinfo + QString(this->qglview->getRendererInfo().c_str()));
|
||||||
this->openglbox->show();
|
qte->setReadOnly( true );
|
||||||
|
openglbox->setMinimumSize( QSize(400,200) );
|
||||||
|
openglbox->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -149,30 +149,9 @@ void QGLView::initializeGL()
|
||||||
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
|
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint rbits, gbits, bbits, abits, dbits, sbits;
|
std::string glewinfo = glew_dump();
|
||||||
glGetIntegerv(GL_RED_BITS, &rbits);
|
std::string glextlist = glew_extensions_dump();
|
||||||
glGetIntegerv(GL_GREEN_BITS, &gbits);
|
rendererInfo = glewinfo + std::string("\n") + glextlist;
|
||||||
glGetIntegerv(GL_BLUE_BITS, &bbits);
|
|
||||||
glGetIntegerv(GL_ALPHA_BITS, &abits);
|
|
||||||
glGetIntegerv(GL_DEPTH_BITS, &dbits);
|
|
||||||
glGetIntegerv(GL_STENCIL_BITS, &sbits);
|
|
||||||
|
|
||||||
|
|
||||||
this->rendererInfo.sprintf("GLEW version %s\n"
|
|
||||||
"OpenGL version %s\n"
|
|
||||||
"%s (%s)\n\n"
|
|
||||||
"RGBA(%d%d%d%d), depth(%d), stencil(%d)\n"
|
|
||||||
"Extensions:\n"
|
|
||||||
"%s\n",
|
|
||||||
glewGetString(GLEW_VERSION),
|
|
||||||
glGetString(GL_VERSION),
|
|
||||||
glGetString(GL_RENDERER),
|
|
||||||
glGetString(GL_VENDOR),
|
|
||||||
rbits, gbits, bbits, abits, dbits, sbits,
|
|
||||||
glGetString(GL_EXTENSIONS));
|
|
||||||
// FIXME: glGetString(GL_EXTENSIONS) is deprecated in OpenGL 3.0.
|
|
||||||
// Use: glGetIntegerv(GL_NUM_EXTENSIONS, &NumberOfExtensions) and
|
|
||||||
// glGetStringi(GL_EXTENSIONS, i)
|
|
||||||
|
|
||||||
const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20");
|
const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20");
|
||||||
if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) {
|
if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) {
|
||||||
|
|
|
@ -1,40 +1,79 @@
|
||||||
|
|
||||||
/* OpenGL helper functions */
|
/* OpenGL helper functions */
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "system-gl.h"
|
#include "system-gl.h"
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
string glew_dump(bool dumpall)
|
double gl_version()
|
||||||
{
|
{
|
||||||
|
string tmp((const char*)glGetString( GL_VERSION ));
|
||||||
|
vector<string> strs;
|
||||||
|
split(strs, tmp, is_any_of("."));
|
||||||
|
stringstream out;
|
||||||
|
if ( strs.size() >= 2)
|
||||||
|
out << strs[0] << "." << strs[1];
|
||||||
|
else
|
||||||
|
out << "0.0";
|
||||||
|
double d;
|
||||||
|
out >> d;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
string glew_extensions_dump()
|
||||||
|
{
|
||||||
|
std::string tmp;
|
||||||
|
if ( gl_version() >= 3.0 ) {
|
||||||
|
GLint numexts = 0;
|
||||||
|
glGetIntegerv(GL_NUM_EXTENSIONS, &numexts);
|
||||||
|
for ( int i=0;i<numexts;i++ ) {
|
||||||
|
tmp += (const char *) glGetStringi(GL_EXTENSIONS, i);
|
||||||
|
tmp += " ";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmp = (const char *) glGetString(GL_EXTENSIONS);
|
||||||
|
}
|
||||||
|
vector<string> extensions;
|
||||||
|
split( extensions, tmp, is_any_of(" "));
|
||||||
|
sort( extensions.begin(), extensions.end() );
|
||||||
|
stringstream out;
|
||||||
|
out << "GL Extensions:";
|
||||||
|
for ( int i=0;i<extensions.size();i++ ) out << extensions[i] << "\n";
|
||||||
|
return out.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
string glew_dump()
|
||||||
|
{
|
||||||
|
GLint rbits, gbits, bbits, abits, dbits, sbits;
|
||||||
|
glGetIntegerv(GL_RED_BITS, &rbits);
|
||||||
|
glGetIntegerv(GL_GREEN_BITS, &gbits);
|
||||||
|
glGetIntegerv(GL_BLUE_BITS, &bbits);
|
||||||
|
glGetIntegerv(GL_ALPHA_BITS, &abits);
|
||||||
|
glGetIntegerv(GL_DEPTH_BITS, &dbits);
|
||||||
|
glGetIntegerv(GL_STENCIL_BITS, &sbits);
|
||||||
|
|
||||||
stringstream out;
|
stringstream out;
|
||||||
out << "GLEW version: " << glewGetString(GLEW_VERSION) << endl
|
out << "GLEW version: " << glewGetString(GLEW_VERSION)
|
||||||
<< "GL Renderer: " << (const char *)glGetString(GL_RENDERER) << endl
|
<< "\nOpenGL Version: " << (const char *)glGetString(GL_VERSION)
|
||||||
<< "GL Vendor: " << (const char *)glGetString(GL_VENDOR) << endl
|
<< "\nGL Renderer: " << (const char *)glGetString(GL_RENDERER)
|
||||||
<< "OpenGL Version: " << (const char *)glGetString(GL_VERSION) << endl;
|
<< "\nGL Vendor: " << (const char *)glGetString(GL_VENDOR)
|
||||||
|
<< boost::format("\nRGBA(%d%d%d%d), depth(%d), stencil(%d)") %
|
||||||
out << "GL Extensions: " << endl;
|
rbits % gbits % bbits % abits % dbits % sbits;
|
||||||
if (dumpall) {
|
out << "\nGL_ARB_framebuffer_object: "
|
||||||
string extensions((const char *)glGetString(GL_EXTENSIONS));
|
|
||||||
replace_all( extensions, " ", "\n " );
|
|
||||||
out << " " << extensions << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
out << "GL_ARB_framebuffer_object: "
|
|
||||||
<< (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no")
|
<< (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no")
|
||||||
<< endl
|
<< "\nGL_EXT_framebuffer_object: "
|
||||||
<< "GL_EXT_framebuffer_object: "
|
|
||||||
<< (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no")
|
<< (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no")
|
||||||
<< endl
|
<< "\nGL_EXT_packed_depth_stencil: "
|
||||||
<< "GL_EXT_packed_depth_stencil: "
|
|
||||||
<< (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no")
|
<< (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no")
|
||||||
<< endl;
|
<< "\n";
|
||||||
|
|
||||||
return out.str();
|
return out.str();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string glew_dump(bool dumpall);
|
std::string glew_dump();
|
||||||
|
std::string glew_extensions_dump();
|
||||||
bool report_glerror(const char * function);
|
bool report_glerror(const char * function);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue