Esempio n. 1
0
TextEditor::TextEditor(QWidget *parent) : QPlainTextEdit(parent)
{
    lineNumberArea = new LineNumberArea(this);

    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();

    QFont font("consolas",9);
    const int tabStop = 4;  // 4 characters
    QFontMetrics metrics(font);
    setTabStopWidth(tabStop * metrics.width(' '));
    setFont(font);
    setLineWrapMode(QPlainTextEdit::NoWrap);

    m_highlighter = new Highlighter(document());

    m_autoUpdate = false;
    m_timer = new QTimer();
    m_timer->setSingleShot(true);
    m_timer->setInterval(1000);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(updateShader()));
    connect(this, SIGNAL(textChanged()), this, SLOT(resetTimer()));
}
void DeferredRendererOld::initialize()
{


  glGenVertexArrays(1, &vao_);
  glBindVertexArray(vao_);
  GlState::enable(GlState::DEPTH_TEST);
  GlState::enable(GlState::CULL_FACE);
  GlState::blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  shader_ = MainManager::resources().loadShader(
    {{ShaderProgram::VERTEX,   "deferredobjrender.vert"},
     {ShaderProgram::FRAGMENT, "deferredobjrender.frag"}});

  updateShader();
  texture_ = MainManager::resources().loadImage("uv_colorgrid.png");
  texture_->setIsMaxFiltering(true);
  texture_->prepareForGl();

  sceneBoxTexture_ = MainManager::resources().loadImage("uv_browngrid.png");
  sceneBoxTexture_->setIsMaxFiltering(true);
  sceneBoxTexture_->prepareForGl();
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

  glClearColor( 0.1f, 0.2f, 0.3f, 1.0f );

  // TO TEXTURE RENDERING INITIALIZATION
  quadRender_.initialize();
  glGenFramebuffers(1, &fboHandle_);
  updateToTextureRenderFBO();
}
Esempio n. 3
0
void display()
{
  static const float ambient [] = {0.5, 0.5, 0.5, 1.0};
  static const float diffuse [] = {1.0, 0.0, 0.0, 1.0};
  static const float specular[] = {1.0, 1.0, 1.0, 1.0};
  static const float lightPos[] = {2.0, 2.0, 2.0, 0.0};
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();

  /* camera transform */
  glTranslatef(0.0, 0.0, -zoom);     /* zoom transform */
  glRotatef(camRotX, 1.0, 0.0, 0.0); /* rotation around x axis */
  glRotatef(camRotY, 0.0, 1.0, 0.0); /* rotation around y axis */

  /* set the light position */
  glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
  glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
  glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
  glMaterialf(GL_FRONT, GL_SHININESS, shininess);

  /* update uniform variable */
  if (options[OPT_SHADING_TOGG])
      updateShader();

  /* draw the scene */
  drawScene();

  /* draw normals */
  drawNormal();

  /* Render the hud */
  glDisable(GL_DEPTH_TEST);
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
  glOrtho(0,1,0,1,-1,1);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  if (options[OPT_LIGHTENING])
      glDisable(GL_LIGHTING);
  /* display current setting */
  glTranslatef(0.0, 0.0, -0.5);
  drawHud();

  if (options[OPT_LIGHTENING])
      glEnable(GL_LIGHTING);

  glMatrixMode(GL_PROJECTION);
  glPopMatrix();
  glMatrixMode(GL_MODELVIEW);
  glEnable(GL_DEPTH_TEST);

  glutSwapBuffers();

  // Check for gl errors.
  checkGLErrors();
}
Esempio n. 4
0
void HeightField::update () {

    if ( !mesh ) {
        //meshGrid( 16, 12, 1 );
        //meshGrid( 16, 12, 1 );
    }
    updateMesh();
    updateShader();
}
void DeferredRendererOld::refresh()
{
  if(shader_->isModified())
    updateShader();

  mesh_.refresh();
  sceneBox_.refresh();
  camera_->update();
  quadRender_.refresh();
  updateViewMatrix();
}
Esempio n. 6
0
void Utility::load() {
  presentation->setTitle(system().title());

  cheatEditor->load({pathname[0], "cheats.bml"});
  stateManager->load({pathname[0], "higan/states.bsa"}, 1);

  synchronizeDSP();

  resize();
  updateShader();
  cheatEditor->synchronize();
  cheatEditor->refresh();
}
Esempio n. 7
0
GuiModel::GuiModel()
{
	updateShader();

	vbo.setNew();
	vbo->addVertexComponent(shader->getAttributeLocation("aPos"), 0, 2);
	vbo->addVertexComponent(shader->getAttributeLocation("aUv"), sizeof(Coord2f), 2);
	vbo->setBytesPerVertex(sizeof(Vertex));
	vbo->setNumIndicesPerPrimitive(3);

	windowSizeLocation = shader->getUniformLocation("uWindowSize");
	positionLocation = shader->getUniformLocation("uPosition");
	textureSizeLocation = shader->getUniformLocation("uTextureSize");
	samplerLocation = shader->getUniformLocation("uSampler");
}
Esempio n. 8
0
void PlotCartesianWidget::paintGL()
{
    if( !isShowing() || !isExposed())
        return;

    glcontext->makeCurrent(this);

    glf->glClearColor(1,1,1,1);
    glf->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glf->glDisable(GL_DEPTH_TEST);

    float currentFWidth = float(width()*devicePixelRatio());
    float currentFHeight = float(height()*devicePixelRatio());
    if(currentFWidth != fWidth || currentFHeight != fHeight)
    {
        fWidth = currentFWidth;
        fHeight = currentFHeight;
        mAspect = fWidth / fHeight;
        updateInputDataLineVAO();
        updateProjectionMatrix();
    }

    glf->glViewport(0, 0, fWidth, fHeight);
    glf->glEnable(GL_MULTISAMPLE);

    drawAxis();
    drawLabels();

    glf->glBindVertexArray(dataLineVAO);
    for( int i = 0; i < (int)brdfs.size(); i++ )
    {
        DGLShader* shader = updateShader( brdfs[i] );
        glf->glDrawArrays(GL_LINE_STRIP_ADJACENCY, 0,  dataLineNPoints);
        shader->disable();
    }
    glf->glBindVertexArray(0);

    glf->glDisable(GL_BLEND);
    glf->glEnable(GL_DEPTH_TEST);

    glcontext->swapBuffers(this);
}
Esempio n. 9
0
	void ShaderProgram::bind()
	{
		updateShader();
		glUseProgram( mHandle );
	}
//--------------------------------------------------------------
void ofApp::update(){

    updateShader(passes);

}