Skip to main content
GameDev.net gamedev.net
🔒 Locked

Repeating Textures

Started by TempHolder Aug 1, 2005 at 6:19 PM 3 replies 700+ views
Original Post
TempHolder
TempHolder
Hey Iam entering the Gamedev contest, Ive been having some problems with my textures repeating, I know this is possible for I have done it before, I have 1 HUGE quad that represents the sea and instead of it stretching the Water texture to its boundaries I want it to repeat it so it looks alot nice But my code Doesnt repeat it at all!. It just stretches it can anyone tell me what I should be doing/am doing wrong? This is my code ------------------------------------------------- unsigned int BMPTexture_Repeat(char *filename) { unsigned int Texture; unsigned char *bmpImg; BITMAPINFOHEADER bmpInfoHeader; bmpImg = LoadBitmapFile(filename, &bmpInfoHeader); glGenTextures(1, &Texture); glBindTexture(GL_TEXTURE_2D, Texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); GL_UNSIGNED_BYTE, bmpImg); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, bmpInfoHeader.biWidth, bmpInfoHeader.biHeight, GL_RGB, GL_UNSIGNED_BYTE, bmpImg); return Texture; } ---------------------- Thank you and hope to hear from anyone who knows how to fix this soon
Enigma
Enigma
What are your texture coordinates? [0..1] will scale your texture across the entire surface, [0..2]/[-1..1] or equivalent will tile it twice, [0..4]/[-2..2] or equivalent will tile it three times, etc.

Enigma
pi_equals_3
pi_equals_3
Generating extra points to make a grid would not be the way to go.

If your water is just a single flat polygon, then do as Enigma said and tile the texture with texture coordinates larger than 1.

Going with the AP's suggestion (if I understood what he was saying right) you'd be dividing your single polygon ocean into thousands of polygons and slowing down your game.
Kincaid
Kincaid
I mostly keep it under 30x30 quads, which renders quite nicely. also, true, many quads cause programs to slow down, but the advantage i was getting at, is that it's very easy to texture the water using such an class, and repeating as much as you want, or even cooler tricks of texture warping are made easy.
It's the same as sais before, with coordinates above one for reapating but it very easy to handle this way.
The water an sich can still be one quad, no problem, your grid of texture coordinates holds something else, aside from the water, but easy to combine with the water. After finishing te water, you probably get to one function of some sort which will send some kind of sinus wave through the grid, but from here on out, I start using shaders to get the wave itself. Your texture-coordinate-grid is from there-on out static (i guess) so this wont affect your speeds

by the way, i was the AP :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.