Example #1
0
void GameObject::loadShader(const string& vsFilename, const string& fsFilename)
{
	GLuint vertexShaderProgram = 0;
	vertexShaderProgram = loadShaderFromFile(vsFilename, VERTEX_SHADER);
	checkForCompilerErrors(vertexShaderProgram);

	GLuint fragmentShaderProgram = 0;
	fragmentShaderProgram = loadShaderFromFile(fsFilename, FRAGMENT_SHADER);
	checkForCompilerErrors(fragmentShaderProgram);

	m_ShaderProgram = glCreateProgram();
	glAttachShader(m_ShaderProgram, vertexShaderProgram);
	glAttachShader(m_ShaderProgram, fragmentShaderProgram);

	//Link attributes
	glBindAttribLocation(m_ShaderProgram, 0, "vertexPosition");
	glBindAttribLocation(m_ShaderProgram, 1, "vertexColour");
	glBindAttribLocation(m_ShaderProgram, 2, "vertexTexCoords");
	glBindAttribLocation(m_ShaderProgram, 3, "vertexNormal");

	glLinkProgram(m_ShaderProgram);
	checkForLinkErrors(m_ShaderProgram);
	//now we can delete the VS & FS Programs
	glDeleteShader(vertexShaderProgram);
	glDeleteShader(fragmentShaderProgram);
}
Example #2
0
ShaderProgram::ShaderProgram(const char *vertexShaderFile, const char *fragmentShaderFile) {

	// create the vertex shader
	vertexShader = loadShaderFromFile(vertexShaderFile, GL_VERTEX_SHADER);
	// create the fragment shader
	fragmentShader = loadShaderFromFile(fragmentShaderFile, GL_FRAGMENT_SHADER);

	// Create the final shader program from our vertex and fragment shaders
	programID = glCreateProgram();
	glAttachShader(programID, vertexShader);
	glAttachShader(programID, fragmentShader);
	glLinkProgram(programID);

	GLint linkSuccess;
	glGetProgramiv(programID, GL_LINK_STATUS, &linkSuccess);
	if (linkSuccess == GL_FALSE) {
		printf("Error linking shader program!\n");
	}

	modelMatrixUniform = glGetUniformLocation(programID, "modelMatrix");
	projectionMatrixUniform = glGetUniformLocation(programID, "projectionMatrix");
	viewMatrixUniform = glGetUniformLocation(programID, "viewMatrix");

	positionAttribute = glGetAttribLocation(programID, "position");
	texCoordAttribute = glGetAttribLocation(programID, "texCoord");

}
Example #3
0
Shader *Shader::fromFiles(const char *vertex, const char *fragment, const char **attributes) {
	GLuint vertexShader = loadShaderFromFile(vertex, "vertex", GL_VERTEX_SHADER);
	GLuint fragmentShader = loadShaderFromFile(fragment, "fragment", GL_FRAGMENT_SHADER);

	Common::String name = Common::String::format("%s/%s", vertex, fragment);
	return new Shader(name, vertexShader, fragmentShader, attributes);
}
Example #4
0
void Shader::loadShaderFromFiles(const string& vsFilename,const string& fsFilename)
{
    GLuint vertexShader=loadShaderFromFile(vsFilename,VERTEX_SHADER);
    setVertexShader(vertexShader);

    GLuint fragmentShader=loadShaderFromFile(fsFilename,FRAGMENT_SHADER);
    setFragmentShader(fragmentShader);
}
Example #5
0
  bool Shader::init()
  {
    program_id_ = glCreateProgram();

    std::string vert_source = loadShaderFromFile(file_path_ + file_name_ + ".vert");
    std::string frag_source = loadShaderFromFile(file_path_ + file_name_ + ".frag");

    return createProgram(vert_source, frag_source);
  }
