Advertisement

Ok, two more questions to you elites out there :)

Started by January 11, 2001 04:43 PM
4 comments, last by Alazorn 23 years, 10 months ago
Ok, need some help again first of all I cant get Masking to work, I only end up either with an nonmasked bitmap or with no bitmap at all, hum strange why? here is da code : void drawquad(GLfloat x, GLfloat y, GLfloat z, GLfloat rx, GLfloat ry, GLfloat rz, GLfloat w,GLfloat h,GLfloat colorr,GLfloat colorg,GLfloat colorb, int texturenum, int texturemask, GLfloat alpha) { glTranslatef(x,y,z); glRotatef(rx,1.0f,0.0f,0.0f); glRotatef(ry,0.0f,1.0f,0.0f); glRotatef(rz,0.0f,0.0f,1.0f); GLfloat bltemps=0; GLfloat bltempd=0; if (texturemask>=0) { glGetFloatv(GL_BLEND_SRC,&bltemps); glGetFloatv(GL_BLEND_DST,&bltempd); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR,GL_ZERO); glBindTexture(GL_TEXTURE_2D,textures[texturemask]); glBegin(GL_QUADS); glNormal3f(0.0f,0.0f,1.0f); glTexCoord2f(0.0f,0.0f); glVertex3f(-w,-h,0); glTexCoord2f(1.0f,0.0f); glVertex3f(w,-h,0); glTexCoord2f(1.0f,1.0f); glVertex3f(w,h,0); glTexCoord2f(0.0f,1.0f); glVertex3f(-w,h,0); glEnd(); glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D,textures[texturenum]); glBegin(GL_QUADS); glNormal3f(0.0f,0.0f,1.0f); glTexCoord2f(0.0f,0.0f); glVertex3f(-w,-h,0); glTexCoord2f(1.0f,0.0f); glVertex3f(w,-h,0); glTexCoord2f(1.0f,1.0f); glVertex3f(w,h,0); glTexCoord2f(0.0f,1.0f); glVertex3f(-w,h,0); glEnd(); glEnable(GL_DEPTH_TEST); glBlendFunc(bltemps,bltempd); } } Pretty long huh but only the stuff betwene glTexCoord should be of interest for solving this problem And my second question is: How can I apply 2d pixel effects to the whole scene (like in the old days), like motion blur, blur, sharpen, emboss, mirror and such, and also copying parts of the complete scene to different areas of the screen with rezising?
And while Im at it I''ll ask one more question : Why is my lines black?

glLoadIdentity();
glBegin(GL_LINES);
glColor4f(1.0f,0.0f,0.0f,0.4f);
glVertex3f(sin(a+rtri/100+sin(rtri*a)),-5.0f,-0.3f);
glVertex3f(sin(a+rtri/100+sin(rtri*a)),5.0f,-0.3f);
glEnd();

I do not use any kind of lightning, hum?
Advertisement
u normally do masking with alpha testing but.

glBlendFunc(GL_ONE,GL_ZERO);
first quad
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
second quad

"And while Im at it I''ll ask one more question : Why is my lines black?"

is blending still enabled if so what blending mode

http://members.xoom.com/myBollux
Hum, I got color on my lines , but still no masking My new code are:

if (texturemask)
{
glGetFloatv(GL_BLEND_SRC,&bltemps);
glGetFloatv(GL_BLEND_DST,&bltempd);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE,GL_ZERO);

glBindTexture(GL_TEXTURE_2D,masks[texturenum]);

glBegin(GL_QUADS);

glNormal3f(0.0f,0.0f,1.0f);

glTexCoord2f(0.0f,0.0f); glVertex3f(-w,-h,0);
glTexCoord2f(1.0f,0.0f); glVertex3f(w,-h,0);
glTexCoord2f(1.0f,1.0f); glVertex3f(w,h,0);
glTexCoord2f(0.0f,1.0f); glVertex3f(-w,h,0);

glEnd();

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glBindTexture(GL_TEXTURE_2D,textures[texturenum]);

glBegin(GL_QUADS);

glNormal3f(0.0f,0.0f,1.0f);

glTexCoord2f(0.0f,0.0f); glVertex3f(-w,-h,0);
glTexCoord2f(1.0f,0.0f); glVertex3f(w,-h,0);
glTexCoord2f(1.0f,1.0f); glVertex3f(w,h,0);
glTexCoord2f(0.0f,1.0f); glVertex3f(-w,h,0);

glEnd();

glEnable(GL_DEPTH_TEST);
glBlendFunc(bltemps,bltempd);
Hum, I just realised that if I use Blending to mask I will not be able to do fadein/fadeout effects,so is there any other wayto do masking with Alpha transparency pherhaps?
Ok, if you can get a hold on a good graphics program that allows saving to alpha channels (I prefer Paint Shop Pro 6, myself), then you''re all set. Save your alpha channel so that you have values for what you want to see as greater than 0.5, and things that are not to be shown as less than 0.5. Then include these two happy lines of code:

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL, 0.5);

That should do it.

S.

This topic is closed to new replies.

Advertisement