void NormalBlendedDecal::initRendering(void)
{
    if (!requireMinAPIVersion(NvGfxAPIVersionGL4_3()))
        return;

    //if (!requireExtension("GL_NV_fragment_shader_interlock"))
    //    return;

    bool isPSISupported = getGLContext()->isExtensionSupported("GL_NV_fragment_shader_interlock");
    if (isPSISupported) {
        mLock = LOCK_PIXEL_SHADER_INTERLOCK;
    } else {
        mLock = LOCK_MEMORY_BARRIER;
    }

    NvAssetLoaderAddSearchPath("gl4-maxwell/NormalBlendedDecal");

    if (!buildShaders()) {
        LOGI("Shader build error");
        return;
    }

    mCube = loadModel("models/cube.obj");
    mModels[BUNNY_MODEL] = loadModel("models/bunny2.obj");
    mModels[BOX_MODEL] = loadModel("models/cube.obj");
    mModelID = BUNNY_MODEL;

    mDecalNormals[0] = NvImage::UploadTextureFromDDSFile("textures/rock_normal.dds");
    mDecalNormals[1] = NvImage::UploadTextureFromDDSFile("textures/brick_normal.dds");

    // Disable wait for vsync
    getGLContext()->setSwapInterval(0);
}
bool btSoftBodySolverOutputCLtoGL::checkInitialized()
{
	if( !m_shadersInitialized )
		if( buildShaders() )
			m_shadersInitialized = true;

	return m_shadersInitialized;
}
Exemple #3
0
void DynamicLighting::processDirty()
{
    if (mIsDirty)
    {
        mIsDirty = false;
        buildObjects();
        buildShaders();
    }
}
void ColoredPyramid::initialize()
{
	GLfloat hH = height/2.0f;
	GLfloat hW = width/2.0f;

	buildShaders();

	GLuint VBO, IBO;

	glGenVertexArrays (1, &vertexArrayObject); 
	glBindVertexArray( vertexArrayObject );

	vector<VertexData> v;

    v.push_back( VertexData( vec3( 0.0f,  hH, 0.0f), vec4( 1.0f, 0.0f, 0.0f, 1.0f )));
    v.push_back( VertexData( vec3(-hW, -hH, hW), vec4( 0.0f, 1.0f, 0.0f, 1.0f )));
    v.push_back( VertexData( vec3( hW, -hH, hW), vec4( 0.0f, 0.0f, 1.0f, 1.0f )));
    v.push_back( VertexData( vec3( hW, -hH, -hW), vec4( 1.0f, 1.0f, 0.0f, 1.0f )));
    v.push_back( VertexData( vec3(-hW, -hH, -hW), vec4( 0.0f, 1.0f, 1.0f, 1.0f )));

 	glGenBuffers(1, &VBO);
	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBufferData(GL_ARRAY_BUFFER, v.size() * sizeof(VertexData), &v[0], GL_STATIC_DRAW);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), 0);
	glEnableVertexAttribArray(0);

	glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData),(const GLvoid*)sizeof(vec3));
	glEnableVertexAttribArray(2);

	vector<unsigned int> i;
	i.push_back(0);
	i.push_back(1);
	i.push_back(2);

	i.push_back(0);
	i.push_back(2);
	i.push_back(3);

	i.push_back(0);
	i.push_back(3);
	i.push_back(4);

	i.push_back(0);
	i.push_back(4);
	i.push_back(1);

	i.push_back(4);
	i.push_back(2);
	i.push_back(1);

	i.push_back(4);
	i.push_back(3);
	i.push_back(2);

	numberOfIndices = sizeof( i );

    glGenBuffers(1, &IBO);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, i.size() * sizeof(unsigned int), &i[0], GL_STATIC_DRAW);

} // end initialize
void NormalBlendedDecal::reloadShaders()
{
    destroyShaders();
    buildShaders();
}