Developing UI GUI and SDL through wxDev-CPP?

Hello, I’ve been using wxDev-cpp to create windows with relative ease and now
I’m trying to create an SDL application with this. I was wanting there to be
a user-interface that would allow GUI elements that would be used for input
and textual output to the user, and then the SDL will be used to create a
different window that will basically show graphics. I’m trying out Lazy
Foo’s tutorials at http://www.lazyfoo.net/SDL_tutorials/lesson01/index2.php
and I loaded lesson01 and it works exactly as is, but when I launch the same
SDL window from within a Windows application using wxDev-Cpp, the SDL window
freezes when I click it and move it (And the image disappears), and then
when I try to click and move the GUI window that I plan to put user
interface elements on, it also freezes. Eventually, I get sick of it doing
nothing and so it’s terminated.

Anybody have insight into what the problem might be and if it’s fixable? If
it isn’t, is there another method for creating a window for user interface
elements and another window that’ll house the SDL that manipulate graphics
and do other SDL-goodness?

The following is the code for the main program.

//---------------------------------------------------------------------------
//
// Name: Project5App.cpp
// Author: a
// Created: 10/14/2009 9:15:12 PM
// Description:
//
//---------------------------------------------------------------------------

#include “Project5App.h”
#include “Project5Frm.h”
#include “SDL/SDL.h”

void startSdlWindow()
{
//The images
SDL_Surface* hello = NULL;
SDL_Surface* screen = NULL;

//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

//Set up screen
screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );

//Load image
hello = SDL_LoadBMP( "hello.bmp" );

//Apply image to screen
SDL_BlitSurface( hello, NULL, screen, NULL );

//Update Screen
SDL_Flip( screen );

//Pause
SDL_Delay( 200000);

//Free the loaded image
SDL_FreeSurface( hello );

//Quit SDL
SDL_Quit();

}

IMPLEMENT_APP(Project5FrmApp)

bool Project5FrmApp::OnInit()
{
Project5Frm* frame = new Project5Frm(NULL);
SetTopWindow(frame);
frame->Show();
//////////////
startSdlWindow();

/////////////

return true;

}

int Project5FrmApp::OnExit()
{
return 0;
}–
View this message in context: http://www.nabble.com/Developing-UI-GUI-and-SDL-through-wxDev-CPP--tp25902943p25902943.html
Sent from the SDL mailing list archive at Nabble.com.

Did you try waiting 200 seconds to see what happens? :slight_smile:
I suspect something when I see SDL_Delay(200000). If you don’t figure
it out right away, I’ll write more when I have time.

Jonny DOn Thu, Oct 15, 2009 at 12:36 AM, swbluto4gems wrote:

Hello, I’ve been using wxDev-cpp to create windows with relative ease and now
I’m trying to create an SDL application with this. I was wanting there to be
a user-interface that would allow GUI elements that would be used for input
and textual output to the user, and then the SDL will be used to create a
different window that will basically show graphics. I’m trying out Lazy
Foo’s tutorials at http://www.lazyfoo.net/SDL_tutorials/lesson01/index2.php
and I loaded lesson01 and it works exactly as is, but when I launch the same
SDL window from within a Windows application using wxDev-Cpp, the SDL window
freezes when I click it and move it (And the image disappears), and then
when I try to click and move the GUI window that I plan to put user
interface elements on, it also freezes. Eventually, I get sick of it doing
nothing and so it’s terminated.

Anybody have insight into what the problem might be and if it’s fixable? If
it isn’t, is there another method for creating a window for user interface
elements and another window that’ll house the SDL that manipulate graphics
and do other SDL-goodness?

The following is the code for the main program.

//---------------------------------------------------------------------------
//
// Name: ? ? ? ?Project5App.cpp
// Author: ? ? ?a
// Created: ? ? 10/14/2009 9:15:12 PM
// Description:
//
//---------------------------------------------------------------------------

#include “Project5App.h”
#include “Project5Frm.h”
#include “SDL/SDL.h”

void startSdlWindow()
{
? ?//The images
? ?SDL_Surface* hello = NULL;
? ?SDL_Surface* screen = NULL;

? ?//Start SDL
? ?SDL_Init( SDL_INIT_EVERYTHING );

? ?//Set up screen
? ?screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );

? ?//Load image
? ?hello = SDL_LoadBMP( “hello.bmp” );

? ?//Apply image to screen
? ?SDL_BlitSurface( hello, NULL, screen, NULL );

? ?//Update Screen
? ?SDL_Flip( screen );

? ?//Pause
? ?SDL_Delay( 200000);

? ?//Free the loaded image
? ?SDL_FreeSurface( hello );

? ?//Quit SDL
? ?SDL_Quit();
}

IMPLEMENT_APP(Project5FrmApp)

bool Project5FrmApp::OnInit()
{
? ?Project5Frm* frame = new Project5Frm(NULL);
? ?SetTopWindow(frame);
? ?frame->Show();
? ?//////////////
? ?startSdlWindow();

? ?/////////////

? ?return true;
}

int Project5FrmApp::OnExit()
{
? ? ? ?return 0;
}

View this message in context: http://www.nabble.com/Developing-UI-GUI-and-SDL-through-wxDev-CPP--tp25902943p25902943.html
Sent from the SDL mailing list archive at Nabble.com.


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

You need a PollEvent() loop, or else you will get the behaviour you
describe. You should call it very frequently, and clear the event
queue each time. Lazy Foo’s tutorials should cover input and SDL.On Thu, Oct 15, 2009 at 5:36 AM, swbluto4gems wrote:

Anybody have insight into what the problem might be and if it’s fixable? If
it isn’t, is there another method for creating a window for user interface
elements and another window that’ll house the SDL that manipulate graphics
and do other SDL-goodness?

So I got this program up and running on my laptop because that’s what’s
available to me at the moment but it doesn’t seem like the GUI UI window
separates from the SDL window. It seems that the SDL window is the only
window that opens. I’m using the same IDE with the same compiler, same
essential code, same SDL and I believe the same project parameters, so this
seems quite weird. I really need code that’ll reliably creates two separate
windows, one for the user interface and the other for SDL.–
View this message in context: http://www.nabble.com/Developing-UI-GUI-and-SDL-through-wxDev-CPP--tp25902943p25913983.html
Sent from the SDL mailing list archive at Nabble.com.

I found a web-page that had an example of integrating openGL with wxDev-CPP
in the same window (It’s what I wanted originally, I just thought separate
windows with SDL would alleviate event-loop conflicts since they both have
event loops.), and I realized wxWidgets could handle keyboard and mouse
events by itself, so I think I’m going to go with that. It seems I have to
learn a little bit about openGL to make 2d graphics, but at least I’m
getting somewhere.–
View this message in context: http://www.nabble.com/Developing-UI-GUI-and-SDL-through-wxDev-CPP--tp25902943p25928522.html
Sent from the SDL mailing list archive at Nabble.com.