I have been trying to implement a program in Cocoa where I take user input values from the user and draw a triangle in response to the values entered . However for some reason the program does not work.. Here is the source code for the implementation file...
#import "Triangle.h"
#include <OpenGL/gl.h>
@implementation Triangle
- (IBAction)nowid)sender
{
ver1x = [vertex1_x floatValue]; //
ver1y = [vertex1_y floatValue];
ver2x = [vertex2_x floatValue];
ver2y = [vertex2_y floatValue];
ver3x = [vertex3_x floatValue];
ver3y = [vertex3_y floatValue];
[self setBoundsNSMakeRect(0, 0, 500, 200) ) ];
[self setNeedsDisplay:YES];
NSLog(@"Taking Inputs");
NSLog(@"of vals %f", ver1x);
NSLog(@"Printing Self%@", self);
}
-(void)drawRectNSRect)bounds{
NSLog(@"DRAWING NOW");
NSLog(@"with values %f", ver1x);
glClearColor( 1, 0, 0, 0 ) ;
glClear( GL_COLOR_BUFFER_BIT ) ;
glColor3f( 0.0f, 1.0f, 0.0f ) ;
glBegin( GL_TRIANGLES) ;
{
glVertex3f( ver1x, ver1y, 0.0 ) ;
glVertex3f( ver2x, ver2y, 0.0 ) ;
glVertex3f( ver3x , ver3y, 0.0 ) ;
}
glEnd() ;
glFlush() ;
}
@end
I am a beginner in Cocoa and have no clue why the thing is not being redrawn.. could any one offer some suggestions as to how I can make buttons and fields in the interface talk to NSView???
Thanks a ton in advance
Vyom
#import "Triangle.h"
#include <OpenGL/gl.h>
@implementation Triangle
- (IBAction)nowid)sender
{
ver1x = [vertex1_x floatValue]; //
ver1y = [vertex1_y floatValue];
ver2x = [vertex2_x floatValue];
ver2y = [vertex2_y floatValue];
ver3x = [vertex3_x floatValue];
ver3y = [vertex3_y floatValue];
[self setBoundsNSMakeRect(0, 0, 500, 200) ) ];
[self setNeedsDisplay:YES];
NSLog(@"Taking Inputs");
NSLog(@"of vals %f", ver1x);
NSLog(@"Printing Self%@", self);
}
-(void)drawRectNSRect)bounds{
NSLog(@"DRAWING NOW");
NSLog(@"with values %f", ver1x);
glClearColor( 1, 0, 0, 0 ) ;
glClear( GL_COLOR_BUFFER_BIT ) ;
glColor3f( 0.0f, 1.0f, 0.0f ) ;
glBegin( GL_TRIANGLES) ;
{
glVertex3f( ver1x, ver1y, 0.0 ) ;
glVertex3f( ver2x, ver2y, 0.0 ) ;
glVertex3f( ver3x , ver3y, 0.0 ) ;
}
glEnd() ;
glFlush() ;
}
@end
I am a beginner in Cocoa and have no clue why the thing is not being redrawn.. could any one offer some suggestions as to how I can make buttons and fields in the interface talk to NSView???
Thanks a ton in advance
Vyom