• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
johnmarinelli

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

8 posts in this topic

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!

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

1

Share this post


Link to post
Share on other sites

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?

0

Share this post


Link to post
Share on other sites

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
1

Share this post


Link to post
Share on other sites

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.

1

Share this post


Link to post
Share on other sites

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.

1

Share this post


Link to post
Share on other sites

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
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0