Compare commits
129 Commits
texman_0_1
...
mesa_6_4
Author | SHA1 | Date | |
---|---|---|---|
|
7cd7a78d72 | ||
|
5c57efd6b4 | ||
|
ea9ed5849f | ||
|
1ef0939a64 | ||
|
d0f9c2887c | ||
|
ed75287003 | ||
|
c01c2fb542 | ||
|
e1d7297812 | ||
|
b4227f0d98 | ||
|
c868c1ee14 | ||
|
a1dcb43658 | ||
|
cc7b6810e2 | ||
|
7b9fecee10 | ||
|
8856180e4f | ||
|
df51dfbdc3 | ||
|
2fd1ed1b45 | ||
|
66b928e95e | ||
|
d5e9cca0b2 | ||
|
c072c17a8c | ||
|
8367420be9 | ||
|
e2a2ed06b2 | ||
|
0cc3703188 | ||
|
fb6c1492fb | ||
|
89ad797f9a | ||
|
fa67028ae7 | ||
|
8e1724dfe9 | ||
|
fbdb5c9b14 | ||
|
4b2728f95c | ||
|
3a7437399f | ||
|
3338f04be7 | ||
|
047f7bb11c | ||
|
5b25acdac7 | ||
|
cb16208ec0 | ||
|
88107bea56 | ||
|
b4d25157f2 | ||
|
c6d1f32ebe | ||
|
281f388e03 | ||
|
c0a0dfeb96 | ||
|
ab07593563 | ||
|
5b08058604 | ||
|
3bf13d3c4b | ||
|
2b05784084 | ||
|
2292262de4 | ||
|
a9358bb3b0 | ||
|
b9d111f202 | ||
|
20fd105e2a | ||
|
1faaa0090a | ||
|
23803bd5fb | ||
|
c000250504 | ||
|
b854297bab | ||
|
3c1b44ad55 | ||
|
bdab2cc216 | ||
|
91ade9ad68 | ||
|
7355bbce55 | ||
|
1d2671e6cb | ||
|
0a405dcc5f | ||
|
b210ffaadf | ||
|
b1e8471898 | ||
|
aefe0dabec | ||
|
758c5b9a7e | ||
|
44db6d7cb8 | ||
|
04f1fdc755 | ||
|
b181773d02 | ||
|
4218cddfb1 | ||
|
a4e35c21d2 | ||
|
5d63323d34 | ||
|
419a350499 | ||
|
db78ec7018 | ||
|
291911aeb5 | ||
|
e15a7d4883 | ||
|
2e95fdc5d8 | ||
|
6e03f6ed43 | ||
|
97790948f6 | ||
|
a882648023 | ||
|
b7f8d69bb3 | ||
|
5bad790e56 | ||
|
382b00f483 | ||
|
718bd385ed | ||
|
402ca8903f | ||
|
25a9c9f370 | ||
|
d73a838f01 | ||
|
c72b2fb2db | ||
|
5a6ce051ef | ||
|
e7c2fa9cff | ||
|
5919aec5c3 | ||
|
f5a6175d83 | ||
|
e41ea35fee | ||
|
38cf2b14f4 | ||
|
66725dca81 | ||
|
59ad040754 | ||
|
5e16f314d6 | ||
|
2376438410 | ||
|
1be13df2c3 | ||
|
1f6892527b | ||
|
e5f6f26c87 | ||
|
e14b3baca0 | ||
|
5eb129de76 | ||
|
3f27b6ffeb | ||
|
270572e543 | ||
|
7b56e1a443 | ||
|
cfaac5dc4f | ||
|
1e5c3e977f | ||
|
831b4143f7 | ||
|
b26b565f91 | ||
|
f4d1dafc18 | ||
|
db70c3f9b6 | ||
|
384b1d03e4 | ||
|
e3c1b594ae | ||
|
453eb90128 | ||
|
cb505bf744 | ||
|
133112c71a | ||
|
a66eebc579 | ||
|
89ea47182d | ||
|
2efe639f26 | ||
|
39e4095560 | ||
|
b19ec5009f | ||
|
afed3e55ba | ||
|
46cf4fa1bd | ||
|
b4198e821a | ||
|
5a1fb7db0e | ||
|
f16fbf03bd | ||
|
ec0c42a3be | ||
|
a4c1895d07 | ||
|
b2971358ad | ||
|
24a36c26fa | ||
|
247e27d0b8 | ||
|
912bcb2386 | ||
|
cee416863f | ||
|
8e946792dc |
11
Makefile
11
Makefile
@@ -134,10 +134,10 @@ ultrix-gcc:
|
||||
|
||||
# Rules for making release tarballs
|
||||
|
||||
DIRECTORY = Mesa-6.5
|
||||
LIB_NAME = MesaLib-6.5
|
||||
DEMO_NAME = MesaDemos-6.5
|
||||
GLUT_NAME = MesaGLUT-6.5
|
||||
DIRECTORY = Mesa-6.4
|
||||
LIB_NAME = MesaLib-6.4
|
||||
DEMO_NAME = MesaDemos-6.4
|
||||
GLUT_NAME = MesaGLUT-6.4
|
||||
|
||||
MAIN_FILES = \
|
||||
$(DIRECTORY)/Makefile* \
|
||||
@@ -269,6 +269,7 @@ DRI_FILES = \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/Makefile.template \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.[ch] \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.po \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/dri_client/imports/*.h \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/*.[chS] \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/Makefile \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/Doxyfile \
|
||||
@@ -322,8 +323,6 @@ DEMO_FILES = \
|
||||
$(DIRECTORY)/progs/demos/*.cxx \
|
||||
$(DIRECTORY)/progs/demos/*.dat \
|
||||
$(DIRECTORY)/progs/demos/README \
|
||||
$(DIRECTORY)/progs/osdemos/Makefile \
|
||||
$(DIRECTORY)/progs/osdemos/*.c \
|
||||
$(DIRECTORY)/progs/xdemos/Makefile* \
|
||||
$(DIRECTORY)/progs/xdemos/descrip.mms \
|
||||
$(DIRECTORY)/progs/xdemos/*.[chf] \
|
||||
|
@@ -51,8 +51,6 @@ fi
|
||||
|
||||
if [ `uname` = "FreeBSD" ] ; then
|
||||
CP_FLAGS="-f"
|
||||
elif [ `uname` = "Darwin" ] ; then
|
||||
CP_FLAGS="-f"
|
||||
else
|
||||
CP_FLAGS="-fd"
|
||||
fi
|
||||
@@ -65,7 +63,6 @@ mkdir ${INCLUDE_DIR}/GL
|
||||
mkdir ${INCLUDE_DIR}/GLES
|
||||
mkdir ${LIB_DIR}
|
||||
cp -f ${TOP}/include/GL/*.h ${INCLUDE_DIR}/GL
|
||||
cp -f ${TOP}/src/glw/*.h ${INCLUDE_DIR}/GL
|
||||
# NOT YET: cp -f ${TOP}/include/GLES/*.h ${INCLUDE_DIR}/GLES
|
||||
cp ${CP_FLAGS} ${TOP}/lib*/lib* ${LIB_DIR}
|
||||
|
||||
|
@@ -209,8 +209,10 @@ case $ARCH in
|
||||
elif [ $STATIC = 1 ] ; then
|
||||
LIBNAME="lib${LIBNAME}" # prefix with "lib"
|
||||
echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
|
||||
rm -f ${LIBNAME}.a
|
||||
ar -ru ${LIBNAME}.a ${OBJECTS}
|
||||
LINK="ar"
|
||||
OPTS="-ru"
|
||||
# make lib
|
||||
${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
|
||||
ranlib ${LIBNAME}.a
|
||||
# finish up
|
||||
FINAL_LIBS=${LIBNAME}.a
|
||||
@@ -426,7 +428,6 @@ case $ARCH in
|
||||
if [ $STATIC = 1 ] ; then
|
||||
LIBNAME="lib${LIBNAME}.a"
|
||||
echo "mklib: Making AIX static library: " ${LIBNAME}
|
||||
rm -f ${LIBNAME}
|
||||
ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
|
||||
FINAL_LIBS=${LIBNAME}
|
||||
else
|
||||
|
@@ -26,8 +26,7 @@ ifeq ($(CPU), x86)
|
||||
-DUSE_3DNOW_ASM \
|
||||
-DUSE_SSE_ASM
|
||||
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
ASM_SOURCES = $(X86_SOURCES) $(X86_API)
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
@@ -5,13 +5,11 @@ include $(TOP)/configs/default
|
||||
CONFIG_NAME = darwin
|
||||
|
||||
# Compiler and flags
|
||||
CC = c++
|
||||
CXX = c++
|
||||
CC = cc
|
||||
CXX = cc
|
||||
CFLAGS = -I/usr/X11R6/include -O3 -fPIC -fno-common -ffast-math -funroll-loops -fexpensive-optimizations -no-cpp-precomp -dynamic -Ddarwin
|
||||
CXXFLAGS = -I/usr/X11R6/include -O3 -fPIC -fno-common -ffast-math -funroll-loops -fexpensive-optimizations -no-cpp-precomp -dynamic -Ddarwin
|
||||
|
||||
MKLIB_OPTIONS = -cplusplus
|
||||
|
||||
# Library names (actual file names)
|
||||
GL_LIB_NAME = libGL.dylib
|
||||
GLU_LIB_NAME = libGLU.dylib
|
||||
|
@@ -7,9 +7,12 @@ CONFIG_NAME = default
|
||||
|
||||
# Version info
|
||||
MESA_MAJOR=6
|
||||
MESA_MINOR=5
|
||||
MESA_MINOR=4
|
||||
MESA_TINY=0
|
||||
|
||||
# external projects. This should be useless now that we use libdrm.
|
||||
DRM_SOURCE_PATH=$(TOP)/../drm
|
||||
|
||||
# Compiler and flags
|
||||
CC = cc
|
||||
CXX = CC
|
||||
|
@@ -9,8 +9,7 @@ CC = gcc
|
||||
CXX = g++
|
||||
MAKE = gmake
|
||||
|
||||
CFLAGS = -O2 -fPIC -pedantic -I/usr/X11R6/include -DUSE_XSHM -DHZ=100 \
|
||||
$(ASM_FLAGS)
|
||||
CFLAGS = -O2 -fPIC -pedantic -I/usr/X11R6/include -DUSE_XSHM -DHZ=100
|
||||
CXXFLAGS = -O2 -fPIC -pedantic
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
|
@@ -16,7 +16,7 @@ X11_INCLUDES = -I/usr/X11R6/include
|
||||
DEFINES = -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
|
||||
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS
|
||||
CFLAGS = $(DEFINES) -Wmissing-prototypes -g -std=c99 -Wundef -fPIC \
|
||||
-ffast-math $(ASM_FLAGS) $(X11_INCLUDES)
|
||||
-ffast-math $(X11_INCLUDES)
|
||||
CXXFLAGS = $(DEFINES) -Wall -g -ansi -pedantic -fPIC
|
||||
|
||||
ASM_SOURCES =
|
||||
@@ -24,7 +24,7 @@ ASM_SOURCES =
|
||||
# Library/program dependencies
|
||||
LIBDRM_LIB = `pkg-config --libs libdrm` -ldrm
|
||||
DRI_LIB_DEPS = -L/usr/local/lib -lm -lpthread -lexpat $(LIBDRM_LIB)
|
||||
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lm -lpthread $(LIBDRM_LIB)
|
||||
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread $(LIBDRM_LIB)
|
||||
|
||||
GLUT_LIB_DEPS = -L$(LIB_DIR) -L/usr/X11R6/lib -lGLU -lGL -lX11 -lXmu -lXt -lXi -lm
|
||||
GLW_LIB_DEPS = -L$(LIB_DIR) -L/usr/X11R6/lib -lGL -lXt -lXm -lX11
|
||||
|
@@ -6,5 +6,4 @@ include $(TOP)/configs/freebsd-dri
|
||||
CONFIG_NAME = freebsd-dri-x86-64
|
||||
|
||||
ASM_FLAGS = -DUSE_X86_64_ASM
|
||||
ASM_SOURCES = $(X86-64_SOURCES)
|
||||
ASM_API = $(X86-64_API)
|
||||
ASM_SOURCES = $(X86-64_SOURCES) $(X86-64_API)
|
||||
|
@@ -10,4 +10,3 @@ PIC_FLAGS =
|
||||
|
||||
ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
|
@@ -8,6 +8,7 @@ CONFIG_NAME = linux
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
||||
WARN_FLAGS = -Wall
|
||||
OPT_FLAGS = -O3 -g
|
||||
PIC_FLAGS = -fPIC
|
||||
|
||||
@@ -21,10 +22,10 @@ DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
|
||||
|
||||
X11_INCLUDES = -I/usr/X11R6/include
|
||||
|
||||
CFLAGS = -Wall -Wmissing-prototypes $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
|
||||
$(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
|
||||
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
|
||||
$(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
|
||||
|
||||
CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
|
||||
CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
|
||||
$(X11_INCLUDES)
|
||||
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
@@ -5,4 +5,4 @@ include $(TOP)/configs/linux
|
||||
CONFIG_NAME = linux-debug
|
||||
|
||||
OPT_FLAGS = -g
|
||||
DEFINES += -DDEBUG -DDEBUG_MATH
|
||||
DEFINES += -DDEBUG -DMESA_DEBUG -DRUN_DEBUG_BENCHMARK
|
||||
|
@@ -17,8 +17,7 @@ HAVE_X86 = $(shell uname -m | grep 'i[3-6]86' >/dev/null && echo yes)
|
||||
ifeq ($(HAVE_X86), yes)
|
||||
CFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
|
||||
CXXFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
ASM_SOURCES = $(X86_SOURCES) $(X86_API)
|
||||
endif
|
||||
|
||||
# Directories
|
||||
|
@@ -9,12 +9,12 @@ CONFIG_NAME = linux-dri
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
||||
#MKDEP = /usr/X11R6/bin/makedepend
|
||||
MKDEP = /usr/X11R6/bin/makedepend
|
||||
#MKDEP = gcc -M
|
||||
#MKDEP_OPTIONS = -MF depend
|
||||
|
||||
#OPT_FLAGS = -g -march=pentium4 -fprefetch-loop-arrays
|
||||
OPT_FLAGS = -O2
|
||||
WARN_FLAGS = -Wall
|
||||
OPT_FLAGS = -O -g
|
||||
PIC_FLAGS = -fPIC
|
||||
|
||||
# Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
|
||||
@@ -23,15 +23,14 @@ ARCH_FLAGS ?=
|
||||
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
|
||||
-D_BSD_SOURCE -D_GNU_SOURCE \
|
||||
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
|
||||
-DDEBUG \
|
||||
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS
|
||||
|
||||
X11_INCLUDES = -I/usr/X11R6/include
|
||||
|
||||
CFLAGS = -Wall -Wmissing-prototypes $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
|
||||
$(DEFINES) $(ASM_FLAGS) -std=c99 -ffast-math
|
||||
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
|
||||
$(ASM_FLAGS) -std=c99 -ffast-math
|
||||
|
||||
CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
|
||||
CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
|
||||
|
||||
|
||||
ASM_SOURCES =
|
||||
@@ -65,7 +64,5 @@ WINDOW_SYSTEM=dri
|
||||
|
||||
# gamma are missing because they have not been converted to use the new
|
||||
# interface.
|
||||
DRI_DIRS = i915 mach64 mga r128 r200 r300 radeon s3v \
|
||||
DRI_DIRS = i810 i830 i915 mach64 mga r128 r200 r300 radeon s3v \
|
||||
savage sis tdfx trident unichrome ffb
|
||||
|
||||
DRI_DIRS = i915
|
||||
|
@@ -13,5 +13,4 @@ ARCH_FLAGS = -m32
|
||||
|
||||
ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
|
||||
|
@@ -8,8 +8,7 @@ CONFIG_NAME = linux-dri-x86-64
|
||||
ARCH_FLAGS = -m64
|
||||
|
||||
ASM_FLAGS = -DUSE_X86_64_ASM
|
||||
ASM_SOURCES = $(X86-64_SOURCES)
|
||||
ASM_API = $(X86-64_API)
|
||||
ASM_SOURCES = $(X86-64_SOURCES) $(X86-64_API)
|
||||
|
||||
LIB_DIR = $(TOP)/lib64
|
||||
|
||||
|
@@ -16,7 +16,6 @@ GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
|
||||
GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
|
||||
APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
|
||||
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
ASM_SOURCES = $(X86_SOURCES) $(X86_API)
|
||||
|
||||
|
||||
|
@@ -24,7 +24,6 @@ GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lX
|
||||
APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
|
||||
MKLIB_OPTIONS = -arch icc
|
||||
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
ASM_SOURCES = $(X86_SOURCES) $(X86_API)
|
||||
|
||||
|
||||
|
@@ -8,9 +8,9 @@ CONFIG_NAME = linux-profile
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
||||
CFLAGS = -pg -O -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG
|
||||
CFLAGS = -pg -O -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG
|
||||
|
||||
CXXFLAGS = -pg -O -ansi -pedantic -Wall -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -DDEBUG
|
||||
CXXFLAGS = -pg -O -ansi -pedantic -Wall -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -DDEBUG -DMESA_DEBUG
|
||||
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
|
@@ -10,4 +10,3 @@ PIC_FLAGS =
|
||||
|
||||
ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
|
22
configs/linux-tcc
Normal file
22
configs/linux-tcc
Normal file
@@ -0,0 +1,22 @@
|
||||
# Configuration for debugging on Linux
|
||||
|
||||
include $(TOP)/configs/default
|
||||
|
||||
CONFIG_NAME = linux-tcc
|
||||
|
||||
# Compiler and flags
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
||||
TCC_DIR=/home/progs/tcc-0.9.20
|
||||
|
||||
CFLAGS = -g -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG -DUSE_TCC -I$(TCC_DIR)
|
||||
|
||||
CXXFLAGS = -g -ansi -pedantic -Wall -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -DDEBUG -DMESA_DEBUG
|
||||
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread -L$(TCC_DIR) -ltcc -ldl
|
||||
GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
|
||||
GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lXt -L/usr/X11R6/lib -lX11
|
||||
APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
|
@@ -5,5 +5,4 @@ include $(TOP)/configs/linux
|
||||
CONFIG_NAME = linux-x86
|
||||
|
||||
ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
ASM_SOURCES = $(X86_SOURCES) $(X86_API)
|
||||
|
@@ -6,8 +6,7 @@ CONFIG_NAME = linux-x86-64
|
||||
|
||||
ARCH_FLAGS = -m64
|
||||
|
||||
ASM_SOURCES = $(X86-64_SOURCES)
|
||||
ASM_API = $(X86-64_API)
|
||||
ASM_SOURCES = $(X86-64_SOURCES) $(X86-64_API)
|
||||
ASM_FLAGS = -DUSE_X86_64_ASM
|
||||
|
||||
LIB_DIR = $(TOP)/lib64
|
||||
|
@@ -4,4 +4,4 @@ include $(TOP)/configs/linux-x86-64
|
||||
|
||||
CONFIG_NAME = linux-x86-64-debug
|
||||
|
||||
DEFINES += -DDEBUG -DDEBUG_MATH
|
||||
DEFINES += -DDEBUG -DMESA_DEBUG -DRUN_DEBUG_BENCHMARK
|
||||
|
@@ -6,4 +6,4 @@ include $(TOP)/configs/linux-x86
|
||||
CONFIG_NAME = linux-x86-debug
|
||||
|
||||
OPT_FLAGS = -g
|
||||
DEFINES += -DDEBUG -DDEBUG_MATH
|
||||
DEFINES += -DDEBUG -DMESA_DEBUG -DRUN_DEBUG_BENCHMARK
|
||||
|
@@ -15,8 +15,7 @@ CXXFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
ASM_SOURCES = $(X86_SOURCES) $(X86_API)
|
||||
|
||||
# Library/program dependencies
|
||||
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -L/usr/local/glide/lib -lglide3x -lm -lpthread
|
||||
|
@@ -15,8 +15,7 @@ CXXFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
|
||||
ASM_SOURCES = $(X86_SOURCES)
|
||||
ASM_API = $(X86_API)
|
||||
ASM_SOURCES = $(X86_SOURCES) $(X86_API)
|
||||
|
||||
# Library/program dependencies
|
||||
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread -lXCB
|
||||
|
@@ -16,8 +16,7 @@ ARCH_FLAGS ?=
|
||||
|
||||
DEFINES = -D_REENTRANT -DUSE_XSHM
|
||||
|
||||
ASM_SOURCES = $(SPARC_SOURCES)
|
||||
ASM_API = $(SPARC_API)
|
||||
ASM_SOURCES = $(SPARC_SOURCES) $(SPARC_API)
|
||||
ASM_FLAGS = -DUSE_SPARC_ASM
|
||||
|
||||
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
|
||||
|
@@ -26,13 +26,7 @@ On Alpha platforms at default a sharable images for the libraries are created.
|
||||
To get a static library make it by typing MMS/MACRO=(NOSHARE=1).
|
||||
On VAX platforms only static libraries can be build.
|
||||
|
||||
23-sep-2005
|
||||
changed default compilation to use /float=ieee/ieee=denorm. The reason for
|
||||
this is that it makes Mesa on OpenVMS better compatible with other platforms
|
||||
and other packages for VMS that I maintain.
|
||||
For more information see
|
||||
http://nchrem.tnw.tudelft.nl/openvms
|
||||
https://bugs.freedesktop.org/show_bug.cgi?id=4270
|
||||
You may want to compile Mesa to use VAX-floating point arithmetic, instead
|
||||
of IEEE floating point by removing the /float=IEEE/denorm flag from the
|
||||
compiler options in the descrip.mms files.
|
||||
|
||||
You may want to compile Mesa to use IEEE floating point arithmetic, instead
|
||||
of VAX floating point by specifying the /float=IEEE flag to the compiler.
|
||||
For more information see https://bugs.freedesktop.org/show_bug.cgi?id=4270
|
||||
|
@@ -47,4 +47,4 @@ in Mesa 6.3.
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
$Id: RELNOTES-6.4,v 3.1 2005/10/24 23:33:27 brianp Exp $
|
||||
$Id: RELNOTES-6.4,v 1.1.2.5 2005/10/24 23:12:29 brianp Exp $
|
||||
|
@@ -1,74 +0,0 @@
|
||||
|
||||
Mesa 6.5 Release Notes
|
||||
|
||||
month, day, 2005
|
||||
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Mesa uses an even/odd version number scheme like the Linux kernel.
|
||||
Odd numbered versions (such as 6.5) designate new developmental releases.
|
||||
Even numbered versions (such as 6.4) designate stable releases.
|
||||
|
||||
|
||||
|
||||
New Features
|
||||
------------
|
||||
|
||||
GL_EXT_timer_query - used to get elapsed time information from the renderer.
|
||||
|
||||
|
||||
|
||||
Driver Interface Changes
|
||||
------------------------
|
||||
|
||||
Stencil: The Driver.StencilOp/Func/Mask() functions have been replaced by
|
||||
the two-sided versions: Driver.Stencil*Separate().
|
||||
|
||||
|
||||
|
||||
To Do
|
||||
-----
|
||||
Fix linux-glide target/driver.
|
||||
Fix lambda calculation for frag progs.
|
||||
|
||||
|
||||
|
||||
|
||||
Removed Extensions
|
||||
------------------
|
||||
|
||||
The following extensions have been removed:
|
||||
|
||||
GL_HP_occlusion_test - this is superceded by GL_ARB_occlusion_query.
|
||||
|
||||
|
||||
|
||||
To Do (someday) items
|
||||
---------------------
|
||||
Switch to freeglut
|
||||
Increase MAX_DRAWBUFFERS
|
||||
|
||||
|
||||
|
||||
|
||||
Driver Status
|
||||
---------------------- ----------------------
|
||||
DRI drivers varies with the driver
|
||||
XMesa (Xlib) implements OpenGL 1.5
|
||||
OSMesa (off-screen) implements OpenGL 1.5
|
||||
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
|
||||
SVGA implements OpenGL 1.3
|
||||
Wind River UGL implements OpenGL 1.3
|
||||
Windows/Win32 implements OpenGL 1.5
|
||||
DJGPP implements OpenGL 1.5
|
||||
GGI implements OpenGL 1.3
|
||||
BeOS implements OpenGL 1.5
|
||||
Allegro needs updating
|
||||
D3D needs updating
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
$Id: RELNOTES-6.5,v 3.1 2005/09/14 14:34:54 brianp Exp $
|
@@ -1405,23 +1405,3 @@ Mesa Version History
|
||||
- GLX encoding for transpose matrix functions was broken
|
||||
- fixed broken fragment program KIL and SWZ instructions
|
||||
- fragment programs that wrote result.depth.z didn't work
|
||||
|
||||
|
||||
6.5 month, day, 2005
|
||||
New:
|
||||
- GL_EXT_packed_depth_stencil extension
|
||||
- GL_EXT_timer_query extension
|
||||
- reflect demo improved to support multiple windows
|
||||
- singlebuffer demo (shows no/little-flicker single-buffered rendering)
|
||||
- r200: enable GL_ARB_texture_env_crossbar, separate the texture
|
||||
sampling unit bits from the texture env combine enable bits
|
||||
- r200: add support for GL_ATI_fragment_shader
|
||||
- added fast XOR-mode line drawing optimization
|
||||
- radeon: add support for all 3 tmus, GL_ARB_texture_cube_map
|
||||
and GL_EXT_fog_coord
|
||||
- MESA_GLX_ALPHA_BITS env var for xlib driver
|
||||
Changes:
|
||||
- removed GL_HP_occlusion_test (use GL_ARB_occlusion_query instead)
|
||||
- removed GL_SGIX/SGIS_pixel_texture extensions
|
||||
Bug fixes:
|
||||
|
||||
|
@@ -79,7 +79,7 @@ a:visited {
|
||||
<b>Links</b>
|
||||
<ul>
|
||||
<li><a href="http://www.opengl.org" target="_parent">OpenGL website</a>
|
||||
<li><a href="http://dri.freedesktop.org" target="_parent">DRI website</a>
|
||||
<li><a href="http://dri.sourceforge.net" target="_parent">DRI website</a>
|
||||
<li><a href="http://www.freedesktop.org" target="_parent">freedesktop.org</a>
|
||||
<li><a href="games.html" target="MainFrame">Games and Entertainment</a>
|
||||
<li><a href="libraries.html" target="MainFrame">Libraries and Toolkits</a>
|
||||
@@ -98,4 +98,4 @@ WIDTH="88" HEIGHT="31" ALIGN="BOTTOM" ALT="Sourceforge.net" BORDER="0"></A>
|
||||
</blockquote>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@@ -9,11 +9,7 @@
|
||||
<H1>Downloading</H1>
|
||||
|
||||
<p>
|
||||
Last development release: <b>6.3.2</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Last stable release: <b>6.2.1</b>
|
||||
Current stable release: <b>6.4</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@@ -37,7 +37,6 @@ software driver:
|
||||
"window" to render into a window, or "disable" to disable the Glide driver.
|
||||
<li>MESA_GLX_FORCE_ALPHA - if set, forces RGB windows to have an alpha channel.
|
||||
<li>MESA_GLX_DEPTH_BITS - specifies default number of bits for depth buffer.
|
||||
<li>MESA_GLX_ALPHA_BITS - specifies default number of bits for alpha channel.
|
||||
</ul>
|
||||
|
||||
|
||||
|
@@ -136,7 +136,7 @@ GL_ARB_fragment_program extensions.
|
||||
<p>
|
||||
Ongoing: Mesa is used as the core of many hardware OpenGL drivers for
|
||||
the XFree86 X.org X servers within the
|
||||
<A href="http://dri.freedesktop.org/" target="_parent">DRI project</A>.
|
||||
<A href="http://dri.sourceforge.net/" target="_parent">DRI project</A>.
|
||||
I continue to enhance Mesa with new extensions and features.
|
||||
</p>
|
||||
|
||||
|
@@ -62,6 +62,8 @@
|
||||
</li><li><a href="http://mesa3d.sourceforge.net/notfound.html">VRweb</a> - VRML browser
|
||||
</li><li><a href="http://www.csv.ica.uni-stuttgart.de/vrml/dune/" target="_parent">white_dune</a>
|
||||
- graphical VRML97 Editor and animation tool
|
||||
</li><li><a href="http://www.wings3d.org/" target="_parent">Wings 3D</a> - static 3D modeller
|
||||
with VRML export. Uses SDL library.
|
||||
</li></ul>
|
||||
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
<h2>October 24, 2005</h2>
|
||||
<p>
|
||||
Mesa 6.4 has been released. This is a stable, bug-fix release.
|
||||
Mesa 6.4 has been released. This is stable, bug-fix release.
|
||||
</p>
|
||||
<pre>
|
||||
New:
|
||||
@@ -50,15 +50,7 @@ Mesa 6.4 has been released. This is a stable, bug-fix release.
|
||||
The MD5 checksums are:
|
||||
</p>
|
||||
<pre>
|
||||
1cce0c1eb4fd15e9dfe837a1ce0c9812 MesaLib-6.4.tar.gz
|
||||
85a84e47a3f718f752f306b9e0954ef6 MesaLib-6.4.tar.bz2
|
||||
b976fea4f3ee06354c53f91b6e3f2ffc MesaLib-6.4.zip
|
||||
d8734f2c69bcf7ef9f5ae454a85743ba MesaDemos-6.4.tar.gz
|
||||
1a8c4d4fc699233f5fdb902b8753099e MesaDemos-6.4.tar.bz2
|
||||
607ab7c7a7de0cc5febbdde2bfa03098 MesaDemos-6.4.zip
|
||||
3260156f66174322a092be0767962d34 MesaGLUT-6.4.tar.gz
|
||||
0465d053f83775f44a12dec4050dfd78 MesaGLUT-6.4.tar.bz2
|
||||
02abfcdcdf72ba938ae00f6e3b70fbe0 MesaGLUT-6.4.zip
|
||||
TBD
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1102,6 +1094,6 @@ source code</a>.</p>
|
||||
|
||||
|
||||
<hr>
|
||||
$Id: news.html,v 3.25 2005/10/24 23:33:27 brianp Exp $
|
||||
$Id: news.html,v 3.24.2.2 2005/10/24 23:12:29 brianp Exp $
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -33,7 +33,7 @@ Be warned that some drivers may be out of date and no longer function.
|
||||
|
||||
<UL>
|
||||
<LI>Xlib driver for the X Window System <A HREF="README.X11">(README.X11)</A>
|
||||
<li><a href="http://dri.freedesktop.org/" target="_parent">
|
||||
<li><a href="http://dri.sourceforge.net/" target="_parent">
|
||||
DRI hardware drivers</a> for the X window system
|
||||
<LI>Microsoft Windows <A HREF="README.WIN32">(README.WIN32)</A>
|
||||
<LI>DEC VMS <A HREF="README.VMS">(README.VMS)</A>
|
||||
@@ -53,4 +53,4 @@ DRI hardware drivers</a> for the X window system
|
||||
</UL>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@@ -2231,68 +2231,6 @@ typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLen
|
||||
#endif /* GL_ATI_blend_equation_separate */
|
||||
|
||||
|
||||
|
||||
#ifndef GL_EXT_timer_query
|
||||
#define GL_EXT_timer_query 1
|
||||
|
||||
/* Define 64-bit types */
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
typedef long long int GLint64EXT;
|
||||
typedef unsigned long long int GLuint64EXT;
|
||||
#elif defined(_WIN32)
|
||||
typedef __int64 GLint64EXT;
|
||||
typedef unsigned __int64 GLuint64EXT;
|
||||
#else
|
||||
/* this might actually be a 32-bit type */
|
||||
typedef long int GLint64EXT;
|
||||
typedef unsigned long int GLuint64EXT;
|
||||
#endif
|
||||
|
||||
#define GL_TIME_ELAPSED_EXT 0x88BF
|
||||
|
||||
GLAPI void GLAPIENTRY glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params);
|
||||
GLAPI void GLAPIENTRY glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params);
|
||||
|
||||
typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params);
|
||||
typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params);
|
||||
|
||||
#endif /* GL_EXT_timer_query */
|
||||
|
||||
|
||||
|
||||
#ifndef GL_EXT_framebuffer_blit
|
||||
#define GL_EXT_framebuffer_blit 1
|
||||
|
||||
#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
|
||||
#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
|
||||
#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
|
||||
|
||||
GLAPI void GLAPIENTRY
|
||||
glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
|
||||
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
||||
GLbitfield mask, GLenum filter);
|
||||
|
||||
typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC)
|
||||
(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
|
||||
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
||||
GLbitfield mask, GLenum filter);
|
||||
|
||||
#endif /* GL_EXT_framebuffer_blit */
|
||||
|
||||
|
||||
|
||||
#ifndef GL_EXT_packed_depth_stencil
|
||||
#define GL_EXT_packed_depth_stencil 1
|
||||
|
||||
#define GL_DEPTH_STENCIL_EXT 0x84F9
|
||||
#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
|
||||
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
|
||||
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
||||
|
||||
#endif /* GL_EXT_packed_depth_stencil */
|
||||
|
||||
|
||||
/**
|
||||
** NOTE!!!!! If you add new functions to this file, or update
|
||||
** glext.h be sure to regenerate the gl_mangle.h file. See comments
|
||||
|
@@ -520,10 +520,8 @@
|
||||
#define glGetProgramStringNV MANGLE(GetProgramStringNV)
|
||||
#define glGetQueryivARB MANGLE(GetQueryivARB)
|
||||
#define glGetQueryiv MANGLE(GetQueryiv)
|
||||
#define glGetQueryObjecti64vEXT MANGLE(GetQueryObjecti64vEXT)
|
||||
#define glGetQueryObjectivARB MANGLE(GetQueryObjectivARB)
|
||||
#define glGetQueryObjectiv MANGLE(GetQueryObjectiv)
|
||||
#define glGetQueryObjectui64vEXT MANGLE(GetQueryObjectui64vEXT)
|
||||
#define glGetQueryObjectuivARB MANGLE(GetQueryObjectuivARB)
|
||||
#define glGetQueryObjectuiv MANGLE(GetQueryObjectuiv)
|
||||
#define glGetRenderbufferParameterivEXT MANGLE(GetRenderbufferParameterivEXT)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 5.1
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -65,7 +65,7 @@ glFBDevGetString( int str );
|
||||
typedef void (*GLFBDevProc)();
|
||||
|
||||
|
||||
extern GLFBDevProc
|
||||
extern const GLFBDevProc
|
||||
glFBDevGetProcAddress( const char *procName );
|
||||
|
||||
|
||||
|
152
include/GL/glx.h
152
include/GL/glx.h
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 6.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
*
|
||||
@@ -302,6 +302,138 @@ extern void (*glXGetProcAddress(const GLubyte *procname))( void );
|
||||
#else
|
||||
|
||||
|
||||
/*
|
||||
* 28. GLX_EXT_visual_info extension
|
||||
*/
|
||||
#ifndef GLX_EXT_visual_info
|
||||
#define GLX_EXT_visual_info 1
|
||||
|
||||
#define GLX_X_VISUAL_TYPE_EXT 0x22
|
||||
#define GLX_TRANSPARENT_TYPE_EXT 0x23
|
||||
#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24
|
||||
#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25
|
||||
#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26
|
||||
#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27
|
||||
#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28
|
||||
#define GLX_TRUE_COLOR_EXT 0x8002
|
||||
#define GLX_DIRECT_COLOR_EXT 0x8003
|
||||
#define GLX_PSEUDO_COLOR_EXT 0x8004
|
||||
#define GLX_STATIC_COLOR_EXT 0x8005
|
||||
#define GLX_GRAY_SCALE_EXT 0x8006
|
||||
#define GLX_STATIC_GRAY_EXT 0x8007
|
||||
#define GLX_NONE_EXT 0x8000
|
||||
#define GLX_TRANSPARENT_RGB_EXT 0x8008
|
||||
#define GLX_TRANSPARENT_INDEX_EXT 0x8009
|
||||
|
||||
#endif /* 28. GLX_EXT_visual_info extension */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 41. GLX_SGI_video_sync
|
||||
*/
|
||||
#ifndef GLX_SGI_video_sync
|
||||
#define GLX_SGI_video_sync 1
|
||||
|
||||
extern int glXGetVideoSyncSGI(unsigned int *count);
|
||||
extern int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
|
||||
|
||||
#endif /* GLX_SGI_video_sync */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 42. GLX_EXT_visual_rating
|
||||
*/
|
||||
#ifndef GLX_EXT_visual_rating
|
||||
#define GLX_EXT_visual_rating 1
|
||||
|
||||
#define GLX_VISUAL_CAVEAT_EXT 0x20
|
||||
/*#define GLX_NONE_EXT 0x8000*/
|
||||
#define GLX_SLOW_VISUAL_EXT 0x8001
|
||||
#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
|
||||
|
||||
#endif /* GLX_EXT_visual_rating */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 47. GLX_EXT_import_context
|
||||
*/
|
||||
#ifndef GLX_EXT_import_context
|
||||
#define GLX_EXT_import_context 1
|
||||
|
||||
#define GLX_SHARE_CONTEXT_EXT 0x800A
|
||||
#define GLX_VISUAL_ID_EXT 0x800B
|
||||
#define GLX_SCREEN_EXT 0x800C
|
||||
|
||||
extern void glXFreeContextEXT(Display *dpy, GLXContext context);
|
||||
|
||||
extern GLXContextID glXGetContextIDEXT(const GLXContext context);
|
||||
|
||||
extern Display *glXGetCurrentDisplayEXT(void);
|
||||
|
||||
extern GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID);
|
||||
|
||||
extern int glXQueryContextInfoEXT(Display *dpy, GLXContext context,
|
||||
int attribute,int *value);
|
||||
|
||||
#endif /* GLX_EXT_import_context */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 215. GLX_MESA_copy_sub_buffer
|
||||
*/
|
||||
#ifndef GLX_MESA_copy_sub_buffer
|
||||
#define GLX_MESA_copy_sub_buffer 1
|
||||
|
||||
extern void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
|
||||
int x, int y, int width, int height );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 216. GLX_MESA_pixmap_colormap
|
||||
*/
|
||||
#ifndef GLX_MESA_pixmap_colormap
|
||||
#define GLX_MESA_pixmap_colormap 1
|
||||
|
||||
extern GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
|
||||
Pixmap pixmap, Colormap cmap );
|
||||
|
||||
#endif /* GLX_MESA_pixmap_colormap */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 217. GLX_MESA_release_buffers
|
||||
*/
|
||||
#ifndef GLX_MESA_release_buffers
|
||||
#define GLX_MESA_release_buffers 1
|
||||
|
||||
extern Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
|
||||
|
||||
#endif /* GLX_MESA_release_buffers */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 218. GLX_MESA_set_3dfx_mode
|
||||
*/
|
||||
#ifndef GLX_MESA_set_3dfx_mode
|
||||
#define GLX_MESA_set_3dfx_mode 1
|
||||
|
||||
#define GLX_3DFX_WINDOW_MODE_MESA 0x1
|
||||
#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
|
||||
|
||||
extern Bool glXSet3DfxModeMESA( int mode );
|
||||
|
||||
#endif /* GLX_MESA_set_3dfx_mode */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ARB 2. GLX_ARB_get_proc_address
|
||||
@@ -309,8 +441,7 @@ extern void (*glXGetProcAddress(const GLubyte *procname))( void );
|
||||
#ifndef GLX_ARB_get_proc_address
|
||||
#define GLX_ARB_get_proc_address 1
|
||||
|
||||
typedef void (*__GLXextFuncPtr)(void);
|
||||
extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
|
||||
extern void (*glXGetProcAddressARB(const GLubyte *procName))();
|
||||
|
||||
#endif /* GLX_ARB_get_proc_address */
|
||||
|
||||
@@ -338,6 +469,19 @@ typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer);
|
||||
#endif /* GLX_NV_vertex_array_range */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ???. GLX_MESA_agp_offset
|
||||
*/
|
||||
#ifndef GLX_MESA_agp_offset
|
||||
#define GLX_MESA_agp_offset 1
|
||||
|
||||
extern GLuint glXGetAGPOffsetMESA(const GLvoid *pointer);
|
||||
typedef GLuint (* PFNGLXGETAGPOFFSETMESAPROC) (const GLvoid *pointer);
|
||||
|
||||
#endif /* GLX_MESA_agp_offset */
|
||||
|
||||
|
||||
/*
|
||||
* ???. GLX_MESA_allocate_memory
|
||||
*/
|
||||
@@ -353,10 +497,8 @@ typedef GLuint (* PFNGLXGETMEMORYOFFSETMESAPROC) (Display *dpy, int scrn, const
|
||||
|
||||
#endif /* GLX_MESA_allocate_memory */
|
||||
|
||||
|
||||
/*
|
||||
* ARB ?. GLX_ARB_render_texture
|
||||
* XXX This was never finalized!
|
||||
*/
|
||||
#ifndef GLX_ARB_render_texture
|
||||
#define GLX_ARB_render_texture 1
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#define DRI_INTERFACE_H
|
||||
|
||||
#include <GL/internal/glcore.h>
|
||||
#include <xf86drm.h>
|
||||
#include <drm.h>
|
||||
|
||||
/**
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 6.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -61,7 +61,7 @@ extern "C" {
|
||||
|
||||
|
||||
#define OSMESA_MAJOR_VERSION 6
|
||||
#define OSMESA_MINOR_VERSION 5
|
||||
#define OSMESA_MINOR_VERSION 3
|
||||
#define OSMESA_PATCH_VERSION 0
|
||||
|
||||
|
||||
@@ -267,15 +267,6 @@ GLAPI OSMESAproc GLAPIENTRY
|
||||
OSMesaGetProcAddress( const char *funcName );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enable/disable color clamping, off by default.
|
||||
* New in Mesa 6.4.2
|
||||
*/
|
||||
GLAPI void GLAPIENTRY
|
||||
OSMesaColorClamp(GLboolean enable);
|
||||
|
||||
|
||||
#if defined(__BEOS__) || defined(__QUICKDRAW__)
|
||||
#pragma export off
|
||||
#endif
|
||||
|
@@ -78,7 +78,7 @@ typedef struct wmesa_context *WMesaContext;
|
||||
* appropriate colormap.
|
||||
*
|
||||
* Input:
|
||||
* hDC - Windows device or memory context
|
||||
* hWnd - Window handle
|
||||
* Pal - Palette to use
|
||||
* rgb_flag - GL_TRUE = RGB mode,
|
||||
* GL_FALSE = color index mode
|
||||
@@ -91,7 +91,7 @@ typedef struct wmesa_context *WMesaContext;
|
||||
*
|
||||
* Return: a WMesa_context or NULL if error.
|
||||
*/
|
||||
extern WMesaContext WMesaCreateContext(HDC hDC,HPALETTE* pPal,
|
||||
extern WMesaContext WMesaCreateContext(HWND hWnd,HPALETTE* pPal,
|
||||
GLboolean rgb_flag,
|
||||
GLboolean db_flag,
|
||||
GLboolean alpha_flag);
|
||||
|
@@ -235,23 +235,21 @@ GLAPI EGLBoolean APIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, Na
|
||||
#ifndef EGL_MESA_screen_surface
|
||||
#define EGL_MESA_screen_surface 1
|
||||
|
||||
#define EGL_BAD_SCREEN_MESA 0x4000
|
||||
#define EGL_BAD_MODE_MESA 0x4001
|
||||
#define EGL_SCREEN_COUNT_MESA 0x4002
|
||||
#define EGL_SCREEN_POSITION_MESA 0x4003
|
||||
#define EGL_SCREEN_POSITION_GRANULARITY_MESA 0x4004
|
||||
#define EGL_MODE_ID_MESA 0x4005
|
||||
#define EGL_REFRESH_RATE_MESA 0x4006
|
||||
#define EGL_OPTIMAL_MESA 0x4007
|
||||
#define EGL_INTERLACED_MESA 0x4008
|
||||
#define EGL_SCREEN_BIT_MESA 0x08
|
||||
#define EGL_BAD_SCREEN_MESA 0x4000
|
||||
#define EGL_BAD_MODE_MESA 0x4001
|
||||
#define EGL_SCREEN_COUNT_MESA 0x4002
|
||||
#define EGL_SCREEN_POSITION_MESA 0x4003
|
||||
#define EGL_MODE_ID_MESA 0x4004
|
||||
#define EGL_REFRESH_RATE_MESA 0x4005
|
||||
#define EGL_OPTIMAL_MODE_MESA 0x4006
|
||||
#define EGL_SCREEN_BIT_MESA 0x08
|
||||
|
||||
GLAPI EGLBoolean APIENTRY eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
||||
GLAPI EGLBoolean APIENTRY eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
||||
GLAPI EGLBoolean APIENTRY eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
|
||||
GLAPI EGLBoolean APIENTRY eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
|
||||
GLAPI EGLSurface APIENTRY eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
||||
GLAPI EGLBoolean APIENTRY eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
|
||||
GLAPI EGLBoolean APIENTRY eglShowSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
|
||||
GLAPI EGLBoolean APIENTRY eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
|
||||
GLAPI EGLBoolean APIENTRY eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
|
||||
GLAPI EGLBoolean APIENTRY eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
|
||||
|
@@ -20,14 +20,11 @@ PROGS = \
|
||||
clearspd \
|
||||
cubemap \
|
||||
drawpix \
|
||||
copypix \
|
||||
drawpix_pbo \
|
||||
fire \
|
||||
fogcoord \
|
||||
fplight \
|
||||
gamma \
|
||||
gears \
|
||||
gearbox \
|
||||
geartrain \
|
||||
glinfo \
|
||||
gloss \
|
||||
@@ -40,13 +37,13 @@ PROGS = \
|
||||
multiarb \
|
||||
occlude \
|
||||
paltex \
|
||||
pixeltex \
|
||||
pointblast \
|
||||
ray \
|
||||
readpix \
|
||||
reflect \
|
||||
renormal \
|
||||
shadowtex \
|
||||
singlebuffer \
|
||||
spectex \
|
||||
spriteblast \
|
||||
stex3d \
|
||||
@@ -54,7 +51,7 @@ PROGS = \
|
||||
terrain \
|
||||
tessdemo \
|
||||
texcyl \
|
||||
texdown-pool \
|
||||
texdown \
|
||||
texenv \
|
||||
texobj \
|
||||
trispd \
|
||||
|
@@ -1,364 +0,0 @@
|
||||
|
||||
/*
|
||||
* glDrawPixels demo/test/benchmark
|
||||
*
|
||||
* Brian Paul September 25, 1997 This file is in the public domain.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "readtex.h"
|
||||
|
||||
#define IMAGE_FILE "../images/girl.rgb"
|
||||
|
||||
static int ImgWidth, ImgHeight;
|
||||
static GLenum ImgFormat;
|
||||
static GLubyte *Image = NULL;
|
||||
|
||||
static int Xpos, Ypos;
|
||||
static int SkipPixels, SkipRows;
|
||||
static int DrawWidth, DrawHeight;
|
||||
static int Scissor = 0;
|
||||
static int Fog = 0;
|
||||
static GLfloat Zpos = -1.0;
|
||||
static float Xzoom, Yzoom;
|
||||
static GLboolean DrawFront = GL_FALSE;
|
||||
static GLboolean Dither = GL_TRUE;
|
||||
|
||||
|
||||
static void Reset( void )
|
||||
{
|
||||
Xpos = Ypos = 20;
|
||||
DrawWidth = ImgWidth;
|
||||
DrawHeight = ImgHeight;
|
||||
SkipPixels = SkipRows = 0;
|
||||
Scissor = 0;
|
||||
Fog = 0;
|
||||
Zpos = -1.0;
|
||||
Xzoom = Yzoom = 1.0;
|
||||
}
|
||||
|
||||
|
||||
static void Display( void )
|
||||
{
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
glRasterPos2i(10, 10);
|
||||
glPixelZoom( 1, 1 );
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_FOG);
|
||||
glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);
|
||||
|
||||
#if 0
|
||||
glRasterPos2i(Xpos, Ypos);
|
||||
#else
|
||||
/* This allows negative raster positions: */
|
||||
glRasterPos3f(0, 0, Zpos);
|
||||
glBitmap(0, 0, 0, 0, Xpos, Ypos, NULL);
|
||||
#endif
|
||||
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows);
|
||||
|
||||
glPixelZoom( Xzoom, Yzoom );
|
||||
|
||||
if (Scissor)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
if (Fog)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
glCopyPixels(10, 10, ImgWidth, ImgHeight, GL_COLOR);
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_FOG);
|
||||
|
||||
if (DrawFront)
|
||||
glFinish();
|
||||
else
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void Benchmark( void )
|
||||
{
|
||||
int startTime, endTime;
|
||||
int draws = 500;
|
||||
double seconds, pixelsPerSecond;
|
||||
|
||||
printf("Benchmarking...\n");
|
||||
/* GL set-up */
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows);
|
||||
glPixelZoom( Xzoom, Yzoom );
|
||||
if (Scissor)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
if (Fog)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
if (DrawFront)
|
||||
glDrawBuffer(GL_FRONT);
|
||||
else
|
||||
glDrawBuffer(GL_BACK);
|
||||
|
||||
/* Run timing test */
|
||||
draws = 0;
|
||||
startTime = glutGet(GLUT_ELAPSED_TIME);
|
||||
do {
|
||||
glCopyPixels(10, 10, ImgWidth, ImgHeight, GL_COLOR);
|
||||
draws++;
|
||||
endTime = glutGet(GLUT_ELAPSED_TIME);
|
||||
} while (endTime - startTime < 4000); /* 4 seconds */
|
||||
|
||||
/* GL clean-up */
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_FOG);
|
||||
|
||||
/* Results */
|
||||
seconds = (double) (endTime - startTime) / 1000.0;
|
||||
pixelsPerSecond = draws * DrawWidth * DrawHeight / seconds;
|
||||
printf("Result: %d draws in %f seconds = %f pixels/sec\n",
|
||||
draws, seconds, pixelsPerSecond);
|
||||
}
|
||||
|
||||
|
||||
static void Reshape( int width, int height )
|
||||
{
|
||||
glViewport( 0, 0, width, height );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glOrtho( 0.0, width, 0.0, height, 0.0, 2.0 );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
|
||||
glScissor(width/4, height/4, width/2, height/2);
|
||||
}
|
||||
|
||||
|
||||
static void Key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case ' ':
|
||||
Reset();
|
||||
break;
|
||||
case 'd':
|
||||
Dither = !Dither;
|
||||
if (Dither)
|
||||
glEnable(GL_DITHER);
|
||||
else
|
||||
glDisable(GL_DITHER);
|
||||
break;
|
||||
case 'w':
|
||||
if (DrawWidth > 0)
|
||||
DrawWidth--;
|
||||
break;
|
||||
case 'W':
|
||||
DrawWidth++;
|
||||
break;
|
||||
case 'h':
|
||||
if (DrawHeight > 0)
|
||||
DrawHeight--;
|
||||
break;
|
||||
case 'H':
|
||||
DrawHeight++;
|
||||
break;
|
||||
case 'p':
|
||||
if (SkipPixels > 0)
|
||||
SkipPixels--;
|
||||
break;
|
||||
case 'P':
|
||||
SkipPixels++;
|
||||
break;
|
||||
case 'r':
|
||||
if (SkipRows > 0)
|
||||
SkipRows--;
|
||||
break;
|
||||
case 'R':
|
||||
SkipRows++;
|
||||
break;
|
||||
case 's':
|
||||
Scissor = !Scissor;
|
||||
break;
|
||||
case 'x':
|
||||
Xzoom -= 0.1;
|
||||
break;
|
||||
case 'X':
|
||||
Xzoom += 0.1;
|
||||
break;
|
||||
case 'y':
|
||||
Yzoom -= 0.1;
|
||||
break;
|
||||
case 'Y':
|
||||
Yzoom += 0.1;
|
||||
break;
|
||||
case 'z':
|
||||
Zpos -= 0.1;
|
||||
printf("RasterPos Z = %g\n", Zpos);
|
||||
break;
|
||||
case 'Z':
|
||||
Zpos += 0.1;
|
||||
printf("RasterPos Z = %g\n", Zpos);
|
||||
break;
|
||||
case 'b':
|
||||
Benchmark();
|
||||
break;
|
||||
case 'F':
|
||||
Fog = !Fog;
|
||||
printf("Fog %d\n", Fog);
|
||||
break;
|
||||
case 'f':
|
||||
DrawFront = !DrawFront;
|
||||
if (DrawFront)
|
||||
glDrawBuffer(GL_FRONT);
|
||||
else
|
||||
glDrawBuffer(GL_BACK);
|
||||
printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK");
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void SpecialKey( int key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP:
|
||||
Ypos += 1;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
Ypos -= 1;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
Xpos -= 1;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
Xpos += 1;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void Init( GLboolean ciMode, const char *filename )
|
||||
{
|
||||
static const GLfloat fogColor[4] = {0, 1, 0, 0};
|
||||
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
Image = LoadRGBImage( filename, &ImgWidth, &ImgHeight, &ImgFormat );
|
||||
if (!Image) {
|
||||
printf("Couldn't read %s\n", filename);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (ciMode) {
|
||||
/* Convert RGB image to grayscale */
|
||||
GLubyte *indexImage = (GLubyte *) malloc( ImgWidth * ImgHeight );
|
||||
GLint i;
|
||||
for (i=0; i<ImgWidth*ImgHeight; i++) {
|
||||
int gray = Image[i*3] + Image[i*3+1] + Image[i*3+2];
|
||||
indexImage[i] = gray / 3;
|
||||
}
|
||||
free(Image);
|
||||
Image = indexImage;
|
||||
ImgFormat = GL_COLOR_INDEX;
|
||||
|
||||
for (i=0;i<255;i++) {
|
||||
float g = i / 255.0;
|
||||
glutSetColor(i, g, g, g);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Loaded %d by %d image\n", ImgWidth, ImgHeight );
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, ImgWidth);
|
||||
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||
glFogf(GL_FOG_START, 0);
|
||||
glFogf(GL_FOG_END, 2);
|
||||
glFogfv(GL_FOG_COLOR, fogColor);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
static void Usage(void)
|
||||
{
|
||||
printf("Keys:\n");
|
||||
printf(" SPACE Reset Parameters\n");
|
||||
printf(" Up/Down Move image up/down\n");
|
||||
printf(" Left/Right Move image left/right\n");
|
||||
printf(" x Decrease X-axis PixelZoom\n");
|
||||
printf(" X Increase X-axis PixelZoom\n");
|
||||
printf(" y Decrease Y-axis PixelZoom\n");
|
||||
printf(" Y Increase Y-axis PixelZoom\n");
|
||||
printf(" w Decrease glDrawPixels width*\n");
|
||||
printf(" W Increase glDrawPixels width*\n");
|
||||
printf(" h Decrease glDrawPixels height*\n");
|
||||
printf(" H Increase glDrawPixels height*\n");
|
||||
printf(" p Decrease GL_UNPACK_SKIP_PIXELS*\n");
|
||||
printf(" P Increase GL_UNPACK_SKIP_PIXELS*\n");
|
||||
printf(" r Decrease GL_UNPACK_SKIP_ROWS*\n");
|
||||
printf(" R Increase GL_UNPACK_SKIP_ROWS*\n");
|
||||
printf(" s Toggle GL_SCISSOR_TEST\n");
|
||||
printf(" F Toggle GL_FOG\n");
|
||||
printf(" z Decrease RasterPos Z\n");
|
||||
printf(" Z Increase RasterPos Z\n");
|
||||
|
||||
printf(" f Toggle front/back buffer drawing\n");
|
||||
printf(" b Benchmark test\n");
|
||||
printf(" ESC Exit\n");
|
||||
printf("* Warning: no limits are imposed on these parameters so it's\n");
|
||||
printf(" possible to cause a segfault if you go too far.\n");
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
GLboolean ciMode = GL_FALSE;
|
||||
const char *filename = IMAGE_FILE;
|
||||
int i = 1;
|
||||
|
||||
if (argc > i && strcmp(argv[i], "-ci")==0) {
|
||||
ciMode = GL_TRUE;
|
||||
i++;
|
||||
}
|
||||
if (argc > i) {
|
||||
filename = argv[i];
|
||||
}
|
||||
|
||||
glutInit( &argc, argv );
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitWindowSize( 500, 400 );
|
||||
|
||||
if (ciMode)
|
||||
glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
|
||||
else
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);
|
||||
|
||||
glutCreateWindow(argv[0]);
|
||||
|
||||
Init(ciMode, filename);
|
||||
Usage();
|
||||
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutSpecialFunc( SpecialKey );
|
||||
glutDisplayFunc( Display );
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -10,7 +10,7 @@
|
||||
##### MACROS #####
|
||||
|
||||
INCDIR = ([--.include],[-.util])
|
||||
CFLAGS =/include=$(INCDIR)/prefix=all/name=(as_is,short)/float=ieee/ieee=denorm
|
||||
CFLAGS = /include=$(INCDIR)/prefix=all/name=(as_is,short)
|
||||
|
||||
.ifdef SHARE
|
||||
GL_LIBS = $(XLIBS)
|
||||
|
@@ -1,376 +0,0 @@
|
||||
|
||||
/*
|
||||
* glDrawPixels demo/test/benchmark
|
||||
*
|
||||
* Brian Paul September 25, 1997 This file is in the public domain.
|
||||
*/
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "readtex.h"
|
||||
|
||||
#define IMAGE_FILE "../images/tree2.rgba"
|
||||
|
||||
static int ImgWidth, ImgHeight;
|
||||
static GLenum ImgFormat;
|
||||
static GLenum ImgType = GL_UNSIGNED_BYTE;
|
||||
static GLubyte *Image = NULL;
|
||||
|
||||
static int Xpos, Ypos;
|
||||
static int SkipPixels, SkipRows;
|
||||
static int DrawWidth, DrawHeight;
|
||||
static int Scissor = 0;
|
||||
static int Fog = 0;
|
||||
static GLfloat Zpos = -1.0;
|
||||
static float Xzoom, Yzoom;
|
||||
static GLboolean DrawFront = GL_FALSE;
|
||||
static GLboolean Dither = GL_TRUE;
|
||||
|
||||
|
||||
static GLuint DrawPBO;
|
||||
|
||||
|
||||
static void Reset( void )
|
||||
{
|
||||
Xpos = Ypos = 20;
|
||||
DrawWidth = ImgWidth;
|
||||
DrawHeight = ImgHeight;
|
||||
SkipPixels = SkipRows = 0;
|
||||
Scissor = 0;
|
||||
Fog = 0;
|
||||
Zpos = -1.0;
|
||||
Xzoom = Yzoom = 1.0;
|
||||
}
|
||||
|
||||
|
||||
static void Display( void )
|
||||
{
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
#if 0
|
||||
glRasterPos2i(Xpos, Ypos);
|
||||
#else
|
||||
/* This allows negative raster positions: */
|
||||
glRasterPos3f(0, 0, Zpos);
|
||||
glBitmap(0, 0, 0, 0, Xpos, Ypos, NULL);
|
||||
#endif
|
||||
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows);
|
||||
|
||||
glPixelZoom( Xzoom, Yzoom );
|
||||
|
||||
if (Scissor)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
if (Fog)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
/*** Draw from the DrawPBO */
|
||||
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
|
||||
glDrawPixels(DrawWidth, DrawHeight, ImgFormat, ImgType, NULL);
|
||||
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_FOG);
|
||||
|
||||
if (DrawFront)
|
||||
glFinish();
|
||||
else
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void Benchmark( void )
|
||||
{
|
||||
int startTime, endTime;
|
||||
int draws = 500;
|
||||
double seconds, pixelsPerSecond;
|
||||
|
||||
printf("Benchmarking...\n");
|
||||
/* GL set-up */
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, SkipPixels);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, SkipRows);
|
||||
glPixelZoom( Xzoom, Yzoom );
|
||||
if (Scissor)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
if (Fog)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
if (DrawFront)
|
||||
glDrawBuffer(GL_FRONT);
|
||||
else
|
||||
glDrawBuffer(GL_BACK);
|
||||
|
||||
/* Run timing test */
|
||||
draws = 0;
|
||||
startTime = glutGet(GLUT_ELAPSED_TIME);
|
||||
do {
|
||||
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
|
||||
glDrawPixels(DrawWidth, DrawHeight, ImgFormat, ImgType, NULL);
|
||||
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
|
||||
draws++;
|
||||
endTime = glutGet(GLUT_ELAPSED_TIME);
|
||||
} while (endTime - startTime < 4000); /* 4 seconds */
|
||||
|
||||
/* GL clean-up */
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_FOG);
|
||||
|
||||
/* Results */
|
||||
seconds = (double) (endTime - startTime) / 1000.0;
|
||||
pixelsPerSecond = draws * DrawWidth * DrawHeight / seconds;
|
||||
printf("Result: %d draws in %f seconds = %f pixels/sec\n",
|
||||
draws, seconds, pixelsPerSecond);
|
||||
}
|
||||
|
||||
|
||||
static void Reshape( int width, int height )
|
||||
{
|
||||
glViewport( 0, 0, width, height );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glOrtho( 0.0, width, 0.0, height, 0.0, 2.0 );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
|
||||
glScissor(width/4, height/4, width/2, height/2);
|
||||
}
|
||||
|
||||
|
||||
static void Key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case ' ':
|
||||
Reset();
|
||||
break;
|
||||
case 'd':
|
||||
Dither = !Dither;
|
||||
if (Dither)
|
||||
glEnable(GL_DITHER);
|
||||
else
|
||||
glDisable(GL_DITHER);
|
||||
break;
|
||||
case 'w':
|
||||
if (DrawWidth > 0)
|
||||
DrawWidth--;
|
||||
break;
|
||||
case 'W':
|
||||
DrawWidth++;
|
||||
break;
|
||||
case 'h':
|
||||
if (DrawHeight > 0)
|
||||
DrawHeight--;
|
||||
break;
|
||||
case 'H':
|
||||
DrawHeight++;
|
||||
break;
|
||||
case 'p':
|
||||
if (SkipPixels > 0)
|
||||
SkipPixels--;
|
||||
break;
|
||||
case 'P':
|
||||
SkipPixels++;
|
||||
break;
|
||||
case 'r':
|
||||
if (SkipRows > 0)
|
||||
SkipRows--;
|
||||
break;
|
||||
case 'R':
|
||||
SkipRows++;
|
||||
break;
|
||||
case 's':
|
||||
Scissor = !Scissor;
|
||||
break;
|
||||
case 'x':
|
||||
Xzoom -= 0.1;
|
||||
break;
|
||||
case 'X':
|
||||
Xzoom += 0.1;
|
||||
break;
|
||||
case 'y':
|
||||
Yzoom -= 0.1;
|
||||
break;
|
||||
case 'Y':
|
||||
Yzoom += 0.1;
|
||||
break;
|
||||
case 'z':
|
||||
Zpos -= 0.1;
|
||||
printf("RasterPos Z = %g\n", Zpos);
|
||||
break;
|
||||
case 'Z':
|
||||
Zpos += 0.1;
|
||||
printf("RasterPos Z = %g\n", Zpos);
|
||||
break;
|
||||
case 'b':
|
||||
Benchmark();
|
||||
break;
|
||||
case 'F':
|
||||
Fog = !Fog;
|
||||
printf("Fog %d\n", Fog);
|
||||
break;
|
||||
case 'f':
|
||||
DrawFront = !DrawFront;
|
||||
if (DrawFront)
|
||||
glDrawBuffer(GL_FRONT);
|
||||
else
|
||||
glDrawBuffer(GL_BACK);
|
||||
printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK");
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void SpecialKey( int key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP:
|
||||
Ypos += 1;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
Ypos -= 1;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
Xpos -= 1;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
Xpos += 1;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void Init( GLboolean ciMode, const char *filename )
|
||||
{
|
||||
static const GLfloat fogColor[4] = {0, 1, 0, 0};
|
||||
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
Image = LoadRGBImage( filename, &ImgWidth, &ImgHeight, &ImgFormat );
|
||||
if (!Image) {
|
||||
printf("Couldn't read %s\n", filename);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (ciMode) {
|
||||
/* Convert RGB image to grayscale */
|
||||
GLubyte *indexImage = (GLubyte *) malloc( ImgWidth * ImgHeight );
|
||||
GLint i;
|
||||
for (i=0; i<ImgWidth*ImgHeight; i++) {
|
||||
int gray = Image[i*3] + Image[i*3+1] + Image[i*3+2];
|
||||
indexImage[i] = gray / 3;
|
||||
}
|
||||
free(Image);
|
||||
Image = indexImage;
|
||||
ImgFormat = GL_COLOR_INDEX;
|
||||
|
||||
for (i=0;i<255;i++) {
|
||||
float g = i / 255.0;
|
||||
glutSetColor(i, g, g, g);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Loaded %d by %d image\n", ImgWidth, ImgHeight );
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, ImgWidth);
|
||||
|
||||
|
||||
/* put image into DrawPBO */
|
||||
glGenBuffersARB(1, &DrawPBO);
|
||||
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, DrawPBO);
|
||||
glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT,
|
||||
ImgWidth * ImgHeight * 4, Image, GL_STATIC_DRAW);
|
||||
|
||||
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||
glFogf(GL_FOG_START, 0);
|
||||
glFogf(GL_FOG_END, 2);
|
||||
glFogfv(GL_FOG_COLOR, fogColor);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
static void Usage(void)
|
||||
{
|
||||
printf("Keys:\n");
|
||||
printf(" SPACE Reset Parameters\n");
|
||||
printf(" Up/Down Move image up/down\n");
|
||||
printf(" Left/Right Move image left/right\n");
|
||||
printf(" x Decrease X-axis PixelZoom\n");
|
||||
printf(" X Increase X-axis PixelZoom\n");
|
||||
printf(" y Decrease Y-axis PixelZoom\n");
|
||||
printf(" Y Increase Y-axis PixelZoom\n");
|
||||
printf(" w Decrease glDrawPixels width*\n");
|
||||
printf(" W Increase glDrawPixels width*\n");
|
||||
printf(" h Decrease glDrawPixels height*\n");
|
||||
printf(" H Increase glDrawPixels height*\n");
|
||||
printf(" p Decrease GL_UNPACK_SKIP_PIXELS*\n");
|
||||
printf(" P Increase GL_UNPACK_SKIP_PIXELS*\n");
|
||||
printf(" r Decrease GL_UNPACK_SKIP_ROWS*\n");
|
||||
printf(" R Increase GL_UNPACK_SKIP_ROWS*\n");
|
||||
printf(" s Toggle GL_SCISSOR_TEST\n");
|
||||
printf(" F Toggle GL_FOG\n");
|
||||
printf(" z Decrease RasterPos Z\n");
|
||||
printf(" Z Increase RasterPos Z\n");
|
||||
|
||||
printf(" f Toggle front/back buffer drawing\n");
|
||||
printf(" b Benchmark test\n");
|
||||
printf(" ESC Exit\n");
|
||||
printf("* Warning: no limits are imposed on these parameters so it's\n");
|
||||
printf(" possible to cause a segfault if you go too far.\n");
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
GLboolean ciMode = GL_FALSE;
|
||||
const char *filename = IMAGE_FILE;
|
||||
int i = 1;
|
||||
|
||||
if (argc > i && strcmp(argv[i], "-ci")==0) {
|
||||
ciMode = GL_TRUE;
|
||||
i++;
|
||||
}
|
||||
if (argc > i) {
|
||||
filename = argv[i];
|
||||
}
|
||||
|
||||
glutInit( &argc, argv );
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitWindowSize( 500, 400 );
|
||||
|
||||
if (ciMode)
|
||||
glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
|
||||
else
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);
|
||||
|
||||
glutCreateWindow(argv[0]);
|
||||
|
||||
Init(ciMode, filename);
|
||||
Usage();
|
||||
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutSpecialFunc( SpecialKey );
|
||||
glutDisplayFunc( Display );
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,486 +0,0 @@
|
||||
/*
|
||||
* Use glCopyTexSubImage2D to draw animated gears on the sides of a box.
|
||||
*
|
||||
* Brian Paul
|
||||
* 27 January 2006
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265
|
||||
#endif
|
||||
|
||||
static GLint WinWidth = 800, WinHeight = 500;
|
||||
static GLint TexWidth, TexHeight;
|
||||
static GLuint TexObj = 1;
|
||||
static GLenum IntFormat = GL_RGBA;
|
||||
|
||||
static GLboolean WireFrame = GL_FALSE;
|
||||
|
||||
static GLint T0 = 0;
|
||||
static GLint Frames = 0;
|
||||
static GLint Win = 0;
|
||||
|
||||
static GLfloat ViewRotX = 20.0, ViewRotY = 30.0, ViewRotZ = 0.0;
|
||||
static GLint Gear1, Gear2, Gear3;
|
||||
static GLfloat GearRot = 0.0;
|
||||
static GLfloat CubeRot = 0.0;
|
||||
|
||||
|
||||
/**
|
||||
Draw a gear wheel. You'll probably want to call this function when
|
||||
building a display list since we do a lot of trig here.
|
||||
|
||||
Input: inner_radius - radius of hole at center
|
||||
outer_radius - radius at center of teeth
|
||||
width - width of gear
|
||||
teeth - number of teeth
|
||||
tooth_depth - depth of tooth
|
||||
**/
|
||||
static void
|
||||
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
|
||||
GLint teeth, GLfloat tooth_depth)
|
||||
{
|
||||
GLint i;
|
||||
GLfloat r0, r1, r2;
|
||||
GLfloat angle, da;
|
||||
GLfloat u, v, len;
|
||||
|
||||
r0 = inner_radius;
|
||||
r1 = outer_radius - tooth_depth / 2.0;
|
||||
r2 = outer_radius + tooth_depth / 2.0;
|
||||
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
|
||||
/* draw front face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw front sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glNormal3f(0.0, 0.0, -1.0);
|
||||
|
||||
/* draw back face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw outward faces of teeth */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
u = r2 * cos(angle + da) - r1 * cos(angle);
|
||||
v = r2 * sin(angle + da) - r1 * sin(angle);
|
||||
len = sqrt(u * u + v * v);
|
||||
u /= len;
|
||||
v /= len;
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
|
||||
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
|
||||
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
}
|
||||
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
|
||||
|
||||
glEnd();
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/* draw inside radius cylinder */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glNormal3f(-cos(angle), -sin(angle), 0.0);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
glDeleteTextures(1, &TexObj);
|
||||
glDeleteLists(Gear1, 1);
|
||||
glDeleteLists(Gear2, 1);
|
||||
glDeleteLists(Gear3, 1);
|
||||
glutDestroyWindow(Win);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawGears(void)
|
||||
{
|
||||
if (WireFrame) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(20/*ViewRotX*/, 1.0, 0.0, 0.0);
|
||||
glRotatef(ViewRotY, 0.0, 1.0, 0.0);
|
||||
glRotatef(ViewRotZ, 0.0, 0.0, 1.0);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.0, -2.0, 0.0);
|
||||
glRotatef(GearRot, 0.0, 0.0, 1.0);
|
||||
glCallList(Gear1);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(3.1, -2.0, 0.0);
|
||||
glRotatef(-2.0 * GearRot - 9.0, 0.0, 0.0, 1.0);
|
||||
glCallList(Gear2);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.1, 4.2, 0.0);
|
||||
glRotatef(-2.0 * GearRot - 25.0, 0.0, 0.0, 1.0);
|
||||
glCallList(Gear3);
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawCube(void)
|
||||
{
|
||||
static const GLfloat texcoords[4][2] = {
|
||||
{ 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 }
|
||||
};
|
||||
static const GLfloat vertices[4][2] = {
|
||||
{ -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 }
|
||||
};
|
||||
static const GLfloat xforms[6][4] = {
|
||||
{ 0, 0, 1, 0 },
|
||||
{ 90, 0, 1, 0 },
|
||||
{ 180, 0, 1, 0 },
|
||||
{ 270, 0, 1, 0 },
|
||||
{ 90, 1, 0, 0 },
|
||||
{ -90, 1, 0, 0 }
|
||||
};
|
||||
static const GLfloat mat[4] = { 1.0, 1.0, 0.5, 1.0 };
|
||||
GLint i, j;
|
||||
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(ViewRotX, 1.0, 0.0, 0.0);
|
||||
glRotatef(15, 1, 0, 0);
|
||||
glRotatef(CubeRot, 0, 1, 0);
|
||||
glScalef(4, 4, 4);
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
glPushMatrix();
|
||||
glRotatef(xforms[i][0], xforms[i][1], xforms[i][2], xforms[i][3]);
|
||||
glTranslatef(0, 0, 1.1);
|
||||
glBegin(GL_POLYGON);
|
||||
glNormal3f(0, 0, 1);
|
||||
for (j = 0; j < 4; j++) {
|
||||
glTexCoord2fv(texcoords[j]);
|
||||
glVertex2fv(vertices[j]);
|
||||
}
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
float ar;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -40.0);
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
/* draw gears */
|
||||
glViewport(0, 0, TexWidth, TexHeight);
|
||||
glScissor(0, 0, TexWidth, TexHeight);
|
||||
glClearColor(0.5, 0.5, 0.8, 0.0);
|
||||
glClearColor(1, 1, 1, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 60.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
DrawGears();
|
||||
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, TexWidth, TexHeight);
|
||||
|
||||
/* draw textured cube */
|
||||
glViewport(TexWidth, 0, WinWidth - TexWidth, WinHeight);
|
||||
glScissor(TexWidth, 0, WinWidth - TexWidth, WinHeight);
|
||||
glClearColor(0.5, 0.5, 0.8, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
ar = (float) (WinWidth - TexWidth) / WinHeight;
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-ar, ar, -1.0, 1.0, 5.0, 60.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
DrawCube();
|
||||
|
||||
/* finish up */
|
||||
glutSwapBuffers();
|
||||
|
||||
Frames++;
|
||||
{
|
||||
GLint t = glutGet(GLUT_ELAPSED_TIME);
|
||||
if (t - T0 >= 5000) {
|
||||
GLfloat seconds = (t - T0) / 1000.0;
|
||||
GLfloat fps = Frames / seconds;
|
||||
printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
|
||||
T0 = t;
|
||||
Frames = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
idle(void)
|
||||
{
|
||||
static double t0 = -1.;
|
||||
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||
if (t0 < 0.0)
|
||||
t0 = t;
|
||||
dt = t - t0;
|
||||
t0 = t;
|
||||
|
||||
GearRot += 70.0 * dt; /* 70 degrees per second */
|
||||
GearRot = fmod(GearRot, 360.0); /* prevents eventual overflow */
|
||||
|
||||
CubeRot += 15.0 * dt;
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
/* change view angle, exit upon ESC */
|
||||
static void
|
||||
key(unsigned char k, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (k) {
|
||||
case 'w':
|
||||
WireFrame = !WireFrame;
|
||||
break;
|
||||
case 'z':
|
||||
ViewRotZ += 5.0;
|
||||
break;
|
||||
case 'Z':
|
||||
ViewRotZ -= 5.0;
|
||||
break;
|
||||
case 27: /* Escape */
|
||||
cleanup();
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
/* change view angle */
|
||||
static void
|
||||
special(int k, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (k) {
|
||||
case GLUT_KEY_UP:
|
||||
ViewRotX += 5.0;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
ViewRotX -= 5.0;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
ViewRotY += 5.0;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
ViewRotY -= 5.0;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
WinWidth = width;
|
||||
WinHeight = height;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(int argc, char *argv[])
|
||||
{
|
||||
static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0};
|
||||
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
|
||||
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
|
||||
static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
|
||||
GLint i;
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
#if 0
|
||||
glEnable(GL_CULL_FACE);
|
||||
#endif
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
/* make the gears */
|
||||
Gear1 = glGenLists(1);
|
||||
glNewList(Gear1, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
gear(1.0, 4.0, 1.0, 20, 0.7);
|
||||
glEndList();
|
||||
|
||||
Gear2 = glGenLists(1);
|
||||
glNewList(Gear2, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
gear(0.5, 2.0, 2.0, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
Gear3 = glGenLists(1);
|
||||
glNewList(Gear3, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
gear(1.3, 2.0, 0.5, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
glEnable(GL_NORMALIZE);
|
||||
|
||||
/* xxx make size dynamic */
|
||||
TexWidth = 256;
|
||||
TexHeight = 256;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, TexObj);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, IntFormat, TexWidth, TexHeight, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
for ( i=1; i<argc; i++ ) {
|
||||
if (strcmp(argv[i], "-info")==0) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
visible(int vis)
|
||||
{
|
||||
if (vis == GLUT_VISIBLE)
|
||||
glutIdleFunc(idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
Win = glutCreateWindow("gearbox");
|
||||
init(argc, argv);
|
||||
|
||||
glutDisplayFunc(draw);
|
||||
glutReshapeFunc(reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutSpecialFunc(special);
|
||||
glutVisibilityFunc(visible);
|
||||
|
||||
glutMainLoop();
|
||||
return 0; /* ANSI C requires main to return int. */
|
||||
}
|
@@ -176,7 +176,6 @@ So the angle is:
|
||||
|
||||
static int mono=0;
|
||||
static int smooth=1;
|
||||
static int anim=1;
|
||||
static GLint WindH, WindW;
|
||||
static GLfloat step=0;
|
||||
static GLfloat seno;
|
||||
@@ -661,6 +660,13 @@ static void draw_ico( void )
|
||||
}
|
||||
|
||||
static void draw ( void ) {
|
||||
static double t0 = -1.;
|
||||
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||
if (t0 < 0.0)
|
||||
t0 = t;
|
||||
dt = t - t0;
|
||||
t0 = t;
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
glPushMatrix();
|
||||
@@ -682,19 +688,11 @@ static void draw ( void ) {
|
||||
|
||||
glutSwapBuffers();
|
||||
|
||||
step += dt;
|
||||
}
|
||||
|
||||
static void idle_( void )
|
||||
{
|
||||
static double t0 = -1.;
|
||||
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||
if (t0 < 0.0)
|
||||
t0 = t;
|
||||
dt = t - t0;
|
||||
t0 = t;
|
||||
|
||||
step += dt;
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
@@ -720,19 +718,11 @@ static void key( unsigned char k, int x, int y )
|
||||
case '4': object=4; break;
|
||||
case '5': object=5; break;
|
||||
case ' ': mono^=1; break;
|
||||
case 's': smooth^=1; break;
|
||||
case 'a':
|
||||
anim^=1;
|
||||
if (anim)
|
||||
glutIdleFunc( idle_ );
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
break;
|
||||
case 13: smooth^=1; break;
|
||||
case 27:
|
||||
exit(0);
|
||||
}
|
||||
pinit();
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void pinit(void)
|
||||
|
210
progs/demos/pixeltex.c
Normal file
210
progs/demos/pixeltex.c
Normal file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* GL_SGIS_pixel_texture demo
|
||||
*
|
||||
* Brian Paul
|
||||
* 6 Apr 2000
|
||||
*
|
||||
* Copyright (C) 2000 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* How this works:
|
||||
* 1. We load the image into a 2D texture.
|
||||
* 2. We generate a sequence of RGB images in which the R component
|
||||
* is really the S texture coordinate and the G component is really
|
||||
* the T texture coordinate.
|
||||
* By warping the mapping from R to S and G to T we can get non-linear
|
||||
* distortions.
|
||||
* 3. Draw the warped image (a 2-D warping function) with pixel texgen
|
||||
* enabled.
|
||||
* 4. Loop over the warped images to animate.
|
||||
*
|
||||
* The pixel texgen extension can also be used to do color-space
|
||||
* conversions. For example, we could convert YCR to RGB with a
|
||||
* 3D texture map which takes YCR as the S,T,R texture coordinate and
|
||||
* returns RGB texel values.
|
||||
*
|
||||
* You can use this extension in (at least) two ways:
|
||||
* 1. glDrawPixels w/ color space conversion/warping
|
||||
* 2. glDrawPixels to spatially warp another image in texture memory
|
||||
*
|
||||
* We're basically using glDrawPixels to draw a texture coordinate image.
|
||||
*/
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "readtex.h"
|
||||
|
||||
#define TEXTURE_FILE "../images/girl.rgb"
|
||||
|
||||
static int ImgWidth = 300, ImgHeight = 300;
|
||||
#define FRAMES 20
|
||||
static GLubyte *ImgData[FRAMES];
|
||||
static GLint Frame = 0;
|
||||
|
||||
static GLboolean TextureFlag = GL_TRUE;
|
||||
|
||||
|
||||
static void Display( void )
|
||||
{
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
if (TextureFlag) {
|
||||
glEnable(GL_PIXEL_TEXTURE_SGIS);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
else {
|
||||
glDisable(GL_PIXEL_TEXTURE_SGIS);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glColor3f(1, 1, 1);
|
||||
glRasterPos2f(10, 10);
|
||||
glDrawPixels(ImgWidth, ImgHeight, GL_RGB, GL_UNSIGNED_BYTE, ImgData[Frame]);
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void Reshape( int width, int height )
|
||||
{
|
||||
glViewport( 0, 0, width, height );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glOrtho(0, width, 0, height, -1, 1);
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
static void Key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case ' ':
|
||||
TextureFlag = !TextureFlag;
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void Idle(void)
|
||||
{
|
||||
Frame++;
|
||||
if (Frame >= FRAMES)
|
||||
Frame = 0;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static GLubyte warp(GLfloat s, int frame)
|
||||
{
|
||||
static const GLfloat pi = 3.14159265;
|
||||
static int halfFrame = FRAMES / 2;
|
||||
GLfloat y, weight, v;
|
||||
if (frame >= halfFrame)
|
||||
frame = halfFrame - (frame - halfFrame);
|
||||
y = sin(s * pi);
|
||||
weight = (float) frame / (FRAMES-1);
|
||||
v = y * (0.8 * weight + 0.2);
|
||||
return (GLint) (v * 255.0F);
|
||||
}
|
||||
|
||||
|
||||
static void InitImage(void)
|
||||
{
|
||||
int i, j, frame;
|
||||
for (frame = 0; frame < FRAMES; frame++) {
|
||||
ImgData[frame] = (GLubyte *) malloc(ImgWidth * ImgHeight * 3);
|
||||
for (i = 0; i < ImgHeight; i++) {
|
||||
for (j = 0; j < ImgWidth; j++) {
|
||||
GLubyte *pixel = ImgData[frame] + (i * ImgWidth + j) * 3;
|
||||
pixel[0] = warp((float) j / (ImgWidth - 0), frame);
|
||||
pixel[1] = warp((float) i / (ImgHeight - 0), frame);
|
||||
pixel[2] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void Init( int argc, char *argv[] )
|
||||
{
|
||||
const char *exten = (const char *) glGetString(GL_EXTENSIONS);
|
||||
if (!strstr(exten, "GL_SGIS_pixel_texture")) {
|
||||
printf("Sorry, GL_SGIS_pixel_texture not supported by this renderer.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* linear filtering looks nicer, but it's slower, since it's in software */
|
||||
#if 1
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
#else
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
#endif
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
|
||||
printf("Error: couldn't load texture image\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glClearColor(0.3, 0.3, 0.4, 1.0);
|
||||
|
||||
InitImage();
|
||||
|
||||
printf("Hit SPACE to toggle pixel texgen\n");
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
glutInit( &argc, argv );
|
||||
glutInitWindowSize( 330, 330 );
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
|
||||
glutCreateWindow(argv[0] );
|
||||
|
||||
Init( argc, argv );
|
||||
|
||||
glutKeyboardFunc( Key );
|
||||
glutReshapeFunc( Reshape );
|
||||
glutDisplayFunc( Display );
|
||||
glutIdleFunc( Idle );
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* Demo of a reflective, texture-mapped surface with OpenGL.
|
||||
* Brian Paul August 14, 1995 This file is in the public domain.
|
||||
@@ -23,11 +24,9 @@
|
||||
* Dirk Reiners (reiners@igd.fhg.de) made some modifications to this code.
|
||||
* Mark Kilgard (April 1997)
|
||||
* Brian Paul (April 2000 - added keyboard d/s options)
|
||||
* Brian Paul (August 2005 - added multi window feature)
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -37,102 +36,40 @@
|
||||
|
||||
|
||||
#define DEG2RAD (3.14159/180.0)
|
||||
|
||||
#define TABLE_TEXTURE "../images/tile.rgb"
|
||||
|
||||
static GLint ImgWidth, ImgHeight;
|
||||
static GLenum ImgFormat;
|
||||
static GLubyte *Image = NULL;
|
||||
|
||||
#define MAX_OBJECTS 2
|
||||
#define INIT_WIDTH 400
|
||||
#define INIT_HEIGHT 300
|
||||
static GLint table_list;
|
||||
static GLint objects_list[MAX_OBJECTS];
|
||||
|
||||
static GLfloat xrot, yrot;
|
||||
static GLfloat spin;
|
||||
|
||||
static GLint Width = 400, Height = 300;
|
||||
static GLenum ShowBuffer = GL_NONE;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
|
||||
/* performance info */
|
||||
static GLint T0 = 0;
|
||||
static GLint Frames = 0;
|
||||
|
||||
|
||||
struct window {
|
||||
int id; /* returned by glutCreateWindow() */
|
||||
int width, height;
|
||||
GLboolean anim;
|
||||
GLfloat xrot, yrot;
|
||||
GLfloat spin;
|
||||
GLenum showBuffer;
|
||||
GLenum drawBuffer;
|
||||
GLuint table_list;
|
||||
GLuint objects_list[MAX_OBJECTS];
|
||||
double t0;
|
||||
struct window *next;
|
||||
};
|
||||
|
||||
|
||||
static struct window *FirstWindow = NULL;
|
||||
|
||||
|
||||
static void
|
||||
CreateWindow(void);
|
||||
|
||||
|
||||
static struct window *
|
||||
CurrentWindow(void)
|
||||
{
|
||||
int id = glutGetWindow();
|
||||
struct window *w;
|
||||
for (w = FirstWindow; w; w = w->next) {
|
||||
if (w->id == id)
|
||||
return w;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
AnyAnimating(void)
|
||||
{
|
||||
struct window *w;
|
||||
for (w = FirstWindow; w; w = w->next) {
|
||||
if (w->anim)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
KillWindow(struct window *w)
|
||||
{
|
||||
struct window *win, *prev = NULL;
|
||||
for (win = FirstWindow; win; win = win->next) {
|
||||
if (win == w) {
|
||||
if (prev) {
|
||||
prev->next = win->next;
|
||||
}
|
||||
else {
|
||||
FirstWindow = win->next;
|
||||
}
|
||||
glutDestroyWindow(win->id);
|
||||
win->next = NULL;
|
||||
free(win);
|
||||
return;
|
||||
}
|
||||
prev = win;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
KillAllWindows(void)
|
||||
{
|
||||
while (FirstWindow)
|
||||
KillWindow(FirstWindow);
|
||||
}
|
||||
|
||||
|
||||
static GLuint
|
||||
MakeTable(void)
|
||||
static void make_table( void )
|
||||
{
|
||||
static GLfloat table_mat[] = { 1.0, 1.0, 1.0, 0.6 };
|
||||
static GLfloat gray[] = { 0.4, 0.4, 0.4, 1.0 };
|
||||
GLuint table_list;
|
||||
|
||||
table_list = glGenLists(1);
|
||||
glNewList( table_list, GL_COMPILE );
|
||||
|
||||
/* load table's texture */
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, table_mat );
|
||||
/*glMaterialfv( GL_FRONT, GL_EMISSION, gray );*/
|
||||
/* glMaterialfv( GL_FRONT, GL_EMISSION, gray );*/
|
||||
glMaterialfv( GL_FRONT, GL_DIFFUSE, table_mat );
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT, gray );
|
||||
|
||||
@@ -151,12 +88,10 @@ MakeTable(void)
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
|
||||
glEndList();
|
||||
return table_list;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
MakeObjects(GLuint *objects_list)
|
||||
static void make_objects( void )
|
||||
{
|
||||
GLUquadricObj *q;
|
||||
|
||||
@@ -181,36 +116,32 @@ MakeObjects(GLuint *objects_list)
|
||||
glMaterialfv( GL_FRONT, GL_EMISSION, black );
|
||||
gluCylinder( q, 1.5, 0.0, 2.5, 15, 1 );
|
||||
glEndList();
|
||||
|
||||
gluDeleteQuadric(q);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
InitWindow(struct window *w)
|
||||
static void init( void )
|
||||
{
|
||||
GLint imgWidth, imgHeight;
|
||||
GLenum imgFormat;
|
||||
GLubyte *image = NULL;
|
||||
make_table();
|
||||
make_objects();
|
||||
|
||||
w->table_list = MakeTable();
|
||||
MakeObjects(w->objects_list);
|
||||
|
||||
image = LoadRGBImage( TABLE_TEXTURE, &imgWidth, &imgHeight, &imgFormat );
|
||||
if (!image) {
|
||||
Image = LoadRGBImage( TABLE_TEXTURE, &ImgWidth, &ImgHeight, &ImgFormat );
|
||||
if (!Image) {
|
||||
printf("Couldn't read %s\n", TABLE_TEXTURE);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, imgWidth, imgHeight,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
free(image);
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, ImgWidth, ImgHeight,
|
||||
ImgFormat, GL_UNSIGNED_BYTE, Image);
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
|
||||
xrot = 30.0;
|
||||
yrot = 50.0;
|
||||
spin = 0.0;
|
||||
|
||||
glShadeModel( GL_FLAT );
|
||||
|
||||
glEnable( GL_LIGHT0 );
|
||||
@@ -222,15 +153,14 @@ InitWindow(struct window *w)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
|
||||
static void reshape(int w, int h)
|
||||
{
|
||||
struct window *w = CurrentWindow();
|
||||
GLfloat yAspect = 2.5;
|
||||
GLfloat xAspect = yAspect * (float) width / (float) height;
|
||||
w->width = width;
|
||||
w->height = height;
|
||||
glViewport(0, 0, width, height);
|
||||
GLfloat xAspect = yAspect * (float) w / (float) h;
|
||||
Width = w;
|
||||
Height = h;
|
||||
glViewport(0, 0, w, h);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum( -xAspect, xAspect, -yAspect, yAspect, 10.0, 30.0 );
|
||||
@@ -239,8 +169,8 @@ Reshape(int width, int height)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawObjects(struct window *w, GLfloat eyex, GLfloat eyey, GLfloat eyez)
|
||||
|
||||
static void draw_objects( GLfloat eyex, GLfloat eyey, GLfloat eyez )
|
||||
{
|
||||
(void) eyex;
|
||||
(void) eyey;
|
||||
@@ -248,65 +178,62 @@ DrawObjects(struct window *w, GLfloat eyex, GLfloat eyey, GLfloat eyez)
|
||||
#ifndef USE_ZBUFFER
|
||||
if (eyex<0.5) {
|
||||
#endif
|
||||
glPushMatrix();
|
||||
glTranslatef( 1.0, 1.5, 0.0 );
|
||||
glRotatef( w->spin, 1.0, 0.5, 0.0 );
|
||||
glRotatef( 0.5*w->spin, 0.0, 0.5, 1.0 );
|
||||
glCallList( w->objects_list[0] );
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*w->spin) ), 0.0 );
|
||||
glRotatef( 0.5*w->spin, 0.0, 0.5, 1.0 );
|
||||
glRotatef( w->spin, 1.0, 0.5, 0.0 );
|
||||
glScalef( 0.5, 0.5, 0.5 );
|
||||
glCallList( w->objects_list[1] );
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
glTranslatef( 1.0, 1.5, 0.0 );
|
||||
glRotatef( spin, 1.0, 0.5, 0.0 );
|
||||
glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
|
||||
glCallList( objects_list[0] );
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 );
|
||||
glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
|
||||
glRotatef( spin, 1.0, 0.5, 0.0 );
|
||||
glScalef( 0.5, 0.5, 0.5 );
|
||||
glCallList( objects_list[1] );
|
||||
glPopMatrix();
|
||||
#ifndef USE_ZBUFFER
|
||||
}
|
||||
else {
|
||||
glPushMatrix();
|
||||
glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*w->spin) ), 0.0 );
|
||||
glRotatef( 0.5*w->spin, 0.0, 0.5, 1.0 );
|
||||
glRotatef( w->spin, 1.0, 0.5, 0.0 );
|
||||
glScalef( 0.5, 0.5, 0.5 );
|
||||
glCallList( w->objects_list[1] );
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 );
|
||||
glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
|
||||
glRotatef( spin, 1.0, 0.5, 0.0 );
|
||||
glScalef( 0.5, 0.5, 0.5 );
|
||||
glCallList( objects_list[1] );
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef( 1.0, 1.5, 0.0 );
|
||||
glRotatef( w->spin, 1.0, 0.5, 0.0 );
|
||||
glRotatef( 0.5*w->spin, 0.0, 0.5, 1.0 );
|
||||
glCallList( w->objects_list[0] );
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
glTranslatef( 1.0, 1.5, 0.0 );
|
||||
glRotatef( spin, 1.0, 0.5, 0.0 );
|
||||
glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
|
||||
glCallList( objects_list[0] );
|
||||
glPopMatrix();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawTable(struct window *w)
|
||||
|
||||
static void draw_table( void )
|
||||
{
|
||||
glCallList(w->table_list);
|
||||
glCallList( table_list );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawWindow(void)
|
||||
|
||||
static void draw_scene( void )
|
||||
{
|
||||
struct window *w = CurrentWindow();
|
||||
static GLfloat light_pos[] = { 0.0, 20.0, 0.0, 1.0 };
|
||||
GLfloat dist = 20.0;
|
||||
GLfloat eyex, eyey, eyez;
|
||||
|
||||
glDrawBuffer(w->drawBuffer);
|
||||
glReadBuffer(w->drawBuffer);
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
eyex = dist * cos(w->yrot * DEG2RAD) * cos(w->xrot * DEG2RAD);
|
||||
eyez = dist * sin(w->yrot * DEG2RAD) * cos(w->xrot * DEG2RAD);
|
||||
eyey = dist * sin(w->xrot * DEG2RAD);
|
||||
|
||||
eyex = dist * cos(yrot*DEG2RAD) * cos(xrot*DEG2RAD);
|
||||
eyez = dist * sin(yrot*DEG2RAD) * cos(xrot*DEG2RAD);
|
||||
eyey = dist * sin(xrot*DEG2RAD);
|
||||
|
||||
/* view from top */
|
||||
glPushMatrix();
|
||||
@@ -320,7 +247,7 @@ DrawWindow(void)
|
||||
glStencilFunc( GL_ALWAYS, 1, 0xffffffff );
|
||||
glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE );
|
||||
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
|
||||
DrawTable(w);
|
||||
draw_table();
|
||||
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
|
||||
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
@@ -337,7 +264,7 @@ DrawWindow(void)
|
||||
/* Reposition light in reflected space. */
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
|
||||
|
||||
DrawObjects(w, eyex, eyey, eyez);
|
||||
draw_objects(eyex, eyey, eyez);
|
||||
glPopMatrix();
|
||||
|
||||
/* Restore light's original unreflected position. */
|
||||
@@ -350,224 +277,128 @@ DrawWindow(void)
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
DrawTable(w);
|
||||
draw_table();
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
glDisable( GL_BLEND );
|
||||
|
||||
/* view from top */
|
||||
glPushMatrix();
|
||||
|
||||
DrawObjects(w, eyex, eyey, eyez);
|
||||
draw_objects(eyex, eyey, eyez);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
if (w->showBuffer == GL_DEPTH) {
|
||||
ShowDepthBuffer(w->width, w->height, 1.0, 0.0);
|
||||
if (ShowBuffer == GL_DEPTH) {
|
||||
ShowDepthBuffer(Width, Height, 1.0, 0.0);
|
||||
}
|
||||
else if (w->showBuffer == GL_STENCIL) {
|
||||
ShowStencilBuffer(w->width, w->height, 255.0, 0.0);
|
||||
else if (ShowBuffer == GL_STENCIL) {
|
||||
ShowStencilBuffer(Width, Height, 255.0, 0.0);
|
||||
}
|
||||
else if (w->showBuffer == GL_ALPHA) {
|
||||
ShowAlphaBuffer(w->width, w->height);
|
||||
else if (ShowBuffer == GL_ALPHA) {
|
||||
ShowAlphaBuffer(Width, Height);
|
||||
}
|
||||
|
||||
if (w->drawBuffer == GL_BACK)
|
||||
glutSwapBuffers();
|
||||
else
|
||||
glFinish();
|
||||
glutSwapBuffers();
|
||||
|
||||
/* calc/show frame rate */
|
||||
{
|
||||
static GLint t0 = 0;
|
||||
static GLint frames = 0;
|
||||
GLint t = glutGet(GLUT_ELAPSED_TIME);
|
||||
frames++;
|
||||
if (t - t0 >= 5000) {
|
||||
GLfloat seconds = (t - t0) / 1000.0;
|
||||
GLfloat fps = frames / seconds;
|
||||
printf("%d frames in %g seconds = %g FPS\n", frames, seconds, fps);
|
||||
t0 = t;
|
||||
frames = 0;
|
||||
Frames++;
|
||||
if (t - T0 >= 5000) {
|
||||
GLfloat seconds = (t - T0) / 1000.0;
|
||||
GLfloat fps = Frames / seconds;
|
||||
printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps);
|
||||
T0 = t;
|
||||
Frames = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
static void idle( void )
|
||||
{
|
||||
double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||
struct window *w;
|
||||
for (w = FirstWindow; w; w = w->next) {
|
||||
if (w->anim) {
|
||||
double dt;
|
||||
if (w->t0 < 0.0)
|
||||
w->t0 = t;
|
||||
dt = t - w->t0;
|
||||
w->t0 = t;
|
||||
w->spin += 60.0 * dt;
|
||||
w->yrot += 90.0 * dt;
|
||||
assert(w->id);
|
||||
glutSetWindow(w->id);
|
||||
glutPostRedisplay();
|
||||
}
|
||||
}
|
||||
static double t0 = -1.;
|
||||
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||
if (t0 < 0.0)
|
||||
t0 = t;
|
||||
dt = t - t0;
|
||||
t0 = t;
|
||||
spin += 60.0 * dt;
|
||||
yrot += 90.0 * dt;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
UpdateIdleFunc(void)
|
||||
static void Key( unsigned char key, int x, int y )
|
||||
{
|
||||
if (AnyAnimating())
|
||||
glutIdleFunc(Idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
struct window *w = CurrentWindow();
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch (key) {
|
||||
case 'd':
|
||||
w->showBuffer = GL_DEPTH;
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case 's':
|
||||
w->showBuffer = GL_STENCIL;
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case 'a':
|
||||
w->showBuffer = GL_ALPHA;
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case 'c':
|
||||
w->showBuffer = GL_NONE;
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case 'f':
|
||||
if (w->drawBuffer == GL_FRONT)
|
||||
w->drawBuffer = GL_BACK;
|
||||
else
|
||||
w->drawBuffer = GL_FRONT;
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case ' ':
|
||||
w->anim = !w->anim;
|
||||
w->t0 = -1;
|
||||
UpdateIdleFunc();
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case 'n':
|
||||
CreateWindow();
|
||||
UpdateIdleFunc();
|
||||
break;
|
||||
case 'k':
|
||||
KillWindow(w);
|
||||
if (FirstWindow == NULL)
|
||||
exit(0);
|
||||
break;
|
||||
case 27:
|
||||
KillAllWindows();
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
if (key == 'd') {
|
||||
ShowBuffer = GL_DEPTH;
|
||||
}
|
||||
else if (key == 's') {
|
||||
ShowBuffer = GL_STENCIL;
|
||||
}
|
||||
else if (key == 'a') {
|
||||
ShowBuffer = GL_ALPHA;
|
||||
}
|
||||
else if (key == ' ') {
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
}
|
||||
else if (key==27) {
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
ShowBuffer = GL_NONE;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
static void SpecialKey( int key, int x, int y )
|
||||
{
|
||||
struct window *w = CurrentWindow();
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP:
|
||||
w->xrot += 3.0;
|
||||
if (w->xrot > 85)
|
||||
w->xrot = 85;
|
||||
xrot += 3.0;
|
||||
if ( xrot > 85 )
|
||||
xrot = 85;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
w->xrot -= 3.0;
|
||||
if (w->xrot < 5)
|
||||
w->xrot = 5;
|
||||
xrot -= 3.0;
|
||||
if ( xrot < 5 )
|
||||
xrot = 5;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
w->yrot += 3.0;
|
||||
yrot += 3.0;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
w->yrot -= 3.0;
|
||||
yrot -= 3.0;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CreateWindow(void)
|
||||
{
|
||||
char title[1000];
|
||||
struct window *w = (struct window *) calloc(1, sizeof(struct window));
|
||||
|
||||
glutInitWindowSize(INIT_WIDTH, INIT_HEIGHT);
|
||||
w->id = glutCreateWindow("foo");
|
||||
sprintf(title, "reflect window %d", w->id);
|
||||
glutSetWindowTitle(title);
|
||||
assert(w->id);
|
||||
w->width = INIT_WIDTH;
|
||||
w->height = INIT_HEIGHT;
|
||||
w->anim = GL_TRUE;
|
||||
w->xrot = 30.0;
|
||||
w->yrot = 50.0;
|
||||
w->spin = 0.0;
|
||||
w->showBuffer = GL_NONE;
|
||||
w->drawBuffer = GL_BACK;
|
||||
|
||||
InitWindow(w);
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutDisplayFunc(DrawWindow);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
||||
/* insert at head of list */
|
||||
w->next = FirstWindow;
|
||||
FirstWindow = w;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Keys:\n");
|
||||
printf(" a - show alpha buffer\n");
|
||||
printf(" d - show depth buffer\n");
|
||||
printf(" s - show stencil buffer\n");
|
||||
printf(" c - show color buffer\n");
|
||||
printf(" f - toggle rendering to front/back color buffer\n");
|
||||
printf(" n - create new window\n");
|
||||
printf(" k - kill window\n");
|
||||
printf(" SPACE - toggle animation\n");
|
||||
printf(" ARROWS - rotate scene\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH |
|
||||
GLUT_STENCIL | GLUT_ALPHA);
|
||||
CreateWindow();
|
||||
glutIdleFunc(Idle);
|
||||
Usage();
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL | GLUT_ALPHA);
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitWindowSize( Width, Height );
|
||||
glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(reshape);
|
||||
glutDisplayFunc(draw_scene);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutIdleFunc(idle);
|
||||
init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,269 +0,0 @@
|
||||
/*
|
||||
* Demo of (nearly) flicker-free drawing with a single color buffer.
|
||||
*
|
||||
* Basically, draw the scene into the Z buffer first, then draw the
|
||||
* scene into the color buffer. Finally, "clear" the background by
|
||||
* setting the fragments we didn't hit earlier.
|
||||
*
|
||||
* This won't work if you need blending. The technique works best
|
||||
* when the scene is relatively simple and can be rendered quickly
|
||||
* (i.e. with hardware), and when the objects don't move too much from
|
||||
* one frame to the next.
|
||||
*
|
||||
* Brian Paul
|
||||
* 25 August 2005
|
||||
*
|
||||
* See Mesa license for terms.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define FLICKER 0
|
||||
#define NO_FLICKER 1
|
||||
|
||||
static GLint Mode = NO_FLICKER;
|
||||
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
static GLfloat ClearColor[4] = {0.2, 0.2, 0.9, 0.0};
|
||||
static GLfloat NearClip = 5.0, FarClip = 25.0, ViewDist = 7.0;
|
||||
static double PrevTime = -1;
|
||||
|
||||
struct box {
|
||||
float tx, ty, tz;
|
||||
float rx, ry, rz, ra;
|
||||
float sx, sy, sz;
|
||||
float color[4];
|
||||
};
|
||||
|
||||
#define NUM_BOXES 25
|
||||
|
||||
struct box Boxes[NUM_BOXES];
|
||||
|
||||
|
||||
/* Return random float in [0,1] */
|
||||
static float
|
||||
Random(void)
|
||||
{
|
||||
int i = rand();
|
||||
return (float) (i % 1000) / 1000.0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
MakeBoxes(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NUM_BOXES; i++) {
|
||||
Boxes[i].tx = -1.0 + 2.0 * Random();
|
||||
Boxes[i].ty = -1.0 + 2.0 * Random();
|
||||
Boxes[i].tz = -1.0 + 2.0 * Random();
|
||||
Boxes[i].sx = 0.1 + Random() * 0.4;
|
||||
Boxes[i].sy = 0.1 + Random() * 0.4;
|
||||
Boxes[i].sz = 0.1 + Random() * 0.4;
|
||||
Boxes[i].rx = Random();
|
||||
Boxes[i].ry = Random();
|
||||
Boxes[i].rz = Random();
|
||||
Boxes[i].ra = Random() * 360.0;
|
||||
Boxes[i].color[0] = Random();
|
||||
Boxes[i].color[1] = Random();
|
||||
Boxes[i].color[2] = Random();
|
||||
Boxes[i].color[3] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawBoxes(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NUM_BOXES; i++) {
|
||||
glPushMatrix();
|
||||
glTranslatef(Boxes[i].tx, Boxes[i].ty, Boxes[i].tz);
|
||||
glRotatef(Boxes[i].ra, Boxes[i].rx, Boxes[i].ry, Boxes[i].rz);
|
||||
glScalef(Boxes[i].sx, Boxes[i].sy, Boxes[i].sz);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, Boxes[i].color);
|
||||
glutSolidCube(1.0);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
double dt, t = glutGet(GLUT_ELAPSED_TIME) * 0.001;
|
||||
if (PrevTime < 0.0)
|
||||
PrevTime = t;
|
||||
dt = t - PrevTime;
|
||||
PrevTime = t;
|
||||
Xrot += 16.0 * dt;
|
||||
Yrot += 12.0 * dt;
|
||||
Zrot += 8.0 * dt;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Draw(void)
|
||||
{
|
||||
if (Mode == FLICKER) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
else {
|
||||
/* don't clear color buffer */
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
/* update Z buffer only */
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(Xrot, 1, 0, 0);
|
||||
glRotatef(Yrot, 0, 1, 0);
|
||||
glRotatef(Zrot, 0, 0, 1);
|
||||
|
||||
DrawBoxes();
|
||||
|
||||
if (Mode == NO_FLICKER) {
|
||||
/* update color buffer now */
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthFunc(GL_EQUAL);
|
||||
DrawBoxes();
|
||||
glDepthFunc(GL_LESS);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
if (Mode == NO_FLICKER) {
|
||||
/* "clear" the untouched pixels now.
|
||||
* Note: if you comment-out this code you'll see something interesting.
|
||||
*/
|
||||
GLfloat x = FarClip / NearClip;
|
||||
GLfloat z = -(FarClip - ViewDist - 1.0);
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor4fv(ClearColor);
|
||||
glBegin(GL_POLYGON);
|
||||
glVertex3f(-x, -x, z);
|
||||
glVertex3f( x, -x, z);
|
||||
glVertex3f( x, x, z);
|
||||
glVertex3f(-x, x, z);
|
||||
glEnd();
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
/* This is where you'd normally do SwapBuffers */
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, NearClip, FarClip);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -ViewDist);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
PrevTime = -1;
|
||||
break;
|
||||
case 'm':
|
||||
Mode = !Mode;
|
||||
break;
|
||||
case 'b':
|
||||
MakeBoxes();
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 3.0;
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP:
|
||||
Xrot -= step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
Xrot += step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
Yrot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
Yrot += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
glClearColor(ClearColor[0], ClearColor[1], ClearColor[2], ClearColor[3]);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_NORMALIZE);
|
||||
MakeBoxes();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Keys:\n");
|
||||
printf(" m - toggle drawing mode (flicker vs. no flicker)\n");
|
||||
printf(" a - toggle animation\n");
|
||||
printf(" b - generate new boxes\n");
|
||||
printf(" ARROWS - rotate scene\n");
|
||||
printf(" ESC - exit\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowSize(800, 800);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
|
||||
glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Draw);
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
Init();
|
||||
Usage();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -38,8 +38,8 @@
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
static GLsizei MaxSize = 2048;
|
||||
static GLsizei TexWidth = 1024, TexHeight = 1024, TexBorder = 0;
|
||||
static GLsizei MaxSize = 1024;
|
||||
static GLsizei TexWidth = 256, TexHeight = 256, TexBorder = 0;
|
||||
static GLboolean ScaleAndBias = GL_FALSE;
|
||||
static GLboolean SubImage = GL_FALSE;
|
||||
static GLdouble DownloadRate = 0.0; /* texels/sec */
|
||||
@@ -47,32 +47,6 @@ static GLdouble DownloadRate = 0.0; /* texels/sec */
|
||||
static GLuint Mode = 0;
|
||||
|
||||
|
||||
/* Try and avoid L2 cache effects by cycling through a small number of
|
||||
* textures.
|
||||
*
|
||||
* At the initial size of 1024x1024x4 == 4mbyte, say 8 textures will
|
||||
* keep us out of most caches at 32mb total.
|
||||
*
|
||||
* This turns into a fairly interesting question of what exactly you
|
||||
* expect to be in cache in normal usage, and what you think should be
|
||||
* outside. There's no rules for this, no reason to favour one usage
|
||||
* over another except what the application you care about happens to
|
||||
* resemble most closely.
|
||||
*
|
||||
* - Should the client texture image be in L2 cache? Has it just been
|
||||
* generated or read from disk?
|
||||
* - Does the application really use >1 texture, or is it constantly
|
||||
* updating one image in-place?
|
||||
*
|
||||
* Different answers will favour different texture upload mechanisms.
|
||||
* To upload an image that is purely outside of cache, a DMA-based
|
||||
* upload will probably win, whereas for small, in-cache textures,
|
||||
* copying looks good.
|
||||
*/
|
||||
#define NR_TEXOBJ 4
|
||||
static GLuint TexObj[NR_TEXOBJ];
|
||||
|
||||
|
||||
struct FormatRec {
|
||||
GLenum Format;
|
||||
GLenum Type;
|
||||
@@ -142,57 +116,25 @@ TypeStr(GLenum type)
|
||||
}
|
||||
}
|
||||
|
||||
/* On x86, there is a performance cliff for memcpy to texture memory
|
||||
* for sources below 64 byte alignment. We do our best with this in
|
||||
* the driver, but it is better if the images are correctly aligned to
|
||||
* start with:
|
||||
*/
|
||||
#define ALIGN (1<<12)
|
||||
|
||||
static unsigned align(unsigned value, unsigned a)
|
||||
{
|
||||
return (value + a - 1) & ~(a-1);
|
||||
}
|
||||
|
||||
static int MIN2(int a, int b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
static void
|
||||
MeasureDownloadRate(void)
|
||||
{
|
||||
const int w = TexWidth + 2 * TexBorder;
|
||||
const int h = TexHeight + 2 * TexBorder;
|
||||
const int image_bytes = align(w * h * BytesPerTexel(Format), ALIGN);
|
||||
const int bytes = image_bytes * NR_TEXOBJ;
|
||||
GLubyte *orig_texImage, *orig_getImage;
|
||||
const int bytes = w * h * BytesPerTexel(Format);
|
||||
GLubyte *texImage, *getImage;
|
||||
GLdouble t0, t1, time;
|
||||
int count;
|
||||
int i;
|
||||
int offset = 0;
|
||||
GLdouble total = 0; /* ints will tend to overflow */
|
||||
|
||||
printf("allocating %d bytes for %d %dx%d images\n",
|
||||
bytes, NR_TEXOBJ, w, h);
|
||||
|
||||
orig_texImage = (GLubyte *) malloc(bytes + ALIGN);
|
||||
orig_getImage = (GLubyte *) malloc(image_bytes + ALIGN);
|
||||
if (!orig_texImage || !orig_getImage) {
|
||||
texImage = (GLubyte *) malloc(bytes);
|
||||
getImage = (GLubyte *) malloc(bytes);
|
||||
if (!texImage || !getImage) {
|
||||
DownloadRate = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
printf("alloc %p %p\n", orig_texImage, orig_getImage);
|
||||
|
||||
texImage = (GLubyte *)align((unsigned)orig_texImage, ALIGN);
|
||||
getImage = (GLubyte *)align((unsigned)orig_getImage, ALIGN);
|
||||
|
||||
for (i = 1; !(((unsigned)texImage) & i); i<<=1)
|
||||
;
|
||||
printf("texture image alignment: %d bytes (%p)\n", i, texImage);
|
||||
|
||||
for (i = 0; i < bytes; i++) {
|
||||
texImage[i] = i & 0xff;
|
||||
}
|
||||
@@ -224,80 +166,51 @@ MeasureDownloadRate(void)
|
||||
count = 0;
|
||||
t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
|
||||
do {
|
||||
int img = count%NR_TEXOBJ;
|
||||
GLubyte *img_ptr = texImage + img * image_bytes;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, TexObj[img]);
|
||||
|
||||
if (SubImage && count > 0) {
|
||||
/* Only update a portion of the image each iteration. This
|
||||
* is presumably why you'd want to use texsubimage, otherwise
|
||||
* you may as well just call teximage again.
|
||||
*
|
||||
* A bigger question is whether to use a pointer that moves
|
||||
* with each call, ie does the incoming data come from L2
|
||||
* cache under normal circumstances, or is it pulled from
|
||||
* uncached memory?
|
||||
*
|
||||
* There's a good argument to say L2 cache, ie you'd expect
|
||||
* the data to have been recently generated. It's possible
|
||||
* that it could have come from a file read, which may or may
|
||||
* not have gone through the cpu.
|
||||
*/
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
-TexBorder,
|
||||
-TexBorder + offset * h/8,
|
||||
w,
|
||||
h/8,
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, -TexBorder, -TexBorder, w, h,
|
||||
FormatTable[Format].Format,
|
||||
FormatTable[Format].Type,
|
||||
#if 1
|
||||
texImage /* likely in L2$ */
|
||||
#else
|
||||
img_ptr + offset * bytes/8 /* unlikely in L2$ */
|
||||
#endif
|
||||
);
|
||||
offset += 1;
|
||||
offset %= 8;
|
||||
total += w * h / 8;
|
||||
FormatTable[Format].Type, texImage);
|
||||
}
|
||||
else {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0,
|
||||
FormatTable[Format].IntFormat, w, h, TexBorder,
|
||||
FormatTable[Format].Format,
|
||||
FormatTable[Format].Type,
|
||||
img_ptr);
|
||||
total += w*h;
|
||||
FormatTable[Format].Type, texImage);
|
||||
}
|
||||
|
||||
#if 1
|
||||
/* Render a texture, but not necessarily the one just uploaded.
|
||||
*/
|
||||
/* glBindTexture(GL_TEXTURE_2D, TexObj[(img + NR_TEXOBJ/2)%NR_TEXOBJ]); */
|
||||
|
||||
/* draw a tiny polygon to force texture into texram */
|
||||
glBegin(GL_TRIANGLES);
|
||||
glTexCoord2f(0, 0); glVertex2f(1, 1);
|
||||
glTexCoord2f(1, 0); glVertex2f(3, 1);
|
||||
glTexCoord2f(0.5, 1); glVertex2f(2, 3);
|
||||
glEnd();
|
||||
/* glFinish(); */
|
||||
#endif
|
||||
|
||||
t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
|
||||
time = t1 - t0;
|
||||
count++;
|
||||
/* printf("total %f count %d\n", total, count); */
|
||||
} while (time < 3.0);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
printf("total texels=%f time=%f\n", total, time);
|
||||
DownloadRate = total / time;
|
||||
printf("w*h=%d count=%d time=%f\n", w*h, count, time);
|
||||
DownloadRate = w * h * count / time;
|
||||
|
||||
#if 0
|
||||
if (!ScaleAndBias) {
|
||||
/* verify texture readback */
|
||||
glGetTexImage(GL_TEXTURE_2D, 0,
|
||||
FormatTable[Format].Format,
|
||||
FormatTable[Format].Type, getImage);
|
||||
for (i = 0; i < w * h; i++) {
|
||||
if (texImage[i] != getImage[i]) {
|
||||
printf("[%d] %d != %d\n", i, texImage[i], getImage[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
free(orig_texImage);
|
||||
free(orig_getImage);
|
||||
free(texImage);
|
||||
free(getImage);
|
||||
|
||||
{
|
||||
GLint err = glGetError();
|
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
eglShowScreenSurfaceMESA(d, screen, screen_surf, mode);
|
||||
eglShowSurfaceMESA(d, screen, screen_surf, mode);
|
||||
|
||||
b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
|
||||
if (!b) {
|
||||
|
@@ -603,7 +603,7 @@ main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
eglShowScreenSurfaceMESA(d, screen, screen_surf, mode);
|
||||
eglShowSurfaceMESA(d, screen, screen_surf, mode);
|
||||
|
||||
b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
|
||||
if (!b) {
|
||||
|
@@ -35,8 +35,6 @@
|
||||
#include <GLES/egl.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define MAX_CONFIGS 10
|
||||
#define MAX_MODES 100
|
||||
|
||||
#define BENCHMARK
|
||||
|
||||
@@ -89,11 +87,9 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
|
||||
static GLint gear1, gear2, gear3;
|
||||
static GLfloat angle = 0.0;
|
||||
|
||||
#if 0
|
||||
static GLfloat eyesep = 5.0; /* Eye separation. */
|
||||
static GLfloat fix_point = 40.0; /* Fixation point distance. */
|
||||
static GLfloat left, right, asp; /* Stereo frustum params. */
|
||||
#endif
|
||||
//static GLfloat eyesep = 5.0; /* Eye separation. */
|
||||
//static GLfloat fix_point = 40.0; /* Fixation point distance. */
|
||||
//static GLfloat left, right, asp; /* Stereo frustum params. */
|
||||
|
||||
|
||||
/*
|
||||
@@ -343,6 +339,7 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
|
||||
|
||||
draw();
|
||||
|
||||
// DBR : Swap the Buffers
|
||||
eglSwapBuffers(dpy, surf);
|
||||
|
||||
|
||||
@@ -362,18 +359,21 @@ main(int argc, char *argv[])
|
||||
int maj, min;
|
||||
EGLContext ctx;
|
||||
EGLSurface screen_surf;
|
||||
EGLConfig configs[MAX_CONFIGS];
|
||||
EGLConfig configs[10];
|
||||
EGLint numConfigs, i;
|
||||
EGLBoolean b;
|
||||
EGLDisplay d;
|
||||
EGLint screenAttribs[10];
|
||||
EGLModeMESA mode[MAX_MODES];
|
||||
EGLScreenMESA screen;
|
||||
EGLint count, chosenMode;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint width = 0, height = 0;
|
||||
|
||||
/* parse cmd line args */
|
||||
const EGLint screenAttribs[] = {
|
||||
EGL_WIDTH, 1024,
|
||||
EGL_HEIGHT, 768,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
EGLModeMESA mode;
|
||||
EGLScreenMESA screen;
|
||||
EGLint count;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-info") == 0)
|
||||
@@ -384,73 +384,42 @@ main(int argc, char *argv[])
|
||||
printf("Warning: unknown parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
/* DBR : Create EGL context/surface etc */
|
||||
d = eglGetDisplay(":0");
|
||||
// DBR : Create EGL context/surface etc
|
||||
EGLDisplay d = eglGetDisplay(":0");
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("eglgears: eglInitialize failed\n");
|
||||
printf("demo: eglInitialize failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("eglgears: EGL version = %d.%d\n", maj, min);
|
||||
printf("eglgears: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
printf("EGL version = %d.%d\n", maj, min);
|
||||
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
|
||||
/* XXX use ChooseConfig */
|
||||
eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
|
||||
eglGetConfigs(d, configs, 10, &numConfigs);
|
||||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
|
||||
if (!eglGetModesMESA(d, screen, mode, MAX_MODES, &count) || count == 0) {
|
||||
printf("eglgears: eglGetModesMESA failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Print list of modes, and find the one to use */
|
||||
printf("eglgears: Found %d modes:\n", count);
|
||||
for (i = 0; i < count; i++) {
|
||||
EGLint w, h;
|
||||
eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w);
|
||||
eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h);
|
||||
printf("%3d: %d x %d\n", i, w, h);
|
||||
if (w > width && h > height && w <= 1280 && h <= 1024) {
|
||||
width = w;
|
||||
height = h;
|
||||
chosenMode = i;
|
||||
}
|
||||
}
|
||||
printf("eglgears: Using screen mode/size %d: %d x %d\n", chosenMode, width, height);
|
||||
eglGetModesMESA(d, screen, &mode, 1, &count);
|
||||
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("eglgears: failed to create context\n");
|
||||
printf("failed to create context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* build up screenAttribs array */
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
screenAttribs[i++] = width;
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
screenAttribs[i++] = height;
|
||||
screenAttribs[i++] = EGL_NONE;
|
||||
|
||||
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
|
||||
if (screen_surf == EGL_NO_SURFACE) {
|
||||
printf("eglgears: failed to create screen surface\n");
|
||||
printf("failed to create screen surface\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglShowScreenSurfaceMESA(d, screen, screen_surf, mode[chosenMode]);
|
||||
if (!b) {
|
||||
printf("eglgears: show surface failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
eglShowSurfaceMESA(d, screen, screen_surf, mode);
|
||||
|
||||
b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
|
||||
if (!b) {
|
||||
printf("eglgears: make current failed\n");
|
||||
printf("make current failed\n");
|
||||
return 0;
|
||||
}
|
||||
// DBR
|
||||
|
||||
if (printInfo)
|
||||
{
|
||||
@@ -460,16 +429,20 @@ main(int argc, char *argv[])
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
reshape(width, height);
|
||||
init(); // Initialise the GL visual
|
||||
reshape(1024,768);
|
||||
|
||||
glDrawBuffer( GL_BACK );
|
||||
glDrawBuffer( GL_BACK );
|
||||
|
||||
// DBR : Run the simulation
|
||||
run_gears(d, screen_surf, 5.0);
|
||||
|
||||
|
||||
// DBR : Destroy EGL context/surface etc
|
||||
eglDestroySurface(d, screen_surf);
|
||||
eglDestroyContext(d, ctx);
|
||||
eglTerminate(d);
|
||||
// DBR
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -48,9 +48,9 @@ PrintConfigs(EGLDisplay d)
|
||||
eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
|
||||
|
||||
printf("Configurations:\n");
|
||||
printf(" bf lv d st colorbuffer dp st supported\n");
|
||||
printf(" bf lv d st colorbuffer dp st supported \n");
|
||||
printf(" id sz l b ro r g b a th cl surfaces \n");
|
||||
printf("---------------------------------------------------\n");
|
||||
printf("----------------------------------------------\n");
|
||||
for (i = 0; i < numConfigs; i++) {
|
||||
EGLint id, size, level;
|
||||
EGLint red, green, blue, alpha;
|
||||
@@ -77,10 +77,6 @@ PrintConfigs(EGLDisplay d)
|
||||
strcat(surfString, "pb,");
|
||||
if (surfaces & EGL_PIXMAP_BIT)
|
||||
strcat(surfString, "pix,");
|
||||
#ifdef EGL_MESA_screen_surface
|
||||
if (surfaces & EGL_SCREEN_BIT_MESA)
|
||||
strcat(surfString, "scrn,");
|
||||
#endif
|
||||
if (strlen(surfString) > 0)
|
||||
surfString[strlen(surfString) - 1] = 0;
|
||||
|
||||
@@ -140,7 +136,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
/*EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);*/
|
||||
EGLDisplay d = eglGetDisplay(":0");
|
||||
EGLDisplay d = eglGetDisplay("!r200_dri");
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("eglinfo: eglInitialize failed\n");
|
||||
|
@@ -1,127 +0,0 @@
|
||||
# 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-param.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 \
|
||||
tri-depth.c \
|
||||
tri-depth2.c \
|
||||
tri-depthwrite.c \
|
||||
tri-depthwrite2.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`
|
@@ -1,107 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,113 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0; \n"
|
||||
"MUL R0, fragment.color, {3.14}.x; \n"
|
||||
"COS result.color.x, R0.x; \n"
|
||||
"COS result.color.y, R0.y; \n"
|
||||
"COS result.color.z, R0.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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
/* scale of 10.0 gives me a visible result on nv hardware.
|
||||
*/
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MUL result.color, fragment.position.z, {10.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, -40.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -40.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -25.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,116 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
/* scale of 10.0 gives me a visible result on nv hardware.
|
||||
*/
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"MUL R0, fragment.position.z, {10.0}.x;\n"
|
||||
"MOV 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|GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, -0.9, -40.0);
|
||||
glVertex3f(-0.9, 0.9, -40.0);
|
||||
glVertex3f( 0.9, 0.0, -25.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_DEPTH;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,107 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MUL result.depth.z, fragment.color.z, {.1}.x; \n"
|
||||
"MOV result.color.xy, 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|GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor4f(.8,0,.5,0);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
|
||||
glColor4f(0,.8,.7,0);
|
||||
glVertex3f(-0.9, -0.9, -40.0);
|
||||
glColor4f(0,.8,.7,0);
|
||||
glVertex3f(-0.9, 0.9, -40.0);
|
||||
glColor4f(0,.8,.3,0);
|
||||
glVertex3f( 0.9, 0.0, -40.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300);
|
||||
|
||||
glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE);
|
||||
|
||||
if (glutCreateWindow("Depth Test") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,107 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MUL result.depth.z, fragment.color.z, {.1}.x; \n"
|
||||
"MOV result.color, fragment.color.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|GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor4f(.8,0,.5,0);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
|
||||
glColor4f(0,.8,.7,0);
|
||||
glVertex3f(-0.9, -0.9, -40.0);
|
||||
glColor4f(0,.8,.7,0);
|
||||
glVertex3f(-0.9, 0.9, -40.0);
|
||||
glColor4f(0,.8,.3,0);
|
||||
glVertex3f( 0.9, 0.0, -40.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300);
|
||||
|
||||
glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE);
|
||||
|
||||
if (glutCreateWindow("Depth Test") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"DST 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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,102 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MOV result.color, program.local[32]; \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);
|
||||
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 32, 0.25, .5, 0.25, 1);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.0, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 32, 0.25, 0, 0.25, 1);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, 0.0, -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();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"MUL result.color, fragment.position, {.005}.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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"ADD R0, fragment.color.x, fragment.color.x; \n"
|
||||
"RCP 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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0; \n"
|
||||
"MUL R0, fragment.color, {3.14}.x; \n"
|
||||
"MOV result.color, {0.0}.x; \n"
|
||||
"SIN result.color.x, R0.x; \n"
|
||||
"SIN result.color.y, R0.y; \n"
|
||||
"SIN result.color.z, R0.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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
#include "GL/gl.h"
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user