• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ LoadShader函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LoadShader函数的典型用法代码示例。如果您正苦于以下问题:C++ LoadShader函数的具体用法?C++ LoadShader怎么用?C++ LoadShader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LoadShader函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: LOGI

GLuint GlUtil::CreateProgram(const char* vertex_source, const char* fragment_source)
{
	LOGI("%s\n", vertex_source);
	GLuint vertexShader = 0;
	GLuint fragment_shader = 0;

	if (vertex_source)
	{
		vertexShader = LoadShader(GL_VERTEX_SHADER, vertex_source);
		if (!vertexShader) {
			return 0;
		}
	}

	if (fragment_source)
	{
		fragment_shader = LoadShader(GL_FRAGMENT_SHADER, fragment_source);
		if (!fragment_shader) {
			return 0;
		}
	}

	GLuint program = glCreateProgram();
	if (program) {
		glAttachShader(program, vertexShader);
		CheckGlError("glAttachShader");
		if (fragment_shader)
		{
			glAttachShader(program, fragment_shader);
			CheckGlError("glAttachShader");
		}
		LinkProgram(program);
	}
	return program;
}
开发者ID:gcasey,项目名称:Experimental_TangoUpsample,代码行数:35,代码来源:GlUtil.cpp


示例2: LoadProgram

static GLuint LoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc )
{
  GLuint vertexShader;
  GLuint fragmentShader;
  GLuint programObject;
  GLint linked;

  // Load the vertex/fragment shaders
  vertexShader = LoadShader ( GL_VERTEX_SHADER, vertShaderSrc );
  if ( vertexShader == 0 )
    return 0;

  fragmentShader = LoadShader ( GL_FRAGMENT_SHADER, fragShaderSrc );
  if ( fragmentShader == 0 )
    {
      glDeleteShader( vertexShader );
      return 0;
    }

  // Create the program object
  programObject = glCreateProgram ( );

  if ( programObject == 0 )
    return 0;

  glAttachShader ( programObject, vertexShader );
  glAttachShader ( programObject, fragmentShader );

  // Link the program
  glLinkProgram ( programObject );

  // Check the link status
  glGetProgramiv ( programObject, GL_LINK_STATUS, &linked );

  if ( !linked )
    {
      GLint infoLen = 0;
      glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen );

      if ( infoLen > 1 )
	{
	  char* infoLog = malloc (sizeof(char) * infoLen );

	  glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog );
	  fprintf (stderr, "Error linking program:\n%s\n", infoLog );

	  free ( infoLog );
	}

      glDeleteProgram ( programObject );
      return 0;
    }

  // Free up no longer needed shader resources
  glDeleteShader ( vertexShader );
  glDeleteShader ( fragmentShader );

  return programObject;
}
开发者ID:pilotniq,项目名称:piChart,代码行数:59,代码来源:graphics.c


示例3: Init

///
// Initialize the shader and program object
//
int Init()
{
   char vShaderStr[] =
       "attribute vec4 vPosition;   \n"
       "void main()                 \n"
       "{                           \n"
       "   gl_Position = vPosition; \n"
       "}                           \n";
   char fShaderStr[] =
       "precision mediump float;                   \n"
       "void main()                                \n"
       "{                                          \n"
#ifndef __FIXED__
       " gl_FragColor = vec4(0.2, 0.5, 0.1, 1.0); \n"
#else
       " gl_FragColor = vec4(0.4, 0.3, 0.7, 1.0); \n"
#endif
       "}                                          \n";
   GLuint vertexShader;
   GLuint fragmentShader;
   GLuint programObject;
   GLint linked;
  // Load the vertex/fragment shaders
  vertexShader = LoadShader(GL_VERTEX_SHADER, vShaderStr);
  fragmentShader = LoadShader(GL_FRAGMENT_SHADER, fShaderStr);
  // Create the program object
  programObject = glCreateProgram();
  if(programObject == 0)
     return -1;
  glAttachShader(programObject, vertexShader);
  glAttachShader(programObject, fragmentShader);
  // Bind vPosition to attribute 0
  glBindAttribLocation(programObject, 0, "vPosition");
  // Link the program
  glLinkProgram(programObject);
  // Check the link status
  glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
  if(!linked)
  {
     GLint infoLen = 0;
     glGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLen);
     if(infoLen > 1)
     {
        char* infoLog = (char*)malloc(sizeof(char) * infoLen);
        glGetProgramInfoLog(programObject, infoLen, NULL, infoLog);
        printf("Error linking program:\n%s\n", infoLog);
        free(infoLog);
     }
     glDeleteProgram(programObject);
     return -1;
  }
  // Store the program object
#ifndef __FIXED__
  glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
#else
  glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
#endif
  return programObject;
}
开发者ID:RanjithkumarRagavan,项目名称:platform_development,代码行数:62,代码来源:triangleV2.cpp


示例4: LoadShader

// load all shaders
void ShaderManager::LoadShaders()
{
    LoadShader(BasicShader, "../common_res/Basic.vsh", "../common_res/Basic.fsh");
    LoadShader(BasicShaderInstanced, "../common_res/BasicInstanced.vsh", "../common_res/Basic.fsh", "../common_res/BasicInstanced.gsh");
    LoadShader(OVRFrustumShader, "../common_res/OVRFrustum.vsh", "../common_res/OVRFrustum.fsh");
    LoadShader(FontShader, "../common_res/Font.vsh", "../common_res/Font.fsh");
    LoadShader(BasicShaderNoTex, "../common_res/BasicNoTex.vsh", "../common_res/BasicNoTex.fsh");
}
开发者ID:BryceSchmidtchen,项目名称:oculusvr_samples,代码行数:9,代码来源:ShaderManager.cpp


示例5: LoadShader

void VulkanTexturedQuad::CreatePipelineStateObject()
{
    vertexShader_ = LoadShader(device_, BasicVertexShader, sizeof(BasicVertexShader));
    fragmentShader_ = LoadShader(device_, TexturedFragmentShader, sizeof(TexturedFragmentShader));

    pipeline_ = CreatePipeline(device_, renderPass_, pipelineLayout_,
        vertexShader_, fragmentShader_);
}
开发者ID:GPUOpen-LibrariesAndSDKs,项目名称:HelloVulkan,代码行数:8,代码来源:VulkanTexturedQuad.cpp


示例6: InitializeProgram

void InitializeProgram(void) {
    std::cout << "OpenGL initialization function\n" << std::endl;
    std::vector<GLuint> shaders;
    shaders.push_back(LoadShader(GL_VERTEX_SHADER, "pass_along.vert"));
    shaders.push_back(LoadShader(GL_FRAGMENT_SHADER, "uniform_color.frag"));
    shader_program = CreateProgram(shaders);
    std::for_each(shaders.begin(), shaders.end(), glDeleteShader);
}
开发者ID:pigoz,项目名称:gltut-osx,代码行数:8,代码来源:gltut2.cpp


示例7: LoadShader

bool cShader::BuildShader(const std::string& vs_filename, const std::string& ps_filename)
{
	GLuint vs = LoadShader(vs_filename, GL_VERTEX_SHADER);
	GLuint ps = LoadShader(ps_filename, GL_FRAGMENT_SHADER);
	mProg = CreateShader(vs, ps);

	return mProg != -1;
}
开发者ID:saadmahboob,项目名称:DeepLoco,代码行数:8,代码来源:Shader.cpp


示例8: main

