Re: Refresh woes for custom OGL pane
Re: Refresh woes for custom OGL pane
- Subject: Re: Refresh woes for custom OGL pane
- From: "Erik M. Buck" <email@hidden>
- Date: Tue, 30 Apr 2002 00:04:58 -0500
- Organization: EMB & Assocites Inc.
----- Original Message -----
From: "Graham Wihlidal" <email@hidden>
>
I've subclassed NSOpenGLView and it is similar setup to Apple's NSGL
>
teapot, etc...
>
>
I am not using DoubleBuffering via a Timer though because it hogs the
>
CPU to hell and since this is the world builder for my 3D engine, I
>
figured it should be easy to use and not have to quit it to smoothly
>
type a message in ICQ :)
I have no idea what you are talking about above. Timers can be used to
stimulate animation. Timers should not consume so much CPU that other
processes degrade. You probably can not disable double buffering. Mac OS X
and Cocoa use double buffering even if you don't when not full screen.
>
>
I'm basically calling [self drawRect] everytime the view changes via
>
user input, etc... This works WAY better. Two problems though (so
>
far :)
NEVER CALL -drawRect:! Call -display or -displayRect: or -setNeedsDisplay:
or -setNeedsDisplayInRect:. Your failure to call one of these methods may
explain all of your problems.
>
>
When the window first loads, the context is blank until I click which
>
causes it to refresh (I have a mouse handler that did that)
>
When the window deminiaturizes it's blank as well
Cocoa call's you view's -drawRect: method automatically when it needs to.
You do not have to do anything special to hadle deminiturizing or initial
drawing or any other reason that your view must be redrawn. You may have to
reload textures to VRAM if you switch between different windows that
eachhave their own GL context. I think the Dock also has its own context and
can trash your textures.
>
>
I am using NSWindowController to manage the window so it works well as a
>
multi document system. I tried using windowDidDeminiaturize but it
>
doesn't seem to be ever called :/
You are on the wrong track.
>
>
Guessing because NSWindowController is made to handle more than one
>
window?
Irrelevant.
>
>
Anyways, I than tried that event within my view's implementation (Cocoa
>
InitGL example has windowWillClose to invalidate timers, I thought it
>
may work :) Nadda, it didn't hehe
>
>
How can I intercept that message and tell my pane to redraw?
Your -drawRect: method is called automatically when needed. Everything else
is handled for you. You are working WAY too hard.
>
>
I also tried calling [self drawRect] in the awakeFromNib and
>
initWithFrame methods for my OGL view, didn't do anything.
Don't do that.
>
>
Any ideas?
>
As it happens, I am also writing a Cocoa multi-document application that is
a world editor for a 3D engine. I make each window's document object the
window's delegate. I implement -windowDidBecomeKey: to re-download all
textures. This works well except for a brief flash when the key window
changes.
My guess is that you could benefit from doing a few simple Cocoa tutorials
so that you will be aware of how much work you DON'T have to do. I also
recommend www.omnigroup.com. They have examples and articles that explain
how they port AAA games to the Mac using Cocoa and OpenGL. They discuss
timers and GL contexts and pixel formats etc. Apple provides lots of GL
examples including one that shows how to maximize texture performance.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.