Sign in to follow this  
X5-Programmer

Load Textures.

Recommended Posts

Hi, I have some problem on how do get sharp good looking textures on Quads for like menues and so on, the loader I am using to load textures is an jpg loader from www.gametutorials.com, but when I load them and put them as an texture on an quad that is the same size as the image, let say we have an 400*400 image. I draw it like this.
glBegin(GL_QUADS);
	
		glTexCoord2f(0.0f, 1.0f);	glVertex2f(0, 0);
		glTexCoord2f(0.0f, 0.0f);	glVertex2f(0, 400.0f);
		glTexCoord2f(1.0f, 0.0f);	glVertex2f(400.0f, 400.0f);
		glTexCoord2f(1.0f, 1.0f);	glVertex2f(400.0f, 0);
	
	glEnd();

But if I open the picture in Photoshop and compare it to the texture in the app it does not have the same sharpness like the image in photoshop. Do you guys know any way to get the same sharpness? And if so can you write an example or explain how to do it. hope anyone can point me somewere. thx.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
but when I load them and put them as an texture on an quad that is the same size as the image, let say we have an 400*400 image.


Same size in screen co-ordinates is what matters, not just gl co-ordinates. It's unclear if you have that.

Share this post


Link to post
Share on other sites
Quote:
Original post by Pipo DeClown
The image-width and image-height should be a power of 2: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, etc.

You missed the "1" [wink].

OGL will (by default?) filter your texture so you must disable filterung manually to avoid such artifacts.

Share this post


Link to post
Share on other sites
If you use glu to upload your texture image, it will re-sample it, and it'll do a poor and slow job. You're much better off uploading the image yourself (using TexSubImage()) and calculating MIP maps yourself (if you need then, which you do for 3D stuff because it makes things render faster, but not for 2D stuff, as you're 1:1).

Thus, if you want a 400x400 image, you allocate a 512x512 texture, and TexSubImage to the lower-left 400x400 pixels of that. Then you use the texture coordinates 0 and (400.0/512.0) for low/left and top/right respectively. If your ortho is set up to be one unit per pixel, then this will give you crisp images, even if you use LINEAR filtering, because it'll sample perfectly at the center of each texel.

If you get small imperfections, you can reduce them by setting filtering to NEAREST, but that shouldn't be necessary -- if you get it RIGHT.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this