Created
August 21, 2012 00:29
-
-
Save mogeta/3409830 to your computer and use it in GitHub Desktop.
Drawing to a Window or View
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
@interface MyOpenGLView : NSOpenGLView | |
{ | |
} | |
- (void) drawRect: (NSRect) bounds; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "MyOpenGLView.h" | |
#include <OpenGL/gl.h> | |
@implementation MyOpenGLView{ | |
} | |
static void drawAnObject () | |
{ | |
glColor3f(1.0f, 0.85f, 0.35f); | |
glBegin(GL_TRIANGLES); | |
{ | |
glVertex3f( 0.0, 0.6, 0.0); | |
glVertex3f( -0.2, -0.3, 0.0); | |
glVertex3f( 0.2, -0.3 ,0.0); | |
} | |
glEnd(); | |
} | |
-(void) drawRect: (NSRect) bounds{ | |
glClearColor(0, 0, 0, 0); | |
glClear(GL_COLOR_BUFFER_BIT); | |
drawAnObject(); | |
glFlush(); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment