obj_rot + obj_trans -> Eigen::Vector. simplify glinfo dialog box.

felipesanches-svg
don bright 2013-02-20 23:02:44 -06:00
parent fc2d9341fa
commit e3ecf26d45
8 changed files with 108 additions and 98 deletions

View File

@ -87,7 +87,7 @@ private:
void loadViewSettings();
void loadDesignSettings();
class QMessageBox *openglbox;
class QDialog *openglbox;
private slots:
void actionNew();

View File

@ -62,7 +62,6 @@ OffscreenContext *create_offscreen_context_common(OffscreenContext *ctx)
std::cerr << "Unable to init GLEW: " << glewGetErrorString(err) << "\n";
return NULL;
}
//cerr << glew_dump(0);
ctx->fbo = fbo_new();
if (!fbo_init(ctx->fbo, ctx->width, ctx->height)) {

View File

@ -83,7 +83,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
std::cerr << "Unable to init GLEW: " << glewGetErrorString(err) << std::endl;
return NULL;
}
glew_dump(false);
glew_dump();
ctx->fbo = fbo_new();
if (!fbo_init(ctx->fbo, w, h)) {

View File

@ -150,18 +150,8 @@ bool OffscreenView::save(std::ostream &output)
const std::string &OffscreenView::getRendererInfo()
{
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)
<< "FBO: RGBA(" << rbits << gbits << bbits << abits
<< "), depth(" << dbits
<< "), stencil(" << sbits << ")\n"
out << glew_dump()
<< offscreen_context_getinfo(this->ctx);
return out.str();

View File

@ -942,7 +942,7 @@ void MainWindow::pasteViewportTranslation()
{
QTextCursor cursor = editor->textCursor();
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);
}
@ -951,7 +951,7 @@ void MainWindow::pasteViewportRotation()
QTextCursor cursor = editor->textCursor();
QString txt;
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);
}
@ -960,15 +960,15 @@ void MainWindow::updateTemporalVariables()
this->root_ctx.set_variable("$t", Value(this->e_tval->text().toDouble()));
Value::VectorType vpt;
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_z));
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.z()));
this->root_ctx.set_variable("$vpt", Value(vpt));
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_y, 360)));
vpr.push_back(Value(fmodf(360 - this->qglview->object_rot_z, 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.z(), 360)));
root_ctx.set_variable("$vpr", Value(vpr));
}
@ -1595,65 +1595,65 @@ void MainWindow::animateUpdate()
void MainWindow::viewAngleTop()
{
this->qglview->object_rot_x = 90;
this->qglview->object_rot_y = 0;
this->qglview->object_rot_z = 0;
this->qglview->object_rot.x() = 90;
this->qglview->object_rot.y() = 0;
this->qglview->object_rot.z() = 0;
this->qglview->updateGL();
}
void MainWindow::viewAngleBottom()
{
this->qglview->object_rot_x = 270;
this->qglview->object_rot_y = 0;
this->qglview->object_rot_z = 0;
this->qglview->object_rot.x() = 270;
this->qglview->object_rot.y() = 0;
this->qglview->object_rot.z() = 0;
this->qglview->updateGL();
}
void MainWindow::viewAngleLeft()
{
this->qglview->object_rot_x = 0;
this->qglview->object_rot_y = 0;
this->qglview->object_rot_z = 90;
this->qglview->object_rot.x() = 0;
this->qglview->object_rot.y() = 0;
this->qglview->object_rot.z() = 90;
this->qglview->updateGL();
}
void MainWindow::viewAngleRight()
{
this->qglview->object_rot_x = 0;
this->qglview->object_rot_y = 0;
this->qglview->object_rot_z = 270;
this->qglview->object_rot.x() = 0;
this->qglview->object_rot.y() = 0;
this->qglview->object_rot.z() = 270;
this->qglview->updateGL();
}
void MainWindow::viewAngleFront()
{
this->qglview->object_rot_x = 0;
this->qglview->object_rot_y = 0;
this->qglview->object_rot_z = 0;
this->qglview->object_rot.x() = 0;
this->qglview->object_rot.y() = 0;
this->qglview->object_rot.z() = 0;
this->qglview->updateGL();
}
void MainWindow::viewAngleBack()
{
this->qglview->object_rot_x = 0;
this->qglview->object_rot_y = 0;
this->qglview->object_rot_z = 180;
this->qglview->object_rot.x() = 0;
this->qglview->object_rot.y() = 0;
this->qglview->object_rot.z() = 180;
this->qglview->updateGL();
}
void MainWindow::viewAngleDiagonal()
{
this->qglview->object_rot_x = 35;
this->qglview->object_rot_y = 0;
this->qglview->object_rot_z = -25;
this->qglview->object_rot.x() = 35;
this->qglview->object_rot.y() = 0;
this->qglview->object_rot.z() = -25;
this->qglview->updateGL();
}
void MainWindow::viewCenter()
{
this->qglview->object_trans_x = 0;
this->qglview->object_trans_y = 0;
this->qglview->object_trans_z = 0;
this->qglview->object_trans.x() = 0;
this->qglview->object_trans.y() = 0;
this->qglview->object_trans.z() = 0;
this->qglview->updateGL();
}
@ -1745,14 +1745,16 @@ void MainWindow::helpLibrary()
qVersion());
if (!this->openglbox) {
this->openglbox = new QMessageBox(QMessageBox::Information,
"OpenGL Info", "Detailed Library Info",
QMessageBox::Ok, this);
this->openglbox = new QDialog( this );
QVBoxLayout *ql = new QVBoxLayout( openglbox );
QTextEdit *qte = new QTextEdit( openglbox );
ql->addWidget( qte );
}
this->openglbox->setDetailedText(libinfo + QString(this->qglview->getRendererInfo()));
this->openglbox->show();
QTextEdit *qte = openglbox->findChild<QTextEdit *>();
qte->setText(libinfo + QString(this->qglview->getRendererInfo().c_str()));
qte->setReadOnly( true );
openglbox->setMinimumSize( QSize(400,200) );
openglbox->show();
}
/*!

View File

@ -149,30 +149,9 @@ void QGLView::initializeGL()
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
}
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);
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)
std::string glewinfo = glew_dump();
std::string glextlist = glew_extensions_dump();
rendererInfo = glewinfo + std::string("\n") + glextlist;
const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20");
if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) {

View File

@ -1,40 +1,79 @@
/* OpenGL helper functions */
#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
#include "system-gl.h"
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
using namespace std;
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;
out << "GLEW version: " << glewGetString(GLEW_VERSION) << endl
<< "GL Renderer: " << (const char *)glGetString(GL_RENDERER) << endl
<< "GL Vendor: " << (const char *)glGetString(GL_VENDOR) << endl
<< "OpenGL Version: " << (const char *)glGetString(GL_VERSION) << endl;
out << "GL Extensions: " << endl;
if (dumpall) {
string extensions((const char *)glGetString(GL_EXTENSIONS));
replace_all( extensions, " ", "\n " );
out << " " << extensions << endl;
}
out << "GL_ARB_framebuffer_object: "
out << "GLEW version: " << glewGetString(GLEW_VERSION)
<< "\nOpenGL Version: " << (const char *)glGetString(GL_VERSION)
<< "\nGL Renderer: " << (const char *)glGetString(GL_RENDERER)
<< "\nGL Vendor: " << (const char *)glGetString(GL_VENDOR)
<< boost::format("\nRGBA(%d%d%d%d), depth(%d), stencil(%d)") %
rbits % gbits % bbits % abits % dbits % sbits;
out << "\nGL_ARB_framebuffer_object: "
<< (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no")
<< endl
<< "GL_EXT_framebuffer_object: "
<< "\nGL_EXT_framebuffer_object: "
<< (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no")
<< endl
<< "GL_EXT_packed_depth_stencil: "
<< "\nGL_EXT_packed_depth_stencil: "
<< (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no")
<< endl;
<< "\n";
return out.str();
};

View File

@ -15,7 +15,8 @@
#include <string>
std::string glew_dump(bool dumpall);
std::string glew_dump();
std::string glew_extensions_dump();
bool report_glerror(const char * function);
#endif