// // Update override for the current frame. // // Make sure we have a proper set of operations. If so then update // shaders and light pruning information. // MStatus viewRenderOverrideShadows::setup(const MString& destination) { // Firewall checks MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer(); if (!renderer) return MStatus::kFailure; const MHWRender::MShaderManager* shaderMgr = renderer->getShaderManager(); if (!shaderMgr) return MStatus::kFailure; // Update render operations // MStatus status = updateRenderOperations(); if (status != MStatus::kSuccess) return status; // Update shaders status = updateShaders( shaderMgr ); if (status != MStatus::kSuccess) return status; // Update light list status = updateLightList(); return status; }
void GLView::initializeGL() { GLenum err; if ( scene->options & Scene::DoMultisampling ) { if ( !glContext->hasExtension( "GL_EXT_framebuffer_multisample" ) ) { scene->options &= ~Scene::DoMultisampling; //qDebug() << "System does not support multisampling"; } /* else { GLint maxSamples; glGetIntegerv( GL_MAX_SAMPLES, &maxSamples ); qDebug() << "Max samples:" << maxSamples; }*/ } initializeTextureUnits( glContext ); if ( scene->renderer->initialize() ) updateShaders(); // Initial viewport values // Made viewport and aspect member variables. // They were being updated every single frame instead of only when resizing. //glGetIntegerv( GL_VIEWPORT, viewport ); aspect = (GLdouble)width() / (GLdouble)height(); // Check for errors while ( ( err = glGetError() ) != GL_NO_ERROR ) qDebug() << tr( "glview.cpp - GL ERROR (init) : " ) << (const char *)gluErrorString( err ); }
void VizWidget::paintGL() { // Clear the buffer with the current clearing color glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //Update the fft buffer updateFFT(); updateShaders(); // Draw stuff glDrawArrays(GL_QUADS, 0, 4); ++frameCount; }
bool CodeResource::load( const char *data, int size ) { if( !Resource::load( data, size ) ) return false; _code.reserve( size ); _code = data; // Compile shaders that require this code block updateShaders(); return true; }
void MObject::draw() { updateShaders(); // enable shaders glUseProgram(shaderID); //texture glActiveTexture(GL_TEXTURE0 + textureID); //after terrain 4 textures glBindTexture(GL_TEXTURE_CUBE_MAP , textureID); // enable vertex arrays glBindVertexArray(varrayIDs[TERRAIN_VARRAY]); // draw the triangles for each three indices glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferIDs[INDEX_BUFFER]); glDrawElements(GL_TRIANGLES, iFactor*iFactor*6, GL_UNSIGNED_INT, 0); // turn of whatever we turned on glBindTexture(GL_TEXTURE_CUBE_MAP, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindVertexArray(0); glUseProgram(0); }
KawaiiGL::KawaiiGL(QWidget *parent) : QMainWindow(parent), m_kView(NULL), m_edDlg(NULL), m_doc(NULL) { ui.setupUi(this); m_sett.loadFromReg(); connect(&m_sett, SIGNAL(changed()), &m_sett, SLOT(storeToReg())); setWindowTitle("KawaiiGL"); show(); // needed becase we're creating display lists in the c'tor. QDir::setCurrent(EXAMPLES_DIR); // we're reading the config and textures from there m_progMenu = new QMenu(this); m_modelsMenu = new QMenu(this); m_doc = new Document(this); // adds to the menus m_progMenu->addSeparator(); QAction *loadFromFileAct = m_progMenu->addAction("From file..."); connect(loadFromFileAct, SIGNAL(triggered(bool)), m_doc, SLOT(loadProgramFile())); m_kView = new T2GLWidget(this, m_doc); setCentralWidget(m_kView); m_edDlg = new KwEdit(this, m_sett.disp, m_doc, m_kView); // need the view for tracking vec2s m_edDlg->show(); m_edDlg->move(pos() + QPoint(width() - 20, 30)); m_control = new MyDialog(this); QBoxLayout *control_l = new QVBoxLayout(); m_control->setLayout(control_l); control_l->setMargin(0); control_l->setSpacing(0); QTabWidget *tabs = new QTabWidget(); control_l->addWidget(tabs); m_contDlg = new ControlPanel(&m_sett.disp, this, m_doc, m_kView); tabs->addTab(m_contDlg, "Config"); m_browse = new ProjBrowser(this, m_doc); tabs->addTab(m_browse, "Browser"); tabs->setCurrentWidget(m_browse); //tabs->setCurrentIndex(m_sett.gui.configWindowTab); tabs->setCurrentIndex(0); m_control->show(); m_control->move(pos() + QPoint(-30, 20)); m_control->resize(100, 100); // make it as small as possible m_doc->model()->m_errAct = new ErrorHighlight(m_edDlg); connect(m_kView, SIGNAL(message(const QString&)), this, SLOT(message(const QString&))); connect(m_edDlg, SIGNAL(changedModel(DocSrc*)), m_doc, SLOT(calc(DocSrc*))); connect(m_edDlg, SIGNAL(updateShaders()), m_doc, SLOT(compileShaders())); // connect(m_kView, SIGNAL(decompProgChanged(const QString&)), m_edDlg, SLOT(curChanged(const QString&))); connect(m_doc, SIGNAL(loaded()), m_kView, SLOT(newModelLoaded())); //connect(m_doc, SIGNAL(loaded()), m_edDlg, SLOT(doVarsUpdate())); // parsed new text. vars defs may be wrong connect(m_doc, SIGNAL(modelChanged()), m_kView, SLOT(updateGL())); connect(m_doc, SIGNAL(progChanged()), m_kView, SLOT(redoFrameBuffers())); connect(m_kView, SIGNAL(changedFBOs()), m_contDlg, SLOT(updateTexEdits())); connect(m_kView, SIGNAL(makeGradientTex(int, const QString&)), m_contDlg, SLOT(externalGradient(int, const QString&))); connect(m_doc, SIGNAL(progParamChanged()), m_kView, SLOT(updateGL())); connect(m_doc, SIGNAL(addModelLine(const QString&)), m_edDlg, SLOT(addModelLine(const QString&))); connect(m_contDlg, SIGNAL(changedRend()), m_doc, SLOT(calcNoParse())); // passes update connect(m_contDlg, SIGNAL(changedFont()), m_kView, SLOT(updateCoordFont())); connect(m_contDlg, SIGNAL(doUpdate()), m_kView, SLOT(updateGL())); // passes update connect(m_contDlg, SIGNAL(resetView()), m_kView, SLOT(resetState())); connect(m_contDlg, SIGNAL(resetLight()), m_kView, SLOT(resetLight())); connect(m_contDlg, SIGNAL(changedTexFile(int)), m_kView, SLOT(setTexture(int))); // connect(m_contDlg, SIGNAL(reassertTex(int)), m_kView, SLOT(rebindTexture(int))); connect(m_contDlg, SIGNAL(saveMesh()), m_doc, SLOT(calcSave())); connect(m_browse, SIGNAL(openDocText(DocElement*)), m_edDlg, SLOT(addPage(DocElement*)) ); connect(m_browse, SIGNAL(openPassConf(DocElement*)), m_edDlg, SLOT(addPage(DocElement*)) ); connect(m_browse, SIGNAL(commitGuiData()), m_edDlg, SLOT(commitAll())); connect(m_doc, SIGNAL(goingToClearProg()), m_edDlg, SLOT(clearingProg())); connect(m_doc, SIGNAL(didReadProg(ProgKeep*)), m_edDlg, SLOT(readProg(ProgKeep*)) ); connect(m_doc, SIGNAL(didReadProg(ProgKeep*)), m_browse, SLOT(readProg(ProgKeep*)) ); connect(m_doc, SIGNAL(didReadModel(DocSrc*)), m_browse, SLOT(readModel()) ); connect(m_doc, SIGNAL(didReadModel(DocSrc*)), m_edDlg, SLOT(readModel(DocSrc*))); connect(&m_sett.disp.bVtxNormals, SIGNAL(changed()), m_doc, SLOT(calcNoParse())); // TBD - this is bad. connect(m_contDlg->ui.clipSlider, SIGNAL(valueChanged(int)), m_kView, SLOT(setClipValue(int))); m_kView->setContextMenuPolicy(Qt::ActionsContextMenu); QPushButton *viewBot = new QPushButton("View"); viewBot->setMaximumSize(60, 19); statusBar()->addPermanentWidget(viewBot); QMenu *view = new QMenu("View"); viewBot->setMenu(view); QPushButton *fpsBot = new QPushButton(QIcon(":/images/arrow-circle.png"), QString()); fpsBot->setMaximumSize(20, 19); statusBar()->addPermanentWidget(fpsBot); (new CheckBoxIn(&m_sett.disp.fullFps, fpsBot))->reload(); QCheckBox *vSyncBox = new QCheckBox("vSync"); vSyncBox->setMaximumHeight(19); statusBar()->addPermanentWidget(vSyncBox); (new CheckBoxIn(&m_sett.disp.vSync, vSyncBox))->reload(); QAction *confVis = new QAction("Display", view); view->addAction(confVis); m_control->connectAction(confVis); QAction *editVis = new QAction("Edit", view); view->addAction(editVis); m_edDlg->connectAction(editVis); m_kView->connectedInit(); processCmdArgs(); }
MObject::MObject() { // buffer objects glGenBuffers(NUM_BUFFERS, bufferIDs); glGenVertexArrays(NUM_VARRAYS, varrayIDs); iFactor = 100; iRadius = 50; vert.resize(iFactor*iFactor*3); normal.resize(iFactor*iFactor*3); indices.resize(iFactor*iFactor*6); float phi, theta; std::vector<GLfloat>::iterator v = vert.begin(); std::vector<GLfloat>::iterator n = normal.begin(); for (int i = 0; i<iFactor; i++) { theta = (M_PI*i)/iFactor; for (int j = 0; j<iFactor; j++) { phi = (2*M_PI*j)/iFactor; *v++ = (float)(sin(theta)*cos(phi)*iRadius); *v++ = (float)(sin(theta)*sin(phi)*iRadius); *v++ = (float)(cos(theta)*iRadius); *n++ = (float)(sin(theta)*cos(phi)); *n++ = (float)(sin(theta)*sin(phi)); *n++ = (float)(cos(theta)); } } // build index array linking sets of three vertices into triangles std::vector<GLint>::iterator k = indices.begin(); for (int i = 0; i<iFactor; i++) { for (int j = 0; j<iFactor; j++) { *k++ = i*iFactor + j; *k++ = (i+1)*iFactor + j; *k++ = i*iFactor + (j + 1); *k++ = (i+1)*iFactor + j; *k++ = (i+1)*iFactor + (j + 1); *k++ = i*iFactor + (j + 1); } } // load vertex and index array to GPU glBindBuffer(GL_ARRAY_BUFFER, bufferIDs[POSITION_BUFFER]); glBufferData(GL_ARRAY_BUFFER, iFactor*iFactor*sizeof(float[3]), &vert.front(), GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferIDs[INDEX_BUFFER]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, (iFactor*iFactor)*sizeof(int[6]), &indices.front(), GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, bufferIDs[NORMAL_BUFFER]); glBufferData(GL_ARRAY_BUFFER, iFactor*iFactor*sizeof(float[3]), &normal.front(), GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // initial shader load shaderParts[0].id = glCreateShader(GL_VERTEX_SHADER); shaderParts[0].file = "cubemapping.vert"; shaderParts[1].id = glCreateShader(GL_FRAGMENT_SHADER); shaderParts[1].file = "cubemapping.frag"; shaderID = glCreateProgram(); updateShaders(); }