Can't get OpenGL to work
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.