/** Executes test iteration.
*
*  @return Returns STOP when test has finished executing, CONTINUE if more iterations are needed.
*/
tcu::TestNode::IterateResult ShaderBallotFunctionBallotTestCase::iterate()
{
	if (!m_context.getContextInfo().isExtensionSupported("GL_ARB_shader_ballot") ||
		!m_context.getContextInfo().isExtensionSupported("GL_ARB_gpu_shader_int64"))
	{
		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not supported");
		return STOP;
	}

	for (ShaderPipelineIter iter = m_shaderPipelines.begin(); iter != m_shaderPipelines.end(); ++iter)
	{
		createShaderPrograms(**iter);
	}

	const glw::Functions& gl = m_context.getRenderContext().getFunctions();

	for (ShaderPipelineIter pipelineIter = m_shaderPipelines.begin(); pipelineIter != m_shaderPipelines.end();
		 ++pipelineIter)
	{
		gl.clearColor(1.0f, 0.0f, 0.0f, 1.0f);
		gl.clear(GL_COLOR_BUFFER_BIT);

		(*pipelineIter)->test(m_context);

		gl.flush();

		bool validationResult = ShaderBallotBaseTestCase::validateScreenPixels(
			m_context, tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
		TCU_CHECK_MSG(validationResult, "Value returned from ballotARB function is not correct");
	}

	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
	return STOP;
}
/** Executes test iteration.
*
*  @return Returns STOP when test has finished executing, CONTINUE if more iterations are needed.
*/
tcu::TestNode::IterateResult ShaderBallotAvailabilityTestCase::iterate()
{
	if (!m_context.getContextInfo().isExtensionSupported("GL_ARB_shader_ballot") ||
		!m_context.getContextInfo().isExtensionSupported("GL_ARB_gpu_shader_int64"))
	{
		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not supported");
		return STOP;
	}

	for (ShaderPipelineIter iter = m_shaderPipelines.begin(); iter != m_shaderPipelines.end(); ++iter)
	{
		createShaderPrograms(**iter);
	}

	const glw::Functions& gl = m_context.getRenderContext().getFunctions();

	for (ShaderPipelineIter pipelineIter = m_shaderPipelines.begin(); pipelineIter != m_shaderPipelines.end();
		 ++pipelineIter)
	{
		gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
		gl.clear(GL_COLOR_BUFFER_BIT);

		(*pipelineIter)->test(m_context);

		gl.flush();
	}

	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
	return STOP;
}
Exemple #3
0
void View::initializeGL()
{
    cout << "Using OpenGL Version " << glGetString(GL_VERSION) << endl << endl;

    glEnable(GL_TEXTURE_2D);
    createShaderPrograms();

    // All OpenGL initialization *MUST* be done during or after this
    // method. Before this method is called, there is no active OpenGL
    // context and all OpenGL calls have no effect.

    // Start a timer that will try to get 60 frames per second (the actual
    // frame rate depends on the operating system and other running programs)
    //time.start();
    //timer.start(1000 / 60);

    // Start the drawing timer
    m_timer.start(1000.0f / MAX_FPS);

    // Center the mouse, which is explained more in mouseMoveEvent() below.
    // This needs to be done here because the mouse may be initially outside
    // the fullscreen window and will not automatically receive mouse move
    // events. This occurs if there are two monitors and the mouse is on the
    // secondary monitor.
    QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));

    glClearColor(0.0f,0.0f,0.0f,0.0f);
    glEnable(GL_COLOR_MATERIAL);
    glShadeModel(GL_SMOOTH);

    // Enable depth testing, so that objects are occluded based on depth instead of drawing order
    glEnable(GL_DEPTH_TEST);
    // Setup blending
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    // Setup the cube map
    setupCubeMap();

    // Enable alpha
    glEnable(GL_ALPHA_TEST);

    setupScene();

    // Load the snow texture
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/snowflake_design.png" ) );
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/second-snowflake.png" ) );
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/snowball-texture.png" ) );
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/snowflake-icon.png" ) );
    m_snowflakeTextures.push_back( ResourceLoader::loadTexture( ":/textures/textures/actual-snowflake.png" ) );
    m_snowEmitter.setTextures(&m_snowflakeTextures);

    m_snowTextureId = ResourceLoader::loadTexture( ":/textures/textures/plain-surface.jpg" );

    updateCamera();

    setupLights();
    glFrontFace(GL_CCW);
    paintGL();
}
Exemple #4
0
void View::InitResources()
{
    createShaderPrograms();
    m_skybox = ResourceLoader::loadSkybox();
    //m_comet  = ResourceLoader::loadObjModel("../final/model/planet.OBJ");
    //m_comet  = ResourceLoader::loadObjModel("/course/cs123/bin/models/xyzrgb_dragon.obj");

    loadCubeMap();

    m_texID_sun = loadTexture(":/textures/sun.png");
    m_texID_earth = loadTexture(":/textures/earthmap1k.jpg");
    m_texID_earth_normal = loadTexture(":/textures/earthbump1k_enhance.png");
    m_texID_earth_cloud = loadTexture(":/textures/earthcloudmap.jpg");
    m_texID_moon = loadTexture(":/textures/moonmap2k.jpg");
    m_texID_moon_normal = loadTexture(":/textures/moonmap2k_enhance2.jpg");
    m_texID_comet = loadTexture(":/textures/mercurymap.jpg");
    m_texID_comet_normal = loadTexture(":/textures/mercurybump_normal.jpg");
    m_texID_saturn = loadTexture(":/textures/saturnmap.jpg");
    m_texID_andy = loadTexture(":/textures/Andy.jpg");


}
Exemple #5
0
void QEglFSCursor::draw(const QRectF &r)
{
    if (!m_program) {
        // one time initialization
        createShaderPrograms();

        if (!m_cursorAtlas.texture) {
            createCursorTexture(&m_cursorAtlas.texture, m_cursorAtlas.image);
            m_cursorAtlas.image = QImage();

            if (m_cursor.shape != Qt::BitmapCursor)
                m_cursor.texture = m_cursorAtlas.texture;
        }
    }

    if (m_cursor.shape == Qt::BitmapCursor && !m_cursor.customCursorImage.isNull()) {
        // upload the custom cursor
        createCursorTexture(&m_cursor.customCursorTexture, m_cursor.customCursorImage);
        m_cursor.texture = m_cursor.customCursorTexture;
        m_cursor.customCursorImage = QImage();
    }

    Q_ASSERT(m_cursor.texture);

    glUseProgram(m_program);

    const GLfloat x1 = r.left();
    const GLfloat x2 = r.right();
    const GLfloat y1 = r.top();
    const GLfloat y2 = r.bottom();
    const GLfloat cursorCoordinates[] = {
        x1, y2,
        x2, y2,
        x1, y1,
        x2, y1
    };

    const GLfloat s1 = m_cursor.textureRect.left();
    const GLfloat s2 = m_cursor.textureRect.right();
    const GLfloat t1 = m_cursor.textureRect.top();
    const GLfloat t2 = m_cursor.textureRect.bottom();
    const GLfloat textureCoordinates[] = {
        s1, t2,
        s2, t2,
        s1, t1,
        s2, t1
    };

    glBindTexture(GL_TEXTURE_2D, m_cursor.texture);

    glEnableVertexAttribArray(m_vertexCoordEntry);
    glEnableVertexAttribArray(m_textureCoordEntry);

    glVertexAttribPointer(m_vertexCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, cursorCoordinates);
    glVertexAttribPointer(m_textureCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinates);

    glUniform1f(m_textureEntry, 0);

    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    glDisable(GL_DEPTH_TEST); // disable depth testing to make sure cursor is always on top
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    glDisable(GL_BLEND);

    glBindTexture(GL_TEXTURE_2D, 0);
    glDisableVertexAttribArray(m_vertexCoordEntry);
    glDisableVertexAttribArray(m_textureCoordEntry);

    glUseProgram(0);
}
void QEGLPlatformCursor::draw(const QRectF &r)
{
    if (!m_program) {
        // one time initialization
        initializeOpenGLFunctions();

        createShaderPrograms();

        if (!m_cursorAtlas.texture) {
            createCursorTexture(&m_cursorAtlas.texture, m_cursorAtlas.image);

            if (m_cursor.shape != Qt::BitmapCursor)
                m_cursor.texture = m_cursorAtlas.texture;
        }
    }

    if (m_cursor.shape == Qt::BitmapCursor && m_cursor.customCursorPending) {
        // upload the custom cursor
        createCursorTexture(&m_cursor.customCursorTexture, m_cursor.customCursorImage);
        m_cursor.texture = m_cursor.customCursorTexture;
        m_cursor.customCursorPending = false;
    }

    Q_ASSERT(m_cursor.texture);

    m_program->bind();

    const GLfloat x1 = r.left();
    const GLfloat x2 = r.right();
    const GLfloat y1 = r.top();
    const GLfloat y2 = r.bottom();
    const GLfloat cursorCoordinates[] = {
        x1, y2,
        x2, y2,
        x1, y1,
        x2, y1
    };

    const GLfloat s1 = m_cursor.textureRect.left();
    const GLfloat s2 = m_cursor.textureRect.right();
    const GLfloat t1 = m_cursor.textureRect.top();
    const GLfloat t2 = m_cursor.textureRect.bottom();
    const GLfloat textureCoordinates[] = {
        s1, t2,
        s2, t2,
        s1, t1,
        s2, t1
    };

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, m_cursor.texture);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    m_program->enableAttributeArray(m_vertexCoordEntry);
    m_program->enableAttributeArray(m_textureCoordEntry);

    m_program->setAttributeArray(m_vertexCoordEntry, cursorCoordinates, 2);
    m_program->setAttributeArray(m_textureCoordEntry, textureCoordinates, 2);

    m_program->setUniformValue(m_textureEntry, 0);

    glDisable(GL_CULL_FACE);
    glFrontFace(GL_CCW);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    glDisable(GL_DEPTH_TEST); // disable depth testing to make sure cursor is always on top
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    glDisable(GL_BLEND);

    glBindTexture(GL_TEXTURE_2D, 0);
    m_program->disableAttributeArray(m_textureCoordEntry);
    m_program->disableAttributeArray(m_vertexCoordEntry);

    m_program->release();
}