void ReflectionScene::render(graphics::ESContext* esContext)
{
	//set the viewport
	glViewport(0, 0, esContext->width, esContext->height);

	//clear the backbuffer and depth buffer
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	checkOpenGL();

	//initialize GL state
	glDisable(GL_BLEND);
	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	checkOpenGL();

	//these values are needed to update for each mesh which is rendered (different model matrix)
	slmath::mat4 matModelView = m_matView * m_matModel;
	slmath::mat4 matModelViewProj = m_matProjection * matModelView;

	//set matrix to shared values
	m_sharedValues.matModelViewProj = matModelViewProj;

	//bind material (sets uniform values)
	m_material->bind();
	checkOpenGL();

	//render the mesh using active material
	m_mesh->render();
	checkOpenGL();
}
Ejemplo n.º 2
0
void Spotlight::RenderDone()
{
	glGetFloatv(GL_MODELVIEW_MATRIX, this->mviewMatrix);
	checkOpenGL("Spotlight::retrieve modelview");
	glGetFloatv(GL_PROJECTION_MATRIX, this->projMatrix);
	checkOpenGL("Spotlight::retrieve projection");
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
	glViewport(this->viewport[0], this->viewport[1], this->viewport[2], this->viewport[3]);
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{



    QApplication app(argc, argv);

    // Chossing proper GUI style from config.ini file.
    QSettings settings("config.ini", QSettings::IniFormat);
    // Dude, this default style is really amazing...
    // Seriously?
    // No...
    QString guiStyle = settings.value("gui_style","DefaultAwesomeStyle").toString();
    app.setStyle(QStyleFactory::create( guiStyle ));

    QFont font;
    font.setFamily(font.defaultFamily());
    font.setPixelSize(10);
    app.setFont(font);

    // removing old log file
    QFile::remove(AB_LOG);


    qInstallMessageHandler(customMessageHandler);
    qDebug() << "Starting application:";

    QMessageBox msgBox;
    if(!checkOpenGL()){

        msgBox.setText("Fatal Error!");
        msgBox.setInformativeText("Sorry but it seems that your graphics card does not support openGL 4.0.\n"
                                  "Program will not run :(\n"
                                  "See log.txt file for more info.");
        msgBox.setStandardButtons(QMessageBox::Close);
        msgBox.show();

        return app.exec();
    }else{


        MainWindow window;
        window.setWindowTitle(AWESOME_BUMP_VERSION);
        window.resize(window.sizeHint());
        int desktopArea = QApplication::desktop()->width() *
                         QApplication::desktop()->height();
        int widgetArea = window.width() * window.height();
        if (((float)widgetArea / (float)desktopArea) < 0.75f)
            window.show();
        else
            window.showMaximized();

        return app.exec();

    }



}
ReflectionScene::ReflectionScene()
{
	LOG("ReflectionScene construct");
	//shader lataus
	FRM_SHADER_ATTRIBUTE attributes[3] = {
		{ "g_vPositionOS", graphics::ATTRIB_POSITION },
		{ "g_vNormalOS", graphics::ATTRIB_NORMAL },
		{ "g_vTextureOS", graphics::ATTRIB_UV }
	};

	//load shader
	core::Ref<graphics::Shader> m_shader =
		new graphics::Shader("assets/BlinnPhong.glvs", "assets/Reflection.glfs",
		attributes, sizeof(attributes) / sizeof(FRM_SHADER_ATTRIBUTE));

	m_mesh = createTeapotMesh();

	checkOpenGL();

	m_totalTime = 0.0f;

	//m_material = new GlobalShaderUniforms(m_shader, &m_sharedValues);

	SimpleMaterialWithTextureUniforms *simpleMaterialWithTextureUniforms =
		new SimpleMaterialWithTextureUniforms(m_shader, &m_sharedValues);

	simpleMaterialWithTextureUniforms->vAmbient = slmath::vec4(0.25f, 0.25f, 0.25f, 1.0f);
	simpleMaterialWithTextureUniforms->vDiffuse = slmath::vec4(0.5f, 0.5f, 0.5f, 1.0f);
	simpleMaterialWithTextureUniforms->vSpecular = slmath::vec4(0.25f, 0.25f, 0.25f, 5.0f);
	m_material = simpleMaterialWithTextureUniforms;

	m_image = graphics::Image::loadFromTGA("assets/WoodDiffuse.tga");
	m_texture = new graphics::Texture2D();
	m_texture->setData(m_image);

	simpleMaterialWithTextureUniforms->diffuseMap = m_texture;

	//skybox
	eastl::string name = "BedroomCubeMap";

	core::Ref<graphics::Image> cubeImageRefs[6];
	cubeImageRefs[0] = graphics::Image::loadFromTGA("assets/" + name + "_RT.tga");
	cubeImageRefs[1] = graphics::Image::loadFromTGA("assets/" + name + "_LF.tga");
	cubeImageRefs[2] = graphics::Image::loadFromTGA("assets/" + name + "_DN.tga");
	cubeImageRefs[3] = graphics::Image::loadFromTGA("assets/" + name + "_UP.tga");
	cubeImageRefs[4] = graphics::Image::loadFromTGA("assets/" + name + "_FR.tga");
	cubeImageRefs[5] = graphics::Image::loadFromTGA("assets/" + name + "_BK.tga");

	graphics::Image *cubeImages[6];
	for (int i = 0; i < 6; i++)
		cubeImages[i] = cubeImageRefs[i].ptr();

	core::Ref<graphics::TextureCube> cubeMap = new graphics::TextureCube();
	cubeMap->setData(cubeImages);

}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    qDebug() << "Application dir:" << QApplication::applicationDirPath();
    qDebug() << "Data dir:" << _find_data_dir("");

    // Chossing proper GUI style from config.ini file.
    QSettings settings("config.ini", QSettings::IniFormat);
    // Dude, this default style is really amazing...
    // Seriously?
    // No...
    QString guiStyle = settings.value("gui_style","DefaultAwesomeStyle").toString();
    app.setStyle(QStyleFactory::create( guiStyle ));

    // Customize some elements:
    app.setStyleSheet("QGroupBox { font-weight: bold; } ");

    QFont font;
    font.setFamily(font.defaultFamily());
    font.setPixelSize(10);
    app.setFont(font);

    // removing old log file
    QFile::remove(AB_LOG);


    QGLFormat glFormat(QGL::SampleBuffers);

#ifdef Q_OS_MAC
    glFormat.setProfile( QGLFormat::CoreProfile );
    glFormat.setVersion( 4, 1 );
#endif

#ifdef USE_OPENGL_330
#ifdef Q_OS_LINUX
    glFormat.setProfile( QGLFormat::CoreProfile );
    glFormat.setVersion( 3, 3 );
#endif
#endif

    QGLFormat::setDefaultFormat(glFormat);


    qInstallMessageHandler(customMessageHandler);
    qDebug() << "Starting application:";

    if(!checkOpenGL()){

        AllAboutDialog msgBox;
        msgBox.setPixmap(":/resources/icon-off.png");
        msgBox.setText("Fatal Error!");

#ifdef USE_OPENGL_330
        msgBox.setInformativeText("Sorry but it seems that your graphics card does not support openGL 3.3.\n"
                                  "Program will not run :(\n"
                                  "See " AB_LOG " file for more info.");
#else
        msgBox.setInformativeText("Sorry but it seems that your graphics card does not support openGL 4.0.\n"
                                  "Program will not run :(\n"
                                  "See " AB_LOG " file for more info.");
#endif


        msgBox.show();

        return app.exec();
    }else{

        MainWindow window;
        window.setWindowTitle(AWESOME_BUMP_VERSION);
        window.resize(window.sizeHint());
        int desktopArea = QApplication::desktop()->width() *
                         QApplication::desktop()->height();
        int widgetArea = window.width() * window.height();
        if (((float)widgetArea / (float)desktopArea) < 0.75f)
            window.show();
        else
            window.showMaximized();

        return app.exec();

    }



}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    qDebug() << "Application dir:" << QApplication::applicationDirPath();
    qDebug() << "Data dir:" << _find_data_dir("");

    // Chossing proper GUI style from config.ini file.
    QSettings settings("config.ini", QSettings::IniFormat);
    // Dude, this default style is really amazing...
    // Seriously?
    // No...
    QString guiStyle = settings.value("gui_style","DefaultAwesomeStyle").toString();
    app.setStyle(QStyleFactory::create( guiStyle ));

    // Customize some elements:
    app.setStyleSheet("QGroupBox { font-weight: bold; } ");

    QFont font;
    font.setFamily(font.defaultFamily());
    font.setPixelSize(10);
    app.setFont(font);

    // removing old log file
    QFile::remove(AB_LOG);


    QGLFormat glFormat(QGL::SampleBuffers);

