Simplest direct sample shader find nothing wrong but no effect

The main code is listed as the following:

c++ code:


readShaderSource("directsampler", &VertexShaderSource, &FragmentShaderSource);
success=installShaders(VertexShaderSource, FragmentShaderSource);

......

GLint baseImageLoc;

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 666);

glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,128,128,0,GL_RGB,GL_UNSIGNED_BYTE,myDemonTextureImage);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);

glUseProgram(progi);
baseImageLoc = getUniLoc(progi, "baseImage");
glUniform1i(baseImageLoc, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 666);

......

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES);
	glTexCoord2f(0, 0);
	glVertex2f(-0.8, 0.8);

	glTexCoord2f(1, 0);
	glVertex2f(0.8, 0.8);

	glTexCoord2f(0.5, 1);
	glVertex2f(0.0, -0.8);
glEnd();
glutSwapBuffers();

vertex shader:



varying vec2 texcoord;

void main()
{
	gl_Position = ftransform();
	texcoord = vec2(gl_MultiTexCoord0);
}

fragment shader:



uniform sampler2D baseImage;

varying vec2 texcoord;

void main(void)
{
	gl_FragColor=texture2D(baseImage,texcoord);
}

The most error-prone part is the c++ code, because v/f shaders are both compiled and linked well.:doh:
Any idea will be appreciated and thanks in advance!

[QUOTE=newbiecow;1246864]
glBindTexture(GL_TEXTURE_2D, 666);[/QUOTE]

what is that?

first, you should use glGenTextures to generate texture object and use the result as glBindTexture second parameter(don’t forget to use glDeleteTextures before closing the programm). second, your vertices should have negative z offset, to avoid near clipping.

http://nehe.gamedev.net/tutorial/your_first_polygon/13002/http://www.nullterminator.net/gltexture.html //updated link

and also, this question has very little
othing to do with glsl. it’s more appropriate in the beginners section, as it is about inability to google basic stuff.

Very well indeed! You seem to be an expert and a Russian.
Can I trust you?
To tell you the truth, I have paid hundreds dollars for a Russian anti virus software and used that for almost ten years!
I just wonder when I may try to use a Russian produced operating system?
Can you Russian be trusted?

Best Regards,

newbiecow

nope:(
following your topic of complete irrelevance, here’s some beatiful picture of novosibirsk:
[ATTACH=CONFIG]352[/ATTACH]

p.s.: topic is solved?
p.p.s.:this russian is a spy

[QUOTE=Nowhere-01;1247195]nope:(
following your topic of complete irrelevance, here’s some beatiful picture of novosibirsk:
[ATTACH=CONFIG]952[/ATTACH]

p.s.: topic is solved?
p.p.s.:this russian is a spy[/QUOTE]

following our topic even more irrelevant.
Have you ever played a game called “Red Alert” made by Westwood?
Beware of dogs!:biggrin-new:

Best regards,

newbiecow

[QUOTE=Nowhere-01;1247195]
p.s.: topic is solved?
p.p.s.:this russian is a spy[/QUOTE]

I solved my question by myself.

p.s.
You know in some place on earth not dog lead the blind but lead a blind dog.

p.p.s.
So can you make out who is the dun and the dung now? :biggrin-new:

Best regards,

newbiecow

i’m pretty sure the person who doesn’t read tutorials and documentation is dung.

Well. You seem to be irritated though I dunno why.

A specification has announced everything properly while an implementation announced none other than the specification’s.
In this case, which doc can you refer? In most cases, you have to query every default value the implementation has set before using the default settings correctly.

Anyway, I have solved my question. You can spare your time to help others now. Good luck, irritable man!:biggrin-new:

Best regards,

newbiecow

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.