ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */


/*
 * $Log: osmesa.h,v $
 * Revision 1.4  1999/02/14 03:39:09  brianp
 * new copyright
 *
 * Revision 1.3  1999/01/03 02:52:30  brianp
 * now using GLAPI and GLAPIENTRY keywords (Ted Jump)
 *
 * Revision 1.2  1998/07/26 01:33:51  brianp
 * added WINGDIAPI and APIENTRY keywords per Ted Jump
 *
 * Revision 1.1  1998/02/13 03:17:50  brianp
 * Initial revision
 *
 */


/*
 * Mesa Off-Screen rendering interface.
 *
 * This is an operating system and window system independent interface to
 * Mesa which allows one to render images into a client-supplied buffer in
 * main memory.  Such images may manipulated or saved in whatever way the
 * client wants.
 *
 * These are the API functions:
 *   OSMesaCreateContext - create a new Off-Screen Mesa rendering context
 *   OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
 *                       and make the specified context the current one.
 *   OSMesaDestroyContext - destroy an OSMesaContext
 *   OSMesaGetCurrentContext - return thread's current context ID
 *   OSMesaPixelStore - controls how pixels are stored in image buffer
 *   OSMesaGetIntegerv - return OSMesa state parameters
 *
 *
 * The limits on the width and height of an image buffer are MAX_WIDTH and
 * MAX_HEIGHT as defined in Mesa/src/config.h.  Defaults are 1280 and 1024.
 * You can increase them as needed but beware that many temporary arrays in
 * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT.
 */



#ifndef OSMESA_H
#define OSMESA_H



#ifdef __cplusplus
extern "C" {
#endif


#include "GL/gl.h"



#define OSMESA_MAJOR_VERSION 3
#define OSMESA_MINOR_VERSION 0



/*
 * Values for the format parameter of OSMesaCreateContext()
 * New in version 2.0.
 */
#define OSMESA_COLOR_INDEX	GL_COLOR_INDEX
#define OSMESA_RGBA		GL_RGBA
#define OSMESA_BGRA		0x1
#define OSMESA_ARGB		0x2
#define OSMESA_RGB		GL_RGB
#define OSMESA_BGR		0x4


/*
 * OSMesaPixelStore() parameters:
 * New in version 2.0.
 */
#define OSMESA_ROW_LENGTH	0x10
#define OSMESA_Y_UP		0x11


/*
 * Accepted by OSMesaGetIntegerv:
 */
#define OSMESA_WIDTH		0x20
#define OSMESA_HEIGHT		0x21
#define OSMESA_FORMAT		0x22
#define OSMESA_TYPE		0x23



typedef struct osmesa_context *OSMesaContext;


#if defined(__BEOS__) || defined(__QUICKDRAW__)
#pragma export on
#endif


/*
 * Create an Off-Screen Mesa rendering context.  The only attribute needed is
 * an RGBA vs Color-Index mode flag.
 *
 * Input:  format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
 *                  OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
 *         sharelist - specifies another OSMesaContext with which to share
 *                     display lists.  NULL indicates no sharing.
 * Return:  an OSMesaContext or 0 if error
 */
GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContext( GLenum format,
                                          OSMesaContext sharelist );




/*
 * Destroy an Off-Screen Mesa rendering context.
 *
 * Input:  ctx - the context to destroy
 */
GLAPI void GLAPIENTRY OSMesaDestroyContext( OSMesaContext ctx );



/*
 * Bind an OSMesaContext to an image buffer.  The image buffer is just a
 * block of memory which the client provides.  Its size must be at least
 * as large as width*height*sizeof(type).  Its address should be a multiple
 * of 4 if using RGBA mode.
 *
 * Image data is stored in the order of glDrawPixels:  row-major order
 * with the lower-left image pixel stored in the first array position
 * (ie. bottom-to-top).
 *
 * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
 * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
 * value.  If the context is in color indexed mode, each pixel will be
 * stored as a 1-byte value.
 *
 * If the context's viewport hasn't been initialized yet, it will now be
 * initialized to (0,0,width,height).
 *
 * Input:  ctx - the rendering context
 *         buffer - the image buffer memory
 *         type - data type for pixel components, only GL_UNSIGNED_BYTE
 *                supported now
 *         width, height - size of image buffer in pixels, at least 1
 * Return:  GL_TRUE if success, GL_FALSE if error because of invalid ctx,
 *          invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
 *          width>internal limit or height>internal limit.
 */
GLAPI GLboolean GLAPIENTRY OSMesaMakeCurrent( OSMesaContext ctx,
                                    void *buffer, GLenum type,
                                    GLsizei width, GLsizei height );




/*
 * Return the current Off-Screen Mesa rendering context handle.
 */
GLAPI OSMesaContext GLAPIENTRY OSMesaGetCurrentContext( void );



/*
 * Set pixel store/packing parameters for the current context.
 * This is similar to glPixelStore.
 * Input:  pname - OSMESA_ROW_LENGTH
 *                    specify actual pixels per row in image buffer
 *                    0 = same as image width (default)
 *                 OSMESA_Y_UP
 *                    zero = Y coordinates increase downward
 *                    non-zero = Y coordinates increase upward (default)
 *         value - the value for the parameter pname
 *
 * New in version 2.0.
 */
GLAPI void GLAPIENTRY OSMesaPixelStore( GLint pname, GLint value );



/*
 * Return context info.  This is like glGetIntegerv.
 * Input:  pname -
 *                 OSMESA_WIDTH  return current image width
 *                 OSMESA_HEIGHT  return current image height
 *                 OSMESA_FORMAT  return image format
 *                 OSMESA_TYPE  return color component data type
 *                 OSMESA_ROW_LENGTH return row length in pixels
 *                 OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
 *         value - pointer to integer in which to return result.
 */
GLAPI void GLAPIENTRY OSMesaGetIntegerv( GLint pname, GLint *value );



/*
 * Return the depth buffer associated with an OSMesa context.
 * Input:  c - the OSMesa context
 * Output:  width, height - size of buffer in pixels
 *          bytesPerValue - bytes per depth value (2 or 4)
 *          buffer - pointer to depth buffer values
 * Return:  GL_TRUE or GL_FALSE to indicate success or failure.
 *
 * New in Mesa 2.4.
 */
GLAPI GLboolean GLAPIENTRY OSMesaGetDepthBuffer( OSMesaContext c,
                                       GLint *width, GLint *height,
                                       GLint *bytesPerValue, void **buffer );




#if defined(__BEOS__) || defined(__QUICKDRAW__)
#pragma export off
#endif


#ifdef __cplusplus
}
#endif


