Hi all,
I'm brand new to Objective-C/Cocoa/OpenGL/XCode (coming from windows web developing environment) and I was trying to run the most basic of OpenGL tutorials from the apple website (https://developer.apple.com/library...html#//apple_ref/doc/uid/TP40001987-CH404-SW8)
All I want to is make a colored triangle, yet my output is blank.
Here is my OpenGLView Class:
Here is a screenshot of how I set up the interface.
Here is my output:
I'm probably doing something insanely basic incorrectly, but I've been banging my head against the wall for hours. I have break points in my drawRect class that aren't being caught (though this could be because I'm not properly running xCode in debug mode...) and I have a label "Test" underneath the OpenGL object on the interface to see if it is getting covered up by a blank drawn window, and as you can see it is not. What am I doing wrong!?
Thanks for your help and patience!
I'm brand new to Objective-C/Cocoa/OpenGL/XCode (coming from windows web developing environment) and I was trying to run the most basic of OpenGL tutorials from the apple website (https://developer.apple.com/library...html#//apple_ref/doc/uid/TP40001987-CH404-SW8)
All I want to is make a colored triangle, yet my output is blank.
Here is my OpenGLView Class:
Code:
//
// MyOpenGLView.m
// Golden Triangle
#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
Here is a screenshot of how I set up the interface.
Here is my output:
I'm probably doing something insanely basic incorrectly, but I've been banging my head against the wall for hours. I have break points in my drawRect class that aren't being caught (though this could be because I'm not properly running xCode in debug mode...) and I have a label "Test" underneath the OpenGL object on the interface to see if it is getting covered up by a blank drawn window, and as you can see it is not. What am I doing wrong!?
Thanks for your help and patience!