Advertisement

texture repeating

Started by February 21, 2003 07:54 AM
3 comments, last by soulspaceuk 22 years ago
hi i''m in the middle of writing some 3d stuff (after going through most of the tutorials & examples here - which were great btw - i didn''t know a thing about opengl 4 days ago.. hehe) but i''ve come across a problem - and i''m not really sure how to fix it.. i have a QUAD that i''m drawing, and I want a texture on it.. I have no problem having the texture on it when i have the texcoords as (0,0) (1,1) (0,1) and (1,0) - but i want the texture to repeat ie (0,0) (2,2) (0,2) (2,0) etc.. i thought that if i did that i''d see the texture on this face 4 times.. however, i just get it once in one corner and then see a stretched lines of just one row of the texture in the other 3 corners.. does anyone know how to fix this? is there some texture setting to allow repeating of textures? i tried doing a couple of searches but couldn''t find it.. thanks in advance jon
its got to do with ur texture clamping method. u're probably using clamp-to-edge or something along that line. Use the following code when u're initializing the textures:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);  


The last value (GL_REPEAT) denotes the repeating state u want. other values are GL_CLAMP and GL_CLAMP_TO_EDGE... i'm sure there's another one around that was introduced in an extension... but thats out of the topic :D

[edited by - crazee on February 21, 2003 9:09:50 AM]
- To learn, we share... Give some to take some -
Advertisement
just out of boredom, i''d like to add that u can also try leaving ur coordinates at [0..1] range and do the ''tiling'' by scaling the texture transformation matrix. not sure if the clamping affects the output, though, but its worth a shot.

just do a glMatrixMode(GL_TEXTURE)... and scale away
- To learn, we share... Give some to take some -
be careful with using the texture matrix as it can dramatically effect vertex throughput.

ie only use it if you really want/have to

| - Project-X - my mega project.. yup, still cracking along - | - adDeath - an ad blocker I made - | - email me - |
quote:

The last value (GL_REPEAT) denotes the repeating state u want. other values are GL_CLAMP and GL_CLAMP_TO_EDGE... i''m sure there''s another one around that was introduced in an extension...

The other one is GL_CLAMP_TO_BORDER. But be careful : neither GL_CLAMP_TO_EDGE nor GL_CLAMP_TO_BORDER is defined into OpenGL1.0 : you have to look if the extension is supported before using one of them.

quote:

just out of boredom, i''d like to add that u can also try leaving ur coordinates at [0..1] range and do the ''tiling'' by scaling the texture transformation matrix. not sure if the clamping affects the output, though, but its worth a shot

Yes it will be clamped.

This topic is closed to new replies.

Advertisement