The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
compiling SDL2 from source for Android
Wins_Vefa


Joined: 15 Sep 2013
Posts: 8
Hi.
There is a cool tool to compile android programs called ‘Nsight Tegra’
It designed to work with Visual Studio 2012

Now I am trying to build SDL2.201 from source but getting following errors:

Code:

SDL2-2.0.1\src\render\opengles\SDL_render_gles.c(203): includes this header: 0:
SDL2-2.0.1/src/render/opengles/SDL_glesfuncs.h: In function 'GLES_LoadFunctions':
SDL2-2.0.1\src\render\opengles\SDL_glesfuncs.h(8,1): error : 'glBlendFuncSeparateOES' undeclared (first use in this function)
SDL2-2.0.1\src\render\opengles\SDL_glesfuncs.h(8,1):  note: each undeclared identifier is reported only once for each function it appears in
SDL2-2.0.1\src\render\opengles\SDL_glesfuncs.h(16,1): error : 'glDrawTexfOES' undeclared (first use in this function)
SDL2-2.0.1\src\render\opengles\SDL_glesfuncs.h(20,1): error : 'glGenFramebuffersOES' undeclared (first use in this function)
SDL2-2.0.1\src\render\opengles\SDL_glesfuncs.h(38,1): error : 'glBindFramebufferOES' undeclared (first use in this function)
SDL2-2.0.1\src\render\opengles\SDL_glesfuncs.h(39,1): error : 'glFramebufferTexture2DOES' undeclared (first use in this function)
SDL2-2.0.1\src\render\opengles\SDL_glesfuncs.h(40,1): error : 'glCheckFramebufferStatusOES' undeclared (first use in this function)
SDL2-2.0.1\src\render\opengles\SDL_glesfuncs.h(45,1): error : 'glDeleteFramebuffersOES' undeclared (first use in this function)


As I understand it has to be smth with OpenGl.
But none of the followings includes help me
#include "gles\gl.h"
#include "gles2\gl2.h"



What am I missing?
Wins_Vefa


Joined: 15 Sep 2013
Posts: 8
problem solved.

I searched for where to add

Code:

#define GL_GLEXT_PROTOTYPES


Util just added it to glext.h itself at the header.
Don't know if it will be correct but the errors are gone.


Now next problem:

Code:

