Re: Equivalent to nullptr

2017-05-16 Thread Leonardo via Digitalmars-d-learn

On Thursday, 4 May 2017 at 04:34:40 UTC, Stanislav Blinov wrote:
In the meantime, you can get around the issue by redeclaring 
the function with another name and loading it manually just 
after calling DerelictSDL2.load():



import derelict.sdl2.sdl;

__gshared SDL_bool function (const(SDL_Point)*, int, 
const(SDL_Rect)*, SDL_Rect*) SDL_EnclosePoints_;


void main()
{
   DerelictSDL2.load();
   DerelictSDL2.bindFunc(cast(void**)_EnclosePoints_, 
"SDL_EnclosePoints");

   // ...
}


Now you'd need to call SDL_EnclosePoints_ instead of 
SDL_EnclosePoints.


Thank you.


Re: Equivalent to nullptr

2017-05-03 Thread Stanislav Blinov via Digitalmars-d-learn
In the meantime, you can get around the issue by redeclaring the 
function with another name and loading it manually just after 
calling DerelictSDL2.load():



import derelict.sdl2.sdl;

__gshared SDL_bool function (const(SDL_Point)*, int, 
const(SDL_Rect)*, SDL_Rect*) SDL_EnclosePoints_;


void main()
{
   DerelictSDL2.load();
   DerelictSDL2.bindFunc(cast(void**)_EnclosePoints_, 
"SDL_EnclosePoints");

   // ...
}


Now you'd need to call SDL_EnclosePoints_ instead of 
SDL_EnclosePoints.


Re: Equivalent to nullptr

2017-05-03 Thread Stanislav Blinov via Digitalmars-d-learn

On Thursday, 4 May 2017 at 03:59:36 UTC, Leonardo wrote:

On Thursday, 4 May 2017 at 02:45:30 UTC, Adam D. Ruppe wrote:

On Thursday, 4 May 2017 at 02:12:13 UTC, Leonardo wrote:

nullptr word. How I use this?


Does it work if you just use `null` ?


No.

First I got: source/app.d(45,69): Error: expression 
(*SDL_EnclosePoints)(& mousePos, 1, , null) of type 
void does not have a boolean value


then I change to:
  event.button.button == SDL_BUTTON_LEFT && SDL_TRUE == 
SDL_EnclosePoints(, 1,  , null)


and got:
source/app.d(45,81): Error: void has no value
source/app.d(45,52): Error: incompatible types for ((SDL_TRUE) 
== ((*SDL_EnclosePoints)(& mousePos, 1, , null))): 
'int' and 'void'


Ahh, looks to be a bug in DerelictSDL2. null will work for that 
last parameter, the problem is that the function should be 
returning an SDL_bool, but in Derelict it's declared as returning 
void: that's what the error message is saying.
I'll file a report, but with the conference underway, it may take 
a while to get fixed.


Re: Equivalent to nullptr

2017-05-03 Thread Leonardo via Digitalmars-d-learn

On Thursday, 4 May 2017 at 02:45:30 UTC, Adam D. Ruppe wrote:

On Thursday, 4 May 2017 at 02:12:13 UTC, Leonardo wrote:

nullptr word. How I use this?


Does it work if you just use `null` ?


No.

First I got: source/app.d(45,69): Error: expression 
(*SDL_EnclosePoints)(& mousePos, 1, , null) of type 
void does not have a boolean value


then I change to:
  event.button.button == SDL_BUTTON_LEFT && SDL_TRUE == 
SDL_EnclosePoints(, 1,  , null)


and got:
source/app.d(45,81): Error: void has no value
source/app.d(45,52): Error: incompatible types for ((SDL_TRUE) == 
((*SDL_EnclosePoints)(& mousePos, 1, , null))): 'int' 
and 'void'




Re: Equivalent to nullptr

2017-05-03 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 4 May 2017 at 02:12:13 UTC, Leonardo wrote:

nullptr word. How I use this?


Does it work if you just use `null` ?


Equivalent to nullptr

2017-05-03 Thread Leonardo via Digitalmars-d-learn
I was trying to use Derelict-SDL2 library, and the tutorial do 
this code below, as C++ code has nullptr word. How I use this?



-
struct Ball
{
  SDL_Rect bbox = {0, 0, 100, 100};
  SDL_Point vel = {1, 1};
}
-
case SDL_MOUSEBUTTONDOWN:
{
  SDL_Point mousePos = {event.button.x, event.button.y};
  if(event.button.button == SDL_BUTTON_LEFT && 
SDL_EnclosePoints(, 1, , nullptr) )

  {
SDL_Log("CLICK");
if(abs(ball.vel.x) < 32)
{
  ball.vel.x *= 2;
  ball.vel.y *= 2;
}
  }
  break;
}