int main( int argc, char* argv[] )
{
    g_InitialCameraPosition = glm::vec3( 0, 0, 10 );
    g_Camera.SetPosition( g_InitialCameraPosition );
    g_Camera.SetRotation( g_InitialCameraRotation );

    InitGL(argc, argv);
    InitGLEW();

    // Load some shaders.
    GLuint vertexShader = LoadShader( GL_VERTEX_SHADER, "../data/shaders/simpleShader.vert" );
    GLuint fragmentShader = LoadShader( GL_FRAGMENT_SHADER, "../data/shaders/simpleShader.frag" );

    std::vector<GLuint> shaders;
    shaders.push_back(vertexShader);
    shaders.push_back(fragmentShader);

    // Create the shader program.
    g_ShaderProgram = CreateShaderProgram( shaders );
    assert( g_ShaderProgram != 0 );

    GLint positionAtribID = glGetAttribLocation( g_ShaderProgram, "in_position" );
    GLint colorAtribID = glGetAttribLocation( g_ShaderProgram, "in_color" );
    g_uniformMVP = glGetUniformLocation( g_ShaderProgram, "MVP" );

    // Create a VAO for the cube.
    glGenVertexArrays( 1, &g_vaoCube );
    glBindVertexArray( g_vaoCube );

    GLuint vertexBuffer, indexBuffer;
    glGenBuffers( 1, &vertexBuffer );
    glGenBuffers( 1, &indexBuffer );

    glBindBuffer( GL_ARRAY_BUFFER, vertexBuffer );
    glBufferData( GL_ARRAY_BUFFER, sizeof(g_Vertices), g_Vertices, GL_STATIC_DRAW );

    glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, indexBuffer );
    glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof(g_Indices), g_Indices, GL_STATIC_DRAW );

    glVertexAttribPointer( positionAtribID, 3, GL_FLOAT, false, sizeof(VertexXYZColor),
                            reinterpret_cast<const GLvoid*>(offsetof(VertexXYZColor,m_Pos)) );
    glEnableVertexAttribArray( positionAtribID );

    glVertexAttribPointer( colorAtribID, 3, GL_FLOAT, false, sizeof(VertexXYZColor),
                            reinterpret_cast<const GLvoid*>(offsetof(VertexXYZColor,m_Color)));
    glEnableVertexAttribArray( colorAtribID );

    // Make sure we disable and unbind everything to prevent rendering issues later.
    glBindVertexArray( 0 );
    glBindBuffer( GL_ARRAY_BUFFER, 0 );
    glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
    glDisableVertexAttribArray( positionAtribID );
    glDisableVertexAttribArray( colorAtribID );

    glutMainLoop();
}
开发者ID:LingboTang,项目名称:GameDev,代码行数:56,代码来源:mainCube.cpp


示例9: Camera

bool APP_SpotRotate::Start()
{
    m_appName = "Spot rotate";

    m_time = 0.0f;

    Gizmos::create();

    GameCam = new Camera();

    // create shaders
    const char* vsSource = nullptr;
    std::string vsResult = LoadShader("./assets/shaders/RotateVertShader.vert");
    vsSource = vsResult.c_str();

    const char* fsSource = nullptr;
    std::string fsResult = LoadShader("./assets/shaders/RotateFragShader.frag");
    fsSource = fsResult.c_str();

    int success = GL_FALSE;
    unsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);
    unsigned int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);

    //glBindAttributeLocation

    glShaderSource(vertexShader, 1, (const char**)&vsSource, 0);
    glCompileShader(vertexShader);
    glShaderSource(fragmentShader, 1, (const char**)&fsSource, 0);
    glCompileShader(fragmentShader);
    m_programID = glCreateProgram();
    glAttachShader(m_programID, vertexShader);
    glAttachShader(m_programID, fragmentShader);
    glLinkProgram(m_programID);

    glGetProgramiv(m_programID, GL_LINK_STATUS, &success);
    if (success == GL_FALSE) {
        int infoLogLength = 0;
        glGetProgramiv(m_programID, GL_INFO_LOG_LENGTH, &infoLogLength);
        char* infoLog = new char[infoLogLength];
        glGetProgramInfoLog(m_programID, infoLogLength, 0, infoLog);
        printf("Error: Failed to link shader program!\n");
        printf("%s\n", infoLog);
        delete[] infoLog;
    }
    glDeleteShader(fragmentShader);
    glDeleteShader(vertexShader);

    // Generate our GL Buffers
    glGenBuffers(1, &m_VBO);
    glGenBuffers(1, &m_IBO);
    glGenVertexArrays(1, &m_VAO); //generate a VertexArrayObject

    isLoaded = true;

    return true; //not being used in this lesson
}
开发者ID:cazBlue,项目名称:ComputerGraphics,代码行数:56,代码来源:APP_SpotRotate.cpp


