Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!



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 Retsu90   Members   -  Reputation: 208

Like
0Likes
Like

Posted 22 December 2012 - 04:54 AM

Hi,
I'm converting my application from using OpenGL 2.0 to OpenGL 3.0. I was using glVertexPointer, glTexCoordPointer and glColorPointer to send the vertices to the GPU and when I doesn't need of Color, I simply disabled it with glDisableClientState(GL_TEXTURE_COORD_ARRAY), so the GPU set gl_Color from vertex shader is white by default. 
Now I'm using glDisableVertexAttribArray to disable the vertices and glVertexAttribPointer to send stuff and now comes the problem. glDisableVertexAttribArray(COLOR) set black the color by default in vertex shader! Now I won't fill all the vertices of 1.0f and force to enable the color, so I'm asking you if there is a way to not send the color where it doesn't required without to use particular tricks (like to create a fragment shader for color stuff and another fragment shader to the texture-only stuff).
 
My shaders looks like this:
#version 330 core
varying vec3 texcoord;
varying vec4 vertex_color;
in  vec4 in_Position;
in  vec4 in_Color;
in  vec4 in_Texture;

void main()
{
	gl_Position = in_Position;
	texcoord = in_Texture;
	vertex_color = in_Color;
}
#version 330 core
uniform sampler3D texture
varying vec3 texcoord;
varying vec4 vertex_color;

void main()
{
	vec4 precolor = texture3D(texture, texcoord);
	precolor *= vertex_color;
	gl_FragColor = precolor;
}

 

 

 



Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 8630

Like
3Likes
Like

Posted 22 December 2012 - 05:57 AM

Use one of the glVertexAttrib-variants to set the default attribute state. If an attribute array is disabled, the corresponding default attribute is used instead.



#3 Retsu90   Members   -  Reputation: 208

Like
0Likes
Like

Posted 22 December 2012 - 06:28 AM

Use one of the glVertexAttrib-variants to set the default attribute state. If an attribute array is disabled, the corresponding default attribute is used instead.

Haha that's it? It works fine :D thank you!



#4 mattdesl   Members   -  Reputation: 176

Like
2Likes
Like

Posted 22 December 2012 - 08:09 PM

If you are using version 330 you should be doing some things a bit differently in GLSL:

 

- Use "in" and "out" instead of "varying" and "attribute"

- Use layout(location=X) to specify the index to bind the attribute to

- Use a custom output instead of gl_FragColor

 

Also just so you know, GL 3.0+ is still not very widely supported. If you are targeting a casual market, you may want to stick with 2.0 as your target. In one thread it was listed that as few as 51% of Minecraft users supports GL 3.0+. It really comes down to what you need; GL 2 is a fine target for most purposes and can be used in almost the same way as the 3+ programmable pipeline. Many drivers will support geometry shaders, FBOs, float textures, etc. through extensions.



#5 Retsu90   Members   -  Reputation: 208

Like
0Likes
Like

Posted 27 December 2012 - 06:29 AM

If you are using version 330 you should be doing some things a bit differently in GLSL:

 

- Use "in" and "out" instead of "varying" and "attribute"

- Use layout(location=X) to specify the index to bind the attribute to

- Use a custom output instead of gl_FragColor

 

Also just so you know, GL 3.0+ is still not very widely supported. If you are targeting a casual market, you may want to stick with 2.0 as your target. In one thread it was listed that as few as 51% of Minecraft users supports GL 3.0+. It really comes down to what you need; GL 2 is a fine target for most purposes and can be used in almost the same way as the 3+ programmable pipeline. Many drivers will support geometry shaders, FBOs, float textures, etc. through extensions.

 

Yes, my laptop with a Intel Atom Z supports only OpenGL 2.1. My real goal is to have a multi-platform framework, with OpenGL 2.1/3.0+/ES1.0/ES2.0 and probably also DirectX 11 for W8 and WP8. OpenGL 3.0 offers great improvements and cool stuff (one of these things that I wanted is "rendering to texture") but I'm not excluding the old platforms :)






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