A bunch of little tests which exercise each ARB_fp instruction plus
a couple of other interesting cases.
This commit is contained in:
parent
f344be793c
commit
a90909e892
|
@ -0,0 +1,122 @@
|
|||
# progs/tests/Makefile
|
||||
|
||||
|
||||
# These programs aren't intended to be included with the normal distro.
|
||||
# They're not too interesting but they're good for testing.
|
||||
|
||||
TOP = ../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
LIBS = $(APP_LIB_DEPS)
|
||||
|
||||
SOURCES = \
|
||||
tri-abs.c \
|
||||
tri-add.c \
|
||||
tri-cmp.c \
|
||||
tri-cos.c \
|
||||
tri-dp3.c \
|
||||
tri-dp4.c \
|
||||
tri-dph.c \
|
||||
tri-dst.c \
|
||||
tri-ex2.c \
|
||||
tri-flr.c \
|
||||
tri-frc.c \
|
||||
tri-kil.c \
|
||||
tri-lg2.c \
|
||||
tri-lit.c \
|
||||
tri-lrp.c \
|
||||
tri-mad.c \
|
||||
tri-max.c \
|
||||
tri-min.c \
|
||||
tri-mov.c \
|
||||
tri-mul.c \
|
||||
tri-pow.c \
|
||||
tri-rcp.c \
|
||||
tri-rsq.c \
|
||||
tri-scs.c \
|
||||
tri-sge.c \
|
||||
tri-sge2.c \
|
||||
tri-sin.c \
|
||||
tri-slt.c \
|
||||
tri-sub.c \
|
||||
tri-swz.c \
|
||||
tri-swz2.c \
|
||||
tri-tex.c \
|
||||
tri-xpd.c \
|
||||
tri-position.c \
|
||||
|
||||
NOTDONE=\
|
||||
tri-txb.c \
|
||||
tri-txp.c \
|
||||
tri-depthwrite.c \
|
||||
tri-fogoption.c
|
||||
|
||||
|
||||
PROGS = $(SOURCES:%.c=%)
|
||||
|
||||
INCLUDES = -I. -I$(TOP)/include -I../samples
|
||||
|
||||
UTIL_FILES = readtex.h readtex.c
|
||||
|
||||
|
||||
##### RULES #####
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c:
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
.S.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
default: $(UTIL_FILES) $(PROGS)
|
||||
|
||||
clean:
|
||||
rm -f $(PROGS)
|
||||
rm -f *.o
|
||||
rm -f getproclist.h
|
||||
|
||||
|
||||
# auto code generation
|
||||
getprocaddress: getprocaddress.c getproclist.h
|
||||
|
||||
getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py
|
||||
python getprocaddress.py > getproclist.h
|
||||
|
||||
|
||||
texrect: texrect.o readtex.o
|
||||
$(CC) texrect.o readtex.o $(LIBS) -o $@
|
||||
|
||||
texrect.o: texrect.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
invert: invert.o readtex.o
|
||||
$(CC) invert.o readtex.o $(LIBS) -o $@
|
||||
|
||||
invert.o: invert.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
readtex.o: readtex.c
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
|
||||
readtex.h: $(TOP)/progs/util/readtex.h
|
||||
ln -s $(TOP)/progs/util/readtex.h .
|
||||
|
||||
readtex.c: $(TOP)/progs/util/readtex.c
|
||||
ln -s $(TOP)/progs/util/readtex.c .
|
||||
|
||||
|
||||
|
||||
|
||||
# Emacs tags
|
||||
tags:
|
||||
etags `find . -name \*.[ch]` `find ../include`
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"SUB R0, {0.5}.x, fragment.color; \n"
|
||||
"ABS result.color, R0; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"ADD R0, fragment.color, fragment.color; \n"
|
||||
"ADD result.color, R0, R0; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"SUB R0, {0.5}.x, fragment.color; \n"
|
||||
"CMP result.color, R0, fragment.color, {0.0}.x; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0; \n"
|
||||
"MUL R0, fragment.color, {3.14}.x; \n"
|
||||
"SIN result.color.x, R0.x; \n"
|
||||
"COS result.color.y, R0.y; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"DP3 result.color, fragment.color, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"DP4 result.color, fragment.color.xxxx, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"DPH result.color, fragment.color, fragment.color.xyzx; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"DST result.color, fragment.position, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"EX2 R0, fragment.color.x; \n"
|
||||
"SUB result.color, R0, {1.0}.x; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
|
||||
glClearColor(0.5, 0.5, 0.5, 0.0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
/* Exit after first frame
|
||||
*/
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"ADD R0, fragment.color, {0.5}.x; \n"
|
||||
"FLR result.color, R0; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"SLT result.color, {0.5}.x, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0; \n"
|
||||
"MUL R0, fragment.color, {3.0}.x; \n"
|
||||
"FRC result.color, R0; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"INV result.color, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"SUB R0, fragment.color, {0.5,0,0,0}; \n"
|
||||
"KIL R0;"
|
||||
"MOV result.color, R0;"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"MUL R0, fragment.color, {4.0}.x; \n"
|
||||
"LG2 result.color, R0.x; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"SUB R0, {0.5}.x, fragment.color; \n"
|
||||
"LIT result.color, R0; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0, R1;\n"
|
||||
"LRP result.color, fragment.color.z, {1,0,0,1}, {0,1,0,1}; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0, R1;\n"
|
||||
"MAD result.color, fragment.color.z, {1,0,0,1}, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MAX result.color, {0.5}.x, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MIN result.color, {0.5}.x, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MOV result.color, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MUL result.color, fragment.color, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MOV result.color, fragment.position; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"POW result.color, fragment.color.x, fragment.color.y; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"RCP result.color, fragment.color.x; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"MUL R0, fragment.color, {3.0}.x; \n"
|
||||
"RSQ result.color, R0.x; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0; \n"
|
||||
"MUL R0, fragment.color, {3.14}.x; \n"
|
||||
"SCS result.color, R0.x; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"SGE result.color, {0.5}.x, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"TEMP R1;\n"
|
||||
"SGE R0, fragment.color, fragment.color.yzxw; \n"
|
||||
"SGE R1, fragment.color, fragment.color.zxyw; \n"
|
||||
"MUL R0, R0, R1; \n"
|
||||
"MUL result.color, R0, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MOV result.color, {0.0}.x; \n"
|
||||
"COS result.color.y, fragment.color.y; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"SLT result.color, {0.5}.x, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"SUB result.color, fragment.color.yzxw, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"SWZ result.color, fragment.color, 1,x,y,z; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0, R1;\n"
|
||||
"SWZ result.color, fragment.color, 1, 0, 0, 1; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "readtex.c"
|
||||
|
||||
|
||||
#define TEXTURE_FILE "../images/girl.rgb"
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEX result.color, fragment.color, texture[0], 2D; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
GLuint Texture;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
assert(glIsProgramARB(modulateProg));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
/* Load texture */
|
||||
glGenTextures(1, &Texture);
|
||||
glBindTexture(GL_TEXTURE_2D, Texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
|
||||
printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE);
|
||||
exit(1);
|
||||
}
|
||||
/* XXX this enable shouldn't really be needed!!! */
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
/* glTexCoord2f(1, 0); */
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
/* glTexCoord2f(1, 1); */
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
/* glTexCoord2f(0, .5); */
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"XPD result.color, fragment.color, {2,2,2,0}; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue