sdl - SDL2 texture repeat / wrapping property -
I want to use texture repeats with SDL2 (SDL_RenderCopy), and how I can not find it by repeating the texture That texture coars have to be given twice in the shape of the texture and it is tiled twice on the surface like this:
How do anyone know how to do this in the SDL? Do I Need To Use Open GL Functions?
Thank you,
This is not the ideal solution, but if you are using OpenGL functions Do not want to go down the route to use:
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, DEFAULT_TEXTURE_WRAP); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, DEFAULT_TEXTURE_WRAP);
Then you can calculate the source and destination sequences on the fly as you attract. For example, think that you have a texture that is 100x100 and a screen drawing area is 150x150. When starting from the top you will see that you can fit the full text in the first call
SDL_Rect dest = {0,100,100} SDL_RenderCopy (renderer, texture, faucet, and amp;); --------- | | | | | | ------ | | | ---------
So now you can see that you only have to stretch the texture width of 50 pixels, but still the full height and point should start with 100
SDL_Rect src = {0,50,100} SDL_Rect dest = {100,0,50,100} SDL_RenderCopy (Renderer, Texture, & src, & amp;;); --------- | | | | | | -------- | | | ---------
You can clear the calculation for that repetition of the work and for you to work. As I said it is not ideal, but this is an option.
Comments
Post a Comment