Hi folks way more knowledgable than me,
This topic is intimately related to that from this thread . I tried the suggested solution, but the shader failed to compile and link.
So, here I am, posting a complete codeblock that will compile under vc++6.0. I ommitted the error checking routines to make it shorter, and for many this code will seem familiar, as it very closely resembles the 3D Lab’s brick example code.
Both shaders are trivial, and should cause the square to be shaded red. However, it ends up black on the screen. I know the shader loading and compiling routines work, because if I change the fragment shader to explicitly set the color to red, it works.
I would be infinitely grateful for any insight into my problem.
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>#include <stdlib.h>
#include <stdio.h>
#define GLEW_STATIC 1
#include <GL/glew.h>
#include <GL/glut.h>
static GLint window;
GLubyte tex2d[16][16][4];
GLuint texhandle;
const GLchar VertexSource[]={"
void main(void)
{
gl_Position = ftransform();
}
“};
const GLchar FragSource[]={”
uniform sampler2D texUnit0;
void main(void)
{
gl_FragColor = texture2D(texUnit0, gl_TexCoord[0].xy);
}
"};
GLuint installShaders(const GLchar *shaderVertex,
const GLchar *shaderFragment)
{
GLuint shaderVS, shaderFS, shaderProg;
GLint vertCompiled, fragCompiled;
GLint linked;
shaderVS = glCreateShader(GL_VERTEX_SHADER);
shaderFS = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(shaderVS, 1, &shaderVertex, NULL);
glShaderSource(shaderFS, 1, &shaderFragment, NULL);
glCompileShader(shaderVS);
glGetShaderiv(shaderVS, GL_COMPILE_STATUS, &vertCompiled);
glCompileShader(shaderFS);
glGetShaderiv(shaderFS, GL_COMPILE_STATUS, &fragCompiled);
if (!vertCompiled