Example #6
0
void initScene()
{

	string modelPath = ASSET_PATH + MODEL_PATH + "/armoredrecon.fbx";
	loadFBXFromFile(modelPath, &currentMesh);
	//Generate Vertex Array
	glGenVertexArrays(1, &VAO);
	glBindVertexArray(VAO);
	glGenBuffers(1, &VBO);
	glBindBuffer(GL_ARRAY_BUFFER, VBO);

	glBufferData(GL_ARRAY_BUFFER, currentMesh.getNumVerts()*sizeof(Vertex), &currentMesh.vertices[0], GL_STATIC_DRAW);

	//create buffer
	glGenBuffers(1, &EBO);
	//Make the EBO active
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
	//Copy Index data to the EBO
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, currentMesh.getNumIndices()*sizeof(int), &currentMesh.indices[0], GL_STATIC_DRAW);

	//Tell the shader that 0 is the position element
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), NULL);

	glEnableVertexAttribArray(1);
	glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void**)(sizeof(vec3)));

	glEnableVertexAttribArray(2);
	glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void**)(sizeof(vec3) + sizeof(vec4)));

	GLuint vertexShaderProgram = 0;
	string vsPath = ASSET_PATH + SHADER_PATH + "/simpleVS.glsl";
	vertexShaderProgram = loadShaderFromFile(vsPath, VERTEX_SHADER);
	checkForCompilerErrors(vertexShaderProgram);

	GLuint fragmentShaderProgram = 0;
	string fsPath = ASSET_PATH + SHADER_PATH + "/simpleFS.glsl";
	fragmentShaderProgram = loadShaderFromFile(fsPath, FRAGMENT_SHADER);
	checkForCompilerErrors(fragmentShaderProgram);

	shaderProgram = glCreateProgram();
	glAttachShader(shaderProgram, vertexShaderProgram);
	glAttachShader(shaderProgram, fragmentShaderProgram);

	//Link attributes
	glBindAttribLocation(shaderProgram, 0, "vertexPosition");
	glBindAttribLocation(shaderProgram, 1, "vertexColour");
	glBindAttribLocation(shaderProgram, 2, "vertexTexCoords");

	glLinkProgram(shaderProgram);
	checkForLinkErrors(shaderProgram);
	//now we can delete the VS & FS Programs
	glDeleteShader(vertexShaderProgram);
	glDeleteShader(fragmentShaderProgram);
}
Example #7
0
void
ShaderProgram::attachGeometryShaderFromFile(PrimitiveType inputPrimitiveType,
                                            PrimitiveType outputPrimitiveType,
                                            int maxOutputVertices,
                                            const char *shaderPath)
{
	string source = loadShaderFromFile(shaderPath);
	attachGeometryShader(inputPrimitiveType, outputPrimitiveType, maxOutputVertices, source.c_str());
}
/*
 * This function is for loading a shader into the prebuilt shader list
 */
