Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

glActiveTexture does not switch texture unit

4: Adsense

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
4 replies to this topic

#1 ravarcade   Members   

121
Like
0Likes
Like

Posted 29 June 2013 - 04:19 PM

Hi

I'm trying to pass 2 textures to fragment shader. But in shader only one texture is avaible.

 

I found that problem is in glActiveTexture.

 

After call with any args, like  glActiveTexture(GL_TEXTURE1), glActiveTexture(GL_TEXTURE2) .... i alway end in texture unit 0

here is part of code:

glActiveTexture(GL_TEXTURE0);

     // debug
     GLenum e = glGetError(); // e = 0
     GLint nn; 
     glGetIntegerv(GL_ACTIVE_TEXTURE, &nn); // nn = GL_ACTIVE_TEXTURE = GL_TEXTURE0 

glBindTexture(GL_TEXTURE_2D, leftEyeTextureHandle);

glActiveTexture(GL_TEXTURE1); // !!! <- it does not work

     //debug
     GLenum e = glGetError(); // e = 0
     GLint nn; 
     glGetIntegerv(GL_ACTIVE_TEXTURE, &nn); // nn = GL_ACTIVE_TEXTURE = GL_TEXTURE0 !!!!!! 

glBindTexture(GL_TEXTURE_2D, rightEyeTextureHandle);

I already cheacked:

- GL_EXTENSIONS for GL_ARB_multitexture

- tested "clean" example for multitexturing program and it work on same computer (GL_ACTIVE_TEXTURE gives GL_TEXTURE1 ...after glActiveTexture(GL_TEXTURE1));

- glActiveTextureARB

- GL_MAX_TEXTURE_IMAGE_UNITS = 20

- GL_MAX_TEXTURE_UNITS = 4

- tests on other computers (gfx ati / nvidia)

 

Problem is in opengl state but i can't figure where is problem.

Is there any "switch" to turn off multitexturing ? 

 

fragment program:

#version 150

uniform sampler2D left;
uniform sampler2D right;

in vec2 UV;

out vec3 color;

void main(){
	if (mod(trunc(gl_FragCoord.x), 2.0) < 0.5)
	{ 
		color = texture(left, UV); 
	} else { 
		color = texture(right, UV); 
	}
}


#2 ravarcade   Members   

121
Like
0Likes
Like

Posted 30 June 2013 - 12:58 AM

Found solution!

 

Problem was in init of glActiveTexture:

PFNGLACTIVETEXTUREARBPROC pglActiveTexture = NULL;

#define glActiveTexture pglActiveTexture;

pglActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress("glActiveTextureARB");

For some reason when i replace:

glActiveTexture(GL_TEXTURE1); 

with

pglActiveTexture(GL_TEXTURE1);

it start working.



#3 BornToCode   Members   

1185
Like
0Likes
Like

Posted 30 June 2013 - 01:36 AM

Why not use glew. That way you do not have to worry about setting up all the extension.



#4 ravarcade   Members   

121
Like
0Likes
Like

Posted 30 June 2013 - 01:55 AM

Why not use glew. That way you do not have to worry about setting up all the extension.

Because i'm writing mod to game, and everything i do, is in intercepted SwapBuffer.

I do not load any libs.



#5 mhagain   Members   

13156
Like
1Likes
Like

Posted 30 June 2013 - 04:06 AM

You can statically link to GLEW and not need to load any libs.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





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.