GPWiki.org
GPWiki.org
It is currently Mon May 20, 2013 10:24 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Oct 01, 2009 1:32 am 
Rookie

Joined: Fri Oct 31, 2008 3:19 pm
Posts: 3
I'm doing some 2D drawing, so depth testing is disabled. I have a texture, and if I turn blending on when I draw it, it doesn't render. If blending is of, it's fine. Any ideas what could be the problem?

Here's a part of the code:
Code:
//The problem is, if I enable blending, then the texture isn't displayed. If I disable it, it's there (however, the transparent pixels on texture's image are black)
//Texture loading part:
   glEnable(GL_TEXTURE_2D);

   glGenTextures( 1, &tex );
   glBindTexture( GL_TEXTURE_2D, tex );

     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    glTexImage2D( GL_TEXTURE_2D, 0, image->format->BytesPerPixel, w, h, 0, texture_format, GL_UNSIGNED_BYTE, image->pixels );

   glDisable(GL_TEXTURE_2D);


//Drawing part (blending is enabled, depth test disabled)

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_COLOR_MATERIAL);

        glColor4f( m_r, m_g, m_b, m_a );
        glBindTexture( GL_TEXTURE_2D, tex->tex );
            glCallList(m_draw_texture);//draws from a list I've set up and tested (works)

        glDisable(GL_TEXTURE_2D);

Thanks[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 01, 2009 12:39 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6708
Location: Lincoln, Englandshire
Make sure your blendFunc is doing what you expect it too.

My glSandbox tool might be useful to check you're actually getting what you expect from the blend.

I don't see glEnable(GL_BLEND) or glBlendFunc(...) in your code. I'm assuming its set elsewhere?

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Sat Apr 16, 2011 10:08 am 
Bit Baby

Joined: Sat Apr 16, 2011 8:44 am
Posts: 8
im am no expert... but as a learning open gl person.... i recommend you get this series book... i have the box set: OpenGl Library...red and orange books... red is ogl standard.. orange is ogl shader language... these books are the ogl bible.... and a super investment.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group