#endif
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               /* $Id: svgamesa.h,v 3.0 1998/02/20 05:07:24 brianp Exp $ */

/*
 * Mesa 3-D graphics library
 * Version:  3.0
 * Copyright (C) 1995-1998  Brian Paul
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */


/*
 * $Log: svgamesa.h,v $
 * Revision 3.0  1998/02/20 05:07:24  brianp
 * initial rev
 *
 */



/*
 * SVGA/Mesa interface for Linux.
 */


/*
 t-cards slot-id))))
			       (get-value (get-top-card 4)))))
		  (and (not (= slot-id 5))
		       (not (empty-slot? 5))
		       (to-tableau? (reverse (get-cards slot-id)) 5)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 5)))))
		  (and (not (= slot-id 7))
		       (not (empty-slot? 7))
		       (to-tableau? (reverse (get-cards slot-id)) 7)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 7)))))
		  (and (not (= slot-id 8))
		       (not (empty-slot? 8))
		       (to-tableau? (reverse (get-cards slot-id)) 8)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 8)))))
		  (and (not (= slot-id 9))
		       (not (empty-slot? 9))
		       (to-tableau? (reverse (get-cards slot-id)) 9)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 9)))))
		  (and (not (= slot-id 10))
		       (not (empty-slot? 10))
		       (to-tableau? (reverse (get-cards slot-id)) 10)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 10)))))
		  (and (not (= slot-id 12))
		       (not (empty-slot? 12))
		       (to-tableau? (reverse (get-cards slot-id)) 12)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 12)))))
		  (and (not (= slot-id 13))
		       (not (empty-slot? 13))
		       (to-tableau? (reverse (get-cards slot-id)) 13)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 13)))))
		  (and (not (= slot-id 14))
		       (not (empty-slot? 14))
		       (to-tableau? (reverse (get-cards slot-id)) 14)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 14)))))
		  (and (not (= slot-id 15))
		       (not (empty-slot? 15))
		       (to-tableau? (reverse (get-cards slot-id)) 15)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 15)))))
		  (and (not (= slot-id 17))
		       (not (empty-slot? 17))
		       (to-tableau? (reverse (get-cards slot-id)) 17)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 17)))))
		  (and (not (= slot-id 18))
		       (not (empty-slot? 18))
		       (to-tableau? (reverse (get-cards slot-id)) 18)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 18)))))
		  (and (not (= slot-id 19))
		       (not (empty-slot? 19))
		       (to-tableau? (reverse (get-cards slot-id)) 19)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 19)))))
		  (and (not (= slot-id 20))
		       (not (empty-slot? 20))
                       (to-tableau? (reverse (get-cards slot-id)) 20)
		       (not (= (get-value (cadr (reverse (get-cards slot-id))))
			       (get-value (get-top-card 20)))))))
	 #t)
	(#t #f)))

(define (check-a-tslot slot1 slot2)
  (if (> slot2 20)
      #f
      (if (and (not (= slot2 6))
	       (not (= slot2 11))
	       (not (= slot2 16))
	       (not (empty-slot? slot2))
	       (not (= slot1 slot2))
	       (not (empty-slot? slot1))
	       (to-tableau? (list (get-top-card slot1)) slot2)
	       (or (= slot1 1)
		   (= (length (get-cards slot1)) 1)
		   (not (= (get-value (cadr (get-cards slot1)))
			   (get-value (get-top-card slot2))))))
	  (if (and (not (= slot1 1))
		   (not (empty-slot? slot2))
		   (to-tableau? (list (get-top-card slot2)) slot1)
		   (check-slot-contents slot2))
	      (list 1 (get-name (get-top-card slot2))
		    (get-name (get-top-card slot1)))
	      (list 1 (get-name (get-top-card slot1))
		    (get-name (get-top-card slot2))))
	  (check-a-tslot slot1 (+ 1 slot2)))))

(define (check-tableau slot-id)
  (if (= slot-id 1)
      (and (not (empty-slot? 1))
	   (check-a-tslot 1 2))
      (if (or (= slot-id 6)
	      (= slot-id 11)
	      (= slot-id 16))
	  (check-tableau (- slot-id 1))
	  (or (check-a-tslot slot-id 2)
	      (check-tableau (- slot-id 1))))))

(define (check-for-empty slot-id)
  (if (= slot-id 21)
      #f
      (if (and (not (= slot-id 6))
	       (not (= slot-id 11))
	       (not (= slot-id 16))
	       (empty-slot? slot-id))
	  slot-id
	  (check-for-empty (+ 1 slot-id)))))

(define (check-rev-tableau slot1 slot2)
  (if (= slot2 21)
      #f
      (if (or (empty-slot? slot2)
	      (= slot1 slot2)
	      (= slot2 6)
	      (= slot2 11)
	      (= slot2 16))
	  (check-rev-tableau slot1 (+ 1 slot2))
	  (if (and (to-tableau? (reverse (get-cards slot1)) slot2)
		   (= (abs (- (get-value (cadr (reverse (get-cards slot1))))
			      (get-value (get-top-card slot2))))
		      2))
	      slot1
	      (check-rev-tableau slot1 (+ 1 slot2))))))

(define (check-for-bottom slot-id)
  (if (= slot-id 21)
      #f
      (if (or (empty-slot? slot-id)
	      (= 1 (length (get-cards slot-id)))
	      (= slot-id 6)
	      (= slot-id 11)
	      (= slot-id 16))
	  (check-for-bottom (+ 1 slot-id))
	  (or (check-rev-tableau slot-id 2)
	      (check-for-bottom (+ 1 slot-id))))))
	      
(define (contents-check slot-id)
  (if (= slot-id 21)
      #f
      (if (and (not (= slot-id 6))
	       (not (= slot-id 11))
	       (not (= slot-id 16))
	       (not (empty-slot? slot-id))
	       (check-slot-contents slot-id))
	  slot-id
	  (contents-check (+ 1 slot-id)))))

(define (check-empty-slot)
  (if (not (check-for-empty 2))
      #f
      (cond ((contents-check 2)
	     (list 2 (get-name (get-top-card (contents-check 2)))
		   "an empty slot"))
	    ((check-for-bottom 2)
	     (list 2 (get-name (get-top-card (check-for-bottom 2)))
		   "an empty slot"))
	    ((not (empty-slot? 1))
	     (list 2 (get-name (get-top-card 1)) "an empty slot"))
	    (#t #f))))

(define (dealable?)
  (if (not (empty-slot? 0))
      (list 0 "Deal a card")
      #f))

(define (get-hint)
  (or (check-to-foundations 1)
      (check-tableau 20)
      (check-empty-slot)
      (dealable?)))

(define (get-options) 
  #f)

(define (apply-options options) 
  #f)

(define (timeout) 
  #f)

(set-lambda new-game button-pressed button-released button-clicked
button-double-clicked game-continuable game-won get-hint get-options
apply-options timeout)

@


1.1
log
@
1999-03-02  Rosanna Yuen  <rwsy@@mit.edu>

	* union_square.scm: added new game
@
text
@d82 1
a82 1
  (set-statusbar-message (get-stock-no-string))
d87 3
d182 1
a182 1
  (set-statusbar-message (get-stock-no-string))
@

