Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Gl Bind Texture is taking over my program X(!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Solid_Spy   Members   -  Reputation: 420

Like
0Likes
Like

Posted 30 April 2014 - 09:35 PM

Hello, I am having a VERY strange problem with openGL recently.

 

To get to the point, I am trying to render objects with textures, and without textures. But for some reason, whenever I render an object with no texture, it ends up appearing black, even though I am using a pixel shader that outputs a red color, for example.

Psoudo code:

Bind Program...
Bind texture...
Bind Vertex Array...
Render textured object, done!

Bind texture(texture_2d, 0) // default texture

Bind Program...
Bind Vertex Array...
Render NON-Textured Object, da fek?? Why is it black!???

It seems like whenever I still use the last texture without setting it to 0, the shader uses one of the colors from the texture to color my non-textured object, even though the shader doesn't accept a texture for input... -.-

 

Here's a picture of what is happening:

help_1_zps4ddc117a.png

 

These are what my color shaders look like:

        public string vertexColorShaderText = @"
#version 130

in vec3 in_Position;

out vec3 out_color;

uniform mat4 worldMatrix;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;

void main(void)
{
    gl_Position = worldMatrix * vec4(in_Position, 1.0f);
	gl_Position = viewMatrix * gl_Position;
	gl_Position = projectionMatrix * gl_Position;
}";

        public string pixelColorShaderText = @"
#version 130

out vec4 last_color;

void main(void)
{
    vec4 derp_color;
    derp_color.r = 1.0;
    derp_color.g = 0.0;
    derp_color.b = 0.0;
    derp_color.a = 1.0;
    last_color = derp_color;
}";

I just don't understand. Is there something I am supposed to be doing here???


Edited by Solid_Spy, 30 April 2014 - 10:14 PM.


Sponsor:

#2 Solid_Spy   Members   -  Reputation: 420

Like
1Likes
Like

Posted 30 April 2014 - 11:44 PM

Update: I fixed the problem.

 

It had NOTHING to do with the bind texture. I had a parameter in my shader compiler that always loaded the texture pixel shader, making the color shader use the texture pixel shader.

 

*rages.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS