Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Alazorn

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

This topic is 6426 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!