Function parameter call by reference?

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

Function parameter call by reference?

Postby h4tt3n » Sep 22, 2019 8:44

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
Posts: 9912
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Function parameter call by reference?

Postby fxm » Sep 22, 2019 9:10

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

Re: Function parameter call by reference?

Postby h4tt3n » Sep 22, 2019 9:23

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
Posts: 9912
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Function parameter call by reference?

Postby fxm » Sep 22, 2019 9:31

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

Return to “General”

Who is online

Users browsing this forum: albert and 7 guests