[DerelictSDL] SDL_RenderCopy does not accept optional arguements when written in a file aside from main

Jack via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 24 01:41:39 PST 2015


So I have separated my texture rendering methods in another file 
and have run into a problem hence the title name.

#main.d
----------

void render()
{
SDL_RenderClear(renderTarget);
renderSprite(renderTarget);
SDL_RenderPresent(renderTarget);
}
----------
#other_file.d
-----------
void renderSprite(SDL_Renderer _renderTarget)
{

SDL_Texture texture = SDL_CreateTextureFromSurface(_renderTarget, 
IMG_Load("image.png"));

SDL_RenderCopy(_renderTarget,texture, null,null);
}
----------

Error: cannot implicitly convert expression (null) of type 
typeof(null) to SDL_Rect
Error: cannot implicitly convert expression (null) of type 
typeof(null) to SDL_Rect

=====================
But when I do this:

#main.d
-------------------

void render()
{
SDL_RenderClear(renderTarget);
SDL_RenderCopy(renderTarget,texture,null,null);
SDL_RenderPresent(renderTarget);
}
--------------------

It works with no problem. I've DerelictSDL2.load and SDL_Init 
already.
So is this a bug or am I doing something wrong here?


More information about the Digitalmars-d-learn mailing list