コード例 #1
0
ファイル: ShadowShader.cpp プロジェクト: gmevelec/firstgame
ShadowShader::ShadowShader(): ShaderProgram("./Resources/shaders/shadowshader")
{
	bindAttributes();
	glLinkProgram(_programID);
	glValidateProgram(_programID);
	getAllUniformLocations();
}
コード例 #2
0
bool HeightMap::buildShaderProgram(const char *mainVert, const char *mainFrag) {
    bool success = true;
    GLuint glerror;

    program.clearProgram();

    success = program.addShader(mainVert, GL_VERTEX_SHADER);
    success &= program.addShader("heightmap-vertfuncs.sdr", GL_VERTEX_SHADER);
    success &= program.addShader(mainFrag, GL_FRAGMENT_SHADER);

    if (success == false) {
        Logger::logprintf(Logger::LOG_ERROR, Logger::LOG_APPLICATION, "Failed to build shader program, missing shader\n");

        return false;
    }

    bindAttributes();

    success = program.linkProgram();

    if (success == false) {
        Logger::logprintf(Logger::LOG_ERROR, Logger::LOG_APPLICATION, "Unable to link rendering program: %s\n", gluErrorString(glerror));

        return false;
    }
    
    glUseProgram(program.programID());
    success &= checkGLError("Error encountered enabling Shader Program\n", Logger::LOG_ERROR);
    return success;
}
コード例 #3
0
ファイル: shader.cpp プロジェクト: mottosso/mygame
ShaderProgram::ShaderProgram(const char* vertexFname,
                             const char* fragmentFname) {
    mProgramId = glCreateProgram();

    mVertexShaderId = loadShader(vertexFname, GL_VERTEX_SHADER);
    mFragmentShaderId = loadShader(fragmentFname, GL_FRAGMENT_SHADER);

    bindAttributes();

    glLinkProgram(mProgramId);
    glValidateProgram(mProgramId);
    getAllUniformLocations();
}
コード例 #4
0
ファイル: Material.cpp プロジェクト: artcom/mobile-spark
 void
 Material::initShader() {
     AC_DEBUG << "Material initShader "<<(void*)this;
     if (vertexShader_.empty() || fragmentShader_.empty()) {
         setShader();
     }
     shaderProgram_ = createProgram(vertexShader_, fragmentShader_);
     if (!shaderProgram_) {
         AC_ERROR << "Could not create program.";
         throw ShaderCreationException("problems during shader program creation of " + vertexShader_ + " or/and " + fragmentShader_, PLUS_FILE_LINE);
     }
     bindAttributes();
     setHandles();
     glLinkProgram(shaderProgram_);
     ASSERT_GL("glLinkProgram", PLUS_FILE_LINE);
 }
コード例 #5
0
ファイル: shadernode.cpp プロジェクト: bigfug/Fugio
void ShaderNode::drawGeometry()
{
	fugio::Performance	Perf( mNode, "drawGeometry" );

	if( !mInitialised )
	{
		return;
	}

	if( !mProgramLinked )
	{
		return;
	}

	QList< QSharedPointer<InterfacePin> >	InpPinLst = mNode->enumInputPins();

	//-------------------------------------------------------------------------

	glUseProgram( mProgramId );

	OPENGL_PLUGIN_DEBUG;

	QList<ShaderBindData>		Bindings;

	bindInputTextures( Bindings );

	bindAttributes();

	//-------------------------------------------------------------------------

	InterfaceOpenGLState		*CurrentState = 0;
	InterfaceOpenGLState		*NextState;
	InterfaceGeometry			*Geometry;

	//-------------------------------------------------------------------------

	for( QList< QSharedPointer<InterfacePin> >::iterator it = InpPinLst.begin() ; it != InpPinLst.end() ; it++ )
	{
		QSharedPointer<InterfacePin>	InpPin = *it;

		if( !InpPin->isConnectedToActiveNode() )
		{
			continue;
		}

		QSharedPointer<InterfacePinControl>		 PinCtl = InpPin->connectedPin()->control();

		if( PinCtl.isNull() )
		{
			continue;
		}

		if( ( Geometry = qobject_cast<InterfaceGeometry *>( PinCtl->object() ) ) != 0 )
		{
			Geometry->drawGeometry();

			continue;
		}

		if( ( NextState = qobject_cast<InterfaceOpenGLState *>( PinCtl->object() ) ) != 0 )
		{
			if( CurrentState != 0 )
			{
				CurrentState->stateEnd();
			}

			CurrentState = NextState;

			CurrentState->stateBegin();
		}
	}

	if( CurrentState != 0 )
	{
		CurrentState->stateEnd();
	}

	releaseAttributes();

	//-------------------------------------------------------------------------

	glUseProgram( 0 );

	//-------------------------------------------------------------------------

	releaseInputTextures( Bindings );

	OPENGL_PLUGIN_DEBUG;
}