示例10: initRender

void initRender() {

    // Create 2 shader programs
    Shader[0] = glCreateShader(GL_VERTEX_SHADER);
    Shader[1] = glCreateShader(GL_FRAGMENT_SHADER);

    LoadShader((char *)VertexShader, Shader[0]);
    LoadShader((char *)FragmentShader, Shader[1]);

    // Create the prorgam and attach the shaders & attributes
    Program   = glCreateProgram();

    glAttachShader(Program, Shader[0]);
    glAttachShader(Program, Shader[1]);

    glBindAttribLocation(Program, 0, "Position");
    glBindAttribLocation(Program, 1, "Normal");
    glBindAttribLocation(Program, 2, "Texture");

    // Link
    glLinkProgram(Program);

    // Validate our work thus far
    int ShaderStatus;
    glGetProgramiv(Program, GL_LINK_STATUS, &ShaderStatus);

    if (ShaderStatus != GL_TRUE) {
        LOGE("Error: Failed to link GLSL program\n");
        int Len = 1024;
        char Error[1024];
        glGetProgramInfoLog(Program, 1024, &Len, Error);
        LOGE("%s",Error);
        exit(-1);
    }

    glValidateProgram(Program);
	checkGlError("glValidateProgram");

    // Enable the program
    glUseProgram                (Program);

    // Retrieve our uniforms
    iProj   = glGetUniformLocation(Program, "Proj");
	iModel  = glGetUniformLocation(Program, "Model");
	iCamera = glGetUniformLocation(Program, "Camera");

    // Basic GL setup
	glClearColor    (0.15, 0.15, 0.15, 1.0);
    glEnable        (GL_CULL_FACE);
    glEnable 		(GL_DEPTH_TEST);
    glCullFace      (GL_BACK);


}
开发者ID:thmoa,项目名称:ChiliSensics,代码行数:54,代码来源:Render.cpp


示例11: InitializeProgram

void InitializeProgram()
{
    std::vector<GLuint> shaderList;

    shaderList.push_back(LoadShader(GL_VERTEX_SHADER, "FragPosition.vert"));
    shaderList.push_back(LoadShader(GL_FRAGMENT_SHADER, "FragPosition.frag"));

    theProgram = CreateProgram(shaderList);

    std::for_each(shaderList.begin(), shaderList.end(), glDeleteShader);
}
开发者ID:captainadamo,项目名称:glfw_gltut,代码行数:11,代码来源:FragPosition.cpp


示例12: InitializeProgram

void InitializeProgram()
{
    std::vector<GLuint> shaderList;

    shaderList.push_back(LoadShader(GL_VERTEX_SHADER, "OrthoWithOffset.vert"));
    shaderList.push_back(LoadShader(GL_FRAGMENT_SHADER, "StandardColors.frag"));

    theProgram = CreateProgram(shaderList);
    offsetUniform = glGetUniformLocation(theProgram, "offset");
    
    std::for_each(shaderList.begin(), shaderList.end(), glDeleteShader);
}
开发者ID:captainadamo,项目名称:glfw_gltut,代码行数:12,代码来源:OrthoCube.cpp


示例13: LoadShaderFile

