Contexts and NSOpenGLViews problem

Hawkeye_a
Unregistered
 
Post: #1
Hey guys,
first post, but ill dive right into it.

My Cocoa+OpenGL application has a main window with 4 NSOpenGLViews in each corner. Each NSOpenGLView has an NSOpenGLContext associated with it. I have builtin the ability to 'maximize' any of the 4 NSOpenGLViews within the window by:
-getting the width and height of the other 3 views to 0
-setting the width and height of the view being maximized to the size of the window
(The size of the NSOpenGLVuews are changed using [self setFrameSize:newSize]Wink

Now, here's the problem, and i'm at my witts end trying to sole it.
I launch the program, and proceede to maximize one of the 4 NSOpenGLViews.
works fine. then i resize the entire window and the maximized view changes to one of the other 3 views(the same one everytime).

Percularily, this problem does not occur IF, after launching the program, i resize the window initially, and then maximize one of the views. it all works fine. Something is going on when i resize the window, and i dont know what its doing that screws up my maximized view.

If anyone can shed some light on this, it would be much appreciated.

Cheers.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #2
Well, not a lot of information. Try posting some code. It sounds like what is happening is your code doesn't know which view should be maximized.

So say for example, you want to maximize the upper left view... you do all that correctly, then store that view into another variable saying that "This is the guy I want maximized."

Then in your resize window code, make sure you are maximizing that window. Other than that, can't really help without seeing anything.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
Make sure each view's context is made current before doing anything with it.
Quote this message in a reply
Member
Posts: 208
Joined: 2005.04
Post: #4
Why not try a single NSOpenGLView instead?

From the Apple docs:
Quote:An NSOpenGLView cannot have subviews. You can, however, divide a single NSOpenGLView into multiple rendering areas using the glViewport function.
Quote this message in a reply
Hawkeye_a
Unregistered
 
Post: #5
Hey guys, thanks for your replies.

Here's some more information on what im doing.

-Basiclaly i want 4 different perspectives of the same scene, so 4 views. (i contemplated dividing the view using viewports, but that would take a lot more bookkeeping, so the cocoa apprach seemed viable and efficient)

All that works just fine. I wanted to include the functionality of being able to resize the quadrants in real time.(thats the purpose/goal of what im doing). So i researched NSSplitView, etc...to try and find a cocoa widget capable of handling it. There wasnt one...at least to my specifications.

So, here's what i did:
-i made one big view inside the window(it's a NSOpenGLView)
-i put the 4 quadrants into this main view
-the mainview keeps track of its center, which can be dragged around using the mouse. that automatically updates the size and origins of the 4 quadrants inside it.
-i put a button on each quadrant that allows a user to 'maximize' or 'restore' any of them. works fine as well(now).

So last night after i started this thread, i gave up trying to figure if there was an issue in my code(as thats what ive been working on for the past week), and i decided to reconstruct the UI in IB all over again. That lead me to the 'springs'(in the 'size' tab in IB). When i had the springs configured in a particular way...the error would occur. If i changed the configuration of the springs, the error would NOT occur. i cant explain it..it just seems to be doing something underneath the hood. But i managed to solve the problem by redoing the interface in IB and messing around with the springs.

And yes, ive been making sure i call
[[self openGLContext] setView:self];
[[self openGLContext] makeCurrentContext];
everytime i draw anything into ANY openGL view.

If you guys have any idea why this anomily is occuring, feel free to advise, cause id like to know as well.

Cheers

P.S.>> the program im working on is a modeller. some output can be seen here http://homepage.mac.com/hawkeye_a/Programming/ (made using a build thats about a year old now)
Quote this message in a reply
Post Reply