← Back to team overview

yade-users team mailing list archive

Re: glutInit() problem.

 

Ye Yonggeng said:     (by the date of Mon, 26 Jun 2006 16:42:26 +0200)


> > does glxgears launched from terminal, work?
> 
> wait, let me try again, but now I have to leave for my class.

I have a feeling that there is a problem with qglviewer. Have you
compiled it locally and installed, or did you use .deb package, or maybe
something else?

please try the small example in the attachment, does it work?


-- 
Janek Kozicki                                                         |

Attachment: makefile
Description: Binary data

#include <QGLViewer/qglviewer.h>
#include <qapplication.h>
#include <cmath>
#include <iostream>

using namespace std;

class Viewer : public QGLViewer
{
protected :
  virtual void draw();
  virtual void init();
};

// Draws a spiral
void Viewer::draw()
{
	const float nbSteps = 21.0;
	const float outsideRadius = 0.5;
	const float insideRadius = 0.4;
	const float height = 1.0;

	float height2 = height*0.5;

	glBegin(GL_QUAD_STRIP);
	glColor3f(1.0, 1.0 , 1.0);
	
	float pi2 = M_PI*2.0;
	float increment = pi2 / nbSteps;
	float s1,c1,s2,c2,s1o,c1o,s2o,c2o;
	for(float ang=0 ; ang <= pi2 ; ang += increment )
	{
		if(ang==0)
		{
			s1o = sin(ang)*outsideRadius;
			c1o = cos(ang)*outsideRadius;
			s2o = sin(ang)*insideRadius;
			c2o = cos(ang)*insideRadius;
		} else
		{
			s1 = sin(ang)*outsideRadius;
			c1 = cos(ang)*outsideRadius;
			s2 = sin(ang)*insideRadius;
			c2 = cos(ang)*insideRadius;
		
			glNormal3f( (s1+s1o)*0.5, (c1+c1o)*0.5, 0 );
			glVertex3f(s1o, c1o, height2 );
			glVertex3f(s1 , c1 , height2 );
			glNormal3f(0,0,-1);
			glVertex3f(s1o, c1o,-height2 );
			glVertex3f(s1 , c1 ,-height2 );

			glNormal3f(-(s1+s1o)*0.5,-(c1+c1o)*0.5, 0 );
			glVertex3f(s2o, c2o,-height2 );
			glVertex3f(s2 , c2 ,-height2 );
			glNormal3f(0,0, 1);
			glVertex3f(s2o, c2o, height2 );
			glVertex3f(s2 , c2 , height2 );
			glVertex3f(s1o, c1o, height2 );
			glVertex3f(s1 , c1 , height2 );

			s1o = s1;
			c1o = c1;
			s2o = s2;
			c2o = c2;
		}
	}

	glEnd();
}

void Viewer::init()
{
  // Restore previous viewer state.
  restoreFromFile();
}

int main(int argc, char** argv)
{
  // Read command lines arguments.
  QApplication application(argc,argv);

  // Instantiate the viewer.
  Viewer v;

  // Make the viewer window visible on screen.
  v.show();
  v.camera()->frame()->setWheelSensitivity(-1.0f);

  // Set the viewer as the application main widget.
  application.setMainWidget(&v);

  // Run main loop.
  return application.exec();
}

Follow ups

References