本文整理汇总了C++中printShaderInfoLog函数的典型用法代码示例。如果您正苦于以下问题:C++ printShaderInfoLog函数的具体用法?C++ printShaderInfoLog怎么用?C++ printShaderInfoLog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printShaderInfoLog函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: printf
void Shader::makeShader(char* vert, char* frag){
char *vs = NULL,*fs = NULL;
printf("Adding shaders\n");
v = glCreateShader(GL_VERTEX_SHADER);
f = glCreateShader(GL_FRAGMENT_SHADER);
vs = textFileRead(vert);
fs = textFileRead(frag);
const char * ff = fs;
const char * vv = vs;
glShaderSource(v, 1, &vv,NULL);
glShaderSource(f, 1, &ff,NULL);
free(vs);free(fs);
glCompileShader(v);
glCompileShader(f);
if(debug){
printf("Vert log\n");
printShaderInfoLog(v);
printf("Frag log\n");
printShaderInfoLog(f);
}
p = glCreateProgram();
glAttachShader(p,f);
glAttachShader(p,v);
glLinkProgram(p);
printf("Shaders added\n");
}
开发者ID:doublethink,项目名称:Cloth-Simulation,代码行数:35,代码来源:Shader.cpp
示例2: glCreateShader
void OpenGL::setShaders() {
char *vs = NULL,*fs = NULL,*fs2 = NULL;
vertShaderId = glCreateShader(GL_VERTEX_SHADER);
fragShaderId = glCreateShader(GL_FRAGMENT_SHADER);
vs = textFileRead("sphereVert.c");
fs = textFileRead("sphereFrag.c");
const char * vv = vs;
const char * ff = fs;
glShaderSource(vertShaderId, 1, &vv,NULL);
glShaderSource(fragShaderId, 1, &ff,NULL);
free(vs);free(fs);
glCompileShader(vertShaderId);
glCompileShader(fragShaderId);
printShaderInfoLog(vertShaderId);
printShaderInfoLog(fragShaderId);
programId = glCreateProgram();
glAttachShader(programId, vertShaderId);
glAttachShader(programId, fragShaderId);
glLinkProgram(programId);
printProgramInfoLog(programId);
glUseProgram(programId);
}
开发者ID:satwikkottur,项目名称:FluidSimulator,代码行数:32,代码来源:glutils.cpp
示例3: setShadersBySource
GLuint setShadersBySource(const char *vfile, const char *ffile, const char *gfile)
{
GLuint p = glCreateProgram();
if (vfile) {
GLuint v = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(v, 1, &vfile,NULL);
glCompileShader(v);
printShaderInfoLog(v);
glAttachShader(p,v);
}
if (ffile) {
GLuint f = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(f, 1, &ffile,NULL);
glCompileShader(f);
printShaderInfoLog(f);
glAttachShader(p,f);
}
if (gfile) {
GLuint g = glCreateShader(GL_GEOMETRY_SHADER_EXT);
glShaderSource(g, 1, &gfile,NULL);
glCompileShader(g);
printShaderInfoLog(g);
glAttachShader(p,g);
}
printProgramInfoLog(p);
return p;
}
开发者ID:xiehao,项目名称:Image-Vectorization,代码行数:33,代码来源:shader.cpp
示例4: glCreateProgram
GLuint GLTools::createShaderProgram(const char* vsFilename, const char* fsFilename){
// create program
GLuint programID = glCreateProgram();
// create and attach shaders
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
string source = readFile(vsFilename);
const char* s = source.c_str();
glShaderSource(vertexShader, 1, &s, NULL);
glCompileShader(vertexShader);
printShaderInfoLog(vertexShader);
source.clear();
glAttachShader(programID, vertexShader);
glDeleteShader(vertexShader);
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
source = readFile(fsFilename);
s = source.c_str();
glShaderSource(fragmentShader, 1, &s, NULL);
glCompileShader(fragmentShader);
printShaderInfoLog(fragmentShader);
source.clear();
glAttachShader(programID, fragmentShader);
glDeleteShader(fragmentShader);
// link program
glLinkProgram(programID);
// check program
printProgramInfoLog(programID);
return programID;
}
开发者ID:hiepkhach7488,项目名称:BeingThere,代码行数:35,代码来源:gl_tools.cpp
示例5: shader_init
void shader_init() {
char *vs,*fs;
v = glCreateShader(GL_VERTEX_SHADER);
f = glCreateShader(GL_FRAGMENT_SHADER);
vs = textFileRead("vert.glsl");
fs = textFileRead("frag.glsl");
const char * vv = vs;
const char * ff = fs;
glShaderSource(v, 1, &vv,NULL);
glShaderSource(f, 1, &ff,NULL);
free(vs);
free(fs);
glCompileShader(v);
printShaderInfoLog(v);
glCompileShader(f);
printShaderInfoLog(f);
p = glCreateProgram();
glAttachShader(p,v);
glAttachShader(p,f);
glLinkProgram(p);
printProgramInfoLog(p);
glUseProgram(p);
}
开发者ID:kcbanner,项目名称:visualizer,代码行数:35,代码来源:main.cpp
示例6: glCreateShader
/*
* Erstellt ein Shaderprogramm aus den angegebenen Shaderdateien.
* Liefert den Index, an dessen Postion das Progemm und die einzelnen Shader in den Vektoren gespeichert werden.
*/
int OpenGLRenderer::createProgram(QString vertexPath, QString pixelPath) {
// Shader laden
GLuint vertex_ID = glCreateShader(GL_VERTEX_SHADER);
GLuint pixel_ID = glCreateShader(GL_FRAGMENT_SHADER);
//const char* vs = readFile(vertexPath).c_str(); // geht nicht in einem Schritt... stürzt ab?!
//const char* fs = readFile(pixelPath).c_str();
std::string vsString = readFile(vertexPath);
std::string fsString = readFile(pixelPath);
const char* vs = vsString.c_str();
const char* fs = fsString.c_str();
glShaderSource(vertex_ID, 1, &vs, 0);
glShaderSource(pixel_ID, 1, &fs, 0);
// Shader kompilieren
glCompileShader(vertex_ID);
printShaderInfoLog(vertex_ID);
glCompileShader(pixel_ID);
printShaderInfoLog(pixel_ID);
// Programm aus Shadern erstellen
GLuint program_ID = glCreateProgram();
glAttachShader(program_ID, vertex_ID); // erst Vertexshader
glAttachShader(program_ID, pixel_ID); // danach Pixelshader
glBindFragDataLocation(program_ID, 0, "fragColor"); // fragColor enthält am Ende die Farbe des Pixels ist (Ausgabe des Pixelshaders)
glLinkProgram(program_ID);
printProgramInfoLog(program_ID);
checkForErrors();
vShader_IDs.append(vertex_ID);
pShader_IDs.append(pixel_ID);
program_IDs.append(program_ID);
return vShader_IDs.size() - 1;
}
开发者ID:jobusch,项目名称:gdv-labor,代码行数:38,代码来源:openglrenderer.cpp
示例7: makeShaderFromSource
GLuint makeShaderFromSource(
const char* vert,
const char* frag,
const char* geom)
{
std::cout << " vs-";
GLuint vertSrc = loadShaderFile(vert, GL_VERTEX_SHADER);
printShaderInfoLog(vertSrc);
std::cout << " fs-";
GLuint fragSrc = loadShaderFile(frag, GL_FRAGMENT_SHADER);
printShaderInfoLog(fragSrc);
// Vertex and fragment shaders are required
if ((vertSrc == 0) || (fragSrc == 0))
{
std::cout << " SHADER NOT COMPILED - source not found." << std::endl;
return 0;
}
//std::cout << " gs: ";
GLuint geomSrc = loadShaderFile(geom, GL_GEOMETRY_SHADER_EXT);
GLuint program = glCreateProgram();
glCompileShader(vertSrc);
glCompileShader(fragSrc);
GLint success = 0;
glGetShaderiv(vertSrc, GL_COMPILE_STATUS, &success);
assert(success == GL_TRUE);
glGetShaderiv(fragSrc, GL_COMPILE_STATUS, &success);
assert(success == GL_TRUE);
glAttachShader(program, vertSrc);
glAttachShader(program, fragSrc);
// Will be deleted when program is.
glDeleteShader(vertSrc);
glDeleteShader(fragSrc);
// Initialize Geometry shader state after creation, before linking.
if (geomSrc)
{
std::cout << " gs-";
printShaderInfoLog(geomSrc);
glCompileShader(geomSrc);
glAttachShader (program, geomSrc);
}
glLinkProgram(program);
std::cout << " prog: ";
printProgramInfoLog(program);
std::cout << std::endl;
glUseProgram(0);
return program;
}
开发者ID:cleoag,项目名称:RiftRay,代码行数:59,代码来源:ShaderFunctions.cpp
示例8: installShaders
// ***********************************************************************
// ***********************************************************************
int installShaders( const GLchar *shVertex,
const GLchar *shFragment,
const int id) {
GLint vertCompiled;
GLint fragCompiled; // status values
// Create a vertex shader object and a fragment shader object
shaderVS = glCreateShader(GL_VERTEX_SHADER);
shaderFS = glCreateShader(GL_FRAGMENT_SHADER);
// Load source code strings into shaders
glShaderSource(shaderVS, 1, &shVertex, NULL);
glShaderSource(shaderFS, 1, &shFragment, NULL);
// Compile the vertex shader, and print out
// the compiler log file.
glCompileShader(shaderVS);
printOpenGLError(); // Check for OpenGL errors
glGetShaderiv(shaderVS, GL_COMPILE_STATUS, &vertCompiled);
printShaderInfoLog(shaderVS);
// Compile the fragment shader, and print out
// the compiler log file.
glCompileShader(shaderFS);
printOpenGLError(); // Check for OpenGL errors
glGetShaderiv(shaderFS, GL_COMPILE_STATUS, &fragCompiled);
printShaderInfoLog(shaderFS);
if (!vertCompiled || !fragCompiled)
return 0;
// Create a program object and attach the two compiled shaders
shaderProg[id] = glCreateProgram();
glAttachShader(shaderProg[id], shaderVS);
glAttachShader(shaderProg[id], shaderFS);
// Link the program object and print out the info log
glLinkProgram(shaderProg[id]);
printOpenGLError(); // Check for OpenGL errors
glGetProgramiv(shaderProg[id], GL_LINK_STATUS, &linked);
printProgramInfoLog(shaderProg[id]);
if (!linked)
return 0;
// Install program object as part of current state
glUseProgram(shaderProg[id]);
return 1;
}
开发者ID:MarcioCerqueira,项目名称:VolumeRendering,代码行数:60,代码来源:shader.cpp
示例9: buildShaders
int buildShaders (const char *vertexShader, const char *fragmentShader)
{
GLuint VS, FS, prog;
GLint vertCompiled, fragCompiled;
GLint linked;
// Create Shader Objects
VS = glCreateShader(GL_VERTEX_SHADER);
FS = glCreateShader(GL_FRAGMENT_SHADER);
// Load source code strings into shaders
glShaderSource(VS, 1, &vertexShader, NULL);
glShaderSource(FS, 1, &fragmentShader, NULL);
debugOut("Compiling vertex shader... \n");
// Compile vertex shader and print log
glCompileShader(VS);
printOpenGLError();
glGetShaderiv(VS, GL_COMPILE_STATUS, &vertCompiled);
printShaderInfoLog (VS);
debugOut("\nCompiling fragment shader... \n");
// Compile fragment shader and print log
glCompileShader(FS);
printOpenGLError();
glGetShaderiv(FS, GL_COMPILE_STATUS, &fragCompiled);
printShaderInfoLog (FS);
if (!vertCompiled || !fragCompiled)
return 0;
debugOut( "\nShaders compiled. \n");
// Create a program object and attach the two compiled shaders
prog = glCreateProgram();
glAttachShader(prog, VS);
glAttachShader(prog, FS);
// Clean up
glDeleteShader (VS);
glDeleteShader (FS);
// Link the program and print log
glLinkProgram(prog);
printOpenGLError();
glGetProgramiv(prog, GL_LINK_STATUS, &linked);
printProgramInfoLog(prog);
if (!linked)
return 0;
debugOut("Shader program linked. \n");
return prog;
}
开发者ID:VillainyStudios,项目名称:opensludge,代码行数:58,代码来源:shaders.cpp
示例10: glx_init
void glx_init(int scr, int w, int h, int radius, float sigma) {
int i;
configs = glXChooseFBConfig(display, scr, pixmap_config, &i);
vis = glXGetVisualFromFBConfig(display, configs[0]);
ctx = glXCreateContext(display, vis, NULL, True);
glXBindTexImageEXT_f = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress(
(GLubyte *)"glXBindTexImageEXT");
if (glXBindTexImageEXT_f == NULL) {
errx(EXIT_FAILURE, "Failed to load extension glXBindTexImageEXT.\n");
}
glXReleaseTexImageEXT_f = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress(
(GLubyte *)"glXReleaseTexImageEXT");
if (glXReleaseTexImageEXT_f == NULL) {
errx(EXIT_FAILURE, "Failed to load extension glXReleaseTexImageEXT.\n");
}
tmp = XCreatePixmap(display, RootWindow(display, vis->screen), w, h,
vis->depth);
glx_tmp = glXCreatePixmap(display, configs[0], tmp, pixmap_attribs);
glXMakeCurrent(display, glx_tmp, ctx);
tmp1 = XCreatePixmap(display, RootWindow(display, vis->screen), w, h,
vis->depth);
glx_tmp1 = glXCreatePixmap(display, configs[0], tmp1, pixmap_attribs);
v_shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(v_shader, 1, &VERT_SHADER, NULL);
glCompileShader(v_shader);
glGetShaderiv(v_shader, GL_COMPILE_STATUS, &i);
#if DEBUG_GL
printf("V Shader: %d\n", i);
printShaderInfoLog(v_shader);
#endif
f_shader = glCreateShader(GL_FRAGMENT_SHADER);
char *fragment_shader = generate_fragment_shader(radius, sigma);
GLchar const *files[] = {fragment_shader};
glShaderSource(f_shader, 1, files, NULL);
free(fragment_shader);
glCompileShader(f_shader);
glGetShaderiv(f_shader, GL_COMPILE_STATUS, &i);
#if DEBUG_GL
printf("F Shader: %d\n", i);
printShaderInfoLog(f_shader);
#endif
shader_prog = glCreateProgram();
glAttachShader(shader_prog, v_shader);
glAttachShader(shader_prog, f_shader);
glLinkProgram(shader_prog);
glGetShaderiv(f_shader, GL_LINK_STATUS, &i);
#if DEBUG_GL
printf("Program: %d\n", i);
printShaderInfoLog(f_shader);
printProgramInfoLog(shader_prog);
#endif
}
开发者ID:zygzagZ,项目名称:i3lock-blur,代码行数:58,代码来源:blur.c
示例11: makeShaderProgram
// On successful return, the returned program object ID can be
// used to install the program as part of current state
// using glUseProgram(). Example:
//
// GLuint prog = makeShaderProgram( vertShaderStr, fragShaderStr,
// myBindAttribLocFunc );
// if ( prog != 0 )
// {
// glUseProgram( prog );
//
// // Set values of uniform variables only
// // after the prog has become current.
// glUniform3f( getUniLoc(prog, "LightPosition"), 10.0, 10.0, 15.0 );
// printOpenGLError();
// glUniform1f( getUniLoc(prog, "Density"), 16.0 );
// printOpenGLError();
// }
//
// Use glUseProgram(0) to restore the original vertex processing
// and fragement processing fixed functionalities.
//
/////////////////////////////////////////////////////////////////////////////
GLuint makeShaderProgram( const GLchar *vertShaderSrcStr,
const GLchar *fragShaderSrcStr,
void (*bindAttribLocFunc)( GLuint progObj ) )
{
GLuint vShader = 0, fShader = 0, prog = 0; // handles to objects.
GLint vCompiled, fCompiled; // status values.
GLint linked;
// Create and compile the vertex shader object.
if ( vertShaderSrcStr != NULL )
{
vShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vShader, 1, &vertShaderSrcStr, NULL);
glCompileShader(vShader);
printOpenGLError(); // Check for OpenGL errors.
glGetShaderiv(vShader, GL_COMPILE_STATUS, &vCompiled);
printShaderInfoLog(vShader);
if (!vCompiled ) return 0;
}
// Create and compile the fragment shader object.
if ( fragShaderSrcStr != NULL )
{
fShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fShader, 1, &fragShaderSrcStr, NULL);
glCompileShader(fShader);
printOpenGLError(); // Check for OpenGL errors.
glGetShaderiv(fShader, GL_COMPILE_STATUS, &fCompiled);
printShaderInfoLog(fShader);
if (!fCompiled ) return 0;
}
// Create a program object and attach the two compiled shaders.
prog = glCreateProgram();
if ( vertShaderSrcStr != NULL ) glAttachShader(prog, vShader);
if ( fragShaderSrcStr != NULL ) glAttachShader(prog, fShader);
// Flag shaders for deletion.
// They will only be actually deleted when the program object is deleted.
glDeleteShader(vShader);
glDeleteShader(fShader);
// If bindAttribLocFunc != NULL, then
// use a user-provided function to assign generic attribute
// locations/indicses to generic attribute names,
// otherwise, just let the linker do the assignment automatically.
if ( bindAttribLocFunc != NULL ) bindAttribLocFunc( prog );
// Link the program object.
glLinkProgram(prog);
printOpenGLError(); // Check for OpenGL errors.
glGetProgramiv(prog, GL_LINK_STATUS, &linked);
printProgramInfoLog(prog);
if (!linked) return 0;
return prog;
}
开发者ID:9gix,项目名称:cg,代码行数:80,代码来源:shader_util.cpp
示例12: setupShaders
GLuint setupShaders(char * vertexfile, char * fragmentfile, GLuint * program)
{
char *vs = NULL,*fs = NULL,*fs2 = NULL;
vertexShader = glCreateShader(GL_VERTEX_SHADER);
fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
if(vertexShader == 0 || fragmentShader == 0)
std::cout << " Error with glCreateShader" << std::endl;
vs = textFileRead(vertexfile);
fs = textFileRead(fragmentfile);
if(vs == NULL)
std::cout << "vs files null\n" << std::endl;
if(fs == NULL)
std::cout << "fs files null\n" << std::endl;
const char * vv = vs;
const char * ff = fs;
glShaderSource(vertexShader, 1, &vv,NULL);
glShaderSource(fragmentShader, 1, &ff,NULL);
free(vs);free(fs);
glCompileShader(vertexShader);
glCompileShader(fragmentShader);
printShaderInfoLog(vertexShader);
printShaderInfoLog(fragmentShader);
*program = glCreateProgram();
glAttachShader(*program,vertexShader);
glAttachShader(*program,fragmentShader);
glBindFragDataLocation(*program, 0, "output");
glBindAttribLocation(*program,vertexLoc,"position");
glBindAttribLocation(*program,normalLoc,"normal");
glBindAttribLocation(*program,texCoordLoc,"texCoord");
glLinkProgram(*program);
glValidateProgram(*program);
IO::printProgramInfoLog(*program);
GLuint k = glGetUniformBlockIndex(*program,"Matrices");
glUniformBlockBinding(*program, k, matricesUniLoc);
glUniformBlockBinding(*program, glGetUniformBlockIndex(*program,"Material"), materialUniLoc);
texUnit = glGetUniformLocation(*program,"texUnit");
return(*program);
}
开发者ID:aarich,项目名称:3DLocalization,代码行数:56,代码来源:ShaderFunctions.cpp
示例13: glCreateShader
void shader_object::setShader(const char *vs, const char *fs)
{
//fprintf(stderr, "**** %s:%s() ****\n", __FILE__, __func__);
v = glCreateShader(GL_VERTEX_SHADER);
f = glCreateShader(GL_FRAGMENT_SHADER);
//printf("set vertex shader source\n");
glShaderSource(v, 1, &vs, NULL);
//printf("set fragment shader source\n");
glShaderSource(f, 1, &fs, NULL);
//printf("compile vertex shader\n");
glCompileShader(v);
GLint params;
glGetShaderiv(v, GL_COMPILE_STATUS, ¶ms);
if(params == GL_FALSE)
{
fprintf(stderr, "compile vertex shader error:\n");
printShaderInfoLog(v);
exit(10);
}
//printf("compile fragment shader\n");
glCompileShader(f);
glGetShaderiv(f, GL_COMPILE_STATUS, ¶ms);
if(params == GL_FALSE)
{
fprintf(stderr, "compile fragment shader error:\n");
printShaderInfoLog(f);
exit(10);
}
//printf("create program\n");
p = glCreateProgram();
//printf("attach shaders to program\n");
glAttachShader(p, v);
glAttachShader(p, f);
//printf("link program\n");
glLinkProgram(p);
glGetProgramiv(p, GL_LINK_STATUS, ¶ms);
if(params == GL_FALSE)
{
fprintf(stderr, "link program error:\n");
printProgramInfoLog(p);
exit(10);
}
//glUseProgram(p);
}
开发者ID:jinghuage,项目名称:pcaster,代码行数:56,代码来源:shader.cpp
示例14: CleanUp
bool Shader::SetShaderFile(char* sVSFileName, char* sFSFileName)
{
if (glIsProgram(m_Program))
{
CleanUp();
}
if (!ReadVertextShader(sVSFileName) || !ReadFragmentShader(sFSFileName))
{
return false;
}
GLint vertCompiled, fragCompiled; //状态值
GLint linked;
//创建shader对象
m_Vert = glCreateShader(GL_VERTEX_SHADER);
m_Frag = glCreateShader(GL_FRAGMENT_SHADER);
const GLchar *vv = m_VertexShader;
const GLchar *ff = m_FragmentShader;
//添加shader
glShaderSource(m_Vert,1,&vv,NULL);
glShaderSource(m_Frag,1,&ff,NULL);
//编译shader
glCompileShader(m_Vert);
printOpenGLError(); //检查OpenGL错误
//glGetObjectParameterivARB(m_Vert, GL_OBJECT_COMPILE_STATUS_ARB, &vertCompiled);
glGetShaderiv(m_Vert, GL_COMPILE_STATUS, &vertCompiled);
printShaderInfoLog(m_Vert);
glCompileShader(m_Frag);
printOpenGLError(); //检查OpenGL错误
//glGetObjectParameterivARB(m_Frag, GL_OBJECT_COMPILE_STATUS_ARB, &fragCompiled);
glGetShaderiv(m_Frag, GL_COMPILE_STATUS, &fragCompiled);
printShaderInfoLog(m_Frag);
if (!vertCompiled || !fragCompiled)
return false;
//创建程序对象
m_Program = glCreateProgram();
//绑定shader到程序对象
glAttachShader(m_Program,m_Vert);
glAttachShader(m_Program,m_Frag);
//链接程序
glLinkProgram(m_Program);
printOpenGLError(); //检查OpenGL错误
//glGetObjectParameterivARB(m_Program, GL_OBJECT_COMPILE_STATUS_ARB, &linked);
glGetProgramiv(m_Program, GL_LINK_STATUS, &linked);
printProgramInfoLog(m_Program);
if (!linked)
return false;
UseShader(true);
return true;
}
开发者ID:PoeLoren,项目名称:PTAMM,代码行数:56,代码来源:GLShader.cpp
示例15: vec3f
gouraudhdl::gouraudhdl()
{
type = "gouraud";
emission = vec3f(0.0, 0.0, 0.0);
ambient = vec3f(0.1, 0.1, 0.1);
diffuse = vec3f(1.0, 1.0, 1.0);
specular = vec3f(1.0, 1.0, 1.0);
shininess = 1.0;
if (vertex == 0 && fragment == 0 && program == 0)
{
/* TODO Assignment 3: Load and link the shaders. Keep in mind that vertex, fragment,
* and program are static variables meaning they are *shared across all instances of
* this class. So you only have to initialize them once when the first instance of
* the class is created.
*/
glEnable(GL_DEPTH_TEST);
vertex = load_shader_file("res/gouraud.vx", GL_VERTEX_SHADER);
fragment = load_shader_file("res/gouraud.ft", GL_FRAGMENT_SHADER);
program = glCreateProgram();
progmap.insert(pair<string, int>("gouraud", program));
//cout << "Program number:" << program <<endl;
printProgramInfoLog(program);
glAttachShader(program, vertex);
glAttachShader(program, fragment);
GLint pok = 0;
glGetProgramiv(program, GL_LINK_STATUS, &pok);
if (pok == GL_FALSE)
cout << "program bad" << endl;
if (pok == GL_TRUE)
cout << "program good" << endl;
glAttachShader(program, vertex);
glAttachShader(program, fragment);
GLint vok = 0;
GLint fok = 0;
glGetShaderiv(vertex, GL_COMPILE_STATUS, &vok);
glGetShaderiv(fragment, GL_COMPILE_STATUS, &fok);
if (vok == GL_FALSE)
cout << "Something in the vertex shader fed up";
if (vok == GL_TRUE)
cout << "gouraud V shader is good";
if (fok == GL_FALSE)
cout << "Something in the fragment shader fed up";
if (vok == GL_TRUE)
cout << "F shader is good";
printShaderInfoLog(vertex);
printShaderInfoLog(fragment);
glLinkProgram(program);
pok = 0;
glGetProgramiv(program, GL_LINK_STATUS, &pok);
if (pok == GL_FALSE)
cout << "program bad" << endl;
if (pok == GL_TRUE)
cout << "program good" << endl;
}
}
开发者ID:chiqomar,项目名称:GLassmt3,代码行数:56,代码来源:material.cpp
示例16: makeShaderByName
/// Append any applicable suffixes to the name given and attempt to find
/// vertex, fragment and (optionally) geometry shader source.
GLuint makeShaderByName(const char* name)
{
if (!name)
return 0;
std::string vs(name);
std::string fs(name);
std::string gs(name);
vs += ".vert";
fs += ".frag";
gs += ".geom";
std::cout << std::endl
<< "makeShaderByName("
<< vs
<< ", "
<< fs
<< ", "
<< gs
<< "):__"
<< std::endl;
GLuint vertSrc = loadShaderFile(vs.c_str(), GL_VERTEX_SHADER);
GLuint fragSrc = loadShaderFile(fs.c_str(), GL_FRAGMENT_SHADER);
GLuint geomSrc = loadShaderFile(gs.c_str(), GL_GEOMETRY_SHADER_EXT);
printShaderInfoLog(vertSrc);
printShaderInfoLog(fragSrc);
GLuint program = glCreateProgram();
glCompileShader(vertSrc);
glCompileShader(fragSrc);
glAttachShader(program, vertSrc);
glAttachShader(program, fragSrc);
// Will be deleted when program is.
glDeleteShader(vertSrc);
glDeleteShader(fragSrc);
// Initialize Geometry shader state after creation, before linking.
if (geomSrc)
{
printShaderInfoLog(geomSrc);
glCompileShader(geomSrc);
glAttachShader (program, geomSrc);
}
glLinkProgram(program);
printProgramInfoLog(program);
glUseProgram(0);
return program;
}
开发者ID:jimbo00000,项目名称:OmniPano,代码行数:57,代码来源:ShaderFunctions.cpp
示例17: glCreateShader
void Display::loadShader( const char* vertFile, const char* fragFile, const char* geomFile, Shader & shader )
{
shader.vertex = glCreateShader(GL_VERTEX_SHADER);
shader.fragment = glCreateShader(GL_FRAGMENT_SHADER);
if( geomFile != NULL ) shader.geometry = glCreateShader(GL_GEOMETRY_SHADER);
shader.program = glCreateProgram();
//load up the source, compile and link the shader program
const char* vertSource = textFileRead(vertFile);
const char* fragSource = textFileRead(fragFile);
const char* geomSource = NULL;
if( geomFile != NULL ) geomSource = textFileRead(geomFile);
glShaderSource(shader.vertex, 1, &vertSource, 0);
glShaderSource(shader.fragment, 1, &fragSource, 0);
if( geomFile != NULL ) glShaderSource(shader.geometry, 1, &geomSource, 0);
glCompileShader(shader.vertex);
glCompileShader(shader.fragment);
if( geomFile != NULL ) glCompileShader(shader.geometry);
//For your convenience, i decided to throw in some compiler/linker output helper functions
//from CIS 565
GLint compiled;
glGetShaderiv(shader.vertex, GL_COMPILE_STATUS, &compiled);
if (!compiled)
{
printShaderInfoLog(shader.vertex);
}
glGetShaderiv(shader.fragment, GL_COMPILE_STATUS, &compiled);
if (!compiled)
{
printShaderInfoLog(shader.fragment);
}
if( geomFile != NULL )
{
glGetShaderiv(shader.geometry, GL_COMPILE_STATUS, &compiled);
if (!compiled)
{
printShaderInfoLog(shader.geometry);
}
}
//finish shader setup
glAttachShader(shader.program, shader.vertex);
glAttachShader(shader.program, shader.fragment);
if( geomFile != NULL ) glAttachShader(shader.program, shader.geometry);
glLinkProgram(shader.program);
//check for linking success
GLint linked;
glGetProgramiv(shader.program,GL_LINK_STATUS, &linked);
if (!linked)
{
printLinkInfoLog(shader.program);
}
}
开发者ID:LingDu-san,项目名称:sph-2,代码行数:54,代码来源:display.cpp
示例18: glCreateProgram
//--------------------------------------------------------------------------------
bool Shader::loadSources(const std::string& vsrc, const std::string& fsrc)
{
bool allIsOk = true;
mProgramID = glCreateProgram();
// vertex shader
{
GLuint shaderID = glCreateShader(GL_VERTEX_SHADER);
//QByteArray vsrc8 = vsrc.toAscii();
const GLchar * arbSource = vsrc.c_str();
glShaderSource(shaderID, 1, (const GLchar **)&arbSource, 0);
glCompileShader(shaderID);
int compiled;
glGetShaderiv(shaderID,GL_COMPILE_STATUS,&compiled);
allIsOk = allIsOk && compiled;
printShaderInfoLog(shaderID);
if(compiled)
glAttachShader(mProgramID, shaderID);
}
// fragment shader
{
GLuint shaderID = glCreateShader(GL_FRAGMENT_SHADER);
//QByteArray fsrc8 = fsrc.toAscii();
const GLchar * arbSource = fsrc.c_str();
glShaderSource(shaderID, 1, (const GLchar **)&arbSource, 0);
glCompileShader(shaderID);
int compiled;
glGetShaderiv(shaderID,GL_COMPILE_STATUS,&compiled);
allIsOk = allIsOk && compiled;
printShaderInfoLog(shaderID);
if(compiled)
glAttachShader(mProgramID, shaderID);
}
glLinkProgram(mProgramID);
int isLinked;
glGetProgramiv(mProgramID, GL_LINK_STATUS, &isLinked);
allIsOk = allIsOk && isLinked;
mIsValid = isLinked == GL_TRUE;
printProgramInfoLog(mProgramID);
return allIsOk;
}
开发者ID:lortael,项目名称:HDR_Display,代码行数:55,代码来源:Shader.cpp
示例19: setupShaders
GLuint setupShaders() {
char *vs = NULL,*fs = NULL,*fs2 = NULL;
GLuint p,v,f;
v = glCreateShader(GL_VERTEX_SHADER);
f = glCreateShader(GL_FRAGMENT_SHADER);
vs = textFileRead(vertexFileName);
fs = textFileRead(fragmentFileName);
const char * vv = vs;
const char * ff = fs;
glShaderSource(v, 1, &vv,NULL);
glShaderSource(f, 1, &ff,NULL);
free(vs);free(fs);
glCompileShader(v);
glCompileShader(f);
printShaderInfoLog(v);
printShaderInfoLog(f);
p = glCreateProgram();
glAttachShader(p,v);
glAttachShader(p,f);
glBindFragDataLocation(p, 0, "output");
glBindAttribLocation(p,vertexLoc,"position");
glBindAttribLocation(p,normalLoc,"normal");
glBindAttribLocation(p,texCoordLoc,"texCoord");
glLinkProgram(p);
glValidateProgram(p);
printProgramInfoLog(p);
program = p;
vertexShader = v;
fragmentShader = f;
GLuint k = glGetUniformBlockIndex(p,"Matrices");
glUniformBlockBinding(p, k, matricesUniLoc);
glUniformBlockBinding(p, glGetUniformBlockIndex(p,"Material"), materialUniLoc);
texUnit = glGetUniformLocation(p,"texUnit");
return(p);
}
开发者ID:bjnix,项目名称:model-viewer,代码行数:52,代码来源:l3dassimpimport.cpp
示例20: glGetShaderiv
void ShapeGen::shaderErrors() {
GLint compiled;
glGetShaderiv(shaderVertID, GL_COMPILE_STATUS, &compiled);
if (!compiled)
{
printShaderInfoLog(shaderVertID);
}
glGetShaderiv(shaderFragID, GL_COMPILE_STATUS, &compiled);
if (!compiled)
{
printShaderInfoLog(shaderFragID);
}
}
开发者ID:djmally,项目名称:lakitu-oculus,代码行数:13,代码来源:ShapeGen.cpp
注:本文中的printShaderInfoLog函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论