• 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

Need help with SWIG and void pointers

0 posts in this topic

Hopefully someone's got an answer. In a nutshell, I need SWIG to generate the ability for IntPtr <-> void *, and IntPtr<-> HWND.


I'm finding either SWIG's directive handling is abysmal or something is very wrong in my interface file. Don't get me wrong I'm extremely grateful for SWIG in general, it's saved my *** by generating a very thorough API for my engine, but it dropped the ball on me when it doesn't handle void pointers or HWND types properly; and if it drops the ball on me there, then it doesn't matter how good it is -- results are what matter, and I need void pointers and HWNDs, if I don't have that then it's no good to me since so much of game programming is around dealing with handles of various sorts. I'm trying to bridge between my engine's DLL and C#. Much of DX and even OpenGL (hRCs, etc) utilize void pointers and HWNDs (which are macroized as void pointers in windef.h I think). Now I'm starting to think it's SWIGs directive handling that is the problem because I've tried 4 different solutions I've found and not one of them provides me the automatic marshaling needed for C# to pass an IntPtr or a void ptr to a SWIGTYPE_p_void or SWIGTYPE_p_HWND without an error in C#.


Here's 4 links that I've tried:





http://www.nickdarnell.com/2011/05/swig-and-a-miss/  -- point #9


with any of them, I get the error: "Error: Cannot implicitly convert type 'System.IntPtr' to 'SWIGTYPE_p_HWND'"


I know why it's saying that. It's because there's no SWIG generated (Or any generated for that matter) code to handle going from an IntPtr to an HWND datatype so it's trying to convert it without code (probably through some compiler generated automatic code) and it's unable to do that -- so it fails.


An honest look as to why I'm trying to avoid extensive learning on typemaps and C# marshaling

I suppose the answer would be for me to learn how to make my own typemaps. The way I see it, for what I'm trying to do, typemaps are a feature of SWIG that will probably not be revisited again once I have the few datatypes, I need for bridging across, set up. I am very familiar with what the argument probably will be... "You don't know what you're going to need in the future". Maybe not, but I know 90% (at the very least) of what I'm doing is being done in the C++ dll, 5% is making calls to the APIs that are exported out from that DLL and the remaining 5% is probably manipulations of the UI of the editor and just basic declarations so that I can pass objects over to the C++ dll. SWIG handles most of the other datatypes perfectly ok. And not for nothing, I have tried to look at it and understand it but got nowhere since there seems to be many different ways of achieving it (as evidenced by the 4 urls I posted), some through %cs_structs, some through %typemaps and some with indepth-marshaling (Involving %typemaps and %defines, and all sorts of nasty looking stuff).


To be brutally honest, I have no interest in learning marshaling. I only need this now because SWIG, with as good as it is, can't really handle void *, and HWND properly out of the box it seems. C++ is my choice of language, not C# and I can't afford to get bogged down in the minutiae of the "wonderful exciting world of marshaling" (or %typemaps for that matter).


Quick reason as to why I'm making the editor in C#

For those of you that followed my other post: http://www.gamedev.net/topic/650937-mfc-splitter-windows-and-cviews-oh-my -- You may find my detailing this ordeal/experience helpful if you're dealing with the same questions

I hate much of the things C# takes away (And yes I'm familiar with the "unsafe {};" constructs tongue.png -- but scoping issues occur rather easily imho). From what I've read, CLI is fine if you want to rewrite your code to be CLI compliant and are ok with it being Windows platform only. Only reason I'm writing my editor in C# is because I can throw together a UI pretty quickly and get it looking the way I want fairly quickly. And I've spent enough time with MFC to realize it works pretty good so long as you stick to it's automatic back-end macro-voodoo it does for window/view creation which is, again, pretty limiting. I guess C#'s purpose is not for language-simplification (As I always believed and managed objects was really more of a bonus), it's completely about managed objects and everything else is either an effect (Simpler language syntax imho), or a bonus (visual design of UI). The visual designing of forms was/is really a tacked on super-nice bonus. If they only did the visual-design feature but for C++.. Oh wait, Borland I think did that with VCL and their .NET implementation... hmm...


I guess an attachment of my .i file is needed? There's nothing in it really except the inclusion of the headers for my engine, and anyone of your choices for the solutions found at the URLs above, but I can certainly post it if it's really needed. Thanks in advance!


-- StakFallT

Edited by StakFallT

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