SFML community forums

Help => Graphics => Topic started by: troopson on June 21, 2010, 06:41:47 pm

Title: sfml/ogl alpha doesnt work
Post by: troopson on June 21, 2010, 06:41:47 pm
wtf.. im using SFML only for window and input things.. i render only using opengl

i initialise gl like this:
Code: [Select]



// glDepthMask(GL_TRUE);
// Enable Texture Mapping ( NEW )
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5f);

// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0f,1.0f,1.0f,0.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix


drawing like this
Code: [Select]


glColor3f(1.0f,1.0f,1.0f);
glEnable(GL_TEXTURE_2D);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();

glColor4f(1.0f,1.0f,1.0f,0.3f);
glBindTexture(GL_TEXTURE_2D, (*texture)[(int)action]);
glBegin(GL_QUADS);
for (int i=0;i<4;++i)
{
glTexCoord2f(Tex(i).x, Tex(i).y) ;
glVertex2f(Xyz(i).x, Xyz(i).y);
}
glEnd();

glDisable(GL_TEXTURE_2D);
glFlush();

trying to use glEnable(GL_BLEND) anywhere here .. but then nothing after  glColor4f(1.0f,1.0f,1.0f,0.3f) shows up

edit:oh and the window im using is sf::Window
Title: sfml/ogl alpha doesnt work
Post by: Laurent on June 21, 2010, 07:49:32 pm
Hi

Can you show a complete code? Do you call window.Display() at the end?
Title: sfml/ogl alpha doesnt work
Post by: troopson on June 21, 2010, 08:03:06 pm
its a big project.
yes i call.
Title: sfml/ogl alpha doesnt work
Post by: Laurent on June 21, 2010, 08:17:26 pm
Quote
its a big project.

So you should extract a complete and minimal example, so that you (and I) can focus on the few relevant percents of the code to find the error.
Title: sfml/ogl alpha doesnt work
Post by: troopson on June 21, 2010, 09:16:48 pm
thought its complete and minimal.
Title: sfml/ogl alpha doesnt work
Post by: Mindiell on June 21, 2010, 10:07:41 pm
Look up at my signature ;)
Title: sfml/ogl alpha doesnt work
Post by: Laurent on June 21, 2010, 11:08:27 pm
"Complete" means that I don't need to add anything to compile it.
"Minimal" means that it contains nothing that has nothing to do with the error.

So obviously it is not complete and minimal ;)
Title: sfml/ogl alpha doesnt work
Post by: troopson on June 21, 2010, 11:22:32 pm
its impossible, thought u would've helped me just looking at this code,nvm.
Title: sfml/ogl alpha doesnt work
Post by: Laurent on June 22, 2010, 08:15:51 am
You seem to think that the error is included in the few lines of code that you showed us. If so, you should be able to wrap them into a very small program (add a main(), a sf::Window and a render loop) and test it alone.

If not, which is my opinion, how do you expect us to help you? Your OpenGL code is rather common and I don't see anything wrong in it. We need to see more code, but it will be hard to figure out with real code from your big project (because it will probably depend on other code etc.), that's why I was talking about writing a minimal and complete application. This is a very powerful way to find the source of an error.