Talk About Network

Google





Graphics > OpenGL 3D API > Re: Draw OpenGL...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 18 Topic 4755 of 5061
Post > Topic >>

Re: Draw OpenGLScene without WM_PAINT

by aku ankka <jukka@[EMAIL PROTECTED] > May 19, 2008 at 03:21 AM

On May 19, 11:47=A0am, Albe <alberto_res...@[EMAIL PROTECTED]
> wrote:
> Hi Wolfgang, thank you for reply but I'm sorry I don't understand your
> message, I'm a newbie in OpenGL and I'm no expert in context ecc
> ecc...
> Just to be clear, I'm using this code
>
> OGLPlo =3D new COpenGLControl();
> ...
> CString className =3D AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW |
> CS_OWNDC,NULL,(HBRUSH)StockObject(BLACK_BRUSH),NULL);
>
> CreateEx( =A0 =A0 =A0 0,className,"OpenGL",WS_CHILD | WS_VISIBLE |
WS_CLIP=
SIBLINGS
> | WS_CLIPCHILDREN,
> rect,parent,0);
> ...
> dc =3D new CClientDC(this);
> ...
> openGLDevice.create(dc->m_hDC);
>
> bool OpenGLDevice::create(HDC& deviceContext,int stencil)
> {
> =A0 =A0 =A0 =A0 if (!deviceContext)
> =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return false;
> =A0 =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0 if (!setDCPixelFormat(deviceContext,stencil))
> =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return false;
> =A0 =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0 renderContext =3D wglCreateContext(deviceContext);
> =A0 =A0 =A0 =A0 wglMakeCurrent(deviceContext, renderContext);
>
> =A0 =A0 =A0 =A0 OpenGLDevice::deviceContext =3D deviceContext;
>
> =A0 =A0 =A0 =A0 return true;}
>
> ...
> "COpenGLControl::InitGL"
> ...
> "COpenGLControl::OnSize"
> ... =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <---- =A0ERROR dc=3D0
> glClear(GL_COLOR_BUFFER_BIT =A0 =A0 =A0| =A0GL_DEPTH_BUFFER_BIT);
> glLoadIdentity();
> ...
> Disegna_Barre();
> ...
> SwapBuffers(dc->m_hDC);
>
> Here there are the main instruction used to create the OpenGL windows,
> it works fine in normal way (when the OnPaint is called from WM_PAINT)
> but when I try to call OnPaint without WM_PAINT (I'm calling OnPaint
> from a function inside the ogl class each time a new data is
> available) the dc is ok before the OnPaint calling, after the dc=3D0 and
> an error occours in
>
> SwapBuffers(dc->m_hDC);
>
> I hope make clear, thank you in advance
>
> Alberto

Don't sweat over the paint messages, they are just artifact of
Microsoft's aged window manager. The window manager doesn't keep a
copy of the canvas contents so any time new ****tions of window are
revealed the window manager has to ask the application to
(re-)generate the content.

This is done much better on modern window managers, but that doesn't
help you much since it appears you are using the GDI (not a bad choise
since it caters for more flavours of windows than just the latest
Vista incarnations).

What you want to do is to beginpaint, do your rendering, endpaint and
repeat that as often as required. If you use FBO's and render-to-
texture, you can use the framebuffer object for the paint messages.
This would go into the category of useless optimizations as you need a
good performance (or so I would be inclined to guess) to begin with.
Might help with lower performance systems if you don't update the
image too frequently, go figure, could depend on how complex your
dataset is.

I didn't catch what you meant by 400 Hz, you want to update the scene
every time a new sample arrives, or batch updates? It will be rather
difficult to display your "signal" at 400 Hz, so it would make sense
to display snapshots of the data after specific time has elapsed for
example. This is kind of embarassingly trivial stuff but since you are
asking I'm forced to assume that there is something unstated in your
question. Care to be more specific what kind of trouble you are
experiencing again?
 




 18 Posts in Topic:
Draw OpenGLScene without WM_PAINT
Albe <alberto_ressia@[  2008-05-19 00:12:21 
Re: Draw OpenGLScene without WM_PAINT
Wolfgang Draxinger <wd  2008-05-19 09:47:36 
Re: Draw OpenGLScene without WM_PAINT
Albe <alberto_ressia@[  2008-05-19 01:47:07 
Re: Draw OpenGLScene without WM_PAINT
aku ankka <jukka@[EMAI  2008-05-19 03:21:22 
Re: Draw OpenGLScene without WM_PAINT
Albe <alberto_ressia@[  2008-05-19 05:57:37 
Re: Draw OpenGLScene without WM_PAINT
Jonno <jonno@[EMAIL PR  2008-05-19 14:23:06 
Re: Draw OpenGLScene without WM_PAINT
Albe <alberto_ressia@[  2008-05-19 07:27:09 
Re: Draw OpenGLScene without WM_PAINT
Jonno <jonno@[EMAIL PR  2008-05-19 15:54:39 
Re: Draw OpenGLScene without WM_PAINT
Albe <alberto_ressia@[  2008-05-19 08:47:09 
Re: Draw OpenGLScene without WM_PAINT
Jonno <jonno@[EMAIL PR  2008-05-19 17:00:35 
Re: Draw OpenGLScene without WM_PAINT
aku ankka <jukka@[EMAI  2008-05-19 23:29:33 
Re: Draw OpenGLScene without WM_PAINT
Albe <alberto_ressia@[  2008-05-20 00:25:21 
Re: Draw OpenGLScene without WM_PAINT
Diego <jose.diego@[EMA  2008-05-21 09:33:15 
Re: Draw OpenGLScene without WM_PAINT
Albe <alberto_ressia@[  2008-05-22 02:33:00 
Re: Draw OpenGLScene without WM_PAINT
Jonno <jonno@[EMAIL PR  2008-05-22 11:24:50 
Re: Draw OpenGLScene without WM_PAINT
"Clemens" <y  2008-05-24 09:56:44 
Re: Draw OpenGLScene without WM_PAINT
Albe <alberto_ressia@[  2008-05-26 02:43:17 
Re: Draw OpenGLScene without WM_PAINT
Jonno <jonno@[EMAIL PR  2008-05-27 09:09:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 16:29:35 PST 2009.