I am providing some rough code for your 3D engine, but I am sure that it will definitely help you :
main.cpp
Code:
srl:: Shader1 FS (GL_FRAGMENT_SHADER_ARB);
srl:: Shader1 VS (GL_VERTEX_SHADER_ARB);
if (! FS. SourceAndCompile ("Data / ShaderTerrain.fs")) printf ("Unable <Error> compile the fragment shader1 \ n"); / / These are not errors and consequent, are compiled shader
if (! VS. SourceAndCompile ("Data / ShaderTerrain.vs")) printf ("Unable <Error> compile the vertex shader1 \ n");
srl:: Program Prg (& VS & FS);
if (! Prg. IsLinked ()) printf
Program.cpp
Code:
Program:: Program (LLP:: Shader1 * sh1, LLP:: Shader1 * sh2) (
id = glCreateProgramObject ();
if (sh1! = 0) glAttachObject (id, sh1 -> id);
if (sh2! = 0) glAttachObject (id, sh2 -> id);
if (sh1! sh2 = 0 & &! = 0) (
glLinkProgram (id);
IsLinked ();
)
)
bool Program:: IsLinked () (
Glint success;
glGetProgramiv (id, GL_LINK_STATUS, & success);
Linked = (success == GL_TRUE)? True: false;
Linked return;
)
std:: string Program:: Log () (
Glint logsize;
glGetProgramiv (id, GL_INFO_LOG_LENGTH, & logsize);
char * log = NULL;
log = (char *) malloc (logsize + 1);
glGetProgramInfoLog (id, logsize, & logsize, log);
return log;
)
Bookmarks