コード例 #1
0
ファイル: renderwidget.cpp プロジェクト: lamogui/rmeditor
RenderWidget::RenderWidget(QWidget *parent) :
  QOpenGLWidget(parent),
  renderFunctions(nullptr),
  render(nullptr),
  quad(nullptr),
  quadShader(nullptr),
  openglDebugLogger(nullptr),
  captureMouse(false),
  onlyShowTexture(false),
  textureDisplayed(color)
{
  // Widget config
  setUpdateBehavior(QOpenGLWidget::NoPartialUpdate);
  setFocusPolicy(Qt::ClickFocus);

  // Update Timer config
  connect(&updateTimer, SIGNAL(timeout()), this, SLOT(update()));
  startUpdateLoop();

  // Open GL Context config
  QSurfaceFormat f;
  f.setRenderableType(QSurfaceFormat::OpenGL);
  f.setMajorVersion(4);
  f.setMinorVersion(5);
  f.setProfile(QSurfaceFormat::CoreProfile);
  f.setOptions(QSurfaceFormat::DebugContext | f.options());
  setFormat(f);
}
コード例 #2
0
/**
  OpenGL intialization.
  */
void MyQGLWidget::initializeGL()
{
    initializeGLFunctions(context());

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    glShadeModel(GL_SMOOTH);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glClearDepth(1.0f);

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    camera_.setPosition(50, 50, 125);
    camera_.lookAt(Vec3f(50, 50, 0), Vec3f(50, 50, 125), Vec3f(0, 1, 0));

    initMaze();
    initShaders();

    startUpdateLoop();
}
コード例 #3
0
ファイル: drone.cpp プロジェクト: dnestelhut/libdrone
bool Drone::startUpdateLoop()
{
	if(_updater == nullptr)
	{
		if(_connected.load())
		{
			_stop_flag = false;
			_updater = new boost::thread(&Drone::runUpdateLoop, this);
		}
		else
		{
			return false;
		}
	}
	else if(_connected.load())
	{
		// When the connection is lost the _updater thread still exists. If it is reestablished, then it needs to be killed.

		stopUpdateLoop();
		_connected.store(true);
		startUpdateLoop();
	}

	return true;
}