更新时间:2023-11-09 12:04:22
您将Image.png *(或其他格式)传递到纹理上,然后将纹理放置在表面"上(可以使用此),然后将其传递到渲染器.因此,您要做的就是更改剪辑和纹理,然后按!RIGHT ORDER将其传递给Renderer!
You pass an Image.png*(or other format) onto a Texture, Then you place the Texture on a "surface"(you can clip the texture with this) which is then passed onto a Renderer. So, all you have to do is change the clip and texture, and pass it to the Renderer In the !RIGHT ORDER!
示例:您将首先渲染背景,然后渲染精灵,然后渲染效果,等等.
Example: You would Render the background first, and then Sprites, and then Effects, etc...
我希望这会有所帮助.
下面的代码是从LAZY FOO网站上获得的!检查它非常有用,以便开始SDL2
BELOW CODE WAS TAKEN FROM LAZY FOO WEBSITE!! CHECK IT OUT VERY USEFULL TO BEGIN SDL2
http://lazyfoo.net/tutorials/SDL/07_texture_loading_and_rendering/index.php
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
}
//Clear the last frame
SDL_RenderClear( gRenderer );
//Render texture to screen
SDL_RenderCopy( gRenderer, gTexture1, NULL, NULL );
SDL_RenderCopy( gRenderer, gTexture2, NULL, NULL );
SDL_RenderCopy( gRenderer, gTexture3, NULL, NULL );
SDL_RenderCopy( gRenderer, gTexture4, NULL, NULL );
//Update screen
SDL_RenderPresent( gRenderer );}
如上面的代码所示,
SDL_RenderCopy使用SAME渲染器渲染不同的纹理.因此,您需要的是许多纹理.
as you can see in the above CODE the SDL_RenderCopy uses the SAME renderer for RENDERING different TEXTURES. so what you need, is, many textures.
我确定可能会使用多个渲染器,但我不知道为什么要这么做?
I'm certain there might be a use for multiple renderers but I have no idea why you would do that?
//第二天// 所以我检查了一下,发现如果您有多窗口应用程序,则可以使用多个渲染器.
//the next day// So I checked this out, and Saw that if you have a Multiple Window Application you Can use Multiple renderers.