Jump to content
  • Advertisement
Sign in to follow this  
philipptr

Drawing parts of textures

This topic is 4826 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

(im making a 2d game with c++ + sdl + ogl) At the moment i use glBlendFunc(GL_DST_COLOR,GL_ZERO); to blit the mask on a quad and then glBlendFunc(GL_ONE, GL_ONE); to blit the texture. What i search for is a way to cut of the texture at sides, so is there a simple way to do that? can i add a second mask, to mask the mask (O_o)? Just an idea if theres no other way: should i use the depth buffer for this? Raise the pixels which shouldnt be blitted and then use depth test?

Share this post


Link to post
Share on other sites
Advertisement
If I understand correctly, you want to only draw part of a texture, but still a rectangular region? Just changing your texture coordinates should work.

Share this post


Link to post
Share on other sites
Quote:
Original post by mrbastard
If I understand correctly, you want to only draw part of a texture, but still a rectangular region? Just changing your texture coordinates should work.


yes but that would make finding the right value harder (original height/blitting height=1/textur coordinate)
i will try to find some information on the stencil buffer.

Share this post


Link to post
Share on other sites
i think the stencil buffer is a bit too complicated for this simple problem.
so can i somehow set the texture coordinates to be instead of max 1, max 64 so that i wouldnt have to divide the size all the time (i guess that wouldnt be very exact)

Share this post


Link to post
Share on other sites
Woot, this helps me out too. I've been dividing the whole time. Didn't know this existed. A quick google gets this from wikipedia:

GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_FLOAT_R32_NV, _width, _height, 0, GL_RED, GL_FLOAT, data);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!