Compiling SDL2 from source for Android

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?

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 toSDL_SYS_HapticInit’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticName': jni\src\haptic\SDL_haptic.c(108): undefined reference toSDL_SYS_HapticName’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticOpen': jni\src\haptic\SDL_haptic.c(147): undefined reference toSDL_SYS_HapticOpen’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_MouseIsHaptic': jni\src\haptic\SDL_haptic.c(219): undefined reference toSDL_SYS_HapticMouse’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticOpenFromMouse': i\src\haptic\SDL_haptic.c(233): undefined reference toSDL_SYS_HapticMouse’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_JoystickIsHaptic': \jni\src\haptic\SDL_haptic.c(257): undefined reference toSDL_SYS_JoystickIsHaptic’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticOpenFromJoystick': \jni\src\haptic\SDL_haptic.c(291): undefined reference toSDL_SYS_JoystickIsHaptic’
\jni\src\haptic\SDL_haptic.c(298): undefined reference to SDL_SYS_JoystickSameHaptic' \jni\src\haptic\SDL_haptic.c(315): undefined reference toSDL_SYS_HapticOpenFromJoystick’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticClose': \jni\src\haptic\SDL_haptic.c(359): undefined reference toSDL_SYS_HapticClose’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticQuit': \jni\src\haptic\SDL_haptic.c(381): undefined reference toSDL_SYS_HapticQuit’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticNewEffect': \jni\src\haptic\SDL_haptic.c(480): undefined reference toSDL_SYS_HapticNewEffect’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticUpdateEffect': \jni\src\haptic\SDL_haptic.c(524): undefined reference toSDL_SYS_HapticUpdateEffect’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticRunEffect': \jni\src\haptic\SDL_haptic.c(546): undefined reference toSDL_SYS_HapticRunEffect’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticStopEffect': \jni\src\haptic\SDL_haptic.c(565): undefined reference toSDL_SYS_HapticStopEffect’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticDestroyEffect': \jni\src\haptic\SDL_haptic.c(587): undefined reference toSDL_SYS_HapticDestroyEffect’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticGetEffectStatus': \jni\src\haptic\SDL_haptic.c(604): undefined reference toSDL_SYS_HapticGetEffectStatus’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticSetGain': \jni\src\haptic\SDL_haptic.c(645): undefined reference toSDL_SYS_HapticSetGain’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticSetAutocenter': \jni\src\haptic\SDL_haptic.c(670): undefined reference toSDL_SYS_HapticSetAutocenter’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticPause': \jni\src\haptic\SDL_haptic.c(691): undefined reference toSDL_SYS_HapticPause’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticUnpause': \jni\src\haptic\SDL_haptic.c(708): undefined reference toSDL_SYS_HapticUnpause’
Tegra-Android/Debug/SDL_haptic.o: In function SDL_HapticStopAll': \jni\src\haptic\SDL_haptic.c(721): undefined reference toSDL_SYS_HapticStopAll’
collect2.exe : error : ld returned 1 exit status

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.

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();

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_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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Also, you may want to look into the Renderer API :)On Fri, Nov 1, 2013 at 12:57 PM, Alex Barry <@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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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

error: incompatible type for argument 2 of ?SDL_FillRect?

AndrewOn November 1, 2013 at 9:57:43 AM, Alex Barry (alex.barry at gmail.com) 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 <@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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


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

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

Mason

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

error: incompatible type for argument 2 of ?SDL_FillRect?

Andrew

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.

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:On Friday, November 1, 2013 10:19 AM, Andrew Havens wrote:
On November 1, 2013 at 9:57:43 AM, Alex Barry (alex.barry at gmail.com) wrote:
On Fri, Nov 1, 2013 at 12:28 PM, Andrew Havens wrote:
error: expected expression before ?SDL_Rect?
How do I correctly draw a square using SDL 2.0?
Thanks,
– Andrew


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


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


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

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.

JustinOn Nov 1, 2013 1:19 PM, “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 (alex.barry at gmail.com<//alex.barry at gmail.com>) 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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


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


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

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.

– AndrewOn November 1, 2013 at 10:30:32 AM, Mason Wheeler (masonwheeler at yahoo.com) 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 (alex.barry at gmail.com) 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 <@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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


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


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


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

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 > 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 (masonwheeler at yahoo.com<//masonwheeler at yahoo.com>) 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 < andrewh at copiousinc.com> 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 (alex.barry at gmail.com<//alex.barry at gmail.com>) 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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


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


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


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


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


Gabriel.

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:

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 (masonwheeler at yahoo.com<//masonwheeler at yahoo.com>) 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 < andrewh at copiousinc.com> 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 (@Alex_Barry<//@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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


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


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


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


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

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. ;-)On Fri, Nov 1, 2013 at 6:39 PM, Andrew Havens wrote:

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 (masonwheeler at yahoo.com) 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 (alex.barry at gmail.com) 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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


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


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


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


SDL mailing list
SDL at lists.libsdl.org
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 |
’---------------------------------------------------------------------’

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.

– AndrewOn November 1, 2013 at 10:49:24 AM, Alex Barry (alex.barry at gmail.com) wrote:

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:
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 (masonwheeler at yahoo.com) 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 (alex.barry at gmail.com) 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 <@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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


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


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


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


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


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

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!

See also this handy resource on C: http://c-faq.comOn 11/1/2013 11:01 AM, Andrew Havens wrote:

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 (alex.barry at gmail.com <mailto://alex.barry at gmail.com>) wrote:

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 <andrewh at copiousinc.com <mailto:andrewh at copiousinc.com>> wrote:

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 (masonwheeler at yahoo.com <mailto://masonwheeler at yahoo.com>) 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 <andrewh at copiousinc.com <mailto:andrewh at copiousinc.com>> 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 (alex.barry at gmail.com <mailto://alex.barry at gmail.com>) 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 <andrewh at copio.us <mailto:andrewh at copio.us>> 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
    SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
    http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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


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

Yay! :)On Fri, Nov 1, 2013 at 4:27 PM, Wins_Vefa wrote:

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org