bool ShaderSystem::loadShaders(string vertex_shader_path, string fragment_shader_path){
    GLhandleARB vertexShaderHandle;
    GLhandleARB fragmentShaderHandle;
    
    char *v_str = new char[vertex_shader_path.length() + 1];
    strcpy(v_str, vertex_shader_path.c_str());
    char *f_str = new char[fragment_shader_path.length() + 1];
    strcpy(f_str, fragment_shader_path.c_str());
    
    vertexShaderHandle = loadShaderFromFile("/Users/ruiqingqiu/Desktop/Qiu_Code/Graphics Engine/light.vert", GL_VERTEX_SHADER);
    fragmentShaderHandle = loadShaderFromFile("/Users/ruiqingqiu/Desktop/Qiu_Code/Graphics Engine/light.frag", GL_FRAGMENT_SHADER);
    
    //vertexShaderHandle = loadShaderFromFile(v_str, GL_VERTEX_SHADER);
    //fragmentShaderHandle = loadShaderFromFile(f_str, GL_FRAGMENT_SHADER);
    
    GLhandleARB shader_id = glCreateProgramObjectARB();
    shader_ids.push_back(shader_id);
    glAttachObjectARB(shader_id, vertexShaderHandle);
    glAttachObjectARB(shader_id, fragmentShaderHandle);
    glLinkProgramARB(shader_id);
    return true;
}
//creates shaders used in Post Processing - RT
void PostProcessing::createShader(string& vertexShaderFilename, string& fragmentShaderFilename)
{
	GLuint vertexShaderProgram = 0;
	vertexShaderProgram = loadShaderFromFile(vertexShaderFilename, VERTEX_SHADER);

	GLuint fragmentShaderProgram = 0;
	fragmentShaderProgram = loadShaderFromFile(fragmentShaderFilename, FRAGMENT_SHADER);

	postProcessingProgram = glCreateProgram();

	glAttachShader(postProcessingProgram, vertexShaderProgram);
	glAttachShader(postProcessingProgram, fragmentShaderProgram);

	glLinkProgram(postProcessingProgram);

	checkForLinkErrors(postProcessingProgram);

	glDeleteShader(vertexShaderProgram);
	glDeleteShader(fragmentShaderProgram);

	glBindAttribLocation(postProcessingProgram, 0, "vertexPosition");

}
ShaderStage::ShaderStage(GLenum type, const char *filename, const char *additionalDefines)
{
    shader = glCreateShader(type);
    if (!loadShaderFromFile(shader, filename, additionalDefines))
        abort();
}
Example #11
0
void
ShaderProgram::attachFragmentShaderFromFile(const char *shaderPath)
{
	string source = loadShaderFromFile(shaderPath);
	attachFragmentShader(source.c_str());
}
Example #12
0
void
initShader(void)
{
    ///////////////////////////////////////////////////////////////////////////
    //
    // Create earth shader
    //
    GLhandleARB terrain_vertex_shader;
    GLhandleARB terrain_fragment_shader;

    //
    // Create and load resources
    //
    g_terrainProgram          = glCreateProgramObjectARB();
    terrain_vertex_shader     = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
    terrain_fragment_shader   = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);

    loadShaderFromFile(terrain_vertex_shader, "shader/terrain.vert");
    loadShaderFromFile(terrain_fragment_shader, "shader/terrain.frag");

    //
    // Compile
    //
    glCompileShaderARB(terrain_vertex_shader);
    GET_GLERROR(0);
    printInfoLog(terrain_vertex_shader);

    glCompileShaderARB(terrain_fragment_shader);
    GET_GLERROR(0);
    printInfoLog(terrain_fragment_shader);

    //
    // Link
    //
    glAttachObjectARB(g_terrainProgram, terrain_vertex_shader);
    glAttachObjectARB(g_terrainProgram, terrain_fragment_shader);
    glLinkProgramARB(g_terrainProgram);
    GET_GLERROR(0);
    printInfoLog(g_terrainProgram);

    ///////////////////////////////////////////////////////////////////////////
    //
    // Setup terrain shader
    //

    //
    // Sampler
    //
    glUseProgramObjectARB(g_terrainProgram);
	GET_GLERROR(0);

	float test;
    //
    // Aufgabe 1.b - Begin
    //
	
	int samplerTerrain = glGetUniformLocationARB(g_terrainProgram, "samplerTerrain");
	GET_GLERROR(0);
	int samplerGradient = glGetUniformLocationARB(g_terrainProgram, "samplerGradient");
	GET_GLERROR(0);

	glUniform1i(samplerTerrain, 0);
	GET_GLERROR(0);
	glUniform1i(samplerGradient, 1);
	GET_GLERROR(0);
    //
    // Aufgabe 1.b - End
    //

	//
	// Bounding Box
	//
	int LLFLocation = glGetUniformLocationARB(g_terrainProgram, "v3LLF");
	GET_GLERROR(0);
	int URBLocation = glGetUniformLocationARB(g_terrainProgram, "v3URB");
	GET_GLERROR(0);

	vec3 LLF = vec3(g_sceneAABB.xMin, g_sceneAABB.yMin, g_sceneAABB.zMin);
	vec3 URB = vec3(g_sceneAABB.xMax, g_sceneAABB.yMax, g_sceneAABB.zMax);

    glUniform3fARB(LLFLocation, g_sceneAABB.xMin, g_sceneAABB.yMin, g_sceneAABB.zMin);
	GET_GLERROR(0);
	glUniform3fARB(URBLocation, g_sceneAABB.xMax, g_sceneAABB.yMax, g_sceneAABB.zMax);
	GET_GLERROR(0);
    return;
}
Example #13
0
void createFramebuffer()
{
	glActiveTexture(GL_TEXTURE0);
	glGenTextures(1, &FBOTexture);
	glBindTexture(GL_TEXTURE_2D, FBOTexture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT, 0, GL_RGBA,
		GL_UNSIGNED_BYTE, NULL);


	glGenRenderbuffers(1, &FBODepthBuffer);
	glBindRenderbuffer(GL_RENDERBUFFER, FBODepthBuffer);
	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT);
	glBindRenderbuffer(GL_RENDERBUFFER, 0);

	glGenFramebuffers(1, &frameBufferObject);
	glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, FBOTexture, 0);
	glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,GL_RENDERBUFFER, FBODepthBuffer);

	GLenum status;
	if ((status = glCheckFramebufferStatus(GL_FRAMEBUFFER)) != GL_FRAMEBUFFER_COMPLETE) {
		cout << "Issue with Framebuffers" << endl;
	}
	float vertices[] = {
		-1, -1,
		1, -1,
		-1, 1,
		1, 1,

	};

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

	glGenBuffers(1, &fullScreenVBO);
	glBindBuffer(GL_ARRAY_BUFFER, fullScreenVBO);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

	glEnableVertexAttribArray(0);
	glVertexAttribPointer(
		0,  // attribute
		2,                  // number of elements per vertex, here (x,y)
		GL_FLOAT,           // the type of each element
		GL_FALSE,           // take our values as-is
		0,                  // no extra data between each position
		0                   // offset of first element
		);

	GLuint vertexShaderProgram = 0;
	string vsPath = ASSET_PATH + SHADER_PATH + "/simplePostProcessVS.glsl";
	vertexShaderProgram = loadShaderFromFile(vsPath, VERTEX_SHADER);
	checkForCompilerErrors(vertexShaderProgram);

	GLuint fragmentShaderProgram = 0;
	string fsPath = ASSET_PATH + SHADER_PATH + "/simplePostProcessFS.glsl";
	fragmentShaderProgram = loadShaderFromFile(fsPath, FRAGMENT_SHADER);
	checkForCompilerErrors(fragmentShaderProgram);

	fullScreenShaderProgram = glCreateProgram();
	glAttachShader(fullScreenShaderProgram, vertexShaderProgram);
	glAttachShader(fullScreenShaderProgram, fragmentShaderProgram);

	//Link attributes
	glBindAttribLocation(fullScreenShaderProgram, 0, "vertexPosition");

	glLinkProgram(fullScreenShaderProgram);
	checkForLinkErrors(fullScreenShaderProgram);
	//now we can delete the VS & FS Programs
	glDeleteShader(vertexShaderProgram);
	glDeleteShader(fragmentShaderProgram);
}
bool LDoubleMultiColorPolygonProgram2D::loadProgram()
{
	//Generate program
	mProgramID = glCreateProgram();

	//Load vertex shader
	GLuint vertexShader = loadShaderFromFile( "36_vertex_array_objects/LDoubleMultiColorPolygonProgram2D.glvs", GL_VERTEX_SHADER );

    //Check for errors
    if( vertexShader == 0 )
    {
        glDeleteProgram( mProgramID );
        mProgramID = 0;
        return false;
    }

	//Attach vertex shader to program
	glAttachShader( mProgramID, vertexShader );


	//Create fragment shader
	GLuint fragmentShader = loadShaderFromFile( "36_vertex_array_objects/LDoubleMultiColorPolygonProgram2D.glfs", GL_FRAGMENT_SHADER );

    //Check for errors
    if( fragmentShader == 0 )
    {
        glDeleteProgram( mProgramID );
        mProgramID = 0;
        return false;
    }

	//Attach fragment shader to program
	glAttachShader( mProgramID, fragmentShader );

	//Link program
    glLinkProgram( mProgramID );

	//Check for errors
	GLint programSuccess = GL_TRUE;
	glGetProgramiv( mProgramID, GL_LINK_STATUS, &programSuccess );
	if( programSuccess != GL_TRUE )
    {
		printf( "Error linking program %d!\n", mProgramID );
		printProgramLog( mProgramID );
        glDeleteProgram( mProgramID );
        mProgramID = 0;
        return false;
    }

	//Get variable locations
	mVertexPos2DLocation = glGetAttribLocation( mProgramID, "LVertexPos2D" );
	if( mVertexPos2DLocation == -1 )
	{
		printf( "%s is not a valid glsl program variable!\n", "LVertexPos2D" );
	}

	mMultiColor1Location = glGetAttribLocation( mProgramID, "LMultiColor1" );
	if( mMultiColor1Location == -1 )
	{
		printf( "%s is not a valid glsl program variable!\n", "LMultiColor1" );
	}

	mMultiColor2Location = glGetAttribLocation( mProgramID, "LMultiColor2" );
	if( mMultiColor2Location == -1 )
	{
		printf( "%s is not a valid glsl program variable!\n", "LMultiColor2" );
	}

	mProjectionMatrixLocation = glGetUniformLocation( mProgramID, "LProjectionMatrix" );
	if( mProjectionMatrixLocation == -1 )
	{
		printf( "%s is not a valid glsl program variable!\n", "LProjectionMatrix" );
	}

	mModelViewMatrixLocation = glGetUniformLocation( mProgramID, "LModelViewMatrix" );
	if( mModelViewMatrixLocation == -1 )
	{
		printf( "%s is not a valid glsl program variable!\n", "LModelViewMatrix" );
	}

	return true;
}
bool BSTexturedPolygonProgram2D::loadProgram(std::string _path_vertex_shader, std::string _path_fragment_shader)
{
	//Generate program
	BSProgramID = glCreateProgram();

	//Load vertex shader
	GLuint vertexShader = loadShaderFromFile( _path_vertex_shader, GL_VERTEX_SHADER );

	//Check for errors
	if( vertexShader == 0 )
	{
		glDeleteProgram( BSProgramID );
		BSProgramID = 0;
		return false;
	}

	//Attach vertex shader to program
	glAttachShader( BSProgramID, vertexShader );

	//Create fragment shader
	GLuint fragmentShader = loadShaderFromFile( _path_fragment_shader, GL_FRAGMENT_SHADER );

	//Check for errors
	if( fragmentShader == 0 )
	{
		glDeleteProgram( BSProgramID );
		BSProgramID = 0;
		return false;
	}

	//Attach fragment shader to program
	glAttachShader( BSProgramID, fragmentShader );

	//Link program
	glLinkProgram( BSProgramID );

	//Check for errors
	GLint programSuccess = GL_TRUE;
	glGetProgramiv( BSProgramID, GL_LINK_STATUS, &programSuccess );
	if( programSuccess != GL_TRUE )
	{
		printf( "Error linking program %d!\n", BSProgramID );
		printProgramLog( BSProgramID );
		glDeleteProgram( BSProgramID );
		BSProgramID = 0;
		return false;
	}

	load_Shader_Attributes_Location(BS_Available_Shaders::vertex_position());
	load_Shader_Attributes_Location(BS_Available_Shaders::texture_coordinates());

	load_Shader_Uniforms_Location(BS_Available_Shaders::scale_size());

	load_Shader_Uniforms_Location(BS_Available_Shaders::is_flake());
	load_Shader_Uniforms_Location(BS_Available_Shaders::is_circle());
	load_Shader_Uniforms_Location(BS_Available_Shaders::is_dark());

	load_Shader_Uniforms_Location(BS_Available_Shaders::circle_radius());
	load_Shader_Uniforms_Location(BS_Available_Shaders::time());

	load_Shader_Uniforms_Location(BS_Available_Shaders::texture_color());
	load_Shader_Uniforms_Location(BS_Available_Shaders::texture_unit());

	load_Shader_Uniforms_Location(BS_Available_Shaders::projection_matrix());
	load_Shader_Uniforms_Location(BS_Available_Shaders::model_view_matrix());

	return true;
}
Shader resourceManagerClass::LoadShader(const GLchar *vShaderFile, const GLchar *fShaderFile, const GLchar *gShaderFile, std::string name)
{
    Shaders[name] = loadShaderFromFile(vShaderFile, fShaderFile, gShaderFile);
    return Shaders[name];
}
Example #17
0
bool ShaderManager::loadProgram( const string& name, const ArrayList<Shader>& shaders )
{
	ArrayList<GLuint> shaderIDs;
	for (unsigned int i = 0; i < shaders.getSize(); ++i)
	{
		const Shader& shader = shaders[i];

		shaderIDs.add(loadShaderFromFile(shader.Filename, shader.Type));
	}

	GLuint program;

	program = glCreateProgram();

	for (unsigned int i = 0; i < shaders.getSize(); ++i)
	{
		glAttachShader(program, shaderIDs[i]);
	}

	glLinkProgram(program);

	GLint programLinked = GL_FALSE;
	glGetProgramiv(program, GL_LINK_STATUS, &programLinked);

	if (programLinked != GL_TRUE)
	{
		Log::ErrorFmt(getClassName(), "Failed to link program %d\n", program);
		printProgramLog(program);
		glDeleteProgram(program);
		program = 0;
	}

	for (unsigned int i = 0; i < shaders.getSize(); ++i)
	{
		glDeleteShader(shaderIDs[i]);
	}

	if (program == 0)
		return false;

	m_Programs.add(name, program);
	m_UniformLocations.add(name, Map<string, GLint>());

	int uniformCount = -1;
	glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &uniformCount); 

	for (GLuint i = 0; i < (unsigned)uniformCount; ++i)
	{
		int nameLength;
		int num;
		GLenum uniformType = GL_ZERO;
		char uniformName[100];

		glGetActiveUniform(program, i, sizeof(uniformName) - 1, &nameLength, &num, &uniformType, uniformName );

		uniformName[nameLength] = '\0';
		GLuint location = i;
		//GLuint location = glGetUniformLocation(program, uniformName);

		m_UniformLocations[name].add(uniformName, location);
	}

	return true;
}
bool BSTexturedPolygonProgram2D::loadProgram()
{
	//Generate program
	BSProgramID = glCreateProgram();
	
	//Load vertex shader
	GLuint vertexShader = loadShaderFromFile( "Shaders/BSTexturedPolygonProgram2D.glvs", GL_VERTEX_SHADER );
	
    //Check for errors
    if( vertexShader == 0 )
    {
        glDeleteProgram( BSProgramID );
        BSProgramID = 0;
        return false;
    }
	
	//Attach vertex shader to program
	glAttachShader( BSProgramID, vertexShader );
	
	
	//Create fragment shader
	GLuint fragmentShader = loadShaderFromFile( "Shaders/BSTexturedPolygonProgram2D.glfs", GL_FRAGMENT_SHADER );
	
    //Check for errors
    if( fragmentShader == 0 )
    {
        glDeleteProgram( BSProgramID );
        BSProgramID = 0;
        return false;
    }
	
	//Attach fragment shader to program
	glAttachShader( BSProgramID, fragmentShader );
	
	//Link program
    glLinkProgram( BSProgramID );
	
	//Check for errors
	GLint programSuccess = GL_TRUE;
	glGetProgramiv( BSProgramID, GL_LINK_STATUS, &programSuccess );
	if( programSuccess != GL_TRUE )
    {
		printf( "Error linking program %d!\n", BSProgramID );
		printProgramLog( BSProgramID );
        glDeleteProgram( BSProgramID );
        BSProgramID = 0;
        return false;
    }
	
	loadShaderAttributesLocation(locationBSVertexPosition3D, "BSVertexPosition3D");
	loadShaderAttributesLocation(locationBSTextureCoordinate, "BSTextureCoordinates");
	
	
    loadShaderUniformsLocation(ShaderCameraExtremeLeft, "CameraExtremeLeft");
    loadShaderUniformsLocation(ShaderCameraExtremeRight, "CameraExtremeRight");
    loadShaderUniformsLocation(ShaderCameraExtremeUp, "CameraExtremeUp");
    loadShaderUniformsLocation(ShaderCameraExtremeDown, "CameraExtremeDown");
	//	ShaderCameraExtremeLeft = glGetUniformLocation(BSProgramID, "CameraExtremeLeft");
	//	ShaderCameraExtremeRight = glGetUniformLocation(BSProgramID, "CameraExtremeRight");
	//	ShaderCameraExtremeUp = glGetUniformLocation(BSProgramID, "CameraExtremeUp");
	//	ShaderCameraExtremeDown = glGetUniformLocation(BSProgramID, "CameraExtremeDown");
	
    loadShaderUniformsLocation(ShaderPlayerCoordinatesX, "PlayerCoordinatesX");
    loadShaderUniformsLocation(ShaderPlayerCoordinatesY, "PlayerCoordinatesY");
	//	ShaderPlayerCoordinatesX = glGetUniformLocation(BSProgramID, "PlayerCoordinatesX");
	//	ShaderPlayerCoordinatesY = glGetUniformLocation(BSProgramID, "PlayerCoordinatesY");
	
    loadShaderUniformsLocation(ShaderScaleSize, "ScaleSize");
    loadShaderUniformsLocation(ShaderScaleOnX, "TheScaleX");
    loadShaderUniformsLocation(ShaderScaleOnY, "TheScaleY");
	//	ShaderScaleSize = glGetUniformLocation(BSProgramID, "ScaleSize");
	//	ShaderScaleOnX = glGetUniformLocation(BSProgramID, "TheScaleX");
	//	ShaderScaleOnY = glGetUniformLocation(BSProgramID, "TheScaleY");
	
    loadShaderUniformsLocation(ShaderFlake, "isFlake");
    loadShaderUniformsLocation(ShaderIsCircle, "isCircle");
    loadShaderUniformsLocation(ShaderDark, "isDark");
	//	ShaderFlake = glGetUniformLocation(BSProgramID, "isFlake");
	//	ShaderIsCircle = glGetUniformLocation(BSProgramID, "isCircle");
	//	ShaderDark = glGetUniformLocation(BSProgramID, "isDark");
	
	
	
	
    loadShaderUniformsLocation(ShaderRotationAngle, "RotationAngle");
    loadShaderUniformsLocation(ShaderCircleRadius, "CircleRadius");
	//	ShaderRotationAngle = glGetUniformLocation(BSProgramID, "RotationAngle");
	//	ShaderCircleRadius = glGetUniformLocation(BSProgramID, "CircleRadius");
	
	
	
	
	
    loadShaderUniformsLocation(locationBSTextureColor, "BSTextureColor");
    loadShaderUniformsLocation(locationBSTextureUnit, "BSTextureUnit");
	
    loadShaderUniformsLocation(locationBSProjectionMatrix, "BSProjectionMatrix");
    loadShaderUniformsLocation(locationBSModelViewMatrix, "BSModelViewMatrix");
	//	mTextureColorLocation = glGetUniformLocation( BSProgramID, "BSTextureColor" );
	//	mTextureUnitLocation = glGetUniformLocation( BSProgramID, "BSTextureUnit" );
	
	//	mProjectionMatrixLocation = glGetUniformLocation( BSProgramID, "BSProjectionMatrix" );
	//	mModelViewMatrixLocation = glGetUniformLocation( BSProgramID, "BSModelViewMatrix" );
	
	return true;
}
Example #19
0
// Loads two Shaders from files
void loadShaders(char * path1, GLenum type1, char * path2, GLenum type2) {
	GLuint id1 = loadShaderFromFile(path1, type1);
	GLuint id2 = loadShaderFromFile(path2, type2);
	GLuint programID = createShadersProgram(id1, id2);
	glUseProgram(programID);
}
Example #20
0
	Shader::Shader( const std::string& fileName, GLenum shaderType )
	{
		loadShaderFromFile( fileName.c_str(), shaderType );
	}
Shader ResourceManager::loadShader(const GLchar* vShaderFile, const GLchar* fShaderFile, const GLchar* gShaderFile, std::string name) {
	if (shaders.count(name) == 0) {
		shaders[name] = loadShaderFromFile(vShaderFile, fShaderFile, gShaderFile);
	}
	return shaders[name];
}