[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2003-11-07
2
Medium Priority
?
688 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

656 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