diff options
Diffstat (limited to 'xc/extras/Mesa/OpenStep/Old_NeXT')
29 files changed, 4773 insertions, 0 deletions
diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/README b/xc/extras/Mesa/OpenStep/Old_NeXT/README new file mode 100644 index 000000000..bd18ad030 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/README @@ -0,0 +1,136 @@ + ======================================= + = NeXT (TM) Mesa-OpenGL (TM) = + ======================================= + by + Pascal Thibaudeau + pthibaud@cribx1.u-bordeaux.fr + pascal@galileo.slip.u-bordeaux.fr (NeXTMail OK) + + +@(#) README 1.4 96/11/29 19:49:23 + +# Revision 1.4 1996/11/29 19:49:23 pascal thibaudeau +# Mesa-2.0.1 fixed +# +# Revision 1.3 1996/10/16 10:59:02 pascal thibaudeau +# Mesa-2.0 fixed +# +# Revision 1.2 1996/05/16 00:17:02 pascal thibaudeau +# Mesa-1.2.8 fixed +# +# Revision 1.1 1996/03/02 15:03:07 pascal thibaudeau +# Initial revision +# + +1. Introduction +--------------- + +This is the README file for the NeXT version of the Mesa library. +The file consists of information specific to the NeXT version of Mesa. +For more general information please read the README file in the main Mesa +directory. + +2. Whats new? +------------- + +See the general Mesa README for all the new items in Mesa-2.0. This +section will only discuss those items which are specific to the NeXT. + + 0.4 Release + ========= + - New demos from the book directory + - old nextdemoX removed + + 0.3 Release + ========= + - Mesa-2.0 is fixed + + 0.2 Release + ========= + - Some tk functions are now supported. + - minor bugs are corrected. + + 0.1 Release + ========= + - Off-Screen rendering buffer is read by NXBitmapImageRep function. + - 32bpp is directly supported. + - WIDTH and HEIGHT are staticly defined. + - The window style is NX_TITLEDSTYLE. + - NeXT demos are straightforward ports of some book/ files. + + +3. The Distribution +------------------- + +NeXT Mesa is distributed in one form. This should make it easier to only +download what you need. The package is as follows: + + Mesa-2.0.tar.gz + +This release contains the complete source to Mesa for the NeXT + +4. Documentation +---------------- + +There is a Mesa WWW page: http://www.ssec.wisc.edu/~brianp/Mesa.html + +There is a general WWW page related to OpenGL under NeXTSTEP: +http://wwwcip.informatik.uni-erlangen.de/user/tsengel/ + +5. Compiling Mesa +---------------- + +In order to compile NeXT Mesa you need the following items: + + NEXTSTEP Developper Kit Release 3.3 + NeXT Mesa-2.0 (source) + +The project files included with the NeXT Mesa source should work +fine. The only things you may need to update are the access paths. +Simply typing "make next" should compile Mesa and a number of NeXT demo +programs found in the NeXT/ directory. This was tested on a i386,m68k running +NEXTSTEP 3.3. + +6. Test suite +------------- + +The NeXT version of Mesa does not pass many of the tests in the +demos or samples suites. This is primarily due to dependencies in the +suites on the size of particular X fonts, and other X related features. We +will be working on developping a more general NeXT suite for Mesa under +the NeXT, but for now, you will not be able to pass many of the tests. +It is, however, much better than the alpha release! + + +6. NeXT Mesa Mailing List +----------------------------- +if uou want to subscribe to the Mesa mailing list., please send the following +message to the address listproc@iqm.unicamp.br + +subs mesa <your name> + +For example: + +subs mesa Pascal Thibaudeau + +You will receive a welcome message from the list server when you have been +added to the list. It tells you how to post messages to the list, how +to unsubscribe, etc. Thanks to Pedro Vazquez for setting up the list. + +7. Acknowledgement +------------------------- +I would also like to thank the following contributors : + +Thomas Engel <tomi@shinto.nbg.sub.org>: GNU3DKit Project +Gregor Hoffleit <flight@mathi.uni-heidelberg.DE>: GNU3DKit Project +Pete French <pete@ohm.york.ac.uk>: + +If you have comments or Bug reports don't hesitate to send them to: +Pascal Thibaudeau +pthibaud@cribx1.u-bordeaux.fr +pascal@galileo.slip.u-bordeaux.fr (NeXTMail OK) + + + + + diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/README.FIRST b/xc/extras/Mesa/OpenStep/Old_NeXT/README.FIRST new file mode 100644 index 000000000..633e0e485 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/README.FIRST @@ -0,0 +1,7 @@ +This directory contains Pascal Thibaudeau's original code for NeXT support +under Mesa 2.0. This is now obsolete and NeXT support is incorporated +into OpenStep support. The generic.m file from this directory has been +used to make some of these demos continue to work. See the README +file in OpenStep/Old_Demos for details. + +-Pete French. (pete@ohm.york.ac.uk) 28/5/98 diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/README.rtf b/xc/extras/Mesa/OpenStep/Old_NeXT/README.rtf new file mode 100644 index 000000000..6657f4460 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/README.rtf @@ -0,0 +1,206 @@ +{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;\f1\fmodern Courier;\f2\fnil Times-Roman;} +\paperw9860 +\paperh12540 +\margl120 +\margr120 +{\colortbl;\red1\green12\blue44;\red3\green0\blue123;\red41\green4\blue44;\red0\green7\blue44;} +\pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\b0\i0\ulnone\fs24\fc0\cf0 \ + +\b\qc NeXT +\b0\fs16\up8 TM +\b\fs24 +\up0 Mesa-OpenGL +\b0\fs16\up8 TM +\fs24\up0 \ +by\ + +\b\gray46\fc1\cf1 Pascal Thibaudeau +\b0\gray0\fc0\cf0 \ +pthibaud@cribx1.u-bordeaux.fr \ +pascal@galileo.slip.u-bordeaux.fr ( +\f1 NeXTMail OK +\f0 )\ + +\ql @(#) README 1.4 96/11/29 19:49:23\ +\ +\ +# Revision 1.4 1996/11/29 19:49:23 pascal thibaudeau \ +# Mesa-2.0.1 fixed\ +#\ +# Revision 1.3 1996/10/16 10:59:02 pascal thibaudeau \ +# Mesa-2.0 fixed\ +#\ +# Revision 1.2 1996/05/16 00:17:02 pascal thibaudeau \ +# Mesa-1.2.8 fixed\ +#\ +# Revision 1.1 1996/03/02 15:03:07 pascal thibaudeau \ +# Mesa-1.2.7 fixed\ +# Initial revision\ +#\ +\ + +\b 1. Introduction +\b0 \ +\ +This is the README file for the NeXT version of the +\i Mesa +\i0 library. \ +The file consists of information specific to the NeXT version of +\i Mesa +\i0 .\ +For more general information please read the README file in the main +\i Mesa +\i0 \ +directory.\ +\ + +\b 2. Whats new? +\b0 \ +\ +See the general +\i Mesa +\i0 README for all new items in Mesa-2.0. This\ +section will only discuss those items which are specific to the NeXT.\ +\ + +\gray56\fc2\cf2 0.4 Release +\gray0\fc0\cf0 \ + =========\ + - New demos from the book directory.\ + - old nextdemoX removed.\ +\ + +\gray56\fc2\cf2 0.3 Release +\gray0\fc0\cf0 \ + =========\ + - Mesa-2.0 is fixed.\ +\ + +\gray56\fc2\cf2 0.2 Release +\gray0\fc0\cf0 \ + =========\ + - Some tk functions are now supported.\ + - minor bugs are corrected.\ +\ + +\gray56\fc2\cf2 0.1 Release +\gray0\fc0\cf0 \ + =========\ + - Off-Screen rendering buffer is read by +\f1 NXBitmapImageRep +\f0 function.\ + - 32bpp is directly supported.\ + - WIDTH and HEIGHT are staticly defined.\ + - The window style is +\f1 NX_TITLEDSTYLE +\f0 .\ + - NeXT demos are straightforward ports of some book/ files.\ + \ + \ + +\b 3. The Distribution +\b0 \ +\ +NeXT +\i Mesa +\i0 is distributed in one form. This should make it easier to \ +download only what you need. The package is as follows:\ +\ + +\f1 Mesa-2.0.tar.gz +\f0 \ +\ +This release contains the complete source to +\i Mesa +\i0 for the NeXT\ +\ + +\b 4. Documentation +\b0 \ +\ +The +\i Mesa +\i0 WWW page is : +\gray75\fc3\cf3 http://www.ssec.wisc.edu/~brianp/Mesa.html +\gray0\fc0\cf0 \ +\ +There is also a general WWW page related to OpenGL under NeXTSTEP:\ + +\gray75\fc3\cf3 http://wwwcip.informatik.uni-erlangen.de/user/tsengel/ +\gray0\fc0\cf0 \ +\ + +\b 5. Compiling Mesa +\b0 \ +\ +In order to compile NeXT +\i Mesa +\i0 you need the following items:\ +\ + NEXTSTEP Developper Kit Release 3.3\ + NeXT Mesa-2.0 (source)\ +\ +The project files included with the NeXT +\i Mesa +\i0 source should work \ +fine. The only things you may need to update are the access paths.\ +Simply typing "make next" should compile Mesa and a number of NeXT demo\ +programs found in the NeXT/ directory. This was tested on a i386,m68k running \ +NEXTSTEP 3.3. \ +\ + +\b 6. Test suite +\b0 \ +\ +The NeXT version of +\i Mesa +\i0 does not pass many of the tests in the\ +demos or samples suites. This is primarily due to dependencies in the \ +suites on the size of particular X fonts, and other X related features. We\ +will be working on developping a more general NeXT suite for +\i Mesa +\i0 under the\ +NeXT, but for now, you will not be able to pass many of the tests. \ +It is, however, much better than the alpha release!\ +\ +\ + +\b 7. NeXT Mesa Mailing List\ +\ + +\b0 If you want to subscribe to the +\i Mesa +\i0 Mailing List, please send the following message to the address listproc@iqm.unicamp.br\ +\ + +\f1 subs mesa <your name> +\f0 \ +\ +For example:\ +\ + +\f1 subs mesa Pascal Thibaudeau\ + +\f0 \ +You will receive a welcome message from the list server when you have been\ +added to the list. It tells you how to post messages to the list, how\ +to unsubscribe, etc. Thanks to Pedro Vazquez for setting up the list.\ +\ + +\b 8. Acknowledgements\ + +\b0 \ +I would also like to thank the following contributors :\ +\ +Thomas Engel <tomi@shinto.nbg.sub.org>: GNU3DKit Project\ +Gregor Hoffleit <flight@mathi.uni-heidelberg.DE>: GNU3DKit Project\ +Pete French <pete@ohm.york.ac.uk>:\ +\ +\ +If you have comments or Bug reports don't hesitate to send them to:\ + +\gray35\fc4\cf4 Pascal Thibaudeau\ +pthibaud@cribx1.u-bordeaux.fr\ +pascal@galileo.slip.u-bordeaux.fr (NeXTMail OK)\ + +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/alpha3D.c b/xc/extras/Mesa/OpenStep/Old_NeXT/alpha3D.c new file mode 100644 index 000000000..96d2db824 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/alpha3D.c @@ -0,0 +1,137 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * alpha3D.c + * This program demonstrates how to intermix opaque and + * alpha blended polygons in the same scene, by using glDepthMask. + * Pressing the left mouse button toggles the eye position. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +void myinit(void) +{ + GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 0.15 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 0.15 }; + GLfloat mat_shininess[] = { 15.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + + glEnable (GL_LIGHTING); + glEnable (GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +GLboolean eyePosition = GL_FALSE; + +void toggleEye (AUX_EVENTREC *event) +{ + if (eyePosition) + eyePosition = GL_FALSE; + else + eyePosition = GL_TRUE; +} + +void display(void) +{ + GLfloat position[] = { 0.0, 0.0, 1.0, 1.0 }; + GLfloat mat_torus[] = { 0.75, 0.75, 0.0, 1.0 }; + GLfloat mat_cylinder[] = { 0.0, 0.75, 0.75, 0.15 }; + + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLightfv (GL_LIGHT0, GL_POSITION, position); + glPushMatrix (); + if (eyePosition) + gluLookAt (0.0, 0.0, 9.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); + else + gluLookAt (0.0, 0.0, -9.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); + glPushMatrix (); + glTranslatef (0.0, 0.0, 1.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_torus); + auxSolidTorus (0.275, 0.85); + glPopMatrix (); + + glEnable (GL_BLEND); + glDepthMask (GL_FALSE); + glBlendFunc (GL_SRC_ALPHA, GL_ONE); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_cylinder); + glTranslatef (0.0, 0.0, -1.0); + auxSolidCylinder (1.0, 2.0); + glDepthMask (GL_TRUE); + glDisable (GL_BLEND); + glPopMatrix (); + + glFlush (); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(30.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ + + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} + + + + + + + diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/checker.c b/xc/extras/Mesa/OpenStep/Old_NeXT/checker.c new file mode 100644 index 000000000..9f777d8ec --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/checker.c @@ -0,0 +1,122 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* checker.c + * This program texture maps a checkerboard image onto + * two rectangles. This program clamps the texture, if + * the texture coordinates fall outside 0.0 and 1.0. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +/* Create checkerboard texture */ +#define checkImageWidth 64 +#define checkImageHeight 64 +GLubyte checkImage[checkImageWidth][checkImageHeight][3]; + +void makeCheckImage(void) +{ + int i, j, r, c; + + for (i = 0; i < checkImageWidth; i++) { + for (j = 0; j < checkImageHeight; j++) { + c = ((((i&0x8)==0)^((j&0x8))==0))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + } + } +} + +void myinit(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + makeCheckImage(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth, + checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, + &checkImage[0][0][0]); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); + glShadeModel(GL_FLAT); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + glEnd(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -3.6); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/checker2.c b/xc/extras/Mesa/OpenStep/Old_NeXT/checker2.c new file mode 100644 index 000000000..76c855484 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/checker2.c @@ -0,0 +1,122 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* checker2.c + * This program texture maps a checkerboard image onto + * two rectangles. This program repeats the texture, if + * the texture coordinates fall outside 0.0 and 1.0. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +/* Create checkerboard texture */ +#define checkImageWidth 64 +#define checkImageHeight 64 +GLubyte checkImage[checkImageWidth][checkImageHeight][3]; + +void makeCheckImage(void) +{ + int i, j, r, c; + + for (i = 0; i < checkImageWidth; i++) { + for (j = 0; j < checkImageHeight; j++) { + c = ((((i&0x8)==0)^((j&0x8))==0))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + } + } +} + +void myinit(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + makeCheckImage(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth, + checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, + &checkImage[0][0][0]); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); + glShadeModel(GL_FLAT); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 3.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(3.0, 3.0); glVertex3f(0.0, 1.0, 0.0); + glTexCoord2f(3.0, 0.0); glVertex3f(0.0, -1.0, 0.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 3.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(3.0, 3.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(3.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + glEnd(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -3.6); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/chess.c b/xc/extras/Mesa/OpenStep/Old_NeXT/chess.c new file mode 100644 index 000000000..1184dd26f --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/chess.c @@ -0,0 +1,120 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* chess.c + * This program texture maps a checkerboard image onto + * two rectangles. The texture coordinates for the + * rectangles are 0.0 to 3.0. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include <math.h> +#include "glaux.h" + +#define checkImageWidth 64 +#define checkImageHeight 64 +GLubyte checkImage[checkImageWidth][checkImageHeight][3]; + +void makecheckimage(void) +{ + int i, j, r, c; + + for (i = 0; i < checkImageWidth; i++) { + for (j = 0; j < checkImageHeight; j++) { + c = ((((i&0x8)==0)^((j&0x8))==0))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + } + } +} + +void myinit(void) +{ + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + makecheckimage(); + glTexImage2D(GL_TEXTURE_2D, 0, 3, + checkImageWidth, checkImageHeight, 0, + GL_RGB, GL_UNSIGNED_BYTE, &checkImage[0][0][0]); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); + glShadeModel(GL_FLAT); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 3.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(3.0, 3.0); glVertex3f(0.0, 1.0, 0.0); + glTexCoord2f(3.0, 0.0); glVertex3f(0.0, -1.0, 0.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 3.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(3.0, 3.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(3.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + glEnd(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -3.6); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/cone.c b/xc/extras/Mesa/OpenStep/Old_NeXT/cone.c new file mode 100644 index 000000000..9e464e504 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/cone.c @@ -0,0 +1,117 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * cone.c + * This program demonstrates the use of the GL lighting model. + * A sphere is drawn using a grey material characteristic. + * A single light source illuminates the object. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +/* Initialize material property, light source, and lighting model. + */ +void myinit(void) +{ + GLfloat mat_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + GLfloat mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 }; +/* mat_specular and mat_shininess are NOT default values */ + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 50.0 }; + + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; +/* light_position is NOT default value */ + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glTranslatef (0.0, -1.0, 0.0); + glRotatef (250.0, 1.0, 0.0, 0.0); + auxSolidCone(1.0, 2.0); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, + 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-1.5*(GLfloat)w/(GLfloat)h, + 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/cone_ball.c b/xc/extras/Mesa/OpenStep/Old_NeXT/cone_ball.c new file mode 100644 index 000000000..4f10e3be9 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/cone_ball.c @@ -0,0 +1,80 @@ +#include <stdio.h> +#include <stdlib.h> +#include "GL/osmesa.h" + +int gl_width=480; +int gl_height=480; + +void init(void) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); +} + +/* + * reshape simply creates an orthographic projection + * within the viewport. + */ +void reshape(int w, int h) +{ + glViewport(0,0,w,h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-2.5, 2.5, -2.5, 2.5, -5.0, 5.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void display(void) +{ + GLfloat red_mat[] = { 1.0, 0.0, 0.0, 0.5 }; + GLfloat green_mat[] = { 0.0, 1.0, 0.0, 0.5 }; + GLfloat blue_mat[] = { 0.0, 0.0, 1.0, 0.5}; + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(20.0, 1.0, 0.0, 0.0); + + glPushMatrix(); + glTranslatef(-0.75, 0.5, 0.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red_mat ); + auxSolidTorus(0.275, 0.85); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-0.75, -0.5, 0.0); + glRotatef(270.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green_mat ); + auxSolidCone(1.0, 2.0); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(0.75, 0.0, -1.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat ); + auxSolidSphere(1.0); + glPopMatrix(); + + glPopMatrix(); +} + +void render_image(void) +{ + init(); + reshape(gl_width,gl_height); + display(); +} + diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/disk.c b/xc/extras/Mesa/OpenStep/Old_NeXT/disk.c new file mode 100644 index 000000000..7ccde828f --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/disk.c @@ -0,0 +1,114 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * disk.c + * This program demonstrates the use of the quadrics + * Utility Library routines to draw circles and arcs. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +GLUquadricObj * quadObj; + +/* Clear the screen. For each triangle, set the current + * color and modify the modelview matrix. + */ +void display(void) +{ + glClearColor (0.0, 0.0, 0.0, 1.0); + glClear (GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + gluQuadricDrawStyle (quadObj, GLU_FILL); + glColor3f (1.0, 1.0, 1.0); + glTranslatef (10.0, 10.0, 0.0); + gluDisk (quadObj, 0.0, 5.0, 10, 2); + glPopMatrix(); + + glPushMatrix(); + glColor3f (1.0, 1.0, 0.0); + glTranslatef (20.0, 20.0, 0.0); + gluPartialDisk (quadObj, 0.0, 5.0, 10, 3, 30.0, 120.0); + glPopMatrix(); + + glPushMatrix(); + gluQuadricDrawStyle (quadObj, GLU_SILHOUETTE); + glColor3f (0.0, 1.0, 1.0); + glTranslatef (30.0, 30.0, 0.0); + gluPartialDisk (quadObj, 0.0, 5.0, 10, 3, 135.0, 270.0); + glPopMatrix(); + + glPushMatrix(); + gluQuadricDrawStyle (quadObj, GLU_LINE); + glColor3f (1.0, 0.0, 1.0); + glTranslatef (40.0, 40.0, 0.0); + gluDisk (quadObj, 2.0, 5.0, 10, 10); + glPopMatrix(); + glFlush(); +} + +void myinit (void) { + quadObj = gluNewQuadric (); + glShadeModel(GL_FLAT); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (0.0, 50.0, + 0.0, 50.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0); + else + glOrtho (0.0, 50.0*(GLfloat)w/(GLfloat)h, + 0.0, 50.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity (); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/dof.c b/xc/extras/Mesa/OpenStep/Old_NeXT/dof.c new file mode 100644 index 000000000..25d2d19b6 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/dof.c @@ -0,0 +1,234 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * dof.c + * This program demonstrates use of the accumulation buffer to + * create an out-of-focus depth-of-field effect. The teapots + * are drawn several times into the accumulation buffer. The + * viewing volume is jittered, except at the focal point, where + * the viewing volume is at the same position, each time. In + * this case, the gold teapot remains in focus. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include <math.h> +#include "glaux.h" +#include "jitter.h" + +#define PI_ 3.14159265358979323846 + +/* accFrustum() + * The first 6 arguments are identical to the glFrustum() call. + * + * pixdx and pixdy are anti-alias jitter in pixels. + * Set both equal to 0.0 for no anti-alias jitter. + * eyedx and eyedy are depth-of field jitter in pixels. + * Set both equal to 0.0 for no depth of field effects. + * + * focus is distance from eye to plane in focus. + * focus must be greater than, but not equal to 0.0. + * + * Note that accFrustum() calls glTranslatef(). You will + * probably want to insure that your ModelView matrix has been + * initialized to identity before calling accFrustum(). + */ +void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, + GLdouble top, GLdouble near, GLdouble far, GLdouble pixdx, + GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus) +{ + GLdouble xwsize, ywsize; + GLdouble dx, dy; + GLint viewport[4]; + + glGetIntegerv (GL_VIEWPORT, viewport); + + xwsize = right - left; + ywsize = top - bottom; + + dx = -(pixdx*xwsize/(GLdouble) viewport[2] + eyedx*near/focus); + dy = -(pixdy*ywsize/(GLdouble) viewport[3] + eyedy*near/focus); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum (left + dx, right + dx, bottom + dy, top + dy, near, far); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef (-eyedx, -eyedy, 0.0); +} + +/* accPerspective() + * + * The first 4 arguments are identical to the gluPerspective() call. + * pixdx and pixdy are anti-alias jitter in pixels. + * Set both equal to 0.0 for no anti-alias jitter. + * eyedx and eyedy are depth-of field jitter in pixels. + * Set both equal to 0.0 for no depth of field effects. + * + * focus is distance from eye to plane in focus. + * focus must be greater than, but not equal to 0.0. + * + * Note that accPerspective() calls accFrustum(). + */ +void accPerspective(GLdouble fovy, GLdouble aspect, + GLdouble near, GLdouble far, GLdouble pixdx, GLdouble pixdy, + GLdouble eyedx, GLdouble eyedy, GLdouble focus) +{ + GLdouble fov2,left,right,bottom,top; + + fov2 = ((fovy*PI_) / 180.0) / 2.0; + + top = near / (cos(fov2) / sin(fov2)); + bottom = -top; + + right = top * aspect; + left = -right; + + accFrustum (left, right, bottom, top, near, far, + pixdx, pixdy, eyedx, eyedy, focus); +} + +void myinit(void) +{ + GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat position[] = { 0.0, 3.0, 3.0, 0.0 }; + + GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + GLfloat local_view[] = { 0.0 }; + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glFrontFace (GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearAccum(0.0, 0.0, 0.0, 0.0); +} + +void renderTeapot (GLfloat x, GLfloat y, GLfloat z, + GLfloat ambr, GLfloat ambg, GLfloat ambb, + GLfloat difr, GLfloat difg, GLfloat difb, + GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine) +{ + float mat[4]; + + glPushMatrix(); + glTranslatef (x, y, z); + mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0; + glMaterialfv (GL_FRONT, GL_AMBIENT, mat); + mat[0] = difr; mat[1] = difg; mat[2] = difb; + glMaterialfv (GL_FRONT, GL_DIFFUSE, mat); + mat[0] = specr; mat[1] = specg; mat[2] = specb; + glMaterialfv (GL_FRONT, GL_SPECULAR, mat); + glMaterialf (GL_FRONT, GL_SHININESS, shine*128.0); + auxSolidTeapot(0.5); + glPopMatrix(); +} + +/* display() draws 5 teapots into the accumulation buffer + * several times; each time with a jittered perspective. + * The focal point is at z = 5.0, so the gold teapot will + * stay in focus. The amount of jitter is adjusted by the + * magnitude of the accPerspective() jitter; in this example, 0.33. + * In this example, the teapots are drawn 8 times. See jitter.h + */ +void display(void) +{ + int jitter; + GLint viewport[4]; + + glGetIntegerv (GL_VIEWPORT, viewport); + glClear(GL_ACCUM_BUFFER_BIT); + + for (jitter = 0; jitter < 8; jitter++) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + accPerspective (45.0, + (GLdouble) viewport[2]/(GLdouble) viewport[3], + 1.0, 15.0, 0.0, 0.0, + 0.33*j8[jitter].x, 0.33*j8[jitter].y, 5.0); +/* ruby, gold, silver, emerald, and cyan teapots */ + renderTeapot (-1.1, -0.5, -4.5, 0.1745, 0.01175, 0.01175, + 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); + renderTeapot (-0.5, -0.5, -5.0, 0.24725, 0.1995, 0.0745, + 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4); + renderTeapot (0.2, -0.5, -5.5, 0.19225, 0.19225, 0.19225, + 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4); + renderTeapot (1.0, -0.5, -6.0, 0.0215, 0.1745, 0.0215, + 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6); + renderTeapot (1.8, -0.5, -6.5, 0.0, 0.1, 0.06, 0.0, 0.50980392, + 0.50980392, 0.50196078, 0.50196078, 0.50196078, .25); + glAccum (GL_ACCUM, 0.125); + } + + glAccum (GL_RETURN, 1.0); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, depth buffer, and handle input events. + */ +int gl_width=250; +int gl_height=250; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/font.c b/xc/extras/Mesa/OpenStep/Old_NeXT/font.c new file mode 100644 index 000000000..cbc1d6b7a --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/font.c @@ -0,0 +1,220 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * font.c + * + * Draws some text in a bitmapped font. Uses glBitmap() + * and other pixel routines. Also demonstrates use of + * display lists. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include <string.h> +#include "glaux.h" + +GLubyte rasters[][13] = { +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36}, +{0x00, 0x00, 0x00, 0x66, 0x66, 0xff, 0x66, 0x66, 0xff, 0x66, 0x66, 0x00, 0x00}, +{0x00, 0x00, 0x18, 0x7e, 0xff, 0x1b, 0x1f, 0x7e, 0xf8, 0xd8, 0xff, 0x7e, 0x18}, +{0x00, 0x00, 0x0e, 0x1b, 0xdb, 0x6e, 0x30, 0x18, 0x0c, 0x76, 0xdb, 0xd8, 0x70}, +{0x00, 0x00, 0x7f, 0xc6, 0xcf, 0xd8, 0x70, 0x70, 0xd8, 0xcc, 0xcc, 0x6c, 0x38}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1c, 0x0c, 0x0e}, +{0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c}, +{0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30}, +{0x00, 0x00, 0x00, 0x00, 0x99, 0x5a, 0x3c, 0xff, 0x3c, 0x5a, 0x99, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0xff, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00}, +{0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x60, 0x60, 0x30, 0x30, 0x18, 0x18, 0x0c, 0x0c, 0x06, 0x06, 0x03, 0x03}, +{0x00, 0x00, 0x3c, 0x66, 0xc3, 0xe3, 0xf3, 0xdb, 0xcf, 0xc7, 0xc3, 0x66, 0x3c}, +{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x38, 0x18}, +{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0xe7, 0x7e}, +{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0x07, 0x03, 0x03, 0xe7, 0x7e}, +{0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xcc, 0x6c, 0x3c, 0x1c, 0x0c}, +{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xff}, +{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, +{0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x03, 0x03, 0xff}, +{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e}, +{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x03, 0x7f, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e}, +{0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06}, +{0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60}, +{0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x18, 0x0c, 0x06, 0x03, 0xc3, 0xc3, 0x7e}, +{0x00, 0x00, 0x3f, 0x60, 0xcf, 0xdb, 0xd3, 0xdd, 0xc3, 0x7e, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18}, +{0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, +{0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, +{0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc}, +{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff}, +{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff}, +{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, +{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, +{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e}, +{0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06}, +{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3}, +{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}, +{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3}, +{0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3}, +{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e}, +{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, +{0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c}, +{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, +{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e}, +{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff}, +{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, +{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, +{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, +{0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, +{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, +{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff}, +{0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c}, +{0x00, 0x03, 0x03, 0x06, 0x06, 0x0c, 0x0c, 0x18, 0x18, 0x30, 0x30, 0x60, 0x60}, +{0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18}, +{0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x30, 0x70}, +{0x00, 0x00, 0x7f, 0xc3, 0xc3, 0x7f, 0x03, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}, +{0x00, 0x00, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x03, 0x03, 0x03, 0x03, 0x03}, +{0x00, 0x00, 0x7f, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x33, 0x1e}, +{0x7e, 0xc3, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0}, +{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00}, +{0x38, 0x6c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x00}, +{0x00, 0x00, 0xc6, 0xcc, 0xf8, 0xf0, 0xd8, 0xcc, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0}, +{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78}, +{0x00, 0x00, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xfe, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xfc, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00}, +{0xc0, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0x00, 0x00, 0x00, 0x00}, +{0x03, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xfe, 0x03, 0x03, 0x7e, 0xc0, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x1c, 0x36, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x00}, +{0x00, 0x00, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00}, +{0xc0, 0x60, 0x60, 0x30, 0x18, 0x3c, 0x66, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0xff, 0x60, 0x30, 0x18, 0x0c, 0x06, 0xff, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x0f, 0x18, 0x18, 0x18, 0x38, 0xf0, 0x38, 0x18, 0x18, 0x18, 0x0f}, +{0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}, +{0x00, 0x00, 0xf0, 0x18, 0x18, 0x18, 0x1c, 0x0f, 0x1c, 0x18, 0x18, 0x18, 0xf0}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x8f, 0xf1, 0x60, 0x00, 0x00, 0x00} +}; + +GLuint fontOffset; + +void makeRasterFont(void) +{ + GLuint i; + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + fontOffset = glGenLists (128); + for (i = 32; i < 127; i++) { + glNewList(i+fontOffset, GL_COMPILE); + glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, rasters[i-32]); + glEndList(); + } +} + +void myinit(void) +{ + glShadeModel (GL_FLAT); + makeRasterFont(); +} + +void printString(char *s) +{ + glPushAttrib (GL_LIST_BIT); + glListBase(fontOffset); + glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s); + glPopAttrib (); +} + +/* Everything above this line could be in a library that defines a font. + * To make it work, you've got to call makeRasterFont() before you start + * making calls to printString(). + */ +void display(void) +{ + GLfloat white[3] = { 1.0, 1.0, 1.0 }; + int i, j; + char teststring[33]; + + glClear(GL_COLOR_BUFFER_BIT); + glColor3fv(white); + for (i = 32; i < 127; i += 32) { + glRasterPos2i(20, 200 - 18*i/32); + for (j = 0; j < 32; j++) + teststring[j] = (char) (i+j); + teststring[32] = 0; + printString(teststring); + } + glRasterPos2i(20, 100); + printString("The quick brown fox jumps"); + glRasterPos2i(20, 82); + printString("over a lazy dog."); + glFlush (); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho (0.0, w, 0.0, h, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/generic.m b/xc/extras/Mesa/OpenStep/Old_NeXT/generic.m new file mode 100644 index 000000000..31bad2e7a --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/generic.m @@ -0,0 +1,121 @@ +/* generic.m*/ + +/* Demo of NEXTSTEP Mesa rendering */ + +/* + * See Mesa/include/GL/osmesa.h for documentation of the OSMesa functions. + * + * If you want to render BIG images you'll probably have to increase + * MAX_WIDTH and MAX_HEIGHT in src/config.h. + * + * This program is in the public domain. + * + * Brian Paul + * + * NEXTSTEP output provided by Pascal Thibaudeau + * pthibaud@cribx1.u-bordeaux.fr + * OpenStep conversion by Pete French + * pete@ohm.york.ac.uk + */ + +#import <appkit/Application.h> +#import <appkit/Window.h> +#import <appkit/Menu.h> +#import <appkit/View.h> +#import <appkit/color.h> +#import <appkit/NXBitmapImageRep.h> +#import <stdio.h> +#import <stdlib.h> +#import "GL/osmesa.h" + +extern int gl_width,gl_height; +extern void render_image(void); + +int main( int argc, char *argv[] ) +{ + OSMesaContext ctx; + unsigned char *buffer; + id myWindow; + id myView; + id myMenu; + char name[50]; + unsigned long start, end; + NXBitmapImageRep *bitmap; + NXRect GR; + + NXApp=[Application new]; + + /* Create an RGBA-mode context */ + ctx = OSMesaCreateContext( GL_RGBA, NULL ); + + /* Allocate the image buffer */ + buffer = malloc( gl_width * gl_height * 4 ); + + /* Bind the buffer to the context and make it current */ + OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, gl_width, gl_height ); + OSMesaPixelStore( OSMESA_Y_UP, 0 ); + + /* Fill the bitmap with the buffer */ + bitmap = [[ NXBitmapImageRep alloc] + initData: buffer + pixelsWide:gl_width + pixelsHigh:gl_height + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpace: 2 + bytesPerRow:gl_width*4 + bitsPerPixel: 32]; + + NXSetRect(&GR,100, 100, gl_width, gl_height); + + myWindow = [[ Window alloc] + initContent: &GR + style:NX_TITLEDSTYLE + backing: NX_BUFFERED + buttonMask: NX_MINIATURIZEBUTTONMASK + defer: NO]; + + sprintf(name, "Mesa demo: `%s'", argv[0]); + + myView = [[ View alloc] initFrame:&GR]; + + myMenu = [[ Menu alloc] initTitle: "NeXTStep Mesa"]; + [myMenu addItem: "Quit" + action:@selector(terminate:) + keyEquivalent: 'q']; + [myMenu sizeToFit]; + + [myWindow setTitle: name]; + [myWindow display]; + [myWindow setContentView:myView]; + [myWindow makeKeyAndOrderFront:nil]; + + [NXApp setMainMenu:myMenu]; + + [myView lockFocus]; + + /* here is the Mesa call */ + start=time(0); + render_image(); + end=time(0); + printf("Rendering took %ld seconds\n",end-start); + fflush(stdout); + + /* draw the bitmap */ + [bitmap draw]; + /* free the bitmap */ + [bitmap free]; + [myWindow flushWindow]; + [myView unlockFocus]; + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + [NXApp run]; + [NXApp free]; + + return 0; +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/jitter.h b/xc/extras/Mesa/OpenStep/Old_NeXT/jitter.h new file mode 100644 index 000000000..1ec08c87f --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/jitter.h @@ -0,0 +1,222 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* +jitter.h + +This file contains jitter point arrays for 2,3,4,8,15,24 and 66 jitters. + +The arrays are named j2, j3, etc. Each element in the array has the form, +for example, j8[0].x and j8[0].y + +Values are floating point in the range -.5 < x < .5, -.5 < y < .5, and +have a gaussian distribution around the origin. + +Use these to do model jittering for scene anti-aliasing and view volume +jittering for depth of field effects. Use in conjunction with the +accwindow() routine. +*/ + +typedef struct +{ + GLfloat x, y; +} jitter_point; + +#define MAX_SAMPLES 66 + + +/* 2 jitter points */ +jitter_point j2[] = +{ + { 0.246490, 0.249999}, + {-0.246490, -0.249999} +}; + + +/* 3 jitter points */ +jitter_point j3[] = +{ + {-0.373411, -0.250550}, + { 0.256263, 0.368119}, + { 0.117148, -0.117570} +}; + + +/* 4 jitter points */ +jitter_point j4[] = +{ + {-0.208147, 0.353730}, + { 0.203849, -0.353780}, + {-0.292626, -0.149945}, + { 0.296924, 0.149994} +}; + + +/* 8 jitter points */ +jitter_point j8[] = +{ + {-0.334818, 0.435331}, + { 0.286438, -0.393495}, + { 0.459462, 0.141540}, + {-0.414498, -0.192829}, + {-0.183790, 0.082102}, + {-0.079263, -0.317383}, + { 0.102254, 0.299133}, + { 0.164216, -0.054399} +}; + + +/* 15 jitter points */ +jitter_point j15[] = +{ + { 0.285561, 0.188437}, + { 0.360176, -0.065688}, + {-0.111751, 0.275019}, + {-0.055918, -0.215197}, + {-0.080231, -0.470965}, + { 0.138721, 0.409168}, + { 0.384120, 0.458500}, + {-0.454968, 0.134088}, + { 0.179271, -0.331196}, + {-0.307049, -0.364927}, + { 0.105354, -0.010099}, + {-0.154180, 0.021794}, + {-0.370135, -0.116425}, + { 0.451636, -0.300013}, + {-0.370610, 0.387504} +}; + + +/* 24 jitter points */ +jitter_point j24[] = +{ + { 0.030245, 0.136384}, + { 0.018865, -0.348867}, + {-0.350114, -0.472309}, + { 0.222181, 0.149524}, + {-0.393670, -0.266873}, + { 0.404568, 0.230436}, + { 0.098381, 0.465337}, + { 0.462671, 0.442116}, + { 0.400373, -0.212720}, + {-0.409988, 0.263345}, + {-0.115878, -0.001981}, + { 0.348425, -0.009237}, + {-0.464016, 0.066467}, + {-0.138674, -0.468006}, + { 0.144932, -0.022780}, + {-0.250195, 0.150161}, + {-0.181400, -0.264219}, + { 0.196097, -0.234139}, + {-0.311082, -0.078815}, + { 0.268379, 0.366778}, + {-0.040601, 0.327109}, + {-0.234392, 0.354659}, + {-0.003102, -0.154402}, + { 0.297997, -0.417965} +}; + + +/* 66 jitter points */ +jitter_point j66[] = +{ + { 0.266377, -0.218171}, + {-0.170919, -0.429368}, + { 0.047356, -0.387135}, + {-0.430063, 0.363413}, + {-0.221638, -0.313768}, + { 0.124758, -0.197109}, + {-0.400021, 0.482195}, + { 0.247882, 0.152010}, + {-0.286709, -0.470214}, + {-0.426790, 0.004977}, + {-0.361249, -0.104549}, + {-0.040643, 0.123453}, + {-0.189296, 0.438963}, + {-0.453521, -0.299889}, + { 0.408216, -0.457699}, + { 0.328973, -0.101914}, + {-0.055540, -0.477952}, + { 0.194421, 0.453510}, + { 0.404051, 0.224974}, + { 0.310136, 0.419700}, + {-0.021743, 0.403898}, + {-0.466210, 0.248839}, + { 0.341369, 0.081490}, + { 0.124156, -0.016859}, + {-0.461321, -0.176661}, + { 0.013210, 0.234401}, + { 0.174258, -0.311854}, + { 0.294061, 0.263364}, + {-0.114836, 0.328189}, + { 0.041206, -0.106205}, + { 0.079227, 0.345021}, + {-0.109319, -0.242380}, + { 0.425005, -0.332397}, + { 0.009146, 0.015098}, + {-0.339084, -0.355707}, + {-0.224596, -0.189548}, + { 0.083475, 0.117028}, + { 0.295962, -0.334699}, + { 0.452998, 0.025397}, + { 0.206511, -0.104668}, + { 0.447544, -0.096004}, + {-0.108006, -0.002471}, + {-0.380810, 0.130036}, + {-0.242440, 0.186934}, + {-0.200363, 0.070863}, + {-0.344844, -0.230814}, + { 0.408660, 0.345826}, + {-0.233016, 0.305203}, + { 0.158475, -0.430762}, + { 0.486972, 0.139163}, + {-0.301610, 0.009319}, + { 0.282245, -0.458671}, + { 0.482046, 0.443890}, + {-0.121527, 0.210223}, + {-0.477606, -0.424878}, + {-0.083941, -0.121440}, + {-0.345773, 0.253779}, + { 0.234646, 0.034549}, + { 0.394102, -0.210901}, + {-0.312571, 0.397656}, + { 0.200906, 0.333293}, + { 0.018703, -0.261792}, + {-0.209349, -0.065383}, + { 0.076248, 0.478538}, + {-0.073036, -0.355064}, + { 0.145087, 0.221726} +}; diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/material.c b/xc/extras/Mesa/OpenStep/Old_NeXT/material.c new file mode 100644 index 000000000..e1324fa6c --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/material.c @@ -0,0 +1,285 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * material.c + * This program demonstrates the use of the GL lighting model. + * Several objects are drawn using different material characteristics. + * A single light source illuminates the objects. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +/* Initialize z-buffer, projection matrix, light source, + * and lighting model. Do not specify a material property here. + */ +void myinit(void) +{ + GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat position[] = { 0.0, 3.0, 2.0, 0.0 }; + GLfloat lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 }; + GLfloat local_view[] = { 0.0 }; + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glClearColor(0.0, 0.1, 0.1, 0.0); +} + +/* Draw twelve spheres in 3 rows with 4 columns. + * The spheres in the first row have materials with no ambient reflection. + * The second row has materials with significant ambient reflection. + * The third row has materials with colored ambient reflection. + * + * The first column has materials with blue, diffuse reflection only. + * The second column has blue diffuse reflection, as well as specular + * reflection with a low shininess exponent. + * The third column has blue diffuse reflection, as well as specular + * reflection with a high shininess exponent (a more concentrated highlight). + * The fourth column has materials which also include an emissive component. + * + * glTranslatef() is used to move spheres to their appropriate locations. + */ + +void display(void) +{ + GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 }; + GLfloat mat_ambient_color[] = { 0.8, 0.8, 0.2, 1.0 }; + GLfloat mat_diffuse[] = { 0.1, 0.5, 0.8, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat no_shininess[] = { 0.0 }; + GLfloat low_shininess[] = { 5.0 }; + GLfloat high_shininess[] = { 100.0 }; + GLfloat mat_emission[] = {0.3, 0.2, 0.2, 0.0}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + +/* draw sphere in first row, first column + * diffuse reflection only; no ambient or specular + */ + glPushMatrix(); + glTranslatef (-3.75, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in first row, second column + * diffuse and specular reflection; low shininess; no ambient + */ + glPushMatrix(); + glTranslatef (-1.25, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in first row, third column + * diffuse and specular reflection; high shininess; no ambient + */ + glPushMatrix(); + glTranslatef (1.25, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in first row, fourth column + * diffuse reflection; emission; no ambient or specular reflection + */ + glPushMatrix(); + glTranslatef (3.75, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in second row, first column + * ambient and diffuse reflection; no specular + */ + glPushMatrix(); + glTranslatef (-3.75, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in second row, second column + * ambient, diffuse and specular reflection; low shininess + */ + glPushMatrix(); + glTranslatef (-1.25, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in second row, third column + * ambient, diffuse and specular reflection; high shininess + */ + glPushMatrix(); + glTranslatef (1.25, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in second row, fourth column + * ambient and diffuse reflection; emission; no specular + */ + glPushMatrix(); + glTranslatef (3.75, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in third row, first column + * colored ambient and diffuse reflection; no specular + */ + glPushMatrix(); + glTranslatef (-3.75, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in third row, second column + * colored ambient, diffuse and specular reflection; low shininess + */ + glPushMatrix(); + glTranslatef (-1.25, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in third row, third column + * colored ambient, diffuse and specular reflection; high shininess + */ + glPushMatrix(); + glTranslatef (1.25, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in third row, fourth column + * colored ambient and diffuse reflection; emission; no specular + */ + glPushMatrix(); + glTranslatef (3.75, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + auxSolidSphere(1.0); + glPopMatrix(); + + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= (h * 2)) + glOrtho (-6.0, 6.0, -3.0*((GLfloat)h*2)/(GLfloat)w, + 3.0*((GLfloat)h*2)/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-6.0*(GLfloat)w/((GLfloat)h*2), + 6.0*(GLfloat)w/((GLfloat)h*2), -3.0, 3.0, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +int gl_width=600; +int gl_height=450; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/model.c b/xc/extras/Mesa/OpenStep/Old_NeXT/model.c new file mode 100644 index 000000000..408152b71 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/model.c @@ -0,0 +1,116 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * model.c + * This program demonstrates the use of OpenGL modeling + * transformations. Four triangles are drawn, each with + * a different transformation. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +void draw_triangle(void) +{ + glBegin(GL_LINE_LOOP); + glVertex2f(0.0, 25.0); + glVertex2f(25.0, -25.0); + glVertex2f(-25.0, -25.0); + glEnd(); +} + +/* Clear the screen. For each triangle, set the current + * color and modify the modelview matrix. + */ +void display(void) +{ + glClearColor (0.0, 0.0, 0.0, 1.0); + glClear (GL_COLOR_BUFFER_BIT); + + glLoadIdentity (); + glColor3f (1.0, 1.0, 1.0); + draw_triangle (); + + glEnable (GL_LINE_STIPPLE); + glLineStipple (1, 0xF0F0); + glLoadIdentity (); + glTranslatef (-20.0, 0.0, 0.0); + draw_triangle (); + + glLineStipple (1, 0xF00F); + glLoadIdentity (); + glScalef (1.5, 0.5, 1.0); + draw_triangle (); + + glLineStipple (1, 0x8888); + glLoadIdentity (); + glRotatef (90.0, 0.0, 0.0, 1.0); + draw_triangle (); + glDisable (GL_LINE_STIPPLE); + + glFlush(); +} + +void myinit (void) +{ + glShadeModel (GL_FLAT); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-50.0, 50.0, -50.0*(GLfloat)h/(GLfloat)w, + 50.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0); + else + glOrtho (-50.0*(GLfloat)w/(GLfloat)h, + 50.0*(GLfloat)w/(GLfloat)h, -50.0, 50.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo1.m b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo1.m new file mode 100644 index 000000000..0bc7123c5 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo1.m @@ -0,0 +1,168 @@ +/* nextdemo.m*/ + +/* Demo of NEXTSTEP Mesa rendering */ + +/* + * See Mesa/include/GL/osmesa.h for documentation of the OSMesa functions. + * + * If you want to render BIG images you'll probably have to increase + * MAX_WIDTH and MAX_HEIGHT in src/config.h. + * + * This program is in the public domain. + * + * Brian Paul + * + * NEXTSTEP output provided by Pascal Thibaudeau + * pthibaud@frbdx11.cribx1.u-bordeaux.fr + */ + +#import <dpsclient/wraps.h> +#import <appkit/Application.h> +#import <appkit/Window.h> +#import <appkit/Menu.h> +#import <appkit/View.h> +#import <appkit/color.h> +#import <appkit/NXBitmapImageRep.h> + +#include <stdio.h> +#include <stdlib.h> +#include "GL/osmesa.h" + +#define WIDTH 480 +#define HEIGHT 480 + +static void render_image() +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + GLfloat red_mat[] = { 1.0, 0.0, 0.0, 0.5 }; + GLfloat green_mat[] = { 0.0, 1.0, 0.0, 0.5 }; + GLfloat blue_mat[] = { 0.0, 0.0, 1.0, 0.5}; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-2.5, 2.5, -2.5, 2.5, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glPushMatrix(); + glRotatef(20.0, 1.0, 0.0, 0.0); + + glPushMatrix(); + glTranslatef(-0.75, 0.5, 0.0); + glRotatef(90.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red_mat ); + auxSolidTorus(0.275, 0.85); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-0.75, -0.5, 0.0); + glRotatef(270.0, 1.0, 0.0, 0.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green_mat ); + auxSolidCone(1.0, 2.0); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(0.75, 0.0, -1.0); + glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat ); + auxSolidSphere(1.0); + glPopMatrix(); + + glPopMatrix(); +} + + + +int main( int argc, char *argv[] ) +{ + OSMesaContext ctx; + void *buffer; + id myWindow, myView, myMenu, image; + char name[50]; + NXRect GR; + NXPoint position; + + NXApp=[Application new]; + + /* Create an RGBA-mode context */ + ctx = OSMesaCreateContext( GL_RGBA, NULL ); + + /* Allocate the image buffer */ + buffer = malloc( WIDTH * HEIGHT * 4 ); + + /* Bind the buffer to the context and make it current */ + OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT ); + + image = [ [ NXBitmapImageRep alloc] + initData: buffer + pixelsWide: WIDTH + pixelsHigh: HEIGHT + bitsPerSample: 8 + samplesPerPixel: 4 + hasAlpha: YES + isPlanar: NO + colorSpace: 2 + bytesPerRow: WIDTH*4 + bitsPerPixel: 32]; + + NXSetRect(&GR,100,100,WIDTH,HEIGHT); + + myWindow = [ [ Window alloc] + initContent: &GR + style: NX_TITLEDSTYLE + backing: NX_BUFFERED + buttonMask: NX_MINIATURIZEBUTTONMASK + defer: NO]; + + sprintf(name, "Graphic Rectangle %d", getpid()); + + myView = [ [ View alloc] initFrame:&GR]; + [myView setOpaque: NO]; + [myView setDrawOrigin: -WIDTH: -HEIGHT]; + [myView rotate: 180.0]; + + myMenu = [ [ Menu alloc] initTitle: "NeXT-OpenGL"]; + [myMenu addItem: "Quit" action: @selector(terminate:) keyEquivalent: 'q']; + [myMenu sizeToFit]; + + [myWindow setTitle: name]; + [myWindow display]; + [myWindow setContentView: myView]; + [myWindow makeKeyAndOrderFront: nil]; + + [NXApp setMainMenu: myMenu]; + + [myView lockFocus]; + + /* here is the Mesa call */ + render_image(); + + [image draw]; + [image free]; + + [myWindow flushWindow]; + [myView unlockFocus]; + + /* free the image buffer */ + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + [NXApp run]; + [NXApp free]; + + return 0; +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo2.m b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo2.m new file mode 100644 index 000000000..c33867059 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo2.m @@ -0,0 +1,213 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * original name: tea.c + * This program demonstrates two-sided lighting and compares + * it with one-sided lighting. Three teapots are drawn, with + * a clipping plane to expose the interior of the objects. + * + * NEXTSTEP output provided by Pascal Thibaudeau + * pthibaud@frbdx11.cribx1.u-bordeaux.fr + */ +#import <dpsclient/wraps.h> +#import <appkit/Application.h> +#import <appkit/Window.h> +#import <appkit/Menu.h> +#import <appkit/View.h> +#import <appkit/color.h> +#import <appkit/NXBitmapImageRep.h> + +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "GL/osmesa.h" + +#define WIDTH 400 +#define HEIGHT 400 + +static void render_image(void) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + +/* light_position is NOT default value */ + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + GLdouble eqn[4] = {1.0, 0.0, -1.0, 1.0}; + GLfloat two_side_on[] = { GL_TRUE }; + GLfloat two_side_off[] = { GL_FALSE }; + GLfloat mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 }; + GLfloat back_diffuse[] = { 0.8, 0.2, 0.8, 1.0 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glFrontFace (GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho (-4.0, 4.0, -4.0*(GLfloat)HEIGHT/(GLfloat)WIDTH, + 4.0*(GLfloat)HEIGHT/(GLfloat)WIDTH, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix (); + glClipPlane (GL_CLIP_PLANE0, eqn); /* slice objects */ + glEnable (GL_CLIP_PLANE0); + + glPushMatrix (); + glTranslatef (0.0, 2.0, 0.0); + auxSolidTeapot(1.0); /* one-sided lighting */ + glPopMatrix (); + + /* two-sided lighting, but same material */ + glLightModelf (GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); + glPushMatrix (); + glTranslatef (0.0, 0.0, 0.0); + auxSolidTeapot(1.0); + glPopMatrix (); + + /* two-sided lighting, two different materials */ + glMaterialfv (GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv (GL_BACK, GL_DIFFUSE, back_diffuse); + glPushMatrix (); + glTranslatef (0.0, -2.0, 0.0); + auxSolidTeapot(1.0); + glPopMatrix (); + + glLightModelf (GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); + glDisable (GL_CLIP_PLANE0); + glPopMatrix (); + glFlush(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + OSMesaContext ctx; + void *buffer; + id myWindow, myView, myMenu, image; + char name[50]; + NXRect GR; + NXPoint position; + NXApp=[Application new]; + + /* Create an RGBA-mode context */ + ctx = OSMesaCreateContext( GL_RGBA, NULL ); + + /* Allocate the image buffer */ + buffer = malloc( WIDTH * HEIGHT * 4 ); + + /* Bind the buffer to the context and make it current */ + OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT ); + + image = [ [ NXBitmapImageRep alloc] + initData: buffer + pixelsWide: WIDTH + pixelsHigh: HEIGHT + bitsPerSample: 8 + samplesPerPixel: 4 + hasAlpha: YES + isPlanar: NO + colorSpace: 2 + bytesPerRow: WIDTH*4 + bitsPerPixel: 32]; + + NXSetRect(&GR,100,100,WIDTH,HEIGHT); + + myWindow = [ [ Window alloc] + initContent: &GR + style: NX_TITLEDSTYLE + backing: NX_BUFFERED + buttonMask: NX_MINIATURIZEBUTTONMASK + defer: NO]; + + sprintf(name, "OpenGL Graphic Rectangle %d", getpid()); + + myView = [ [ View alloc] initFrame:&GR]; + [myView setOpaque: NO]; + [myView setDrawOrigin: -WIDTH: -HEIGHT]; + [myView rotate: 180.0]; + + myMenu = [ [ Menu alloc] initTitle: "NeXT-Mesa"]; + [myMenu addItem: "Quit" action: @selector(terminate:) keyEquivalent: 'q']; + [myMenu sizeToFit]; + + [myWindow setTitle: name]; + [myWindow display]; + [myWindow setContentView: myView]; + [myWindow makeKeyAndOrderFront: nil]; + + [NXApp setMainMenu: myMenu]; + + [myView lockFocus]; + + /* here is the Mesa call */ + render_image(); + + [image draw]; + [image free]; + + [myWindow flushWindow]; + [myView unlockFocus]; + + /* free the image buffer */ + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + [NXApp run]; + [NXApp free]; + + return 0; + + } + diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo3.m b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo3.m new file mode 100644 index 000000000..e89865807 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo3.m @@ -0,0 +1,257 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * teapots.c + * This program demonstrates lots of material properties. + * A single light source illuminates the objects. + * + * NEXTSTEP output provided by Pascal Thibaudeau + * pthibaud@frbdx11.cribx1.u-bordeaux.fr + */ +#import <dpsclient/wraps.h> +#import <appkit/Application.h> +#import <appkit/Window.h> +#import <appkit/Menu.h> +#import <appkit/View.h> +#import <appkit/color.h> +#import <appkit/NXBitmapImageRep.h> + +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "GL/osmesa.h" + +#define WIDTH 400 +#define HEIGHT 400 + +/* Move object into position. Use 3rd through 12th parameters + * to specify the material property. Draw a teapot. + */ +void renderTeapot (GLfloat x, GLfloat y, + GLfloat ambr, GLfloat ambg, GLfloat ambb, + GLfloat difr, GLfloat difg, GLfloat difb, + GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine) +{ + float mat[4]; + + glPushMatrix(); + glTranslatef (x, y, 0.0); + mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0; + glMaterialfv (GL_FRONT, GL_AMBIENT, mat); + mat[0] = difr; mat[1] = difg; mat[2] = difb; + glMaterialfv (GL_FRONT, GL_DIFFUSE, mat); + mat[0] = specr; mat[1] = specg; mat[2] = specb; + glMaterialfv (GL_FRONT, GL_SPECULAR, mat); + glMaterialf (GL_FRONT, GL_SHININESS, shine*128.0); + auxSolidTeapot(1.0); + glPopMatrix(); +} + + +/* Initialize depth buffer, projection matrix, light source, + * and lighting model. Do not specify a material property here. + */ +static void render_image(void) +{ + GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat position[] = { 0.0, 3.0, 3.0, 0.0 }; + + GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + GLfloat local_view[] = { 0.0 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glFrontFace (GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho (0.0, 16.0, 0.0, 16.0*(GLfloat)HEIGHT/(GLfloat)WIDTH, + -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + renderTeapot (2.0, 17.0, 0.0215, 0.1745, 0.0215, + 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6); + renderTeapot (2.0, 14.0, 0.135, 0.2225, 0.1575, + 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1); + renderTeapot (2.0, 11.0, 0.05375, 0.05, 0.06625, + 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3); + renderTeapot (2.0, 8.0, 0.25, 0.20725, 0.20725, + 1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088); + renderTeapot (2.0, 5.0, 0.1745, 0.01175, 0.01175, + 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); + renderTeapot (2.0, 2.0, 0.1, 0.18725, 0.1745, + 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1); + renderTeapot (6.0, 17.0, 0.329412, 0.223529, 0.027451, + 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843, + 0.21794872); + renderTeapot (6.0, 14.0, 0.2125, 0.1275, 0.054, + 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2); + renderTeapot (6.0, 11.0, 0.25, 0.25, 0.25, + 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6); + renderTeapot (6.0, 8.0, 0.19125, 0.0735, 0.0225, + 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1); + renderTeapot (6.0, 5.0, 0.24725, 0.1995, 0.0745, + 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4); + renderTeapot (6.0, 2.0, 0.19225, 0.19225, 0.19225, + 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4); + renderTeapot (10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01, + 0.50, 0.50, 0.50, .25); + renderTeapot (10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, + 0.50196078, 0.50196078, 0.50196078, .25); + renderTeapot (10.0, 11.0, 0.0, 0.0, 0.0, + 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, .25); + renderTeapot (10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, + 0.7, 0.6, 0.6, .25); + renderTeapot (10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55, + 0.70, 0.70, 0.70, .25); + renderTeapot (10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, + 0.60, 0.60, 0.50, .25); + renderTeapot (14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, + 0.4, 0.4, 0.4, .078125); + renderTeapot (14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5, + 0.04, 0.7, 0.7, .078125); + renderTeapot (14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4, + 0.04, 0.7, 0.04, .078125); + renderTeapot (14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4, + 0.7, 0.04, 0.04, .078125); + renderTeapot (14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5, + 0.7, 0.7, 0.7, .078125); + renderTeapot (14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4, + 0.7, 0.7, 0.04, .078125); + glFlush(); + +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + OSMesaContext ctx; + void *buffer; + id myWindow, myView, myMenu, image; + char name[50]; + NXRect GR; + NXPoint position; + NXApp=[Application new]; + + /* Create an RGBA-mode context */ + ctx = OSMesaCreateContext( GL_RGBA, NULL ); + + /* Allocate the image buffer */ + buffer = malloc( WIDTH * HEIGHT * 4 ); + + /* Bind the buffer to the context and make it current */ + OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT ); + + image = [ [ NXBitmapImageRep alloc] + initData: buffer + pixelsWide: WIDTH + pixelsHigh: HEIGHT + bitsPerSample: 8 + samplesPerPixel: 4 + hasAlpha: YES + isPlanar: NO + colorSpace: 2 + bytesPerRow: WIDTH*4 + bitsPerPixel: 32]; + + NXSetRect(&GR,100,100,WIDTH,HEIGHT); + + myWindow = [ [ Window alloc] + initContent: &GR + style: NX_TITLEDSTYLE + backing: NX_BUFFERED + buttonMask: NX_MINIATURIZEBUTTONMASK + defer: NO]; + + sprintf(name, "Graphic Rectangle %d", getpid()); + + myView = [ [ View alloc] initFrame:&GR]; + [myView setOpaque: NO]; + [myView setDrawOrigin: -WIDTH: -HEIGHT]; + [myView rotate: 180.0]; + + myMenu = [ [ Menu alloc] initTitle: "NeXT-OpenGL"]; + [myMenu addItem: "Quit" action: @selector(terminate:) keyEquivalent: 'q']; + [myMenu sizeToFit]; + + [myWindow setTitle: name]; + [myWindow display]; + [myWindow setContentView: myView]; + [myWindow makeKeyAndOrderFront: nil]; + + [NXApp setMainMenu: myMenu]; + + [myView lockFocus]; + + /* here is the Mesa call */ + render_image(); + + [image draw]; + [image free]; + + [myWindow flushWindow]; + [myView unlockFocus]; + + /* free the image buffer */ + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + [NXApp run]; + [NXApp free]; + + return 0; + + } + diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo4.m b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo4.m new file mode 100644 index 000000000..794343bd5 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo4.m @@ -0,0 +1,206 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* chess.c + * This program texture maps a checkerboard image onto + * two rectangles. The texture coordinates for the + * rectangles are 0.0 to 3.0. + * + * NEXTSTEP output provided by Pascal Thibaudeau + * pthibaud@frbdx11.cribx1.u-bordeaux.fr + */ +#import <dpsclient/wraps.h> +#import <appkit/Application.h> +#import <appkit/Window.h> +#import <appkit/Menu.h> +#import <appkit/View.h> +#import <appkit/color.h> +#import <appkit/NXBitmapImageRep.h> + +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include <math.h> +#include "GL/osmesa.h" + +#define WIDTH 500 +#define HEIGHT 500 + +#define checkImageWidth 64 +#define checkImageHeight 64 +GLubyte checkImage[checkImageWidth][checkImageHeight][3]; + +void makecheckimage(void) +{ + int i, j, r, c; + + for (i = 0; i < checkImageWidth; i++) { + for (j = 0; j < checkImageHeight; j++) { + c = ((((i&0x8)==0)^((j&0x8))==0))*255; + checkImage[i][j][0] = (GLubyte) c; + checkImage[i][j][1] = (GLubyte) c; + checkImage[i][j][2] = (GLubyte) c; + } + } +} + +static void render_image(void) +{ + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + makecheckimage(); + glTexImage2D(GL_TEXTURE_2D, 0, 3, + checkImageWidth, checkImageHeight, 0, + GL_RGB, GL_UNSIGNED_BYTE, &checkImage[0][0][0]); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); + glShadeModel(GL_FLAT); + + glViewport(0, 0, WIDTH, HEIGHT); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)WIDTH/(GLfloat)HEIGHT, 1.0, 30.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -3.6); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, 3.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(3.0, 3.0); glVertex3f(0.0, 1.0, 0.0); + glTexCoord2f(3.0, 0.0); glVertex3f(0.0, -1.0, 0.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 3.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(3.0, 3.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(3.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + glEnd(); + glFlush(); + +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + OSMesaContext ctx; + void *buffer; + id myWindow, myView, myMenu, image; + char name[50]; + NXRect GR; + NXPoint position; + NXApp=[Application new]; + + /* Create an RGBA-mode context */ + ctx = OSMesaCreateContext( GL_RGBA, NULL ); + + /* Allocate the image buffer */ + buffer = malloc( WIDTH * HEIGHT * 4 ); + + /* Bind the buffer to the context and make it current */ + OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT ); + + image = [ [ NXBitmapImageRep alloc] + initData: buffer + pixelsWide: WIDTH + pixelsHigh: HEIGHT + bitsPerSample: 8 + samplesPerPixel: 4 + hasAlpha: YES + isPlanar: NO + colorSpace: 2 + bytesPerRow: WIDTH*4 + bitsPerPixel: 32]; + + NXSetRect(&GR,100,100,WIDTH,HEIGHT); + + myWindow = [ [ Window alloc] + initContent: &GR + style: NX_TITLEDSTYLE + backing: NX_BUFFERED + buttonMask: NX_MINIATURIZEBUTTONMASK + defer: NO]; + + sprintf(name, "OpenGL Graphic Rectangle %d", getpid()); + + myView = [ [ View alloc] initFrame:&GR]; + [myView setOpaque: NO]; + [myView setDrawOrigin: -WIDTH: -HEIGHT]; + [myView rotate: 180.0]; + + myMenu = [ [ Menu alloc] initTitle: "NeXT-Mesa"]; + [myMenu addItem: "Quit" action: @selector(terminate:) keyEquivalent: 'q']; + [myMenu sizeToFit]; + + [myWindow setTitle: name]; + [myWindow display]; + [myWindow setContentView: myView]; + [myWindow makeKeyAndOrderFront: nil]; + + [NXApp setMainMenu: myMenu]; + + [myView lockFocus]; + + /* here is the Mesa call */ + render_image(); + + [image draw]; + [image free]; + + [myWindow flushWindow]; + [myView unlockFocus]; + + /* free the image buffer */ + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + [NXApp run]; + [NXApp free]; + + return 0; + + } + diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo5.m b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo5.m new file mode 100644 index 000000000..4432b09e8 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo5.m @@ -0,0 +1,357 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * material.c + * This program demonstrates the use of the GL lighting model. + * Several objects are drawn using different material characteristics. + * A single light source illuminates the objects. + * + * NEXTSTEP output provided by Pascal Thibaudeau + * pthibaud@frbdx11.cribx1.u-bordeaux.fr + */ +#import <dpsclient/wraps.h> +#import <appkit/Application.h> +#import <appkit/Window.h> +#import <appkit/Menu.h> +#import <appkit/View.h> +#import <appkit/color.h> +#import <appkit/NXBitmapImageRep.h> + +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "GL/osmesa.h" + +#define WIDTH 600 +#define HEIGHT 450 + +/* Initialize z-buffer, projection matrix, light source, + * and lighting model. Do not specify a material property here. + */ +static void render_image(void) +{ + GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat position[] = { 0.0, 3.0, 2.0, 0.0 }; + GLfloat lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 }; + GLfloat local_view[] = { 0.0 }; + + GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 }; + GLfloat mat_ambient_color[] = { 0.8, 0.8, 0.2, 1.0 }; + GLfloat mat_diffuse[] = { 0.1, 0.5, 0.8, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat no_shininess[] = { 0.0 }; + GLfloat low_shininess[] = { 5.0 }; + GLfloat high_shininess[] = { 100.0 }; + GLfloat mat_emission[] = {0.3, 0.2, 0.2, 0.0}; + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glClearColor(0.0, 0.1, 0.1, 0.0); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glViewport(0, 0, WIDTH, HEIGHT); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (WIDTH<= (HEIGHT * 2)) + glOrtho (-6.0, 6.0, -3.0*((GLfloat)HEIGHT*2)/(GLfloat)WIDTH, + 3.0*((GLfloat)HEIGHT*2)/(GLfloat)WIDTH, -10.0, 10.0); + else + glOrtho (-6.0*(GLfloat)WIDTH/((GLfloat)HEIGHT*2), + 6.0*(GLfloat)WIDTH/((GLfloat)HEIGHT*2), -3.0, 3.0, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); + + +/* draw sphere in first row, first column + * diffuse reflection only; no ambient or specular + */ + glPushMatrix(); + glTranslatef (-3.75, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in first row, second column + * diffuse and specular reflection; low shininess; no ambient + */ + glPushMatrix(); + glTranslatef (-1.25, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in first row, third column + * diffuse and specular reflection; high shininess; no ambient + */ + glPushMatrix(); + glTranslatef (1.25, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in first row, fourth column + * diffuse reflection; emission; no ambient or specular reflection + */ + glPushMatrix(); + glTranslatef (3.75, 3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in second row, first column + * ambient and diffuse reflection; no specular + */ + glPushMatrix(); + glTranslatef (-3.75, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in second row, second column + * ambient, diffuse and specular reflection; low shininess + */ + glPushMatrix(); + glTranslatef (-1.25, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in second row, third column + * ambient, diffuse and specular reflection; high shininess + */ + glPushMatrix(); + glTranslatef (1.25, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in second row, fourth column + * ambient and diffuse reflection; emission; no specular + */ + glPushMatrix(); + glTranslatef (3.75, 0.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in third row, first column + * colored ambient and diffuse reflection; no specular + */ + glPushMatrix(); + glTranslatef (-3.75, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in third row, second column + * colored ambient, diffuse and specular reflection; low shininess + */ + glPushMatrix(); + glTranslatef (-1.25, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in third row, third column + * colored ambient, diffuse and specular reflection; high shininess + */ + glPushMatrix(); + glTranslatef (1.25, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); + auxSolidSphere(1.0); + glPopMatrix(); + +/* draw sphere in third row, fourth column + * colored ambient and diffuse reflection; emission; no specular + */ + glPushMatrix(); + glTranslatef (3.75, -3.0, 0.0); + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); + glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); + glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + auxSolidSphere(1.0); + glPopMatrix(); + + glFlush(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + OSMesaContext ctx; + void *buffer; + id myWindow, myView, myMenu, image; + char name[50]; + NXRect GR; + NXPoint position; + NXApp=[Application new]; + + /* Create an RGBA-mode context */ + ctx = OSMesaCreateContext( GL_RGBA, NULL ); + + /* Allocate the image buffer */ + buffer = malloc( WIDTH * HEIGHT * 4 ); + + /* Bind the buffer to the context and make it current */ + OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT ); + + image = [ [ NXBitmapImageRep alloc] + initData: buffer + pixelsWide: WIDTH + pixelsHigh: HEIGHT + bitsPerSample: 8 + samplesPerPixel: 4 + hasAlpha: YES + isPlanar: NO + colorSpace: 2 + bytesPerRow: WIDTH*4 + bitsPerPixel: 32]; + + NXSetRect(&GR,100,100,WIDTH,HEIGHT); + + myWindow = [ [ Window alloc] + initContent: &GR + style: NX_TITLEDSTYLE + backing: NX_BUFFERED + buttonMask: NX_MINIATURIZEBUTTONMASK + defer: NO]; + + sprintf(name, "OpenGL Graphic Rectangle %d", getpid()); + + myView = [ [ View alloc] initFrame:&GR]; + [myView setOpaque: NO]; + [myView setDrawOrigin: -WIDTH: -HEIGHT]; + [myView rotate: 180.0]; + + myMenu = [ [ Menu alloc] initTitle: "NeXT-Mesa"]; + [myMenu addItem: "Quit" action: @selector(terminate:) keyEquivalent: 'q']; + [myMenu sizeToFit]; + + [myWindow setTitle: name]; + [myWindow display]; + [myWindow setContentView: myView]; + [myWindow makeKeyAndOrderFront: nil]; + + [NXApp setMainMenu: myMenu]; + + [myView lockFocus]; + + /* here is the Mesa call */ + render_image(); + + [image draw]; + [image free]; + + [myWindow flushWindow]; + [myView unlockFocus]; + + /* free the image buffer */ + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + [NXApp run]; + [NXApp free]; + + return 0; + + } + + diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo6.m b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo6.m new file mode 100644 index 000000000..716647980 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/nextdemo6.m @@ -0,0 +1,215 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* texgen.c + * This program draws a texture mapped teapot with + * automatically generated texture coordinates. The + * texture is rendered as stripes on the teapot. + * + * NEXTSTEP output provided by Pascal Thibaudeau + * pthibaud@frbdx11.cribx1.u-bordeaux.fr + */ +#import <dpsclient/wraps.h> +#import <appkit/Application.h> +#import <appkit/Window.h> +#import <appkit/Menu.h> +#import <appkit/View.h> +#import <appkit/color.h> +#import <appkit/NXBitmapImageRep.h> + +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "GL/osmesa.h" + +#define WIDTH 400 +#define HEIGHT 400 + +#define stripeImageWidth 16 +GLubyte stripeImage[3*stripeImageWidth]; + +void makeStripeImage(void) +{ + int j; + + for (j = 0; j < stripeImageWidth; j++) { + stripeImage[3*j] = (j<=4) ? 255 : 0; + stripeImage[3*j+1] = (j>4) ? 255 : 0; + stripeImage[3*j+2] = 0; + } +} + +/* glTexGen stuff: */ + +GLfloat sgenparams[] = {1.0, 1.0, 1.0, 0.0}; + +static void render_image(void) +{ + glViewport(0, 0, WIDTH, HEIGHT); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (WIDTH <= HEIGHT) + glOrtho (-3.5, 3.5, -3.5*(GLfloat)HEIGHT/(GLfloat)WIDTH, + 3.5*(GLfloat)HEIGHT/(GLfloat)WIDTH, -3.5, 3.5); + else + glOrtho (-3.5*(GLfloat)WIDTH/(GLfloat)HEIGHT, + 3.5*(GLfloat)WIDTH/(GLfloat)HEIGHT, -3.5, 3.5, -3.5, 3.5); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glClearColor (0.0, 0.0, 0.0, 0.0); + + makeStripeImage(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexImage1D(GL_TEXTURE_1D, 0, 3, stripeImageWidth, 0, + GL_RGB, GL_UNSIGNED_BYTE, stripeImage); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGenfv(GL_S, GL_OBJECT_PLANE, sgenparams); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_1D); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glFrontFace(GL_CW); + glCullFace(GL_BACK); + glMaterialf (GL_FRONT, GL_SHININESS, 64.0); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix (); + glRotatef(-45.0, -180.0, -40.0, 1.0); + auxSolidTeapot(3.0); + glPopMatrix (); + glFlush(); +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + OSMesaContext ctx; + void *buffer; + id myWindow, myView, myMenu, image; + char name[50]; + NXRect GR; + NXPoint position; + NXApp=[Application new]; + + /* Create an RGBA-mode context */ + ctx = OSMesaCreateContext( GL_RGBA, NULL ); + + /* Allocate the image buffer */ + buffer = malloc( WIDTH * HEIGHT * 4 ); + + /* Bind the buffer to the context and make it current */ + OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT ); + + image = [ [ NXBitmapImageRep alloc] + initData: buffer + pixelsWide: WIDTH + pixelsHigh: HEIGHT + bitsPerSample: 8 + samplesPerPixel: 4 + hasAlpha: YES + isPlanar: NO + colorSpace: 2 + bytesPerRow: WIDTH*4 + bitsPerPixel: 32]; + + NXSetRect(&GR,100,100,WIDTH,HEIGHT); + + myWindow = [ [ Window alloc] + initContent: &GR + style: NX_TITLEDSTYLE + backing: NX_BUFFERED + buttonMask: NX_MINIATURIZEBUTTONMASK + defer: NO]; + + sprintf(name, "OpenGL Graphic Rectangle %d", getpid()); + + myView = [ [ View alloc] initFrame:&GR]; + [myView setOpaque: NO]; + [myView setDrawOrigin: -WIDTH: -HEIGHT]; + [myView rotate: 180.0]; + + myMenu = [ [ Menu alloc] initTitle: "NeXT-Mesa"]; + [myMenu addItem: "Quit" action: @selector(terminate:) keyEquivalent: 'q']; + [myMenu sizeToFit]; + + [myWindow setTitle: name]; + [myWindow display]; + [myWindow setContentView: myView]; + [myWindow makeKeyAndOrderFront: nil]; + + [NXApp setMainMenu: myMenu]; + + [myView lockFocus]; + + /* here is the Mesa call */ + render_image(); + + [image draw]; + [image free]; + + [myWindow flushWindow]; + [myView unlockFocus]; + + /* free the image buffer */ + free( buffer ); + + /* destroy the context */ + OSMesaDestroyContext( ctx ); + + [NXApp run]; + [NXApp free]; + + return 0; + + } + + + diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/nurbs.c b/xc/extras/Mesa/OpenStep/Old_NeXT/nurbs.c new file mode 100644 index 000000000..14c8e3dc9 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/nurbs.c @@ -0,0 +1,192 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * nurbs.c + * This program shows a NURBS (Non-uniform rational B-splines) + * surface, shaped like a heart. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +#define S_NUMPOINTS 13 +#define S_ORDER 3 +#define S_NUMKNOTS (S_NUMPOINTS + S_ORDER) +#define T_NUMPOINTS 3 +#define T_ORDER 3 +#define T_NUMKNOTS (T_NUMPOINTS + T_ORDER) +#define SQRT2 1.41421356237309504880 + +/* initialized local data */ + +GLfloat sknots[S_NUMKNOTS] = + {-1.0, -1.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, + 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 9.0, 9.0}; +GLfloat tknots[T_NUMKNOTS] = {1.0, 1.0, 1.0, 2.0, 2.0, 2.0}; + +GLfloat ctlpoints[S_NUMPOINTS][T_NUMPOINTS][4] = { +{ {4.,2.,2.,1.},{4.,1.6,2.5,1.},{4.,2.,3.0,1.} }, +{ {5.,4.,2.,1.},{5.,4.,2.5,1.},{5.,4.,3.0,1.} }, +{ {6.,5.,2.,1.},{6.,5.,2.5,1.},{6.,5.,3.0,1.} }, +{ {SQRT2*6.,SQRT2*6.,SQRT2*2.,SQRT2}, + {SQRT2*6.,SQRT2*6.,SQRT2*2.5,SQRT2}, + {SQRT2*6.,SQRT2*6.,SQRT2*3.0,SQRT2} }, +{ {5.2,6.7,2.,1.},{5.2,6.7,2.5,1.},{5.2,6.7,3.0,1.} }, +{ {SQRT2*4.,SQRT2*6.,SQRT2*2.,SQRT2}, + {SQRT2*4.,SQRT2*6.,SQRT2*2.5,SQRT2}, + {SQRT2*4.,SQRT2*6.,SQRT2*3.0,SQRT2} }, +{ {4.,5.2,2.,1.},{4.,4.6,2.5,1.},{4.,5.2,3.0,1.} }, +{ {SQRT2*4.,SQRT2*6.,SQRT2*2.,SQRT2}, + {SQRT2*4.,SQRT2*6.,SQRT2*2.5,SQRT2}, + {SQRT2*4.,SQRT2*6.,SQRT2*3.0,SQRT2} }, +{ {2.8,6.7,2.,1.},{2.8,6.7,2.5,1.},{2.8,6.7,3.0,1.} }, +{ {SQRT2*2.,SQRT2*6.,SQRT2*2.,SQRT2}, + {SQRT2*2.,SQRT2*6.,SQRT2*2.5,SQRT2}, + {SQRT2*2.,SQRT2*6.,SQRT2*3.0,SQRT2} }, +{ {2.,5.,2.,1.},{2.,5.,2.5,1.},{2.,5.,3.0,1.} }, +{ {3.,4.,2.,1.},{3.,4.,2.5,1.},{3.,4.,3.0,1.} }, +{ {4.,2.,2.,1.},{4.,1.6,2.5,1.},{4.,2.,3.0,1.} } +}; + +GLUnurbsObj *theNurb; + +/* Initialize material property, light source, lighting model, + * and depth buffer. + */ +void myinit(void) +{ + GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_diffuse[] = { 1.0, 0.2, 1.0, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 50.0 }; + + GLfloat light0_position[] = { 1.0, 0.1, 1.0, 0.0 }; + GLfloat light1_position[] = { -1.0, 0.1, 1.0, 0.0 }; + + GLfloat lmodel_ambient[] = { 0.3, 0.3, 0.3, 1.0 }; + + glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + glLightfv(GL_LIGHT0, GL_POSITION, light0_position); + glLightfv(GL_LIGHT1, GL_POSITION, light1_position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHT1); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glEnable(GL_AUTO_NORMAL); + + theNurb = gluNewNurbsRenderer(); + + gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); + gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glTranslatef (4., 4.5, 2.5); + glRotatef (220.0, 1., 0., 0.); + glRotatef (115.0, 0., 1., 0.); + glTranslatef (-4., -4.5, -2.5); + + gluBeginSurface(theNurb); + gluNurbsSurface(theNurb, + S_NUMKNOTS, sknots, + T_NUMKNOTS, tknots, + 4 * T_NUMPOINTS, + 4, + &ctlpoints[0][0][0], + S_ORDER, T_ORDER, + GL_MAP2_VERTEX_4); + gluEndSurface(theNurb); + + glPopMatrix(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-2.0, 2.0, -2.0, 2.0, 0.8, 10.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt(7.0,4.5,4.0, 4.5,4.5,2.0, 6.0,-3.0,2.0); +} + +#ifdef OLD_CODE +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + auxInitDisplayMode (AUX_SINGLE | AUX_RGB | AUX_DEPTH); + auxInitPosition (0, 0, 500, 500); + auxInitWindow (argv[0]); + myinit(); + auxReshapeFunc (myReshape); + auxMainLoop(display); +} +#endif + +/* + * This is how we port nurbs.c to OpenStep. Forget the aux calls, + * simply call init(), then reshape() with the window size and finally + * display(). The two size integers are global to generic.m so that it + * knows how big to make the OpenStep window. + */ + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/sphere.c b/xc/extras/Mesa/OpenStep/Old_NeXT/sphere.c new file mode 100644 index 000000000..b545a2777 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/sphere.c @@ -0,0 +1,81 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * sphere.c + * This program draws a wire frame sphere. It uses + * glTranslatef() as a viewing transformation. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +void display (void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glColor3f (1.0, 1.0, 1.0); + glPushMatrix(); +/* glTranslatef() as viewing transformation */ + glTranslatef (0.0, 0.0, -5.0); + auxWireSphere(1.0); + glPopMatrix(); + glFlush(); +} + +void myinit (void) +{ + glShadeModel (GL_FLAT); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); + glMatrixMode(GL_MODELVIEW); +} + +int gl_width=400; +int gl_height=400; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/surface.c b/xc/extras/Mesa/OpenStep/Old_NeXT/surface.c new file mode 100644 index 000000000..5c9795178 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/surface.c @@ -0,0 +1,143 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * surface.c + * This program draws a NURBS surface in the shape of a + * symmetrical hill. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +GLfloat ctlpoints[4][4][3]; + +GLUnurbsObj *theNurb; + +/* + * Initializes the control points of the surface to a small hill. + * The control points range from -3 to +3 in x, y, and z + */ +void init_surface(void) +{ + int u, v; + for (u = 0; u < 4; u++) { + for (v = 0; v < 4; v++) { + ctlpoints[u][v][0] = 2.0*((GLfloat)u - 1.5); + ctlpoints[u][v][1] = 2.0*((GLfloat)v - 1.5); + + if ( (u == 1 || u == 2) && (v == 1 || v == 2)) + ctlpoints[u][v][2] = 3.0; + else + ctlpoints[u][v][2] = -3.0; + } + } +} + +/* Initialize material property and depth buffer. + */ +void myinit(void) +{ + GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; + GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat mat_shininess[] = { 100.0 }; + + glClearColor (0.0, 0.0, 0.0, 1.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + + init_surface(); + + theNurb = gluNewNurbsRenderer(); + gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); + gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); +} + +void display(void) +{ + GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(330.0, 1.,0.,0.); + glScalef (0.5, 0.5, 0.5); + + gluBeginSurface(theNurb); + gluNurbsSurface(theNurb, + 8, knots, + 8, knots, + 4 * 3, + 3, + &ctlpoints[0][0][0], + 4, 4, + GL_MAP2_VERTEX_3); + gluEndSurface(theNurb); + + glPopMatrix(); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective (45.0, (GLdouble)w/(GLdouble)h, 3.0, 8.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef (0.0, 0.0, -5.0); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/tea.c b/xc/extras/Mesa/OpenStep/Old_NeXT/tea.c new file mode 100644 index 000000000..cb2a4164d --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/tea.c @@ -0,0 +1,135 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * tea.c + * This program demonstrates two-sided lighting and compares + * it with one-sided lighting. Three teapots are drawn, with + * a clipping plane to expose the interior of the objects. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +/* Initialize light source. + */ +void myinit(void) +{ + GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; +/* light_position is NOT default value */ + GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + glFrontFace (GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); +} + +void display(void) +{ + GLdouble eqn[4] = {1.0, 0.0, -1.0, 1.0}; + GLfloat two_side_on[] = { GL_TRUE }; + GLfloat two_side_off[] = { GL_FALSE }; + GLfloat mat_diffuse[] = { 0.8, 0.8, 0.8, 1.0 }; + GLfloat back_diffuse[] = { 0.8, 0.2, 0.8, 1.0 }; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix (); + glClipPlane (GL_CLIP_PLANE0, eqn); /* slice objects */ + glEnable (GL_CLIP_PLANE0); + + glPushMatrix (); + glTranslatef (0.0, 2.0, 0.0); + auxSolidTeapot(1.0); /* one-sided lighting */ + glPopMatrix (); + + /* two-sided lighting, but same material */ + glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); + glPushMatrix (); + glTranslatef (0.0, 0.0, 0.0); + auxSolidTeapot(1.0); + glPopMatrix (); + + /* two-sided lighting, two different materials */ + glMaterialfv (GL_FRONT, GL_DIFFUSE, mat_diffuse); + glMaterialfv (GL_BACK, GL_DIFFUSE, back_diffuse); + glPushMatrix (); + glTranslatef (0.0, -2.0, 0.0); + auxSolidTeapot(1.0); + glPopMatrix (); + + glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); + glDisable (GL_CLIP_PLANE0); + glPopMatrix (); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-4.0, 4.0, -4.0*(GLfloat)h/(GLfloat)w, + 4.0*(GLfloat)h/(GLfloat)w, -10.0, 10.0); + else + glOrtho (-4.0*(GLfloat)w/(GLfloat)h, + 4.0*(GLfloat)w/(GLfloat)h, -4.0, 4.0, -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +int gl_width=500; +int gl_height=500; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/teapots.c b/xc/extras/Mesa/OpenStep/Old_NeXT/teapots.c new file mode 100644 index 000000000..959531761 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/teapots.c @@ -0,0 +1,180 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* + * teapots.c + * This program demonstrates lots of material properties. + * A single light source illuminates the objects. + */ +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +/* Initialize depth buffer, projection matrix, light source, + * and lighting model. Do not specify a material property here. + */ +void myinit(void) +{ + GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat specular[] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat position[] = { 0.0, 3.0, 3.0, 0.0 }; + + GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; + GLfloat local_view[] = { 0.0 }; + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + + glFrontFace (GL_CW); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); +} + +/* Move object into position. Use 3rd through 12th parameters + * to specify the material property. Draw a teapot. + */ +void renderTeapot (GLfloat x, GLfloat y, + GLfloat ambr, GLfloat ambg, GLfloat ambb, + GLfloat difr, GLfloat difg, GLfloat difb, + GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine) +{ + float mat[4]; + + glPushMatrix(); + glTranslatef (x, y, 0.0); + mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0; + glMaterialfv (GL_FRONT, GL_AMBIENT, mat); + mat[0] = difr; mat[1] = difg; mat[2] = difb; + glMaterialfv (GL_FRONT, GL_DIFFUSE, mat); + mat[0] = specr; mat[1] = specg; mat[2] = specb; + glMaterialfv (GL_FRONT, GL_SPECULAR, mat); + glMaterialf (GL_FRONT, GL_SHININESS, shine*128.0); + auxSolidTeapot(1.0); + glPopMatrix(); +} + +/* First column: emerald, jade, obsidian, pearl, ruby, turquoise + * 2nd column: brass, bronze, chrome, copper, gold, silver + * 3rd column: black, cyan, green, red, white, yellow plastic + * 4th column: black, cyan, green, red, white, yellow rubber + */ +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + renderTeapot (2.0, 17.0, 0.0215, 0.1745, 0.0215, + 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6); + renderTeapot (2.0, 14.0, 0.135, 0.2225, 0.1575, + 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1); + renderTeapot (2.0, 11.0, 0.05375, 0.05, 0.06625, + 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3); + renderTeapot (2.0, 8.0, 0.25, 0.20725, 0.20725, + 1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088); + renderTeapot (2.0, 5.0, 0.1745, 0.01175, 0.01175, + 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); + renderTeapot (2.0, 2.0, 0.1, 0.18725, 0.1745, + 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1); + renderTeapot (6.0, 17.0, 0.329412, 0.223529, 0.027451, + 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843, + 0.21794872); + renderTeapot (6.0, 14.0, 0.2125, 0.1275, 0.054, + 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2); + renderTeapot (6.0, 11.0, 0.25, 0.25, 0.25, + 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6); + renderTeapot (6.0, 8.0, 0.19125, 0.0735, 0.0225, + 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1); + renderTeapot (6.0, 5.0, 0.24725, 0.1995, 0.0745, + 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4); + renderTeapot (6.0, 2.0, 0.19225, 0.19225, 0.19225, + 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4); + renderTeapot (10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01, + 0.50, 0.50, 0.50, .25); + renderTeapot (10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, + 0.50196078, 0.50196078, 0.50196078, .25); + renderTeapot (10.0, 11.0, 0.0, 0.0, 0.0, + 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, .25); + renderTeapot (10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, + 0.7, 0.6, 0.6, .25); + renderTeapot (10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55, + 0.70, 0.70, 0.70, .25); + renderTeapot (10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, + 0.60, 0.60, 0.50, .25); + renderTeapot (14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, + 0.4, 0.4, 0.4, .078125); + renderTeapot (14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5, + 0.04, 0.7, 0.7, .078125); + renderTeapot (14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4, + 0.04, 0.7, 0.04, .078125); + renderTeapot (14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4, + 0.7, 0.04, 0.04, .078125); + renderTeapot (14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5, + 0.7, 0.7, 0.7, .078125); + renderTeapot (14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4, + 0.7, 0.7, 0.04, .078125); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (0.0, 16.0, 0.0, 16.0*(GLfloat)h/(GLfloat)w, + -10.0, 10.0); + else + glOrtho (0.0, 16.0*(GLfloat)w/(GLfloat)h, 0.0, 16.0, + -10.0, 10.0); + glMatrixMode(GL_MODELVIEW); +} + +int gl_width=500; +int gl_height=600; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/texgen.c b/xc/extras/Mesa/OpenStep/Old_NeXT/texgen.c new file mode 100644 index 000000000..93b5aaa54 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/texgen.c @@ -0,0 +1,129 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* texgen.c + * This program draws a texture mapped teapot with + * automatically generated texture coordinates. The + * texture is rendered as stripes on the teapot. + */ + +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" + +#define stripeImageWidth 32 +GLubyte stripeImage[3*stripeImageWidth]; + +void makeStripeImage(void) +{ + int j; + + for (j = 0; j < stripeImageWidth; j++) { + stripeImage[3*j] = (j<=4) ? 255 : 0; + stripeImage[3*j+1] = (j>4) ? 255 : 0; + stripeImage[3*j+2] = 0; + } +} + +/* glTexGen stuff: */ + +GLfloat sgenparams[] = {1.0, 1.0, 1.0, 0.0}; + +void myinit(void) +{ + glClearColor (0.0, 0.0, 0.0, 0.0); + + makeStripeImage(); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexImage1D(GL_TEXTURE_1D, 0, 3, stripeImageWidth, 0, + GL_RGB, GL_UNSIGNED_BYTE, stripeImage); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGenfv(GL_S, GL_OBJECT_PLANE, sgenparams); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_1D); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_AUTO_NORMAL); + glEnable(GL_NORMALIZE); + glFrontFace(GL_CW); + glCullFace(GL_BACK); + glMaterialf (GL_FRONT, GL_SHININESS, 64.0); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix (); + glRotatef(45.0, 0.0, 0.0, 1.0); + auxSolidTeapot(2.0); + glPopMatrix (); + glFlush(); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho (-3.5, 3.5, -3.5*(GLfloat)h/(GLfloat)w, + 3.5*(GLfloat)h/(GLfloat)w, -3.5, 3.5); + else + glOrtho (-3.5*(GLfloat)w/(GLfloat)h, + 3.5*(GLfloat)w/(GLfloat)h, -3.5, 3.5, -3.5, 3.5); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +int gl_width=200; +int gl_height=200; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} diff --git a/xc/extras/Mesa/OpenStep/Old_NeXT/texturesurf.c b/xc/extras/Mesa/OpenStep/Old_NeXT/texturesurf.c new file mode 100644 index 000000000..a8995d8f1 --- /dev/null +++ b/xc/extras/Mesa/OpenStep/Old_NeXT/texturesurf.c @@ -0,0 +1,138 @@ +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ +/* texturesurf.c + * This program uses evaluators to generate a curved + * surface and automatically generated texture coordinates. + */ + +#include <GL/gl.h> +#include <GL/glu.h> +#include <stdlib.h> +#include "glaux.h" +#include <math.h> + +GLfloat ctrlpoints[4][4][3] = { + {{ -1.5, -1.5, 4.0}, { -0.5, -1.5, 2.0}, + {0.5, -1.5, -1.0}, {1.5, -1.5, 2.0}}, + {{ -1.5, -0.5, 1.0}, { -0.5, -0.5, 3.0}, + {0.5, -0.5, 0.0}, {1.5, -0.5, -1.0}}, + {{ -1.5, 0.5, 4.0}, { -0.5, 0.5, 0.0}, + {0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}}, + {{ -1.5, 1.5, -2.0}, { -0.5, 1.5, -2.0}, + {0.5, 1.5, 0.0}, {1.5, 1.5, -1.0}} +}; + +GLfloat texpts[2][2][2] = {{{0.0, 0.0}, {0.0, 1.0}}, + {{1.0, 0.0}, {1.0, 1.0}}}; + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glColor3f(1.0, 1.0, 1.0); + glEvalMesh2(GL_FILL, 0, 20, 0, 20); + glFlush(); +} + +#define imageWidth 64 +#define imageHeight 64 +GLubyte image[3*imageWidth*imageHeight]; + +void makeImage(void) +{ + int i, j; + float ti, tj; + + for (i = 0; i < imageWidth; i++) { + ti = 2.0*3.14159265*i/imageWidth; + for (j = 0; j < imageHeight; j++) { + tj = 2.0*3.14159265*j/imageHeight; + + image[3*(imageHeight*i+j)] = (GLubyte) 127*(1.0+sin(ti)); + image[3*(imageHeight*i+j)+1] = (GLubyte) 127*(1.0+cos(2*tj)); + image[3*(imageHeight*i+j)+2] = (GLubyte) 127*(1.0+cos(ti+tj)); + } + } +} + +void myinit(void) +{ + glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, + 0, 1, 12, 4, &ctrlpoints[0][0][0]); + glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, + 0, 1, 4, 2, &texpts[0][0][0]); + glEnable(GL_MAP2_TEXTURE_COORD_2); + glEnable(GL_MAP2_VERTEX_3); + glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0); + makeImage(); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, 3, imageWidth, imageHeight, 0, + GL_RGB, GL_UNSIGNED_BYTE, image); + glEnable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + glEnable(GL_NORMALIZE); + glShadeModel (GL_FLAT); +} + +void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + glOrtho(-4.0, 4.0, -4.0*(GLfloat)h/(GLfloat)w, + 4.0*(GLfloat)h/(GLfloat)w, -4.0, 4.0); + else + glOrtho(-4.0*(GLfloat)w/(GLfloat)h, + 4.0*(GLfloat)w/(GLfloat)h, -4.0, 4.0, -4.0, 4.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glRotatef(85.0, 1.0, 1.0, 1.0); +} + +int gl_width=300; +int gl_height=300; + +void render_image(void) +{ + myinit(); + myReshape(gl_width,gl_height); + display(); +} |