speartip
2017-02-08 01:20:30 UTC
Hi,
I am struggling with some pretty straight forward c/c++ & SDL code. But I am not feeling the straightforwardness of it though. I don't know if its a c++ issue or SDL. I try to call SDL fx code from an external .cpp/.h. I am trying to make these reusable and to release main from clutter. Everything runs smoothly until the second block:
Code:
int horizontal = 0;
int vertical = 0;
SDL_DisplayMode dm;
cout<<"Gobot call:";
gobot(horizontal, vertical,&dm);
Code:
#ifndef GOBOT_CPP_
#define GOBOT_CPP_
#include "SDL.h"
#include "gobot.h"
int gobot( int &horizontal, int &vertical, &dm )
{
//SDL_GetDesktopDisplayMode(0, &dm);
horizontal = dm->w;
vertical = dm->h;
return 0;
}
//cout<<"Resolution: x = "<<Width<<" y = "<<Height<<endl;
#endif /* GOBOT_CPP_ */
Code:
#ifndef GOBOT_H_
#define GOBOT_H_
#include"SDL.h"
int SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * dm);
int gobot(int horizontal, int vertical, SDL_DisplayMode * dm);
#endif /* GOBOT_H_ */
error:
In function 'int SDL_main(int, char**)':
..\src\SpearTip.cpp:50:35: error: cannot convert 'SDL_DisplayMode' to 'SDL_DisplayMode*' for argument '3' to 'int gobot(int, int, SDL_DisplayMode*)'
gobot(horizontal, vertical, dm);
Thanks
I am struggling with some pretty straight forward c/c++ & SDL code. But I am not feeling the straightforwardness of it though. I don't know if its a c++ issue or SDL. I try to call SDL fx code from an external .cpp/.h. I am trying to make these reusable and to release main from clutter. Everything runs smoothly until the second block:
Code:
int horizontal = 0;
int vertical = 0;
SDL_DisplayMode dm;
cout<<"Gobot call:";
gobot(horizontal, vertical,&dm);
Code:
#ifndef GOBOT_CPP_
#define GOBOT_CPP_
#include "SDL.h"
#include "gobot.h"
int gobot( int &horizontal, int &vertical, &dm )
{
//SDL_GetDesktopDisplayMode(0, &dm);
horizontal = dm->w;
vertical = dm->h;
return 0;
}
//cout<<"Resolution: x = "<<Width<<" y = "<<Height<<endl;
#endif /* GOBOT_CPP_ */
Code:
#ifndef GOBOT_H_
#define GOBOT_H_
#include"SDL.h"
int SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * dm);
int gobot(int horizontal, int vertical, SDL_DisplayMode * dm);
#endif /* GOBOT_H_ */
error:
In function 'int SDL_main(int, char**)':
..\src\SpearTip.cpp:50:35: error: cannot convert 'SDL_DisplayMode' to 'SDL_DisplayMode*' for argument '3' to 'int gobot(int, int, SDL_DisplayMode*)'
gobot(horizontal, vertical, dm);
Thanks