//--------------------------- Constructor
cShader::cShader(char* Filename){
	//printf("------------- Loading Shader. /n");
//Temp Variables
	GLint iPass = 0;
	GLchar cErrorLog[1024] = { 0 };
//create 2 temp chars, adding the .vert and .frag extensions
//vert
	std::string sVert;
	sVert.append(Filename);
	sVert.append(".vert");
	char* vertShad = Filename;
	vertShad = LoadShaderFile(sVert.c_str());
//frag
	std::string sFrag;
	sFrag.append(Filename);
	sFrag.append(".frag");
	char* fragShad = Filename;
	fragShad = LoadShaderFile(sFrag.c_str());
//Create the shader Program
	GLuint ShaderProgram = glCreateProgram();
//check it opened
	if (ShaderProgram == 0){
		printf("Error creating ShaderProgram \n '%i' \n",ShaderProgram);
		iShaderID = -1;
		return;
	}
//apply the shader
	LoadShader(ShaderProgram,GL_VERTEX_SHADER,vertShad);
	LoadShader(ShaderProgram,GL_FRAGMENT_SHADER,fragShad);
//Link the Shader
	glLinkProgram(ShaderProgram);
	glGetProgramiv(ShaderProgram,GL_LINK_STATUS,&iPass);
//Check it is linked
	if (iPass == 0){
		glGetProgramInfoLog(ShaderProgram,sizeof(cErrorLog),NULL,cErrorLog);
		printf("Error while linking ShaderProgram \n '%s' \n",cErrorLog);
		iShaderID = -1;
		return;
	}
//Validate the Shader
	glValidateProgram(ShaderProgram);
	glGetProgramiv(ShaderProgram,GL_LINK_STATUS,&iPass);
//Check it is Valid
	if (iPass == 0){
		glGetProgramInfoLog(ShaderProgram,sizeof(cErrorLog),NULL,cErrorLog);
		printf("Error while validating ShaderProgram \n '%s' \n",cErrorLog);
		iShaderID = -1;
		return;
	}
	iShaderID = ShaderProgram;
	//printf("------------- Shader Loading finished! \n \n");	
}
开发者ID:lukemonaghan,项目名称:YR01_04_OpenGLFramework,代码行数:53,代码来源:Shader.cpp


示例14: glCreateProgram

		GLuint Shader::load()
		{
			GLuint program = glCreateProgram();
			GLuint vertex = glCreateShader(GL_VERTEX_SHADER);
			GLuint fragment = glCreateShader(GL_FRAGMENT_SHADER);

			std::string vertSourceString = LoadShader(m_Vertpath);
			std::string fragSourceString = LoadShader(m_Fragpath);

			const char* vertSource = vertSourceString.c_str();
			const char* fragSource = fragSourceString.c_str();

			glShaderSource(vertex, 1, &vertSource, NULL);
			glCompileShader(vertex);

			GLint result;
			glGetShaderiv(vertex, GL_COMPILE_STATUS, &result);

			if (result == GL_FALSE)
			{
				GLint length;
				glGetShaderiv(vertex, GL_INFO_LOG_LENGTH, &length);
				std::vector<char> error(length);
				glGetShaderInfoLog(vertex, length, &length, &error[0]);
				std::cout <<"Vertex Failed : "  << &error[0] << std::endl;
				glDeleteShader(vertex);
				return 0;
			}
			glShaderSource(fragment, 1, &fragSource, NULL);
			glCompileShader(fragment);
			glGetShaderiv(fragment, GL_COMPILE_STATUS, &result);
			if (result == GL_FALSE)
			{
				GLint length;
				glGetShaderiv(fragment, GL_INFO_LOG_LENGTH, &length);
				std::vector<char> error(length);
				glGetShaderInfoLog(fragment, length, &length, &error[0]);
				std::cout << "fragment fucked " << &error[0] << std::endl;
				glDeleteShader(fragment);
				return 0;
			}
			glAttachShader(program, vertex);
			glAttachShader(program, fragment);

			glLinkProgram(program);
			glValidateProgram(program);

			glDeleteShader(vertex);
			glDeleteShader(fragment);

			return program;
		}
开发者ID:AlisterGreg,项目名称:FireCoreEngine,代码行数:52,代码来源:FC_Shader.cpp


示例15: LoadShader

