Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Getting OpenGL to work in Cocoa

Getting OpenGL to work in Cocoa
Thread Tools
Fresh-Faced Recruit
Join Date: Apr 2001
Location: Murray, Utah, USA
Status: Offline
Reply With Quote
May 1, 2001, 09:34 AM
 
Okay, guys, sorry, but this is getting obnoxious. I've been programming C++ forever it seems, but I can't get this NSOpenGLView to work. I'm sure I'm just missing a simple step (like swapping buffers or adding the wrong framework). So I'll guide you all through what I do, and you can tell me what is wrong (I hope)

New project (call it "Test").

Open Interface Builder
In the window add an NSOpenGLView
In classes, subclass NSOpenGLView -- call it TestView
Instantiate TestView
Info panel GLView and make it a TestView
Create files for TestView

(back to Project Builder)
In TestView.h add the line:
- (void) drawRectNSRect)rect;

In TestView.m add:
#include <gl/gl.h> // Also add OpenGL Framework

- (void) drawRectNSRect)rect {
NSBeep(); // Test if reached
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glBegin(GL_QUADS);
glVertex3f(-0.5,-0.5,-1.0);
glVertex3f(0.5,-0.5,-1.0);
glVertex3f(0.5,0.5,-1.0);
glVertex3f(-0.5,0.5,-1.0);
glEnd();
}

At the end of the function I think I have tried everything I can think of from trying GLUT framework swapping buffers with GLUT to [[self openGLContext] flushBuffer] and nothing will appear.

The beep occurs -- just no rendering.

Thanks for any assistance here!

Jeff
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
May 1, 2001, 09:45 AM
 
No need to instantiate the TestView, just make the GL view in the window into a TestView.

I don't know how recent this is, but try looking at this example. It's from the PB...
http://gilgalad.dyndns.org/OpenGL.tar.gz
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Fresh-Faced Recruit
Join Date: Apr 2001
Location: Murray, Utah, USA
Status: Offline
Reply With Quote
May 1, 2001, 10:28 AM
 
** Bowing humbly with praise and thanks **

Thank you -- exactly what I needed Someone should probably try and post a simple example to NeHe's OpenGL tutorials page (all they have for OS X is GLUT).

Thanks, again!
Jeff
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:41 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2