void VoxCad::SetupGLWindow(void)
{
	QGLFormat format; // double buffering and depth buffering is turned on in the default format, so no need to reset those
	GLWindow = new CQOpenGL(format);
	ui.horizontalLayout->addWidget(GLWindow);

	//opengl info
	connect(GLWindow, SIGNAL(FindDims(Vec3D<>*, Vec3D<>*)), &MainObj, SLOT(GetDim(Vec3D<>*, Vec3D<>*)));
	connect(GLWindow, SIGNAL(DrawGL(bool)), this, SLOT(DrawCurScene(bool)));
	connect(GLWindow, SIGNAL(DrawGLOverlay()), this, SLOT(DrawCurSceneOverlay()));
	connect(GLWindow, SIGNAL(MousePressIndex(int)), this, SLOT(SetGLSelected(int)));
	connect(GLWindow, SIGNAL(FastModeChanged(bool)), this, SLOT(FastModeChanged(bool)));

	//mouse handling
	connect(GLWindow, SIGNAL(WantGLIndex(bool*)), this, SLOT(WantGLIndex(bool*)));
	connect(GLWindow, SIGNAL(WantCoord3D(bool*)), this, SLOT(WantCoord3D(bool*)));

	connect(GLWindow, SIGNAL(MouseMoveHover(float, float, float)), this, SLOT(HoverMove(float, float, float)));
	connect(GLWindow, SIGNAL(LMouseMovePressed(float, float, float)), this, SLOT(LMouseDownMove(float, float, float)));
	connect(GLWindow, SIGNAL(LMouseDown(float, float, float, bool)), this, SLOT(LMouseDown(float, float, float, bool)));
	connect(GLWindow, SIGNAL(LMouseUp(float, float, float)), this, SLOT(LMouseUp(float, float, float)));
	connect(GLWindow, SIGNAL(PressedEscape()), this, SLOT(PressedEscape()));
	connect(GLWindow, SIGNAL(CtrlWheelRoll(bool)), this, SLOT(CtrlMouseRoll(bool)));

	MainSim.pGLWin = GLWindow;
}
Exemple #2
0
void CQOpenGL::GLDrawScene()
{
    CGL_Utils::CurContextID = MyID;
    glRenderMode(GL_RENDER);

    glMatrixMode(GL_PROJECTION); // Select the Projection Matrix
    glLoadIdentity();
    GLSetPersp(); //dynamic control over the perspective

    //move the view to follow something if this signal is hooked up to something that changes its value
    Vec3D<> CurTarget(m_Cam.TargetX, m_Cam.TargetY, m_Cam.TargetZ);
    emit FindCamTarget(&CurTarget);
    m_Cam.TargetX = CurTarget.x;
    m_Cam.TargetY = CurTarget.y;
    m_Cam.TargetZ = CurTarget.z;

    // Set camera view
    glMatrixMode(GL_MODELVIEW); //Back to model view
    glLoadIdentity();
    GLTranslateCam();

    GLSetLighting(); //Enable to have specular highlight in accurate place
    //End Bonuses


    glPushMatrix();
    switch (CurView){ //this makes sure the axes and bounds are out front of drawing...
    case VTOP: glTranslated(0, 0, CurEnv.z); break;
    case VBOTTOM: glTranslated(0, 0, -CurEnv.z); break;
    case VLEFT: glTranslated(0, -CurEnv.y, 0); break;
    case VRIGHT: glTranslated(0, CurEnv.y, 0); break;
    case VFRONT: glTranslated(CurEnv.x, 0, 0); break;
    case VBACK: glTranslated( -CurEnv.x, 0, 0); break;
    }

    if (bDrawAxes)
        GLDrawAxes();

    glPopMatrix();

    if (bDrawBounds)
        GLDrawBounds();

//	CGL_Utils::DrawSphere(LastPickedPoint, 0.0002, Vec3D<>(1,1,1), CColor(.5, .5, .5));

    QTime t;
    t.start();
    //draw geometry:
    emit DrawGL(FastMode); //Draw anything connected to this!

    int MStoDraw = t.elapsed();
    if (MStoDraw > 200 && !IsFastMode() && !AskedAboutFastMode){
        AskedAboutFastMode = true;
        if (QMessageBox::question(NULL, "Enter fast draw mode?", "Do you want to enter fast drawing mode?", QMessageBox::Yes | QMessageBox::No)==QMessageBox::Yes)
            EnterFastMode(true);
    }

//	glPushMatrix();
    //draw 2D overlay!


    glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
      glLoadIdentity();
      glOrtho(0, WindowSize.width(), WindowSize.height(), 0, -1, 1);
      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
        glLoadIdentity();
        glDisable(GL_LIGHTING);
        emit DrawGLOverlay(); //draw any 2D connected to this!
      glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glPopAttrib();

}