head	1.1;
access;
symbols;
locks; strict;
comment	@// @;


1.1
date	99.06.08.00.56.10;	author brianp;	state Exp;
branches;
next	;


desc
@@


1.1
log
@initial check-in
@
text
@#import <MesaView.h>

@@interface MesaView(Private)
-(void)_renderImage;
-(void)_createViewport;
-(void)_startDrag;
-(void)_stopDrag:(NSTimer*)the_timer;
@@end

@@implementation MesaView

- initWithFrame:(NSRect)frameRect
{
    [super initWithFrame: frameRect];
    ctx = NULL;
    buffer = NULL;
    zoomDist=130;
    spinAngle=0;
    elevAngle=30;
    draggingBase=NO;
    averagingNormals=0;
    colourDrape=0;
    whiteBackground=NO;
    timer_object=nil;
    make_matrix();
    [self _createViewport];
    return self;
}

- (void)awakeFromNib
{
    [zoomSlider setFloatValue:zoomDist];
    [spinSlider setFloatValue:spinAngle];
    [elevSlider setFloatValue:elevAngle];
}


- (void)dealloc
{
    OSMesaDestroyContext(ctx);
    free(buffer);
    [timer_object invalidate];
    [timer_object release];
    [super dealloc];
}


- (BOOL)isOpaque
{
    return YES;
}

- (void)_createViewport
{
    if(buffer)
      free(buffer);
    buffer=malloc([self bounds].size.width*[self bounds].size.height*4);

    if(ctx)
      OSMesaDestroyContext(ctx);
    ctx = OSMesaCreateContext( GL_RGBA, NULL );
    OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE,
                       [self bounds].size.width, [self bounds].size.height );
    OSMesaPixelStore( OSMESA_Y_UP, 0 );


    my_init([self bounds].size.width,[self bounds].size.height);
}

- (void)resizeWithOldSuperviewSize:(NSSize)old
{
    [super resizeWithOldSuperviewSize:old];
    [self _createViewport];
    [self setNeedsDisplay:YES];
}

- (void)drawRect:(NSRect)rect
{
    set_viewpoint(zoomDist, elevAngle, spinAngle);
    if(draggingBase)
    {
      if(whiteBackground)
       {
        PSsetgray(1);
        NSRectFill(rect);
        PSsetgray(0);
       }
      else
       {
        PSsetgray(0);
        NSRectFill(rect);
        PSsetgray(1);
       }
       outline_scene();
       
    }
    else
    {
  *v>%uN\XJNm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