\JNI\SRC\HAPTIC\DUMMY\SDL_SYSHAPTIC.C is missing it's .d file: Tegra-Android\Debug\SDL_syshaptic.d
\JNI\SRC\HAPTIC\LINUX\SDL_SYSHAPTIC.C is missing it's .d file: Tegra-Android\Debug\SDL_syshaptic.d
\JNI\SRC\HAPTIC\WINDOWS\SDL_SYSHAPTIC.C is missing it's .d file: Tegra-Android\Debug\SDL_syshaptic.d
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticInit':
  \jni\src\haptic\SDL_haptic.c(42):  undefined reference to `SDL_SYS_HapticInit'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticName':
  jni\src\haptic\SDL_haptic.c(108):  undefined reference to `SDL_SYS_HapticName'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticOpen':
  jni\src\haptic\SDL_haptic.c(147):  undefined reference to `SDL_SYS_HapticOpen'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_MouseIsHaptic':
  jni\src\haptic\SDL_haptic.c(219):  undefined reference to `SDL_SYS_HapticMouse'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticOpenFromMouse':
  i\src\haptic\SDL_haptic.c(233):  undefined reference to `SDL_SYS_HapticMouse'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_JoystickIsHaptic':
  \jni\src\haptic\SDL_haptic.c(257):  undefined reference to `SDL_SYS_JoystickIsHaptic'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticOpenFromJoystick':
  \jni\src\haptic\SDL_haptic.c(291):  undefined reference to `SDL_SYS_JoystickIsHaptic'
  \jni\src\haptic\SDL_haptic.c(298):  undefined reference to `SDL_SYS_JoystickSameHaptic'
  \jni\src\haptic\SDL_haptic.c(315):  undefined reference to `SDL_SYS_HapticOpenFromJoystick'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticClose':
 \jni\src\haptic\SDL_haptic.c(359):  undefined reference to `SDL_SYS_HapticClose'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticQuit':
 \jni\src\haptic\SDL_haptic.c(381):  undefined reference to `SDL_SYS_HapticQuit'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticNewEffect':
  \jni\src\haptic\SDL_haptic.c(480):  undefined reference to `SDL_SYS_HapticNewEffect'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticUpdateEffect':
  \jni\src\haptic\SDL_haptic.c(524):  undefined reference to `SDL_SYS_HapticUpdateEffect'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticRunEffect':
  \jni\src\haptic\SDL_haptic.c(546):  undefined reference to `SDL_SYS_HapticRunEffect'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticStopEffect':
  \jni\src\haptic\SDL_haptic.c(565):  undefined reference to `SDL_SYS_HapticStopEffect'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticDestroyEffect':
  \jni\src\haptic\SDL_haptic.c(587):  undefined reference to `SDL_SYS_HapticDestroyEffect'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticGetEffectStatus':
  \jni\src\haptic\SDL_haptic.c(604):  undefined reference to `SDL_SYS_HapticGetEffectStatus'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticSetGain':
  \jni\src\haptic\SDL_haptic.c(645):  undefined reference to `SDL_SYS_HapticSetGain'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticSetAutocenter':
  \jni\src\haptic\SDL_haptic.c(670):  undefined reference to `SDL_SYS_HapticSetAutocenter'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticPause':
  \jni\src\haptic\SDL_haptic.c(691):  undefined reference to `SDL_SYS_HapticPause'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticUnpause':
 \jni\src\haptic\SDL_haptic.c(708):  undefined reference to `SDL_SYS_HapticUnpause'
  Tegra-Android/Debug/SDL_haptic.o: In function `SDL_HapticStopAll':
  \jni\src\haptic\SDL_haptic.c(721):  undefined reference to `SDL_SYS_HapticStopAll'
collect2.exe : error : ld returned 1 exit status
Wins_Vefa


Joined: 15 Sep 2013
Posts: 8
problem solved

For some reason SDL_haptic.c didn't saw SDL_SYS_haptic.c defined functions, though all flags were enabled.
I just added SDL_sys_haptic.c contents to SDL_haptic.c in above and it is now compiling.

Yeah, fine.


next problem

.apk application does not even installing on a device giving an error.
Wins_Vefa


Joined: 15 Sep 2013
Posts: 8
problem solved.

That was due to .apk key certification.
I should have to set up signing option in my compiler fot outgoing *.apk.


And Now i am FINALY get SDL to run on Android. !!!

Here the next problem:

Code:
"Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?"


This error message returned by SDL_GetError();
How to draw a square using SDL 2.0?
Andrew Havens
Guest

Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:
//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:
error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew
How to draw a square using SDL 2.0?
MrOzBarry


Joined: 26 Jun 2010
Posts: 620
SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.

Quote:

SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));



That should fix it for you, I think.

On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:

Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:

//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:

error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

How to draw a square using SDL 2.0?
MrOzBarry


Joined: 26 Jun 2010
Posts: 620
Also, you may want to look into the Renderer API Smile


On Fri, Nov 1, 2013 at 12:57 PM, Alex Barry wrote:
Quote:
SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.

Quote:

SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));



That should fix it for you, I think.

On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:


Quote:

Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:

//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:

error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





How to draw a square using SDL 2.0?
Andrew Havens
Guest

Unfortunately, that did not work. I get this error:


error: incompatible type for argument 2 of ‘SDL_FillRect’


Andrew




On November 1, 2013 at 9:57:43 AM, Alex Barry ([email]//[/email])) wrote:
Quote:
SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.

Quote:

SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));



That should fix it for you, I think.

On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:

Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:

//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));


It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:

error: expected expression before ‘SDL_Rect’


How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


How to draw a square using SDL 2.0?
Mason Wheeler
Guest

That's because it wants a pointer to the rect, not the rect itself.

Mason




On Friday, November 1, 2013 10:19 AM, Andrew Havens wrote:

Unfortunately, that did not work. I get this error:

error: incompatible type for argument 2 of ‘SDL_FillRect’

Andrew

On November 1, 2013 at 9:57:43 AM, Alex Barry ([email]//[/email])) wrote:


SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.
Quote:
SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));


That should fix it for you, I think. On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:
Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:
//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:
error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________SDL mailinghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
How to draw a square using SDL 2.0?
arosian


Joined: 22 Oct 2013
Posts: 13
Andrew,
Your questions indicate that you aren't very familiar with C. You should first begin by getting acquainted with the programming language basics before utilizing a framework like SDL.
You can also check out the documentation on the SDL wiki.
Justin On Nov 1, 2013 1:19 PM, "Andrew Havens" wrote:
Quote:
Unfortunately, that did not work. I get this error:


error: incompatible type for argument 2 of ‘SDL_FillRect’


Andrew




On November 1, 2013 at 9:57:43 AM, Alex Barry ([email]//[/email])) wrote:
Quote:
SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.

Quote:


SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));



That should fix it for you, I think.

On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:

Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:


//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));


It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:


error: expected expression before ‘SDL_Rect’


How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

How to draw a square using SDL 2.0?
Andrew Havens
Guest

I thought that prefixing a variable with an asterisk would create a pointer. Would this be the same thing?


SDL_Rect *rect;
…
SDL_FillRect(screenSurface, rect, …)


It's true, I'm not super familiar with C. I'm still getting used to the syntax. Unfortunately, the SDL wiki doesn't provide many basic examples.


-- Andrew








On November 1, 2013 at 10:30:32 AM, Mason Wheeler ([email]//[/email])) wrote:
Quote:
That's because it wants a pointer to the rect, not the rect itself.

Mason




On Friday, November 1, 2013 10:19 AM, Andrew Havens wrote:

Unfortunately, that did not work. I get this error:

error: incompatible type for argument 2 of ‘SDL_FillRect’

Andrew

On November 1, 2013 at 9:57:43 AM, Alex Barry ([email]//[/email])) wrote:


SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.
Quote:

SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));


That should fix it for you, I think. On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:
Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:

//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:

error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


How to draw a square using SDL 2.0?
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
My first advice is...either look for a C tutorial and take some time to learn the language, or pick one of the scripting languages bindings for SDL (Python comes to mind) and use that, it's a much easier way to get started.

Having said that, what you probably need to do is:


SDL_Rect rect = {0,0,100,100};
SDL_FillRect(screenSurface, &rect, somecolor);


(You can't use a pointer that's not been initialized, I don't quite remember if you get a warning or an error from the compiler, or just a nice crash).


2013/11/1 Andrew Havens
Quote:
I thought that prefixing a variable with an asterisk would create a pointer. Would this be the same thing?


SDL_Rect *rect;

SDL_FillRect(screenSurface, rect, …)


It's true, I'm not super familiar with C. I'm still getting used to the syntax. Unfortunately, the SDL wiki doesn't provide many basic examples.


-- Andrew








On November 1, 2013 at 10:30:32 AM, Mason Wheeler ([email]//[/email])) wrote:
Quote:
That's because it wants a pointer to the rect, not the rect itself.

Mason




On Friday, November 1, 2013 10:19 AM, Andrew Havens wrote:

Unfortunately, that did not work. I get this error:

error: incompatible type for argument 2 of ‘SDL_FillRect’

Andrew

On November 1, 2013 at 9:57:43 AM, Alex Barry ([email]//[/email])) wrote:


SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.
Quote:

SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));


That should fix it for you, I think. On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:
Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:

//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:

error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
Gabriel.
How to draw a square using SDL 2.0?
MrOzBarry


Joined: 26 Jun 2010
Posts: 620
Yes and no.  Using the asterisk creates a pointer, but if you don't assign it anything, it points wherever the compiler or runtime environment decides.Dereferencing a non-pointer variable (using '&') is good in this case because if you used a pointer directly, then you are responsible for allocating and freeing the memory for that variable.  If it's not a pointer, then the runtime environment deals with memory management for you, which is always preferable.



On Fri, Nov 1, 2013 at 1:39 PM, Andrew Havens wrote:
Quote:
I thought that prefixing a variable with an asterisk would create a pointer. Would this be the same thing?


SDL_Rect *rect;

SDL_FillRect(screenSurface, rect, …)


It's true, I'm not super familiar with C. I'm still getting used to the syntax. Unfortunately, the SDL wiki doesn't provide many basic examples.


-- Andrew








On November 1, 2013 at 10:30:32 AM, Mason Wheeler ([email]//[/email])) wrote:
Quote:
That's because it wants a pointer to the rect, not the rect itself.

Mason




On Friday, November 1, 2013 10:19 AM, Andrew Havens wrote:

Unfortunately, that did not work. I get this error:

error: incompatible type for argument 2 of ‘SDL_FillRect’

Andrew

On November 1, 2013 at 9:57:43 AM, Alex Barry ([email]//[/email])) wrote:


SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.
Quote:

SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));


That should fix it for you, I think. On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:
Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:

//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:

error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org






_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

How to draw a square using SDL 2.0?
David Olofson
Guest

The SDL Wiki is about using the SDL API, primarily aimed at C, C++ and
similar languages. It doesn't cover the basics of any specific
language - not ever C.

You're probably better off learning C from books, tutorials etc
specifically aimed at that. That said, C is a rather low level
language, and there will be plenty of frustration if you don't really
understand what you're doing. You might be better off trying a
language a bit further from assembly language, unless you enjoy doing
things the hard way. Wink

On Fri, Nov 1, 2013 at 6:39 PM, Andrew Havens wrote:
Quote:
I thought that prefixing a variable with an asterisk would create a pointer.
Would this be the same thing?

SDL_Rect *rect;

SDL_FillRect(screenSurface, rect, …)

It's true, I'm not super familiar with C. I'm still getting used to the
syntax. Unfortunately, the SDL wiki doesn't provide many basic examples.

-- Andrew


On November 1, 2013 at 10:30:32 AM, Mason Wheeler
wrote:

That's because it wants a pointer to the rect, not the rect itself.

Mason



On Friday, November 1, 2013 10:19 AM, Andrew Havens
wrote:
Unfortunately, that did not work. I get this error:

error: incompatible type for argument 2 of ‘SDL_FillRect’

Andrew

On November 1, 2013 at 9:57:43 AM, Alex Barry wrote:

SDL_Rect is a struct, and in C, iirc, you can't use default constructors on
structs.

SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00,
0x00, 0x00));


That should fix it for you, I think.

On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:

Hello,
I'm getting started with SDL and am having a hard time finding tutorials
that are updated to work with version 2.0. I've got the basic setup/teardown
working, now I would like to do something simple like draw a square on the
screen. The example that I copied is not working.

//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF,
0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100),
SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:

error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
| http://consulting.olofson.net http://olofsonarcade.com |
'---------------------------------------------------------------------'
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
How to draw a square using SDL 2.0?
Andrew Havens
Guest

Quote:
Yes and no. Using the asterisk creates a pointer, but if you don't assign it anything, it points wherever the compiler or runtime environment decides.Dereferencing a non-pointer variable (using '&') is good in this case because if you used a pointer directly, then you are responsible for allocating and freeing the memory for that variable. If it's not a pointer, then the runtime environment deals with memory management for you, which is always preferable.


Ah, that makes a lot of sense. Thanks!


P.S. Yes, I know C is a lower-level language than Python. I have plenty of experience with higher level languages using SDL and similar libraries. I have been learning C over the past month from online tutorials. I know I'm going to make mistakes but I'm ready to dive into writing C code even if I don't understand everything yet. That's how you learn. I understand the wiki is API documentation and not tutorials, but examples are helpful to see how the various components work together, rather than referenced in isolation.




-- Andrew




On November 1, 2013 at 10:49:24 AM, Alex Barry ([email]//[/email])) wrote:
Quote:
Yes and no. Using the asterisk creates a pointer, but if you don't assign it anything, it points wherever the compiler or runtime environment decides. Dereferencing a non-pointer variable (using '&') is good in this case because if you used a pointer directly, then you are responsible for allocating and freeing the memory for that variable. If it's not a pointer, then the runtime environment deals with memory management for you, which is always preferable.



On Fri, Nov 1, 2013 at 1:39 PM, Andrew Havens wrote:
Quote:
I thought that prefixing a variable with an asterisk would create a pointer. Would this be the same thing?


SDL_Rect *rect;
…
SDL_FillRect(screenSurface, rect, …)


It's true, I'm not super familiar with C. I'm still getting used to the syntax. Unfortunately, the SDL wiki doesn't provide many basic examples.


-- Andrew








On November 1, 2013 at 10:30:32 AM, Mason Wheeler ([email]//[/email])) wrote:
Quote:
That's because it wants a pointer to the rect, not the rect itself.

Mason




On Friday, November 1, 2013 10:19 AM, Andrew Havens wrote:

Unfortunately, that did not work. I get this error:

error: incompatible type for argument 2 of ‘SDL_FillRect’

Andrew

On November 1, 2013 at 9:57:43 AM, Alex Barry ([email]//[/email])) wrote:


SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.
Quote:

SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));


That should fix it for you, I think. On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:
Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:

//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:

error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org






_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Wins_Vefa


Joined: 15 Sep 2013
Posts: 8
Oh, nicely done, guys.

Nevermind. SDL2 on android compilation issue was due to some kind of wrong options importing method to Insight Tegra.
Check carefully to import existing Android project and KEEEP it's build options / configurations files!

YAY, my application running on my phone!
How to draw a square using SDL 2.0?
Andreas Schiffler
Guest

See also this handy resource on C: http://c-faq.com

On 11/1/2013 11:01 AM, Andrew Havens wrote:

Quote:
Quote:
Yes and no. Using the asterisk creates a pointer, but if you don't assign it anything, it points wherever the compiler or runtime environment decides. Dereferencing a non-pointer variable (using '&') is good in this case because if you used a pointer directly, then you are responsible for allocating and freeing the memory for that variable. If it's not a pointer, then the runtime environment deals with memory management for you, which is always preferable.


Ah, that makes a lot of sense. Thanks!


P.S. Yes, I know C is a lower-level language than Python. I have plenty of experience with higher level languages using SDL and similar libraries. I have been learning C over the past month from online tutorials. I know I'm going to make mistakes but I'm ready to dive into writing C code even if I don't understand everything yet. That's how you learn. I understand the wiki is API documentation and not tutorials, but examples are helpful to see how the various components work together, rather than referenced in isolation.




-- Andrew




On November 1, 2013 at 10:49:24 AM, Alex Barry ([email]//[/email])) wrote:
Quote:
Yes and no. Using the asterisk creates a pointer, but if you don't assign it anything, it points wherever the compiler or runtime environment decides. Dereferencing a non-pointer variable (using '&') is good in this case because if you used a pointer directly, then you are responsible for allocating and freeing the memory for that variable. If it's not a pointer, then the runtime environment deals with memory management for you, which is always preferable.



On Fri, Nov 1, 2013 at 1:39 PM, Andrew Havens wrote:
Quote:
I thought that prefixing a variable with an asterisk would create a pointer. Would this be the same thing?


SDL_Rect *rect;
…
SDL_FillRect(screenSurface, rect, …)


It's true, I'm not super familiar with C. I'm still getting used to the syntax. Unfortunately, the SDL wiki doesn't provide many basic examples.


-- Andrew








On November 1, 2013 at 10:30:32 AM, Mason Wheeler ([email]//[/email])) wrote:
Quote:
That's because it wants a pointer to the rect, not the rect itself.

Mason




On Friday, November 1, 2013 10:19 AM, Andrew Havens wrote:

Unfortunately, that did not work. I get this error:

error: incompatible type for argument 2 of ‘SDL_FillRect’

Andrew

On November 1, 2013 at 9:57:43 AM, Alex Barry ([email]//[/email])) wrote:


SDL_Rect is a struct, and in C, iirc, you can't use default constructors on structs.
Quote:
SDL_Rect rect; //(0,0,100,100)
rect.x = 0;
rect.y = 0;
rect.w = 100;
rect.h = 100;
SDL_FillRect(screenSurface, rect, SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));


That should fix it for you, I think. On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
Quote:
Hello,
I'm getting started with SDL and am having a hard time finding tutorials that are updated to work with version 2.0. I've got the basic setup/teardown working, now I would like to do something simple like draw a square on the screen. The example that I copied is not working.
Quote:
//Get window surface
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);

//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

//create a square
SDL_FillRect(screenSurface, SDL_Rect(0,0,100,100), SDL_MapRGB(screenSurface->format, 0x00, 0x00, 0x00));

It correctly fills the screen white, but fails on the call to SDL_Rect:
Quote:
error: expected expression before ‘SDL_Rect’

How do I correctly draw a square using SDL 2.0?
Thanks,
-- Andrew

_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org






_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




Quote:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
compiling SDL2 from source for Android
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Yay! Smile


On Fri, Nov 1, 2013 at 4:27 PM, Wins_Vefa wrote:
Quote:
Oh, nicely done, guys.

Nevermind. SDL2 on android compilation issue was due to some kind of wrong options importing method to Insight Tegra.
Check carefully to import existing Android project and KEEEP it's build options / configurations files!

YAY, my application running on my phone!


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org