Jump to content

  • Log In with Google      Sign In   
  • Create Account


novice gl question


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

#1 shizik   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 October 2001 - 09:33 AM

hello, I am trying to create a simple sprite based game and am having a problem my sprites are quads textured with the bitmap of the sprite. I was able to make the black background around the sprite be transparent by: glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE); glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f); glEnd(); glDisable(GL_BLEND); now when I compose my scene I want my sprites to be on the foreground and lets say a bunch of points or quads on the background, I have enabled depth-testing, but my background objects are always overwriting my sprites, NO MATTER what their Z position is whats going on?

Sponsor:

#2 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 17 October 2001 - 09:58 AM

If I know what you mean, I had this problem a while ago too. The best way of getting around it is to disable Depth Testing, and sort the objects yourself. If you think about it, that method is faster too. Instead of testing for each pixel, you test once per object.

[Resist Windows XP''s Invasive Production Activation Technology!]

#3 Bretttido   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 October 2001 - 10:00 AM

I believe what you''ll want to do is draw all of your background objects first, making sure that GL_DEPTH_TEST is enabled.

Then draw your sprites with GL_DEPTH_TEST disables. I believe this will fix your problem.. let me know

#4 shizik   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 October 2001 - 11:35 AM

neither of these two solutions work

when I set the backgorund to green, it seems that the texture on my sprite is being blended with the background color
why is this happening?

anything I draw seems to superimpose itself over my sprite
even if I draw it before the sprite and behind the sprite

any ideas?
thanks


#5 Derilect101   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 October 2001 - 01:27 PM

I would personally use .tga files for sprites cuz of the alpha channel in them and use
glAlphaFunc(GL_GREATER, 0.1f);
glEnable(GL_ALPHA_TEST);
That will make everything that is black (in the alpha channel in the tga file) not appear if ya need more help be glad to help ya.

#6 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 17 October 2001 - 05:49 PM

quote:
Original post by shizik
when I set the backgorund to green, it seems that the texture on my sprite is being blended with the background color
why is this happening?

anything I draw seems to superimpose itself over my sprite
even if I draw it before the sprite and behind the sprite


Why didn''t you say that in the first place? That''s different than what I though you meant .

[Resist Windows XP''s Invasive Production Activation Technology!]

#7 Etwinox   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 October 2001 - 02:17 AM

I''m just beginning in OpenGL, so correct me if I''m wrong, but can''t you disable blending or use some sort of masking to accomplish your intended effect?

Oh, and how are you guys doing the "quote: HR ''whatever'' HR"? Does this form even support HTML?

#8 Dactylos   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 October 2001 - 02:37 AM

Yes this form supports html tags. To make a quote-thingy you write:

[ quote ]
Quoted text here
[ /quote ]
But without spaces within the [ and ] brackets.

Or you can simply click the little "quote"-link in the top-right corner of a post. (clicking the "quote" or "edit" links on a post containing special tags is a good way to see how to write them).

Edited by - Dactylos on October 19, 2001 9:42:00 AM




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