Solved

Combination of an OpenGL CView, and OpenGL CWnd, and GDI

Posted on 2003-11-07
2
654 Views
Last Modified: 2013-12-06
This is my first actual question to the site but I have lurked long enough and am ready to join.  I've got an open source game that's a port of the board game Settlers of Catan, and it uses OpenGL in a CView for the game rendering and GDI over that for information display and user interaction.  The game is available at http://www.settlers3d.net and the source is all at SourceForge.net under the project 'settlers3d'.

I am now in the process of adding a brand-new expansion to the game and I want to have a separate 3D rendering of the progress of a certain ship piece over a certain tile (called the 'barbarian attack' in the game).  This rendering will be informational only and totally static, meaning the users can't interact with it like they do the main CView OpenGL window.

I'm trying to create a new CWnd based OpenGL window for this barbarian attack that is displayed in its own area that overlays the OpenGL CView.  (It actually slides in and out from the side of the game window, but that's extemperaneous to the problem.)  I have created the new OpenGL CWnd and gotten it to display what I want, however, all of the Windows GDI drawing is now very messed up.  Here is a screenshot: http://www.settlers3d.net/images/gdiproblem.jpg
 
It seems that with the OpenGL CWnd turned on, all of the rendering contexts for the GDI drawing are incorrect.  If I comment out the Create() call for the CWnd, everything works properly again.  If I move the application window around, the GDI snaps back into correct drawing, but as soon as I do something in the game that changes the GDI information displays, nothing updates properly.

Does anyone have any idea what would cause this?  I don't want to clutter up the question with massive source code pastes, but I can post some links to the files on SourceForge if it would help.
0
Comment
Question by:jmfugate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
jmfugate earned 0 total points
ID: 9703352
I figured out my own answer.  In the OnPaint handler for the CWnd derived class, you need the following calls:

/////////////////////////////////////////////////////////////////////////////
// drawing
/////////////////////////////////////////////////////////////////////////////
void CGLBaseWnd::OnPaint()
{
      PAINTSTRUCT ps;

      //prepare painting region
      BeginPaint(&ps);

      ... your code ...

      EndPaint(&ps);
}

The BeginPaint and EndPaint set the clipping regions properly for the window being drawn.  It wasn't actually related to the OpenGL code at all.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question