• 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
Can't get OpenGL to work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can't get OpenGL to work


  • Subject: Can't get OpenGL to work
  • From: Drew Cunningham <email@hidden>
  • Date: Sun, 24 Mar 2002 16:41:27 -0500

It seemed like simple code, but I can't get this OpenGL code to show anything. Am I missing something? I've set the custom view as a MyOpenGLView, and here is the code for it:

/* MyOpenGLView.h */

#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
#include <OpenGL/CGLRenderers.h>

@interface MyOpenGLView : NSOpenGLView
{

}
@end

/* MyOpenGLView.m */
#import "MyOpenGLView.h"

@implementation MyOpenGLView

- (void)drawRect:(NSRect)rect
{
[[self openGLContext] makeCurrentContext];

// Basic drawing routine. Override of drawRect function
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glBegin(GL_QUADS);
glColor4f(1.0, 0.0, 0.0, 1.0);
glVertex3f(-0.5, -0.5, 0.0);

glColor4f(0.0, 1.0, 0.0, 1.0);
glVertex3f(0.5, -0.5, 0.0);

glColor4f(0.0, 0.0, 1.0, 1.0);
glVertex3f(0.5, 0.5, 0.0);

glColor4f(1.0, 0.0, 1.0, 1.0);
glVertex3f(-0.5, 0.5, 0.0);
glEnd();

// Update the GL context
[[self openGLContext] flushBuffer];

}
@end
_______________________________________________
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.

  • Follow-Ups:
    • Re: Can't get OpenGL to work
      • From: Thomas Lachand-Robert <email@hidden>
  • Prev by Date: Re: palettes
  • Next by Date: document types
  • Previous by thread: Re: palettes
  • Next by thread: Re: Can't get OpenGL to work
  • Index(es):
    • Date
    • Thread