Sign in to follow this  

Repeating Textures

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

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

Share this post


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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I allways use an Quadmap class which genereates all the points within an specified grid. So generating a gridsystem with texture coordinates keeps it very easy to use and to resize. Just generate your sea using some sort of grid class (which takes a width and a length and an number of quads in bort directions(resolution)).
Instantiate 1 class using water-width and -length. Instatiate another with width 1, and length 1 (texture coordintes).
By using one your texture will stretch over the, by using 100, it will repeat 100 times etc. etc.

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

This topic is 4518 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.

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