• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Follow-up OpenGL question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Follow-up OpenGL question


  • Subject: Follow-up OpenGL question
  • From: David Newberry <email@hidden>
  • Date: Sat, 11 May 2002 23:15:38 -0700

Hi all,

Thanks to the few people who replied to my last email off list. Unfortunately, I haven't yet been able to get a working solution, so I thought I'd be a little more specific.

I did a search with Google and found a project called OpenGLViewSample which was apparently made by someone on this list. I brazenly stole code from it. :P Most of that... borrowed code is below.

Currently, I have an NSOpenGLView subclass who's drawRect: method is this:

static float t = 0;

t+=.1;

// First, we clear the view

// This is not necessary. Looks like it is done by default
glViewport( 0,0,NSWidth([self bounds]),NSHeight([self bounds]) );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glClearColor( 0,0,0,0 );
glClear( GL_COLOR_BUFFER_BIT );


// The we set a coordinate system, and a point of view
gluPerspective( 60,1,1.5,20 );
glMatrixMode( GL_MODELVIEW );

glLoadIdentity();
gluLookAt( 0,0,5,0,0,0,0,1,0 );

// We rotate depeding on the status of the sliders
glRotatef( t,1,0,0 );
//glRotatef( [itsRotateYSlider floatValue],0,1,0 );
//glRotatef( [itsRotateZSlider floatValue],0,0,1 );

// We scale depending of the zoom slider
//glScalef( [itsZoomSlider floatValue], [itsZoomSlider floatValue], [itsZoomSlider floatValue] );

// We emit a quad with colored vertexes
glBegin( GL_QUADS );

glNormal3d( 0, 0, 1 );

glColor3d( 0, 0, 1 );

//[self emitGlColor:[itsColorWell0 color]];
glVertex3f( -1, -1, 0 );
//[self emitGlColor:[itsColorWell1 color]];
glVertex3f( 1, -1, 0 );
//[self emitGlColor:[itsColorWell2 color]];
glVertex3f( 1, 1, 0 );
//[self emitGlColor:[itsColorWell3 color]];
glVertex3f( -1, 1, 0 );

glNormal3d( 0, 1, 0 );

glColor3d( 0, 1, 0 );

//[self emitGlColor:[itsColorWell0 color]];
glVertex3f( -1, 0, -1 );
//[self emitGlColor:[itsColorWell1 color]];
glVertex3f( 1, 0, -1 );
//[self emitGlColor:[itsColorWell2 color]];
glVertex3f( 1, 0, 1 );
//[self emitGlColor:[itsColorWell3 color]];
glVertex3f( -1, 0, 1 );

glEnd();

[[self openGLContext] flushBuffer];

This is basically the only place I have any code that relates to OpenGL. It works fairly well, except for two major problems:
a] it doesn't do hidden face removal (is that the proper term?) and b] it doesn't use light sources -- everything is just whatever color it is. Every time I put in code that I *think* should remedy those two things, it always screws up the drawing in very bizarre ways. My hope is that perhaps someone on the list can tell me exactly what I need to do to get this to work.

Thanks all,
-David Newberry
_______________________________________________
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.

  • Prev by Date: draw pdf crash with certain pdfs
  • Next by Date: NSProgressIndicator -setFrameOrigin visual updating anomaly
  • Previous by thread: draw pdf crash with certain pdfs
  • Next by thread: NSProgressIndicator -setFrameOrigin visual updating anomaly
  • Index(es):
    • Date
    • Thread