void VulkanQuad::CreatePipelineStateObject ()
{
    vertexShader_ = LoadShader (device_, BasicVertexShader, sizeof (BasicVertexShader));
    fragmentShader_ = LoadShader (device_, BasicFragmentShader, sizeof (BasicFragmentShader));

    pipelineLayout_ = CreatePipelineLayout (device_);
    VkExtent2D extent = {
        static_cast<uint32_t> (window_->GetWidth ()),
        static_cast<uint32_t> (window_->GetHeight ())
    };
    pipeline_ = CreatePipeline(device_, renderPass_, pipelineLayout_,
        vertexShader_, fragmentShader_, extent);
}
开发者ID:GPUOpen-LibrariesAndSDKs,项目名称:HelloVulkan,代码行数:13,代码来源:VulkanQuad.cpp


示例16: Free

bool GLSLShader::LoadShaders( const char* vertex_file, const char* fragment_file )
{
	Free();

	FILE *fp = nullptr;
	fopen_s(&fp, vertex_file, "r");
	if (fp)
	{
		vertex = glCreateShaderObjectARB( GL_VERTEX_SHADER_ARB );
		LoadShader( vertex, fp );

		fclose(fp);
	}
	
		
	fopen_s(&fp, fragment_file, "r");
	if (fp)
	{
		fragment = glCreateShaderObjectARB( GL_FRAGMENT_SHADER_ARB );
		LoadShader( fragment, fp );

		fclose(fp);
	}
	

	if (vertex > 0 && fragment > 0)
	{

	  programObj = glCreateProgramObjectARB();
	  // check for errors
	  //if ( checkopenglerror ) return false;
	  // attach shader to program object
	  glAttachObjectARB( programObj, vertex );
	  // attach shader to program object
	  glAttachObjectARB( programObj, fragment );

	  GLint linked;
	  // link the program object and print out the info log
	  glLinkProgramARB( programObj );
	
	  CHECK_GL_ERROR();
	  //if ( checkopenglerror ) return false;

	  glGetObjectParameterivARB( programObj, GL_OBJECT_LINK_STATUS_ARB, &linked );
	  loadlog( programObj );

	  return (linked != 0);
	}

	return false;
}
开发者ID:Neill3d,项目名称:MoBu,代码行数:51,代码来源:glslShader.cpp


示例17: LoadProgram

GLuint LoadProgram(const char* pVtxFilename, const char* pFragFilename)
{
	GLuint uVtx = LoadShader(GL_VERTEX_SHADER, pVtxFilename);
	if (!uVtx)
	{
		return 0;
	}
	
	GLuint uFrag = LoadShader(GL_FRAGMENT_SHADER, pFragFilename);
	if (!uFrag)
	{
		glDeleteShader(uVtx);
		return 0;
	}
	
	GLuint uProg = glCreateProgram();
	glAttachShader(uProg, uVtx);
	glAttachShader(uProg, uFrag);
	glLinkProgram(uProg);
	
	glDeleteShader(uVtx);
	glDeleteShader(uFrag);
	
	int nStatus;
	glGetProgramiv(uProg, GL_LINK_STATUS, &nStatus);
	
	if (nStatus != GL_TRUE)
	{
		int nLogLen;
		glGetProgramiv(uProg, GL_INFO_LOG_LENGTH, &nLogLen);
		
		if (nLogLen > 0)
		{
			char* pInfoLog = new char[nLogLen + 1];
			pInfoLog[nLogLen] = 0;
		
			glGetProgramInfoLog(uProg, nLogLen, NULL, pInfoLog);
		
			printf("Linking error with:\nVertex Shader: %s\nFragment Shader: %s\n", pVtxFilename, pFragFilename);
			printf(pInfoLog);
		
			delete[] pInfoLog;
		}
		
		glDeleteProgram(uProg);
		
		return 0;
	}
	
	return uProg;
}
开发者ID:Allanis,项目名称:SComp,代码行数:51,代码来源:glstuff.cpp


示例18: Init

