Function parameter call by reference?

General FreeBASIC programming questions.
Post Reply
h4tt3n
Posts: 698
Joined: Oct 22, 2005 21:12
Location: Denmark

Function parameter call by reference?

Post by h4tt3n »

Hello folks, while translating this SDL2 tutorial to fb, I've run into a challenge.

Code: Select all

/**
* Draw an SDL_Texture to an SDL_Renderer at position x, y, preserving
* the texture's width and height
* @param tex The source texture we want to draw
* @param ren The renderer we want to draw to
* @param x The x coordinate to draw to
* @param y The y coordinate to draw to
*/
void renderTexture(SDL_Texture *tex, SDL_Renderer *ren, int x, int y){
	int w, h;
	SDL_QueryTexture(tex, NULL, NULL, &w, &h);
	renderTexture(tex, ren, x, y, w, h);
}
How do I pass w and h "by reference" in the SDL_QueryTexture function? What's the FB analogy to &w, &h?
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Function parameter call by reference?

Post by fxm »

h4tt3n
Posts: 698
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: Function parameter call by reference?

Post by h4tt3n »

Thanks. This confirms what I thought, that it should simply be @w, @h, but this returns a suspicious pointer warning and doesn't work. So, I'm guessing there may be a small error either in the original code or in the FB SDL header.
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Function parameter call by reference?

Post by fxm »

Warning:
C 'int' is always a 32-bit, thus corresponding to a FB 'Long' (not FB 'Integer').
Post Reply