Skip to content

Commit

Permalink
Merge pull request #402 from dartsim/multisample_anti_aliasing
Browse files Browse the repository at this point in the history
Multisample anti-aliasing
  • Loading branch information
jslee02 committed Jun 10, 2015
2 parents d1ec56c + 4993cd3 commit 60da070
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 32 deletions.
5 changes: 3 additions & 2 deletions dart/gui/GlutWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ void GlutWindow::initWindow(int _w, int _h, const char* _name) {
mWinWidth = _w;
mWinHeight = _h;

glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE |GLUT_RGBA | GLUT_STENCIL
| GLUT_ACCUM);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE);
glutInitWindowPosition(150, 100);
glutInitWindowSize(_w, _h);
mWinIDs.push_back(glutCreateWindow(_name));
Expand All @@ -99,6 +98,8 @@ void GlutWindow::initWindow(int _w, int _h, const char* _name) {
mRI->initialize();
// glutTimerFunc(mDisplayTimeout, refreshTimer, 0);
// glutTimerFunc(mDisplayTimeout, runTimer, 0);

glDisable(GL_MULTISAMPLE);
}

void GlutWindow::reshape(int _w, int _h) {
Expand Down
68 changes: 38 additions & 30 deletions dart/gui/Win3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ void Win3D::keyboard(unsigned char _key, int _x, int _y) {
case 'c':
case 'C': // screen capture
mCapture = !mCapture;
if (mCapture)
glEnable(GL_MULTISAMPLE);
else
glDisable(GL_MULTISAMPLE);
break;
case 27: // ESC
exit(0);
Expand Down Expand Up @@ -159,13 +163,6 @@ void Win3D::drag(int _x, int _y) {
}

void Win3D::render() {
if (mCapture) {
capturing();
glutSwapBuffers();
screenshot();
return;
}

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(mPersp,
Expand All @@ -179,39 +176,48 @@ void Win3D::render() {

mTrackBall.applyGLRotation();

glEnable(GL_DEPTH_TEST);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glLineWidth(2.0);
if (mRotate || mTranslate || mZooming) {
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_LINES);
glVertex3f(-0.1f, 0.0f, -0.0f);
glVertex3f(0.15f, 0.0f, -0.0f);
glEnd();

glColor3f(0.0f, 1.0f, 0.0f);
glBegin(GL_LINES);
glVertex3f(0.0f, -0.1f, 0.0f);
glVertex3f(0.0f, 0.15f, 0.0f);
glEnd();

glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, -0.1f);
glVertex3f(0.0f, 0.0f, 0.15f);
glEnd();
// Draw world origin indicator
if (!mCapture)
{
glEnable(GL_DEPTH_TEST);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glLineWidth(2.0);
if (mRotate || mTranslate || mZooming) {
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_LINES);
glVertex3f(-0.1f, 0.0f, -0.0f);
glVertex3f(0.15f, 0.0f, -0.0f);
glEnd();

glColor3f(0.0f, 1.0f, 0.0f);
glBegin(GL_LINES);
glVertex3f(0.0f, -0.1f, 0.0f);
glVertex3f(0.0f, 0.15f, 0.0f);
glEnd();

glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, -0.1f);
glVertex3f(0.0f, 0.0f, 0.15f);
glEnd();
}
}

glScalef(mZoom, mZoom, mZoom);
glTranslatef(mTrans[0]*0.001, mTrans[1]*0.001, mTrans[2]*0.001);

initLights();
draw();

if (mRotate)
// Draw trackball indicator
if (mRotate && !mCapture)
mTrackBall.draw(mWinWidth, mWinHeight);

glutSwapBuffers();

if (mCapture)
screenshot();
}

void Win3D::initGL() {
Expand Down Expand Up @@ -261,6 +267,7 @@ void Win3D::initLights() {
glEnable(GL_NORMALIZE);
}

// Remove once deprecated function, capturing(), is removed
void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble nearPlane, GLdouble farPlane,
GLdouble pixdx, GLdouble pixdy, GLdouble eyedx, GLdouble eyedy,
Expand All @@ -285,6 +292,7 @@ void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
glTranslatef(-eyedx, -eyedy, 0.0);
}

// Remove once deprecated function, capturing(), is removed
void accPerspective(GLdouble fovy, GLdouble aspect,
GLdouble nearPlane, GLdouble farPlane,
GLdouble pixdx, GLdouble pixdy,
Expand Down
2 changes: 2 additions & 0 deletions dart/gui/Win3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include <Eigen/Eigen>

#include "dart/common/Deprecated.h"
#include "dart/gui/GlutWindow.h"
#include "dart/gui/Trackball.h"

Expand All @@ -57,6 +58,7 @@ class Win3D : public GlutWindow {
virtual void click(int _button, int _state, int _x, int _y);
virtual void drag(int _x, int _y);

DEPRECATED(5.0)
virtual void capturing();
virtual void initGL();
virtual void initLights();
Expand Down

0 comments on commit 60da070

Please sign in to comment.