• 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
knos991

Drawing elements on a GDI control

7 posts in this topic

I'd like to draw simple shapes (e.g. a triangle filled with a color) in one of my GDI+ controls. How should I go for that?

If I'm not mistaken one might store the bitmap for the triangle in the resources and then call LoadBitmap, but I don't really like this method. Is there any other way of doing this?

Is it possible to extract a bitmap of the scene and somehow draw to it? I definitely need some suggestions here please

0

Share this post


Link to post
Share on other sites


in one of my GDI+ controls

 

Are you subclassing a Win32 control, or do you have a custom control class that you implement with GDI+?

 

If the latter, you should look at the Graphics.FillPath function. Creating a path by adding lines to form the desired triangle and filling that path with a SolidBrush of the appropriate color should serve your needs.

1

Share this post


Link to post
Share on other sites

Thanks! Yes I'm creating custom GDI+ controls and drawing them from scratch.
 
One more question if I may: I'm trying to create an entire custom UI and right now I'm doing something like this in the window's WM_PAINT event

case WM_PAINT:
    for_each( visible_control )
        paint_that_control(window_hdc);

I somehow feel that this approach is painfully slow and I'd like some advice.. I'd like to avoid creating multiple win32 elements, is there another better approach?

0

Share this post


Link to post
Share on other sites

I'm trying to create an entire custom UI

 

Considering the existing Win32 API has been in development for decades, you've got a long row to hoe. As it appears you've already started to use the Win32 API, why not continue?

 

EDIT: Do you, perhaps, mean you want a custom look to the Win32 interface? happy.png  Or do you really intend to change the behavior of the controls? If the latter, that's going to confuse your users as they will expect a button to behave in the same way, whatever it looks like.

 

 


I'm doing something like this in the window's WM_PAINT event <snippet>

 

An easier alternative may be to do it similarly to Win32. Create each control window as a child to the main window, store a pointer to your custom class or a data structure in the control window's userdata area (or subclass it by changing the HWND's window procedure to your custom control WNDPROC), and let the main window itself dispatch the paint calls to its children.

Edited by Buckeye
0

Share this post


Link to post
Share on other sites

Since I'm a newbie I've probably written something terribly wrong, sorry biggrin.png

 

What I'm trying to do is to render my controls with GDI+ into a window client area (every single one I use... the app is a simple one and doesn't use many :) )

 

Since I'm rendering everything in that area (and I wanted those controls to "blend a bit" together) I kind of disliked the idea of having multiple different win32 control windows. Is there an alternative?

0

Share this post


Link to post
Share on other sites

I kind of disliked the idea of having multiple different win32 control windows.

 

Any particular reason? That's the common method for controls.

 

 

 


Is there an alternative?

 

Render them as you posted above.

Edited by Buckeye
0

Share this post


Link to post
Share on other sites

The reason not to have multiple win32 controls is that I want to "blend those controls" together a bit... and having different stuff won't probably work (or will become messy with signals).

 

What I'm really interested in is if there's an advantage on using win32 window controls instead of rendering my own ones: how are signals for redrawing parts of the client area handled if I render my controls?

 

Do I have to redraw everything each time even a small corner of the client win32 area gets covered and then uncovered?

0

Share this post


Link to post
Share on other sites


I want to "blend those controls" together a bit... and having different stuff won't probably work (or will become messy with signals)

 

Not sure what you mean by "blend," I'm afraid. Graphics? Functionality? Also, difficult to respond to a question when you use technical terms like "stuff" and "messy." wink.png

 

As mentioned above, Win32 controls are child windows of another window. They don't get "signals" - Win32 windows use a window messaging system. A control, being a window, gets a message to repaint only when all or a portion of the window needs to be redrawn.

 

With regard to handling child window messages, considering the questions you're asking, I would strongly suggest you get familiar with how parent-child communication is handled in the Win32 API. Reading up on the messaging system, and creating a small project to try the things you want to do will really be a benefit - whether you draw your own objects or use controls. There are a couple ways to approach drawing your own controls - google for things like "BS_OWNERDRAW" and "windows controls subclassing."

 

You may also benefit from purchasing a copy of Charles Petzold's book (Microsoft Press) "Programming Windows." Though the 5th edition is copyright 1998, I haven't found anything that doesn't work as advertised as late as Windows 7. It comes with a lot of example code that is very straightforward, compiles and runs out-of-the-box.

 


What I'm really interested in is if there's an advantage on using win32 window controls

 

I mentioned some of the drawing aspects above. The primary advantage of using the API controls (whether you do the drawing or not), is you won't have to code response behavior to button-clicks, dropdowns, mouseovers, getting/losing focus, etc., etc. Petzold devotes a chapter to Child Window Controls.

0

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