int Init ()
{
   GLbyte vShaderStr[] =  
      "attribute vec4 vPosition;    \n"
      "void main()                  \n"
      "{                            \n"
      "   gl_Position = vPosition;  \n"
      "}                            \n";
   
   GLbyte fShaderStr[] =  
      "precision mediump float;\n"\
      "void main()                                  \n"
      "{                                            \n"
      "  gl_FragColor = vec4 ( 0.0, 0.0, 1.0, 1.0 );\n"
      "}                                            \n";

   GLuint vertexShader;
   GLuint fragmentShader;
   GLint linked;

   vertexShader = LoadShader ( GL_VERTEX_SHADER, vShaderStr );
   fragmentShader = LoadShader ( GL_FRAGMENT_SHADER, fShaderStr );

   programObject = glCreateProgram ( );
   if ( programObject == 0 )
      return 0;

   glAttachShader ( programObject, vertexShader );
   glAttachShader ( programObject, fragmentShader );
   glBindAttribLocation ( programObject, 0, "vPosition" );
   glLinkProgram ( programObject );
   glGetProgramiv ( programObject, GL_LINK_STATUS, &linked );
   if ( !linked ) 
   {
      GLint infoLen = 0;
      glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen );
      if ( infoLen > 1 )
      {
         char* infoLog = malloc (sizeof(char) * infoLen );
         glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog );
         printf ( "Error linking program:\n%s\n", infoLog );            
         free ( infoLog );
      }
      glDeleteProgram ( programObject );
      return GL_FALSE;
   }

   glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
   return GL_TRUE;
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:50,代码来源:sdl_gl_read.c


示例19: LoadShader

ShaderManager::ShaderManager()
{
    for(int i  = 0; i < MAX_SHADERS; i++)
    {
        shaders[i] = 0;
        vertShaders[i] = 0;
        fragShaders[i] = 0;
        vaos[i] = 0;
    }

    LoadShader("vert.vsh","frag.fsh",0);
    LoadShader("colorVert.vsh","colorFrag.fsh",1);
    numShaders = 2;
}
开发者ID:mholtkamp,项目名称:DingleEngine,代码行数:14,代码来源:ShaderManager2.cpp


示例20: LoadProgram

void LoadProgram(shader_prog_t* shaderProg,const char* vertexShaderPath, const char* fragmentShaderPath, uchar props)
{
	GLuint vertexShader; 
	GLuint fragmentShader; 
	
	GLint linked;
	

	
	//Load simple shader
	vertexShader = LoadShader(vertexShaderPath,GL_VERTEX_SHADER,props);
	fragmentShader = LoadShader(fragmentShaderPath,GL_FRAGMENT_SHADER,props);
	
	
	// Create the program object 
	shaderProg->prog = glCreateProgram(); 
	if(shaderProg->prog == 0) 
	{
		printf("Could not create GL program.");
		return ; 
	}
	
	glAttachShader(shaderProg->prog, vertexShader); 
	glAttachShader(shaderProg->prog, fragmentShader);
	
	
	// Link the program 
	glLinkProgram(shaderProg->prog); 
	
	// Check the link status 
	glGetProgramiv(shaderProg->prog, GL_LINK_STATUS, &linked); 
	if(!linked) 
	{ 
		GLint infoLen = 0; 
		glGetProgramiv(shaderProg->prog, GL_INFO_LOG_LENGTH, &infoLen); 
		
		if(infoLen > 1) 
		{ 
			char* infoLog = malloc(sizeof(char) * infoLen); 
			glGetProgramInfoLog(shaderProg->prog, infoLen, NULL, infoLog); 
			printf("Error linking program:\n%s\n", infoLog); 
			
			free(infoLog); 
		} 
		glDeleteProgram(shaderProg->prog); 
		return ; 
	} 
	
}
开发者ID:marcclintdion,项目名称:iOS_WIN3,代码行数:49,代码来源:renderer_progr.c



注:本文中的LoadShader函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LoadShaders函数代码示例发布时间:2022-05-30
下一篇:
C++ LoadSettings函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap