Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now