Solved

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

Posted on 2003-11-07
2
643 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

Industry Leaders: 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

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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