#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
     /*
     * Commenting out the next line because it causes rendering to fail.  QGLFormat::CoreProfile
     * disables all OpenGL functions that are depreciated as of OpenGL 3.0.  This fix is a workaround.
     * The full solution is to replace all depreciated OpenGL functions with their current implements.
    */
# if defined(Q_OS_MAC)
	glFormat.setProfile( QGLFormat::CoreProfile );
# endif
    glFormat.setVersion( GL_MAJOR, GL_MINOR );
#endif

    QGLFormat::setDefaultFormat(glFormat);


    qInstallMessageHandler(customMessageHandler);
    qDebug() << "Starting application:";

    if(!checkOpenGL()){

        AllAboutDialog msgBox;
        msgBox.setPixmap(":/resources/icon-off.png");
        msgBox.setText("Fatal Error!");

        msgBox.setInformativeText(QString("Sorry but it seems that your graphics card does not support openGL %1.%2.\n"
                                          "Program will not run :(\n"
                                          "See " AB_LOG " file for more info.").arg(GL_MAJOR).arg(GL_MINOR));

        msgBox.show();

        return app.exec();
    }else{

        MainWindow window;
        window.setWindowTitle(AWESOME_BUMP_VERSION);
        window.resize(window.sizeHint());
        int desktopArea = QApplication::desktop()->width() *
                         QApplication::desktop()->height();
        int widgetArea = window.width() * window.height();
        if (((float)widgetArea / (float)desktopArea) < 0.75f)
            window.show();
        else
            window.showMaximized();

        return app.exec();

    }



}