Jump to content

  • Log In with Google      Sign In   
  • Create Account


Plans on building a 2D level editor with SDL & WXWidgets - which one handles the window?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 johnmarinelli   Members   -  Reputation: 304

Like
0Likes
Like

Posted 19 September 2013 - 08:18 PM

Hi all,

 

As the title suggests, I plan on making a pretty simple 2D level editor with SDL for rendering and wxWidgets for the GUI.

 

I've used SDL before, but I haven't used wxWidgets.

 

The biggest question to me is which library should handle the window?  I imagine that I should let wxWidgets handle the window and let SDL render inside - would this be too complicated?

 

I'm open to any alternative suggestions.

 

Thanks!



Sponsor:

#2 markr   Crossbones+   -  Reputation: 1653

Like
0Likes
Like

Posted 20 September 2013 - 02:45 AM

My alternative suggestion is not to build a level editor *at all*.

 

You didn't say what kind of level editor it needs to be - tilemap, vector etc, but there are plenty of existing editors which do most of what you need with much less coding.

 

Instead maybe you need to write conversion tools to convert from a different format.

 

For object-placement, or other tricky stuff, it might be better to build the editor into your game:

 

* An editor built into the game requires less code than implementing some fancy UI

* You can see how the layout looks using the in-game view, as you go.

 

For tilemaps, you can use: Text editors, Bitmap graphics editors (e.g. gimp), standard tilemap editors.

For vectors you can use: 2d vectors such as Flash, Inkscape etc, 3d vectors such as Blender or whatever-tool-you-want.

For things like colour-mapping, you can use a bitmap graphics editor.

 

For things like game logic, e.g. triggers, wiring logic up to make doors open when the button is pressed, monster stats, you might need a custom editor. Build it into your game if possible, or use an existing editor.



#3 wintertime   Members   -  Reputation: 1640

Like
0Likes
Like

Posted 20 September 2013 - 05:39 AM

For such a simple thing as a 2d tilemap I wouldnt bother with writing an editor, too.

You just start LibreOffice Calc or Excel, write id numbers into a table, save as csv.

Then you maybe create a simple converter command line program to translate it into some binary format.

Then read it into your game and verify its right.



#4 DekuTree64   Members   -  Reputation: 972

Like
1Likes
Like

Posted 20 September 2013 - 08:16 AM

WxWidgets will do the windows and controls. SDL could be used for blitting, and then transfer the SDL buffer to your map window.

 

I almost used WxWidgets for my map editor, but ended up going with FLTK because it makes a small standalone .exe rather than needing a monster .dll somewhere (annoying when you want to share it). But basically the same functionality, just a little less fancy.

 

And in my game engine, I do all graphics in software, and only use SDL to dump the completed image to the screen. Same code works in the editor, except I dump it to the map window. No SDL necessary.

 

As others have said, writing an editor is a lot of work and possibly not necessary. Mine is 16K lines of code, but I don't regret writing it. Really nice being able to quickly add anything I need, rather than having my game designs influenced by what my editor can do. It's a little over the top fancy, so you could certainly make something useful with a lot less effort. But definitely not trivial.

 

IMO, the primary purpose of the editor is to place entities on the map, and input any data pertaining to them (e.g. destination map and spawn point for a door, or what dialog to display when talking to an NPC). Second purpose is to define collision data. Third is the actual tilemap editing.



#5 johnmarinelli   Members   -  Reputation: 304

Like
0Likes
Like

Posted 20 September 2013 - 05:28 PM

I'm fully aware that there are plenty of editors - I'd just like to write a really simple one myself.

 

@DekuTree64, could you explain more about transferring the SDL buffer to a map window?



#6 Servant of the Lord   Crossbones+   -  Reputation: 18279

Like
1Likes
Like

Posted 20 September 2013 - 06:48 PM

If you decide wxWidgets isn't to your taste, I find Qt more in line with my own liking.

On the flip side, Qt isn't a small library by any means... it's a huge collection of libraries that covers quite alot more than just GUI widgets.

 

In answer to your question - I think wxWidgets is supposed to manage the window IIRC, and SDL render to it. Same with Qt.


Edited by Servant of the Lord, 20 September 2013 - 06:50 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                            [Need web hosting? I personally like A Small Orange]
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#7 DekuTree64   Members   -  Reputation: 972

Like
1Likes
Like

Posted 20 September 2013 - 07:55 PM

I'm fully aware that there are plenty of editors - I'd just like to write a really simple one myself.

 

@DekuTree64, could you explain more about transferring the SDL buffer to a map window?

I've never actually used SDL this way, or used WxWidgets for more than a day of learning to see how I liked it, so I'm half guessing here. But I think you'd initialize SDL video to render to a software surface. Then each frame after you're done rendering everything, lock the surface, and copy the pixel data over to your WxWidgets window. Not sure exactly how the copying would be done. Quick check of the documentation, it doesn't look like it will be very straightforward. Possibly a combination of wxGraphicsContext and wxBitmap (copy the SDL surface pixels to the bitmap, then draw the bitmap to the window)

 

One more point in favor of FLTK. Just call fl_draw_image, give it the SDL surface's pixel pointer, and bam, done :) There may be something similar in WxWidgets that I didn't find, though. Perhaps someone more experienced with it will come along and enlighten us.



#8 dejaime   Crossbones+   -  Reputation: 3983

Like
1Likes
Like

Posted 20 September 2013 - 08:42 PM

I guess you can use only SDL for the whole editor. Maybe using a GUI library like SDL-widgets...

 

Still, as posted before, there's also the possibility of using programs like Tiled and write a simple addon to configure it for your desired output format.



#9 Aldacron   GDNet+   -  Reputation: 3113

Like
1Likes
Like

Posted 21 September 2013 - 11:08 PM

In SDL 2.0, you can create your render window in wxWidgets, get the native window handle, then pass it to SDL_CreateWindowFrom. Beyond that, I'm not clear on all the details. I know you should be able to use the Surface API for drawing, but for the accelerated API using SDL_Renderer I can only guess.

Most definitely you'll need to make sure a proper rendering context is set up on the window. I assume wxWidgets provides a means to create an OpenGL context (and it has to be a compatibility profile, not core), so that will need to be done before passing the window handle to SDL. Then when creating the renderer you'll need to explicitly request the OpenGL renderer. Similar for using D3D, if wxWidgets enables that.

 

Then there's events. I think it's safe to assume that you will handle events on the wxWidgets side, but I have no idea if SDL tries to hook into the event proc of windows it didn't create. 

 

At any rate, it may be a lot simpler than I make it appear here. It's probably a good idea to ask in the SDL forum for the details if you decide to go that route.


Edited by Aldacron, 21 September 2013 - 11:10 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS