initial Regal commit

This commit is contained in:
Cass Everitt 2012-05-11 16:44:03 -05:00
parent af109c32dc
commit e126329aab
371 changed files with 357576 additions and 0 deletions

311
Makefile Normal file
View file

@ -0,0 +1,311 @@
include config/version
SHELL = /bin/sh
SYSTEM ?= $(shell config/config.guess | cut -d - -f 3 | sed -e 's/[0-9\.]//g;')
SYSTEM.SUPPORTED = $(shell test -f config/Makefile.$(SYSTEM) && echo 1)
ifeq ($(SYSTEM.SUPPORTED), 1)
include config/Makefile.$(SYSTEM)
else
$(error "Platform '$(SYSTEM)' not supported")
endif
REGAL_DEST ?= /usr
BINDIR ?= $(REGAL_DEST)/bin
LIBDIR ?= $(REGAL_DEST)/lib
# To disable stripping of binaries either:
# - use STRIP= on gmake command-line
# - edit this makefile to set STRIP to the empty string
#
# To disable symlinks:
# - use LN= on gmake command-line
AR ?= ar
INSTALL ?= install
STRIP ?= strip
RM ?= rm -f
LN ?= ln -sf
ifeq ($(MAKECMDGOALS), debug)
OPT = -g
STRIP :=
else
OPT = $(POPT)
endif
INCLUDE = -Iinclude
CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA)
all debug: regal.lib glew.lib glut.lib regal.bin
# REGAL shared and static libraries
export:
scripts/Export.py --api gl 4.2 --api wgl 4.0 --api glx 4.0 --api cgl 1.4 --api egl 1.0 --outdir src/regal
LIB.LDFLAGS := $(LDFLAGS.EXTRA) $(LDFLAGS.GL) -lstdc++ -lpthread
LIB.LIBS := $(GL_LDFLAGS)
LIB.SRCS :=
LIB.SRCS += src/regal/RegalIff.cpp
LIB.SRCS += src/regal/Regal.cpp
LIB.SRCS += src/regal/RegalLookup.cpp
LIB.SRCS += src/regal/RegalEmuDispatch.cpp
LIB.SRCS += src/regal/RegalErrorDispatch.cpp
LIB.SRCS += src/regal/RegalLoaderDispatch.cpp
LIB.SRCS.NAMES := $(notdir $(LIB.SRCS))
LIB.DEPS :=
LIB.DEPS += include/GL/Regal.h
LIB.DEPS += src/regal/RegalPrivate.h
LIB.OBJS := $(addprefix tmp/$(SYSTEM)/regal/static/,$(LIB.SRCS.NAMES))
LIB.OBJS := $(LIB.OBJS:.cpp=.o)
LIB.SOBJS := $(addprefix tmp/$(SYSTEM)/regal/shared/,$(LIB.SRCS.NAMES))
LIB.SOBJS := $(LIB.SOBJS:.cpp=.o)
regal.lib: lib lib/$(LIB.SHARED) lib/$(LIB.STATIC)
lib:
mkdir lib
lib/$(LIB.STATIC): $(LIB.OBJS)
$(AR) cr $@ $^
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
lib/$(LIB.SHARED): $(LIB.SOBJS)
$(LD) $(LDFLAGS.SO) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS)
ifneq ($(LN),)
$(LN) $(LIB.SHARED) lib/$(LIB.SONAME)
$(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK)
ifneq ($(LIB.FRAMEWORK),)
$(LN) $(LIB.SHARED) lib/$(LIB.FRAMEWORK)
endif
endif
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
tmp/$(SYSTEM)/regal/static/%.o: src/regal/%.cpp $(LIB.DEPS)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(CFLAGS.SO) -o $@ -c $<
tmp/$(SYSTEM)/regal/shared/%.o: src/regal/%.cpp $(LIB.DEPS)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) -o $@ -c $<
#
# RegalGLEW
#
GLEW.SRCS += src/glew/src/glew.c
GLEW.SRCS.NAMES := $(notdir $(GLEW.SRCS))
GLEW.OBJS := $(addprefix tmp/$(SYSTEM)/glew/shared/,$(GLEW.SRCS.NAMES))
GLEW.OBJS := $(GLEW.OBJS:.c=.o)
GLEW.CFLAGS := -Isrc/glew/include -DGLEW_EXPORTS -DGLEW_BUILD
GLEW.SHARED := libRegalGLEW.$(EXT.DYNAMIC)
GLEW.STATIC := libRegalGLEW.a
glew.lib: lib lib/$(GLEW.SHARED)
tmp/$(SYSTEM)/glew/shared/%.o: src/glew/src/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(PICFLAG) $(GLEW.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
lib/$(GLEW.SHARED): $(GLEW.OBJS)
$(LD) $(LDFLAGS.DYNAMIC) -o $@ $^ $(LIB.LDFLAGS) $(GLEW.LIBS) -lpthread
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
ifneq ($(filter darwin%,$(SYSTEM)),)
glut.lib:
else
#
# RegalGLUT
#
# NOT for windows...
GLUT.SRCS += src/glut/src/capturexfont.c
GLUT.SRCS += src/glut/src/glut_glxext.c
GLUT.SRCS += src/glut/src/glut_menu.c
GLUT.SRCS += src/glut/src/glut_menu2.c
GLUT.SRCS += src/glut/src/layerutil.c
# Windows and Linux...
GLUT.SRCS += src/glut/src/glut_8x13.c
GLUT.SRCS += src/glut/src/glut_9x15.c
GLUT.SRCS += src/glut/src/glut_bitmap.c
GLUT.SRCS += src/glut/src/glut_bwidth.c
GLUT.SRCS += src/glut/src/glut_cindex.c
GLUT.SRCS += src/glut/src/glut_cmap.c
GLUT.SRCS += src/glut/src/glut_cursor.c
GLUT.SRCS += src/glut/src/glut_dials.c
GLUT.SRCS += src/glut/src/glut_dstr.c
GLUT.SRCS += src/glut/src/glut_event.c
GLUT.SRCS += src/glut/src/glut_ext.c
GLUT.SRCS += src/glut/src/glut_fcb.c
GLUT.SRCS += src/glut/src/glut_fullscrn.c
GLUT.SRCS += src/glut/src/glut_gamemode.c
GLUT.SRCS += src/glut/src/glut_get.c
GLUT.SRCS += src/glut/src/glut_hel10.c
GLUT.SRCS += src/glut/src/glut_hel12.c
GLUT.SRCS += src/glut/src/glut_hel18.c
GLUT.SRCS += src/glut/src/glut_init.c
GLUT.SRCS += src/glut/src/glut_input.c
GLUT.SRCS += src/glut/src/glut_joy.c
GLUT.SRCS += src/glut/src/glut_key.c
GLUT.SRCS += src/glut/src/glut_keyctrl.c
GLUT.SRCS += src/glut/src/glut_keyup.c
GLUT.SRCS += src/glut/src/glut_mesa.c
GLUT.SRCS += src/glut/src/glut_modifier.c
GLUT.SRCS += src/glut/src/glut_mroman.c
GLUT.SRCS += src/glut/src/glut_overlay.c
GLUT.SRCS += src/glut/src/glut_roman.c
GLUT.SRCS += src/glut/src/glut_shapes.c
GLUT.SRCS += src/glut/src/glut_space.c
GLUT.SRCS += src/glut/src/glut_stroke.c
GLUT.SRCS += src/glut/src/glut_swap.c
GLUT.SRCS += src/glut/src/glut_swidth.c
GLUT.SRCS += src/glut/src/glut_tablet.c
GLUT.SRCS += src/glut/src/glut_teapot.c
GLUT.SRCS += src/glut/src/glut_tr10.c
GLUT.SRCS += src/glut/src/glut_tr24.c
GLUT.SRCS += src/glut/src/glut_util.c
GLUT.SRCS += src/glut/src/glut_vidresize.c
GLUT.SRCS += src/glut/src/glut_warp.c
GLUT.SRCS += src/glut/src/glut_win.c
GLUT.SRCS += src/glut/src/glut_winmisc.c
GLUT.SRCS += src/glut/src/glut_ppm.c
GLUT.SRCS.NAMES := $(notdir $(GLUT.SRCS))
GLUT.OBJS := $(addprefix tmp/$(SYSTEM)/glut/shared/,$(GLUT.SRCS.NAMES))
GLUT.OBJS := $(GLUT.OBJS:.c=.o)
GLUT.CFLAGS := -Isrc/glut/include -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DGLUT_STATIC
GLUT.SHARED := libRegalGLUT.$(EXT.DYNAMIC)
GLUT.STATIC := libRegalGLUT.a
glut.lib: lib lib/$(GLUT.SHARED)
tmp/$(SYSTEM)/glut/shared/%.o: src/glut/src/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(PICFLAG) $(GLUT.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
lib/$(GLUT.SHARED): $(GLUT.OBJS)
$(LD) $(LDFLAGS.DYNAMIC) -o $@ $^ -Llib -lRegal -lGLU -lX11 -lXmu -lXi -lpthread
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
endif
# Examples
regal.bin: bin bin/dreamtorus bin/tiger bin/byte_code_shaders
bin:
mkdir bin
#
# dreamtorus
#
DREAMTORUS.SRCS += examples/dreamtorus/src/render.cpp
DREAMTORUS.SRCS += examples/dreamtorus/glut/code/main.cpp
DREAMTORUS.SRCS.NAMES := $(notdir $(DREAMTORUS.SRCS))
DREAMTORUS.OBJS := $(addprefix tmp/$(SYSTEM)/dreamtorus/static/,$(DREAMTORUS.SRCS.NAMES))
DREAMTORUS.OBJS := $(DREAMTORUS.OBJS:.cpp=.o)
DREAMTORUS.CFLAGS := -Iinclude -Iexamples/dreamtorus/src
tmp/$(SYSTEM)/dreamtorus/static/%.o: examples/dreamtorus/src/%.cpp
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DREAMTORUS.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
tmp/$(SYSTEM)/dreamtorus/static/%.o: examples/dreamtorus/glut/code/%.cpp
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DREAMTORUS.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
bin/dreamtorus: $(DREAMTORUS.OBJS)
$(LD) -o $@ $^ $(LIB.LDFLAGS) $(LIB.LIBS) $(LDFLAGS.GLUT) $(LDFLAGS.GL) -Llib -l$(NAME) -lm -lpthread
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
#
# tiger
#
TIGER.SRCS += examples/tiger/nvpr_tiger.c
TIGER.SRCS += examples/tiger/tiger.c
TIGER.SRCS += examples/tiger/xform.c
TIGER.SRCS.NAMES := $(notdir $(TIGER.SRCS))
TIGER.OBJS := $(addprefix tmp/$(SYSTEM)/tiger/static/,$(TIGER.SRCS.NAMES))
TIGER.OBJS := $(TIGER.OBJS:.c=.o)
TIGER.CFLAGS := -Iinclude
tmp/$(SYSTEM)/tiger/static/%.o: examples/tiger/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(TIGER.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
bin/tiger: $(TIGER.OBJS)
$(LD) -o $@ $^ -Llib -l$(NAME) -lRegalGLEW $(LDFLAGS.GLUT) -lm -lpthread
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
#
# byte_code_shaders
#
BYTE_CODE_SHADERS.SRCS += examples/byte_code_shaders/main.cpp
BYTE_CODE_SHADERS.SRCS += examples/byte_code_shaders/xform.cpp
BYTE_CODE_SHADERS.SRCS += src/mojoshader/mojoshader_assembler.c
BYTE_CODE_SHADERS.SRCS += src/mojoshader/mojoshader.c
BYTE_CODE_SHADERS.SRCS += src/mojoshader/mojoshader_common.c
BYTE_CODE_SHADERS.SRCS += src/mojoshader/mojoshader_compiler.c
BYTE_CODE_SHADERS.SRCS += src/mojoshader/mojoshader_effects.c
BYTE_CODE_SHADERS.SRCS += src/mojoshader/mojoshader_lexer.c
#BYTE_CODE_SHADERS.SRCS += src/mojoshader/mojoshader_opengl.c
BYTE_CODE_SHADERS.SRCS += src/mojoshader/mojoshader_preprocessor.c
BYTE_CODE_SHADERS.SRCS.NAMES := $(notdir $(BYTE_CODE_SHADERS.SRCS))
BYTE_CODE_SHADERS.OBJS := $(addprefix tmp/$(SYSTEM)/byte_code_shaders/static/,$(BYTE_CODE_SHADERS.SRCS.NAMES))
BYTE_CODE_SHADERS.OBJS := $(BYTE_CODE_SHADERS.OBJS:.c=.o)
BYTE_CODE_SHADERS.OBJS := $(BYTE_CODE_SHADERS.OBJS:.cpp=.o)
BYTE_CODE_SHADERS.CFLAGS := -Iinclude
BYTE_CODE_SHADERS.CFLAGS += -Isrc/mojoshader/
BYTE_CODE_SHADERS.CFLAGS += -DMOJOSHADER_NO_VERSION_INCLUDE
#BYTE_CODE_SHADERS.CFLAGS += -DREGAL_NO_TYPEDEF_GL_VERSION_1_0
#BYTE_CODE_SHADERS.CFLAGS += -DREGAL_NO_DECLARATION_GL_VERSION_1_0
tmp/$(SYSTEM)/byte_code_shaders/static/%.o: examples/byte_code_shaders/%.cpp
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(BYTE_CODE_SHADERS.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
tmp/$(SYSTEM)/byte_code_shaders/static/%.o: src/mojoshader/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(BYTE_CODE_SHADERS.CFLAGS) $(CFLAGS.SO) -o $@ -c $<
bin/byte_code_shaders: $(BYTE_CODE_SHADERS.OBJS)
$(LD) -o $@ $^ -Llib -l$(NAME) -lRegalGLEW $(LDFLAGS.GLUT) -lstdc++ -lm -lpthread
ifneq ($(STRIP),)
$(STRIP) -x $@
endif
clean:
$(RM) -r tmp/
$(RM) -r lib/
$(RM) -r bin/
$(RM) glew.pc glewmx.pc
.PHONY: export
.PHONY: regal.lib regal.bin all debug
.PHONY: clean distclean tardist dist-win32 dist-src

23
config/Makefile.cygwin Executable file
View file

@ -0,0 +1,23 @@
NAME = $(REGAL_NAME)
CC = cc
LD = cc
PICFLAG =
LDFLAGS.EXTRA =
LIBDIR =
LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11
LDFLAGS.GLUT = -lglut
LDFLAGS.STATIC = -Wl,-Bstatic
LDFLAGS.DYNAMIC = -Wl,-Bdynamic
WARN = -Wall -W
POPT = -O2
BIN.SUFFIX =
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
LIB.DEVLNK = lib$(NAME).so
LIB.SHARED = lib$(NAME).so.$(SO_VERSION)
LIB.STATIC = lib$(NAME).a
LDFLAGS.SO = -shared -Wl,-soname=$(LIB.SONAME)
LIB.SONAME.MX = lib$(NAME)mx.so.$(SO_MAJOR)
LIB.DEVLNK.MX = lib$(NAME)mx.so
LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -shared -Wl,-soname=$(LIB.SONAME.MX)

30
config/Makefile.darwin Normal file
View file

@ -0,0 +1,30 @@
NAME = $(REGAL_NAME)
CC = cc
LD = cc
EXT.DYNAMIC = dylib
CFLAGS.EXTRA = -no-cpp-precomp -dynamic -fno-common
PICFLAG = -fPIC
LDFLAGS.EXTRA =
ifneq (undefined, $(origin REGAL_APPLE_GLX))
CFLAGS.EXTRA += -I/usr/X11R6/include -D'REGAL_APPLE_GLX'
LDFLAGS.GL = -L/usr/X11R6/lib -lXmu -lXi -lGLU -lGL -lXext -lX11
else
LDFLAGS.GL = -framework AGL -framework OpenGL
LDFLAGS.GLUT = -framework GLUT
endif
LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = -dynamiclib
WARN = -Wall -W -Wno-unused-parameter
POPT = -O2
BIN.SUFFIX =
LIB.SONAME = lib$(NAME).$(SO_MAJOR).dylib
LIB.DEVLNK = lib$(NAME).dylib
LIB.SHARED = lib$(NAME).$(SO_VERSION).dylib
LIB.STATIC = lib$(NAME).a
LIB.FRAMEWORK = $(NAME)
LDFLAGS.SO = $(LDFLAGS.DYNAMIC) -install_name $(REGAL_DEST)/lib/$(LIB.SHARED) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)
LIB.SONAME.MX = lib$(NAME)mx.$(SO_MAJOR).dylib
LIB.DEVLNK.MX = lib$(NAME)mx.dylib
LIB.SHARED.MX = lib$(NAME)mx.$(SO_VERSION).dylib
LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -dynamiclib -install_name $(REGAL_DEST)/lib/$(LIB.SHARED.MX) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)

View file

@ -0,0 +1,30 @@
NAME = $(REGAL_NAME)
CC = cc
LD = cc
EXT.DYNAMIC = dylib
CFLAGS.EXTRA = -arch ppc -no-cpp-precomp -dynamic -fno-common
PICFLAG = -fPIC
LDFLAGS.EXTRA = -arch ppc
ifneq (undefined, $(origin REGAL_APPLE_GLX))
CFLAGS.EXTRA += -I/usr/X11R6/include -D'REGAL_APPLE_GLX'
LDFLAGS.GL = -L/usr/X11R6/lib -lXmu -lXi -lGLU -lGL -lXext -lX11
else
LDFLAGS.GL = -framework AGL -framework OpenGL
LDFLAGS.GLUT = -framework GLUT
endif
LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = -dynamiclib
WARN = -Wall -W -Wno-unused-parameter
POPT = -O2
BIN.SUFFIX =
LIB.SONAME = lib$(NAME).$(SO_MAJOR).dylib
LIB.DEVLNK = lib$(NAME).dylib
LIB.SHARED = lib$(NAME).$(SO_VERSION).dylib
LIB.STATIC = lib$(NAME).a
LIB.FRAMEWORK = $(NAME)
LDFLAGS.SO = $(LDFLAGS.DYNAMIC) -install_name $(REGAL_DEST)/lib/$(LIB.SHARED) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)
LIB.SONAME.MX = lib$(NAME)mx.$(SO_MAJOR).dylib
LIB.DEVLNK.MX = lib$(NAME)mx.dylib
LIB.SHARED.MX = lib$(NAME)mx.$(SO_VERSION).dylib
LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -dynamiclib -install_name $(REGAL_DEST)/lib/$(LIB.SHARED.MX) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)

View file

@ -0,0 +1,30 @@
NAME = $(REGAL_NAME)
CC = cc
LD = cc
EXT.DYNAMIC = dylib
CFLAGS.EXTRA = -arch x86_64 -no-cpp-precomp -dynamic -fno-common
PICFLAG = -fPIC
LDFLAGS.EXTRA = -arch x86_64
ifneq (undefined, $(origin REGAL_APPLE_GLX))
CFLAGS.EXTRA += -I/usr/X11R6/include -D'REGAL_APPLE_GLX'
LDFLAGS.GL = -L/usr/X11R6/lib -lXmu -lXi -lGLU -lGL -lXext -lX11
else
LDFLAGS.GL = -framework AGL -framework OpenGL
LDFLAGS.GLUT = -framework GLUT
endif
LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = -dynamiclib
WARN = -Wall -W -Wno-unused-parameter
POPT = -O2
BIN.SUFFIX =
LIB.SONAME = lib$(NAME).$(SO_MAJOR).dylib
LIB.DEVLNK = lib$(NAME).dylib
LIB.SHARED = lib$(NAME).$(SO_VERSION).dylib
LIB.STATIC = lib$(NAME).a
LIB.FRAMEWORK = $(NAME)
LDFLAGS.SO = $(LDFLAGS.DYNAMIC) -install_name $(REGAL_DEST)/lib/$(LIB.SHARED) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)
LIB.SONAME.MX = lib$(NAME)mx.$(SO_MAJOR).dylib
LIB.DEVLNK.MX = lib$(NAME)mx.dylib
LIB.SHARED.MX = lib$(NAME)mx.$(SO_VERSION).dylib
LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = -dynamiclib -install_name $(REGAL_DEST)/lib/$(LIB.SHARED.MX) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)

30
config/Makefile.linux Normal file
View file

@ -0,0 +1,30 @@
NAME = $(REGAL_NAME)
CC = cc
LD = cc
EXT.DYNAMIC = so
PICFLAG = -fPIC
M_ARCH ?= $(shell uname -m)
ifeq (x86_64,${M_ARCH})
LDFLAGS.EXTRA = -L/usr/X11R6/lib64
LIBDIR = $(REGAL_DEST)/lib64
else
LDFLAGS.EXTRA = -L/usr/X11R6/lib
LIBDIR = $(REGAL_DEST)/lib
endif
LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11
LDFLAGS.GLUT = -lglut
LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = -shared
WARN = -Wall -W -Wno-unused-parameter
POPT = -O2
BIN.SUFFIX =
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
LIB.DEVLNK = lib$(NAME).so
LIB.SHARED = lib$(NAME).so.$(SO_VERSION)
LIB.STATIC = lib$(NAME).a
LDFLAGS.SO = $(LDFLAGS.DYNAMIC) -Wl,-soname=$(LIB.SONAME)
LIB.SONAME.MX = lib$(NAME)mx.so.$(SO_MAJOR)
LIB.DEVLNK.MX = lib$(NAME)mx.so
LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = $(LDFLAGS.DYNAMIC) -Wl,-soname=$(LIB.SONAME.MX)

32
config/Makefile.linux-32 Normal file
View file

@ -0,0 +1,32 @@
NAME = $(REGAL_NAME)
CC = cc
LD = cc
EXT.DYNAMIC = so
PICFLAG = -fPIC
M_ARCH ?= $(shell uname -m)
ifeq (x86_64,${M_ARCH})
LDFLAGS.EXTRA = -L/usr/X11R6/lib64
LIBDIR = $(REGAL_DEST)/lib64
else
LDFLAGS.EXTRA = -L/usr/X11R6/lib
LIBDIR = $(REGAL_DEST)/lib
endif
CFLAGS.EXTRA += -m32
LDFLAGS.EXTRA += -m32
LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11
LDFLAGS.GLUT = -lglut
LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = -shared
WARN = -Wall -W -Wno-unused-parameter
POPT = -O2
BIN.SUFFIX =
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
LIB.DEVLNK = lib$(NAME).so
LIB.SHARED = lib$(NAME).so.$(SO_VERSION)
LIB.STATIC = lib$(NAME).a
LDFLAGS.SO = $(LDFLAGS.DYNAMIC) -Wl,-soname=$(LIB.SONAME)
LIB.SONAME.MX = lib$(NAME)mx.so.$(SO_MAJOR)
LIB.DEVLNK.MX = lib$(NAME)mx.so
LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = $(LDFLAGS.DYNAMIC) -Wl,-soname=$(LIB.SONAME.MX)

32
config/Makefile.linux-64 Normal file
View file

@ -0,0 +1,32 @@
NAME = $(REGAL_NAME)
CC = cc
LD = cc
EXT.DYNAMIC = so
PICFLAG = -fPIC
M_ARCH ?= $(shell uname -m)
ifeq (x86_64,${M_ARCH})
LDFLAGS.EXTRA = -L/usr/X11R6/lib64
LIBDIR = $(REGAL_DEST)/lib64
else
LDFLAGS.EXTRA = -L/usr/X11R6/lib
LIBDIR = $(REGAL_DEST)/lib
endif
CFLAGS.EXTRA += -m64
LDFLAGS.EXTRA += -m64
LDFLAGS.GL = -lXmu -lXi -lGLU -lGL -lXext -lX11
LDFLAGS.GLUT = -lglut
LDFLAGS.STATIC =
LDFLAGS.DYNAMIC = -shared
WARN = -Wall -W -Wno-unused-parameter
POPT = -O2
BIN.SUFFIX =
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
LIB.DEVLNK = lib$(NAME).so
LIB.SHARED = lib$(NAME).so.$(SO_VERSION)
LIB.STATIC = lib$(NAME).a
LDFLAGS.SO = $(LDFLAGS.DYNAMIC) -Wl,-soname=$(LIB.SONAME)
LIB.SONAME.MX = lib$(NAME)mx.so.$(SO_MAJOR)
LIB.DEVLNK.MX = lib$(NAME)mx.so
LIB.SHARED.MX = lib$(NAME)mx.so.$(SO_VERSION)
LIB.STATIC.MX = lib$(NAME)mx.a
LDFLAGS.SO.MX = $(LDFLAGS.DYNAMIC) -Wl,-soname=$(LIB.SONAME.MX)

1523
config/config.guess vendored Executable file

File diff suppressed because it is too large Load diff

7
config/version Normal file
View file

@ -0,0 +1,7 @@
REGAL_MAJOR = 1
REGAL_MINOR = 0
REGAL_MICRO = 0
REGAL_VERSION = $(REGAL_MAJOR).$(REGAL_MINOR).$(REGAL_MICRO)
REGAL_NAME = Regal
SO_MAJOR = $(REGAL_MAJOR).$(REGAL_MINOR)
SO_VERSION = $(REGAL_VERSION)

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>minimalAndroid</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nvidia.minimalAndroid">
<application
android:label="@string/minimalAndroid_activity"
>
<activity android:name="MinimalAndroidActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-feature android:glEsVersion="0x00020000"/>
<uses-sdk android:minSdkVersion="10"/>
</manifest>

View file

@ -0,0 +1,2 @@
# Project target.
target=android-15

View file

@ -0,0 +1,45 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libminimalAndroid
LOCAL_CFLAGS := -Werror
LOCAL_ARM_MODE := arm
REGAL_DIR := ../../../..
REGAL_SRC = $(REGAL_DIR)/src/RegalIff.cpp
REGAL_SRC += $(REGAL_DIR)/gen/Regal.cpp
REGAL_SRC += $(REGAL_DIR)/gen/RegalEmuDispatch.cpp
REGAL_SRC += $(REGAL_DIR)/gen/RegalErrorDispatch.cpp
REGAL_SRC += $(REGAL_DIR)/gen/RegalLoaderDispatch.cpp
REGAL_INC := $(REGAL_DIR)/gen $(REGAL_DIR)/src
SHARED_DIR := ../../src
REGAL_SRC_FILES := $(wildcard $(REGAL_DIR)/src/*.cpp $(REGAL_DIR)/gen/*.cpp)
LOCAL_C_INCLUDES := $(patsubst %, $(LOCAL_PATH)/%, $(REGAL_INC) $(SHARED_DIR) )
LOCAL_SRC_FILES := $(REGAL_SRC)
LOCAL_SRC_FILES += gl_code.cpp $(SHARED_DIR)/render.cpp
LOCAL_CFLAGS := -DANDROID=1
LOCAL_LDLIBS := -llog
#-lGLESv2
include $(BUILD_SHARED_LIBRARY)

View file

@ -0,0 +1,3 @@
APP_STL := stlport_static

View file

@ -0,0 +1,19 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := Regal
LOCAL_CFLAGS := -Werror
LOCAL_ARM_MODE := arm
REGAL_DIR := ../../..
REGAL_GEN := $(REGAL_DIR)/gen
REGAL_SRC := $(REGAL_DIR)/src
REGAL_SRC_FILES := $(wildcard $(REGAL_SRC)/*.cpp) $(wildcard $(REGAL_GEN)/*.cpp)
LOCAL_C_INCLUDES := $(REGAL_GEN) $(REGAL_SRC)
LOCAL_SRC_FILES := $(REGAL_SRC_FILES)
LOCAL_CFLAGS := -DANDROID=1
include $(BUILD_STATIC_LIBRARY)

View file

@ -0,0 +1,197 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// OpenGL ES 2.0 code
#include <jni.h>
#include <android/log.h>
#include <GL/Regal.h>
#include "render.h"
#include <cmath>
#include <cstdio>
#include <cstdlib>
#define LOG_TAG "libgl2jni"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
static void printGLString(const char *name, GLenum s) {
const char *v = (const char *) glGetString(s);
LOGI("GL %s = %s\n", name, v);
}
static void checkGlError(const char* op) {
for (GLint error = glGetError(); error; error
= glGetError()) {
LOGI("after %s() glError (0x%x)\n", op, error);
}
}
static const char gVertexShader[] =
"attribute vec4 vPosition;\n"
"void main() {\n"
" gl_Position = vPosition;\n"
"}\n";
static const char gFragmentShader[] =
"precision mediump float;\n"
"void main() {\n"
" gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
"}\n";
GLuint loadShader(GLenum shaderType, const char* pSource) {
GLuint shader = glCreateShader(shaderType);
if (shader) {
glShaderSource(shader, 1, &pSource, NULL);
glCompileShader(shader);
GLint compiled = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
if (!compiled) {
GLint infoLen = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
if (infoLen) {
char* buf = (char*) malloc(infoLen);
if (buf) {
glGetShaderInfoLog(shader, infoLen, NULL, buf);
LOGE("Could not compile shader %d:\n%s\n",
shaderType, buf);
free(buf);
}
glDeleteShader(shader);
shader = 0;
}
}
}
return shader;
}
GLuint createProgram(const char* pVertexSource, const char* pFragmentSource) {
GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource);
if (!vertexShader) {
return 0;
}
GLuint pixelShader = loadShader(GL_FRAGMENT_SHADER, pFragmentSource);
if (!pixelShader) {
return 0;
}
GLuint program = glCreateProgram();
if (program) {
glAttachShader(program, vertexShader);
checkGlError("glAttachShader");
glAttachShader(program, pixelShader);
checkGlError("glAttachShader");
glLinkProgram(program);
GLint linkStatus = GL_FALSE;
glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
if (linkStatus != GL_TRUE) {
GLint bufLength = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &bufLength);
if (bufLength) {
char* buf = (char*) malloc(bufLength);
if (buf) {
glGetProgramInfoLog(program, bufLength, NULL, buf);
LOGE("Could not link program:\n%s\n", buf);
free(buf);
}
}
glDeleteProgram(program);
program = 0;
}
}
return program;
}
GLuint gProgram;
GLuint gvPositionHandle;
static bool initialized = false;
void initialize() {
if( initialized ) {
return;
}
initialized = true;
RegalMakeCurrent( eglGetCurrentContext() );
}
bool setupGraphics(int w, int h) {
initialize();
printGLString("Version", GL_VERSION);
printGLString("Vendor", GL_VENDOR);
printGLString("Renderer", GL_RENDERER);
printGLString("Extensions", GL_EXTENSIONS);
LOGI("setupGraphics(%d, %d)", w, h);
gProgram = createProgram(gVertexShader, gFragmentShader);
if (!gProgram) {
LOGE("Could not create program.");
return false;
}
gvPositionHandle = glGetAttribLocation(gProgram, "vPosition");
checkGlError("glGetAttribLocation");
LOGI("glGetAttribLocation(\"vPosition\") = %d\n",
gvPositionHandle);
reshape( w, h );
checkGlError("glViewport");
return true;
}
const GLfloat gTriangleVertices[] = { 0.0f, 0.5f, -0.5f, -0.5f,
0.5f, -0.5f };
void renderFrame() {
static float grey;
grey += 0.01f;
if (grey > 1.0f) {
grey = 0.0f;
}
glClearColor(grey, grey, grey, 1.0f);
checkGlError("glClearColor");
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
checkGlError("glClear");
glUseProgram(gProgram);
checkGlError("glUseProgram");
glVertexAttribPointer(gvPositionHandle, 2, GL_FLOAT, GL_FALSE, 0, gTriangleVertices);
checkGlError("glVertexAttribPointer");
glEnableVertexAttribArray(gvPositionHandle);
checkGlError("glEnableVertexAttribArray");
glDrawArrays(GL_TRIANGLES, 0, 3);
checkGlError("glDrawArrays");
display( false );
}
extern "C" {
JNIEXPORT void JNICALL Java_com_nvidia_minimalAndroid_MinimalAndroidLib_init(JNIEnv * env, jobject obj, jint width, jint height);
JNIEXPORT void JNICALL Java_com_nvidia_minimalAndroid_MinimalAndroidLib_step(JNIEnv * env, jobject obj);
};
JNIEXPORT void JNICALL Java_com_nvidia_minimalAndroid_MinimalAndroidLib_init(JNIEnv * env, jobject obj, jint width, jint height)
{
setupGraphics(width, height);
}
JNIEXPORT void JNICALL Java_com_nvidia_minimalAndroid_MinimalAndroidLib_step(JNIEnv * env, jobject obj)
{
renderFrame();
}

View file

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-10

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<!-- This file contains resource definitions for displayed strings, allowing
them to be changed based on the locale and options. -->
<resources>
<!-- Simple strings. -->
<string name="minimalAndroid_activity">minimalAndroid</string>
</resources>

View file

@ -0,0 +1,46 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nvidia.minimalAndroid;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
import java.io.File;
public class MinimalAndroidActivity extends Activity {
MinimalAndroidView mView;
@Override protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mView = new MinimalAndroidView(getApplication());
setContentView(mView);
}
@Override protected void onPause() {
super.onPause();
mView.onPause();
}
@Override protected void onResume() {
super.onResume();
mView.onResume();
}
}

View file

@ -0,0 +1,33 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nvidia.minimalAndroid;
// Wrapper for native library
public class MinimalAndroidLib {
static {
System.loadLibrary("minimalAndroid");
}
/**
* @param width the current view width
* @param height the current view height
*/
public static native void init(int width, int height);
public static native void step();
}

View file

@ -0,0 +1,339 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nvidia.minimalAndroid;
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.content.Context;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10;
/**
* A simple GLSurfaceView sub-class that demonstrate how to perform
* OpenGL ES 2.0 rendering into a GL Surface. Note the following important
* details:
*
* - The class must use a custom context factory to enable 2.0 rendering.
* See ContextFactory class definition below.
*
* - The class must use a custom EGLConfigChooser to be able to select
* an EGLConfig that supports 2.0. This is done by providing a config
* specification to eglChooseConfig() that has the attribute
* EGL10.ELG_RENDERABLE_TYPE containing the EGL_OPENGL_ES2_BIT flag
* set. See ConfigChooser class definition below.
*
* - The class must select the surface's format, then choose an EGLConfig
* that matches it exactly (with regards to red/green/blue/alpha channels
* bit depths). Failure to do so would result in an EGL_BAD_MATCH error.
*/
class MinimalAndroidView extends GLSurfaceView {
private static String TAG = "MinimalAndroidView";
private static final boolean DEBUG = false;
public MinimalAndroidView(Context context) {
super(context);
init(false, 0, 0);
}
public MinimalAndroidView(Context context, boolean translucent, int depth, int stencil) {
super(context);
init(translucent, depth, stencil);
}
private void init(boolean translucent, int depth, int stencil) {
/* By default, GLSurfaceView() creates a RGB_565 opaque surface.
* If we want a translucent one, we should change the surface's
* format here, using PixelFormat.TRANSLUCENT for GL Surfaces
* is interpreted as any 32-bit surface with alpha by SurfaceFlinger.
*/
if (translucent) {
this.getHolder().setFormat(PixelFormat.TRANSLUCENT);
}
/* Setup the context factory for 2.0 rendering.
* See ContextFactory class definition below
*/
setEGLContextFactory(new ContextFactory());
/* We need to choose an EGLConfig that matches the format of
* our surface exactly. This is going to be done in our
* custom config chooser. See ConfigChooser class definition
* below.
*/
setEGLConfigChooser( translucent ?
new ConfigChooser(8, 8, 8, 8, depth, stencil) :
new ConfigChooser(5, 6, 5, 0, depth, stencil) );
/* Set the renderer responsible for frame rendering */
setRenderer(new Renderer());
}
private static class ContextFactory implements GLSurfaceView.EGLContextFactory {
private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
Log.w(TAG, "creating OpenGL ES 2.0 context");
checkEglError("Before eglCreateContext", egl);
int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
checkEglError("After eglCreateContext", egl);
return context;
}
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
egl.eglDestroyContext(display, context);
}
}
private static void checkEglError(String prompt, EGL10 egl) {
int error;
while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
}
}
private static class ConfigChooser implements GLSurfaceView.EGLConfigChooser {
public ConfigChooser(int r, int g, int b, int a, int depth, int stencil) {
mRedSize = r;
mGreenSize = g;
mBlueSize = b;
mAlphaSize = a;
mDepthSize = depth;
mStencilSize = stencil;
}
/* This EGL config specification is used to specify 2.0 rendering.
* We use a minimum size of 4 bits for red/green/blue, but will
* perform actual matching in chooseConfig() below.
*/
private static int EGL_OPENGL_ES2_BIT = 4;
private static int[] s_configAttribs2 =
{
EGL10.EGL_RED_SIZE, 4,
EGL10.EGL_GREEN_SIZE, 4,
EGL10.EGL_BLUE_SIZE, 4,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL10.EGL_NONE
};
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
/* Get the number of minimally matching EGL configurations
*/
int[] num_config = new int[1];
egl.eglChooseConfig(display, s_configAttribs2, null, 0, num_config);
int numConfigs = num_config[0];
if (numConfigs <= 0) {
throw new IllegalArgumentException("No configs match configSpec");
}
/* Allocate then read the array of minimally matching EGL configs
*/
EGLConfig[] configs = new EGLConfig[numConfigs];
egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config);
if (DEBUG) {
printConfigs(egl, display, configs);
}
/* Now return the "best" one
*/
return chooseConfig(egl, display, configs);
}
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
EGLConfig[] configs) {
for(EGLConfig config : configs) {
int d = findConfigAttrib(egl, display, config,
EGL10.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(egl, display, config,
EGL10.EGL_STENCIL_SIZE, 0);
// We need at least mDepthSize and mStencilSize bits
if (d < mDepthSize || s < mStencilSize)
continue;
// We want an *exact* match for red/green/blue/alpha
int r = findConfigAttrib(egl, display, config,
EGL10.EGL_RED_SIZE, 0);
int g = findConfigAttrib(egl, display, config,
EGL10.EGL_GREEN_SIZE, 0);
int b = findConfigAttrib(egl, display, config,
EGL10.EGL_BLUE_SIZE, 0);
int a = findConfigAttrib(egl, display, config,
EGL10.EGL_ALPHA_SIZE, 0);
if (r == mRedSize && g == mGreenSize && b == mBlueSize && a == mAlphaSize)
return config;
}
return null;
}
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
EGLConfig config, int attribute, int defaultValue) {
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
return mValue[0];
}
return defaultValue;
}
private void printConfigs(EGL10 egl, EGLDisplay display,
EGLConfig[] configs) {
int numConfigs = configs.length;
Log.w(TAG, String.format("%d configurations", numConfigs));
for (int i = 0; i < numConfigs; i++) {
Log.w(TAG, String.format("Configuration %d:\n", i));
printConfig(egl, display, configs[i]);
}
}
private void printConfig(EGL10 egl, EGLDisplay display,
EGLConfig config) {
int[] attributes = {
EGL10.EGL_BUFFER_SIZE,
EGL10.EGL_ALPHA_SIZE,
EGL10.EGL_BLUE_SIZE,
EGL10.EGL_GREEN_SIZE,
EGL10.EGL_RED_SIZE,
EGL10.EGL_DEPTH_SIZE,
EGL10.EGL_STENCIL_SIZE,
EGL10.EGL_CONFIG_CAVEAT,
EGL10.EGL_CONFIG_ID,
EGL10.EGL_LEVEL,
EGL10.EGL_MAX_PBUFFER_HEIGHT,
EGL10.EGL_MAX_PBUFFER_PIXELS,
EGL10.EGL_MAX_PBUFFER_WIDTH,
EGL10.EGL_NATIVE_RENDERABLE,
EGL10.EGL_NATIVE_VISUAL_ID,
EGL10.EGL_NATIVE_VISUAL_TYPE,
0x3030, // EGL10.EGL_PRESERVED_RESOURCES,
EGL10.EGL_SAMPLES,
EGL10.EGL_SAMPLE_BUFFERS,
EGL10.EGL_SURFACE_TYPE,
EGL10.EGL_TRANSPARENT_TYPE,
EGL10.EGL_TRANSPARENT_RED_VALUE,
EGL10.EGL_TRANSPARENT_GREEN_VALUE,
EGL10.EGL_TRANSPARENT_BLUE_VALUE,
0x3039, // EGL10.EGL_BIND_TO_TEXTURE_RGB,
0x303A, // EGL10.EGL_BIND_TO_TEXTURE_RGBA,
0x303B, // EGL10.EGL_MIN_SWAP_INTERVAL,
0x303C, // EGL10.EGL_MAX_SWAP_INTERVAL,
EGL10.EGL_LUMINANCE_SIZE,
EGL10.EGL_ALPHA_MASK_SIZE,
EGL10.EGL_COLOR_BUFFER_TYPE,
EGL10.EGL_RENDERABLE_TYPE,
0x3042 // EGL10.EGL_CONFORMANT
};
String[] names = {
"EGL_BUFFER_SIZE",
"EGL_ALPHA_SIZE",
"EGL_BLUE_SIZE",
"EGL_GREEN_SIZE",
"EGL_RED_SIZE",
"EGL_DEPTH_SIZE",
"EGL_STENCIL_SIZE",
"EGL_CONFIG_CAVEAT",
"EGL_CONFIG_ID",
"EGL_LEVEL",
"EGL_MAX_PBUFFER_HEIGHT",
"EGL_MAX_PBUFFER_PIXELS",
"EGL_MAX_PBUFFER_WIDTH",
"EGL_NATIVE_RENDERABLE",
"EGL_NATIVE_VISUAL_ID",
"EGL_NATIVE_VISUAL_TYPE",
"EGL_PRESERVED_RESOURCES",
"EGL_SAMPLES",
"EGL_SAMPLE_BUFFERS",
"EGL_SURFACE_TYPE",
"EGL_TRANSPARENT_TYPE",
"EGL_TRANSPARENT_RED_VALUE",
"EGL_TRANSPARENT_GREEN_VALUE",
"EGL_TRANSPARENT_BLUE_VALUE",
"EGL_BIND_TO_TEXTURE_RGB",
"EGL_BIND_TO_TEXTURE_RGBA",
"EGL_MIN_SWAP_INTERVAL",
"EGL_MAX_SWAP_INTERVAL",
"EGL_LUMINANCE_SIZE",
"EGL_ALPHA_MASK_SIZE",
"EGL_COLOR_BUFFER_TYPE",
"EGL_RENDERABLE_TYPE",
"EGL_CONFORMANT"
};
int[] value = new int[1];
for (int i = 0; i < attributes.length; i++) {
int attribute = attributes[i];
String name = names[i];
if ( egl.eglGetConfigAttrib(display, config, attribute, value)) {
Log.w(TAG, String.format(" %s: %d\n", name, value[0]));
} else {
// Log.w(TAG, String.format(" %s: failed\n", name));
while (egl.eglGetError() != EGL10.EGL_SUCCESS);
}
}
}
// Subclasses can adjust these values:
protected int mRedSize;
protected int mGreenSize;
protected int mBlueSize;
protected int mAlphaSize;
protected int mDepthSize;
protected int mStencilSize;
private int[] mValue = new int[1];
}
private static class Renderer implements GLSurfaceView.Renderer {
public void onDrawFrame(GL10 gl) {
MinimalAndroidLib.step();
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
MinimalAndroidLib.init(width, height);
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// Do nothing.
}
}
}

View file

@ -0,0 +1,63 @@
//
// main.cpp
// minimal_glut
//
// Created by Cass Everitt on 2/1/12.
// Copyright (c) 2012 n/a. All rights reserved.
//
#include <GL/Regal.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/RegalGLUT.h>
#endif
#include "render.h"
#include <cstdlib>
static void myDisplay()
{
display(true);
glutSwapBuffers();
}
static void myTick(int dummy)
{
glutPostRedisplay();
glutTimerFunc( 16, myTick, 0 );
}
static void myKeyboard(unsigned char c, int x, int y)
{
switch (c)
{
case 'q':
case 27: /* Esc key */
exit(0);
break;
}
}
int main(int argc, const char *argv[])
{
glutInitDisplayString("rgba>=8 depth double");
glutInitWindowSize(500, 500);
glutInit( &argc, (char **) argv);
glutCreateWindow("dreamtorus");
// Regal workaround for OSX GLUT
#ifdef __APPLE__
RegalMakeCurrent(CGLGetCurrentContext());
#endif
glutTimerFunc(16, myTick, 0);
glutDisplayFunc(myDisplay);
glutReshapeFunc(reshape);
glutKeyboardFunc(myKeyboard);
glutMainLoop();
return 0;
}

View file

@ -0,0 +1,36 @@
all: dreamtorus
clean:
rm -f dreamtorus
rm -rf obj
REGAL_DIR := ../../../../regal
REGAL_SRC := $(wildcard $(REGAL_DIR)/gen/*.cpp $(REGAL_DIR)/src/*.cpp)
REGAL_INC := $(REGAL_DIR)/gen $(REGAL_DIR)/src
SHARED_DIR := ../src
SHARED_SRC := $(wildcard $(SHARED_DIR)/*.cpp)
SHARED_INC := $(SHARED_DIR)
LOCAL_SRC := $(wildcard *.cpp)
MY_SRC := $(REGAL_SRC) $(LOCAL_SRC) $(SHARED_SRC)
MY_SRC_DIRS := $(sort $(dir $(MY_SRC)))
MY_OBJ := $(MY_SRC)
MY_OBJ := $(patsubst %.cpp, obj$(CURDIR)/%.o, $(MY_OBJ))
MY_OBJ := $(patsubst %.c, obj$(CURDIR)/%.o, $(MY_OBJ))
MY_OBJ_DIRS := $(sort $(dir $(MY_OBJ)))
MY_INC := $(REGAL_INC) $(SHARED_INC)
MY_CMD_INC := $(patsubst %, -I %, $(MY_INC))
obj$(CURDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
g++ -g -c -o $@ $(MY_CMD_INC) $<
@echo $@ ---- $<
dreamtorus: $(MY_OBJ)
g++ -g -o $@ $(MY_OBJ) -lX11 -lpthread

View file

@ -0,0 +1,105 @@
#include <X11/Xdefs.h>
#include <X11/Xutil.h>
typedef XID GLXDrawable;
#include <GL/Regal.h>
#include "render.h"
#include <unistd.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
int main (int argc, char ** argv)
{
Display *dpy = XOpenDisplay(0);
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = NULL;
const char *extensions = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
printf("%s\n",extensions);
static int visual_attribs[] =
{
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, true,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None
};
printf("Getting framebuffer config.\n");
int fbcount;
GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), visual_attribs, &fbcount);
if (!fbc)
{
printf("Failed to retrieve a framebuffer config.\n");
return 1;
}
printf("Getting XVisualInfo\n");
XVisualInfo *vi = glXGetVisualFromFBConfig(dpy, fbc[0]);
XSetWindowAttributes swa;
printf("Creating colormap\n");
swa.colormap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
swa.border_pixel = 0;
swa.event_mask = StructureNotifyMask;
printf("Creating window\n");
int width = 500;
int height = 500;
Window win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, width, height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel|CWColormap|CWEventMask, &swa);
if (!win)
{
printf("Failed to create window\n");
return 1;
}
printf("Mapping window\n");
XMapWindow(dpy, win);
// Create an oldstyle context first, to get the correct function pointer for glXCreateContextAttribsARB
GLXContext ctx_old = glXCreateContext(dpy, vi, 0, GL_TRUE);
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
printf("glxCreateContextAttribsARB %p\n",glXCreateContextAttribsARB);
glXMakeCurrent(dpy, 0, 0);
glXDestroyContext(dpy, ctx_old);
if (glXCreateContextAttribsARB == NULL)
{
printf("glXCreateContextAttribsARB entry point not found. Aborting.\n");
return false;
}
static int context_attribs[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
None
};
printf("Creating context\n");
GLXContext ctx = glXCreateContextAttribsARB(dpy, fbc[0], NULL, true, context_attribs);
if (!ctx)
{
printf("Failed to create GL3 context.\n");
return 1;
}
printf("Making context current.\n");
glXMakeCurrent(dpy, win, ctx);
reshape( width, height );
for(int i = 0; i < 1000000; i++ ) {
display( true );
usleep( 16000 );
glXSwapBuffers( dpy, win );
}
ctx = glXGetCurrentContext();
glXMakeCurrent(dpy, 0, 0);
glXDestroyContext(dpy, ctx);
}

View file

@ -0,0 +1,16 @@
/* Copyright (c) 2006-2007 Christopher J. W. Lloyd
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 THE AUTHORS OR COPYRIGHT HOLDERS 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. */
#import <OpenGLES/EAGL.h>
@interface RGLOpenGLContext : NSObject {
}
+ (BOOL) setCurrentContext:(EAGLContext*) context;
@end

View file

@ -0,0 +1,15 @@
#import "RGLOpenGLContext.h"
void RegalMakeCurrent( void * sysctx );
@implementation RGLOpenGLContext
+ (BOOL)setCurrentContext: (EAGLContext*) context
{
BOOL res = [EAGLContext setCurrentContext: context];
RegalMakeCurrent( (void *)context );
return res;
}
@end

View file

@ -0,0 +1,34 @@
//
// EAGLView.h
// OpenGLES_iPhone
//
// Created by mmalc Crawford on 11/18/10.
// Copyright 2010 Apple Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
@class EAGLContext;
// This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
// The view content is basically an EAGL surface you render your OpenGL scene into.
// Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
@interface EAGLView : UIView {
// The pixel dimensions of the CAEAGLLayer.
GLint framebufferWidth;
GLint framebufferHeight;
// The OpenGL ES names for the framebuffer and renderbuffer used to render to this view.
GLuint defaultFramebuffer, colorRenderbuffer, depthRenderbuffer;
}
@property (nonatomic, retain) EAGLContext *context;
- (void)setFramebuffer;
- (BOOL)presentFramebuffer;
@end

View file

@ -0,0 +1,148 @@
//
// EAGLView.m
// OpenGLES_iPhone
//
// Created by mmalc Crawford on 11/18/10.
// Copyright 2010 Apple Inc. All rights reserved.
//
#import "EAGLView.h"
#import "RGLOpenGLContext.h"
#import <QuartzCore/QuartzCore.h>
#include "render.h"
@interface EAGLView (PrivateMethods)
- (void)createFramebuffer;
- (void)deleteFramebuffer;
@end
@implementation EAGLView
@synthesize context;
// You must implement this method
+ (Class)layerClass
{
return [CAEAGLLayer class];
}
//The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:.
- (id)initWithCoder:(NSCoder*)coder
{
self = [super initWithCoder:coder];
if (self) {
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = TRUE;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
nil];
}
return self;
}
- (void)dealloc
{
[self deleteFramebuffer];
[context release];
[super dealloc];
}
- (void)setContext:(EAGLContext *)newContext
{
if (context != newContext) {
[self deleteFramebuffer];
[context release];
context = [newContext retain];
[RGLOpenGLContext setCurrentContext:nil];
}
}
- (void)createFramebuffer
{
if (context && !defaultFramebuffer) {
[RGLOpenGLContext setCurrentContext:context];
// Create default framebuffer object.
glGenFramebuffers(1, &defaultFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
// Create color render buffer and allocate backing store.
glGenRenderbuffers(1, &colorRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer];
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &framebufferWidth);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &framebufferHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER, depthRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, framebufferWidth, framebufferHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
}
}
- (void)deleteFramebuffer
{
if (context) {
[RGLOpenGLContext setCurrentContext:context];
if (defaultFramebuffer) {
glDeleteFramebuffers(1, &defaultFramebuffer);
defaultFramebuffer = 0;
}
if (colorRenderbuffer) {
glDeleteRenderbuffers(1, &colorRenderbuffer);
colorRenderbuffer = 0;
}
}
}
- (void)setFramebuffer
{
if (context) {
[RGLOpenGLContext setCurrentContext:context];
if (!defaultFramebuffer)
[self createFramebuffer];
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
reshape( framebufferWidth, framebufferHeight);
}
}
- (BOOL)presentFramebuffer
{
BOOL success = FALSE;
if (context) {
[RGLOpenGLContext setCurrentContext:context];
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
success = [context presentRenderbuffer:GL_RENDERBUFFER];
}
return success;
}
- (void)layoutSubviews
{
// The framebuffer will be re-created at the beginning of the next setFramebuffer method call.
[self deleteFramebuffer];
}
@end

View file

@ -0,0 +1,7 @@
in vec4 colorVarying;
void main()
{
gl_FragColor = colorVarying;
}

View file

@ -0,0 +1,16 @@
in vec4 position;
in vec4 color;
out vec4 colorVarying;
uniform float translate;
void main()
{
gl_Position = position;
gl_Position.y += sin(translate) / 2.0;
gl_Position.z = 0.9;
colorVarying = color;
}

View file

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

View file

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1056</int>
<string key="IBDocument.SystemVersion">10H574</string>
<string key="IBDocument.InterfaceBuilderVersion">1248</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">106</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>IBUIWindow</string>
<string>IBUICustomObject</string>
<string>IBUIViewController</string>
<string>IBProxyObject</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="dict.values" ref="0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBProxyObject" id="841351856">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="191355593">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUICustomObject" id="664661524">
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIViewController" id="692423605">
<string key="IBUINibName">minimal_iosViewController</string>
<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
<int key="IBUIInterfaceOrientation">1</int>
<int key="interfaceOrientation">1</int>
</object>
<bool key="IBUIWantsFullScreenLayout">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIHorizontal">NO</bool>
</object>
<object class="IBUIWindow" id="380026005">
<nil key="NSNextResponder"/>
<int key="NSvFlags">1316</int>
<object class="NSPSMatrix" key="NSFrameMatrix"/>
<string key="NSFrameSize">{320, 460}</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIVisibleAtLaunch">YES</bool>
<bool key="IBUIResizesToFullScreen">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="664661524"/>
</object>
<int key="connectionID">4</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="380026005"/>
</object>
<int key="connectionID">5</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">viewController</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="692423605"/>
</object>
<int key="connectionID">11</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="380026005"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="841351856"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="664661524"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="191355593"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="692423605"/>
<reference key="parent" ref="0"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
<string>10.CustomClassName</string>
<string>10.IBEditorWindowLastContentRect</string>
<string>10.IBPluginDependency</string>
<string>2.IBAttributePlaceholdersKey</string>
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
<string>3.CustomClassName</string>
<string>3.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIApplication</string>
<string>UIResponder</string>
<string>minimal_iosViewController</string>
<string>{{415, 586}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSMutableDictionary">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<string>{{228, 376}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>minimal_iosAppDelegate</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">11</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3100" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">OpenGLES_iPhone.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">106</string>
</data>
</archive>

View file

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1024</int>
<string key="IBDocument.SystemVersion">10H574</string>
<string key="IBDocument.InterfaceBuilderVersion">1248</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">106</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>IBProxyObject</string>
<string>IBUIView</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="dict.values" ref="0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBProxyObject" id="841351856">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="371349661">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="184854543">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="184854543"/>
</object>
<int key="connectionID">3</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="841351856"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="371349661"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="184854543"/>
<reference key="parent" ref="0"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
<string>2.CustomClassName</string>
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>minimal_iosViewController</string>
<string>UIResponder</string>
<string>EAGLView</string>
<string>{{401, 662}, {320, 460}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">4</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<integer value="1024" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3100" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">Untitled.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">106</string>
</data>
</archive>

View file

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1056</int>
<string key="IBDocument.SystemVersion">11C74</string>
<string key="IBDocument.InterfaceBuilderVersion">907</string>
<string key="IBDocument.AppKitVersion">1138.23</string>
<string key="IBDocument.HIToolboxVersion">567.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">141</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBProxyObject" id="841351856">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBProxyObject" id="191355593">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBUICustomObject" id="664661524">
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBUIViewController" id="692423605">
<string key="IBUINibName">minimal_iosViewController</string>
<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
<int key="interfaceOrientation">1</int>
</object>
<bool key="IBUIWantsFullScreenLayout">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBUIHorizontal">NO</bool>
</object>
<object class="IBUIWindow" id="380026005">
<nil key="NSNextResponder"/>
<int key="NSvFlags">1316</int>
<object class="NSPSMatrix" key="NSFrameMatrix"/>
<string key="NSFrameSize">{320, 480}</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBUIVisibleAtLaunch">YES</bool>
<bool key="IBUIResizesToFullScreen">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="664661524"/>
</object>
<int key="connectionID">4</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="380026005"/>
</object>
<int key="connectionID">5</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">viewController</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="692423605"/>
</object>
<int key="connectionID">11</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="380026005"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="841351856"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="664661524"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="191355593"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="692423605"/>
<reference key="parent" ref="0"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
<string>10.CustomClassName</string>
<string>10.IBEditorWindowLastContentRect</string>
<string>10.IBPluginDependency</string>
<string>2.IBAttributePlaceholdersKey</string>
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
<string>3.CustomClassName</string>
<string>3.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIApplication</string>
<string>UIResponder</string>
<string>minimal_iosViewController</string>
<string>{{415, 586}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSMutableDictionary">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<string>{{228, 376}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>minimal_iosAppDelegate</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">11</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBIPadFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<integer value="1056" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3100" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">OpenGLES_iPhone.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">141</string>
</data>
</archive>

View file

@ -0,0 +1,17 @@
//
// main.m
// minimal_ios
//
// Created by Cass Everitt on 1/25/12.
// Copyright 2012 n/a. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>nu.r3.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
<string>MainWindow</string>
<key>NSMainNibFile~ipad</key>
<string>MainWindow-iPad</string>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View file

@ -0,0 +1,14 @@
//
// Prefix header for all source files of the 'minimal_ios' target in the 'minimal_ios' project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

View file

@ -0,0 +1,19 @@
//
// minimal_iosAppDelegate.h
// minimal_ios
//
// Created by Cass Everitt on 1/25/12.
// Copyright 2012 n/a. All rights reserved.
//
#import <UIKit/UIKit.h>
@class minimal_iosViewController;
@interface minimal_iosAppDelegate : NSObject <UIApplicationDelegate>
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet minimal_iosViewController *viewController;
@end

View file

@ -0,0 +1,76 @@
//
// minimal_iosAppDelegate.m
// minimal_ios
//
// Created by Cass Everitt on 1/25/12.
// Copyright 2012 n/a. All rights reserved.
//
#import "minimal_iosAppDelegate.h"
#import "EAGLView.h"
#import "minimal_iosViewController.h"
@implementation minimal_iosAppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
[self.viewController stopAnimation];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
[self.viewController startAnimation];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
[self.viewController stopAnimation];
}
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
@end

View file

@ -0,0 +1,33 @@
//
// minimal_iosViewController.h
// minimal_ios
//
// Created by Cass Everitt on 1/25/12.
// Copyright 2012 n/a. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
@interface minimal_iosViewController : UIViewController {
EAGLContext *context;
GLuint program;
BOOL animating;
NSInteger animationFrameInterval;
CADisplayLink *displayLink;
}
@property (readonly, nonatomic, getter=isAnimating) BOOL animating;
@property (nonatomic) NSInteger animationFrameInterval;
- (void)startAnimation;
- (void)stopAnimation;
@end

View file

@ -0,0 +1,395 @@
//
// minimal_iosViewController.m
// minimal_ios
//
// Created by Cass Everitt on 1/25/12.
// Copyright 2012 n/a. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import "minimal_iosViewController.h"
#import "EAGLView.h"
#include "render.h"
// Uniform index.
enum {
UNIFORM_TRANSLATE,
NUM_UNIFORMS
};
GLint uniforms[NUM_UNIFORMS];
// Attribute index.
enum {
ATTRIB_VERTEX,
ATTRIB_COLOR,
NUM_ATTRIBUTES
};
@interface minimal_iosViewController ()
@property (nonatomic, retain) EAGLContext *context;
@property (nonatomic, assign) CADisplayLink *displayLink;
- (BOOL)loadShaders;
- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file;
- (BOOL)linkProgram:(GLuint)prog;
- (BOOL)validateProgram:(GLuint)prog;
@end
@implementation minimal_iosViewController
@synthesize animating;
@synthesize context;
@synthesize displayLink;
- (void)awakeFromNib
{
EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (!aContext) {
aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
}
if (!aContext)
NSLog(@"Failed to create ES context");
else if (![EAGLContext setCurrentContext:aContext])
NSLog(@"Failed to set ES context current");
self.context = aContext;
[aContext release];
[(EAGLView *)self.view setContext:context];
[(EAGLView *)self.view setFramebuffer];
if ([context API] == kEAGLRenderingAPIOpenGLES2)
[self loadShaders];
animating = FALSE;
animationFrameInterval = 1;
self.displayLink = nil;
}
- (void)dealloc
{
if (program) {
glDeleteProgram(program);
program = 0;
}
// Tear down context.
if ([EAGLContext currentContext] == context)
[EAGLContext setCurrentContext:nil];
[context release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewWillAppear:(BOOL)animated
{
[self startAnimation];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self stopAnimation];
[super viewWillDisappear:animated];
}
- (void)viewDidUnload
{
[super viewDidUnload];
if (program) {
glDeleteProgram(program);
program = 0;
}
// Tear down context.
if ([EAGLContext currentContext] == context)
[EAGLContext setCurrentContext:nil];
self.context = nil;
}
- (NSInteger)animationFrameInterval
{
return animationFrameInterval;
}
- (void)setAnimationFrameInterval:(NSInteger)frameInterval
{
/*
Frame interval defines how many display frames must pass between each time the display link fires.
The display link will only fire 30 times a second when the frame internal is two on a display that refreshes 60 times a second. The default frame interval setting of one will fire 60 times a second when the display refreshes at 60 times a second. A frame interval setting of less than one results in undefined behavior.
*/
if (frameInterval >= 1) {
animationFrameInterval = frameInterval;
if (animating) {
[self stopAnimation];
[self startAnimation];
}
}
}
- (void)startAnimation
{
if (!animating) {
CADisplayLink *aDisplayLink = [[UIScreen mainScreen] displayLinkWithTarget:self selector:@selector(drawFrame)];
[aDisplayLink setFrameInterval:animationFrameInterval];
[aDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
self.displayLink = aDisplayLink;
animating = TRUE;
}
}
- (void)stopAnimation
{
if (animating) {
[self.displayLink invalidate];
self.displayLink = nil;
animating = FALSE;
}
}
- (void)drawFrame
{
[(EAGLView *)self.view setFramebuffer];
// Replace the implementation of this method to do your own custom drawing.
static const GLfloat squareVertices[] = {
-0.5f, -0.33f,
0.5f, -0.33f,
-0.5f, 0.33f,
0.5f, 0.33f,
};
static const GLubyte squareColors[] = {
255, 255, 0, 255,
0, 255, 255, 255,
0, 0, 0, 0,
255, 0, 255, 255,
};
static float transY = 0.0f;
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
glClearDepthf( 1.0f );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable( GL_DEPTH_TEST );
if ([context API] == kEAGLRenderingAPIOpenGLES2) {
// Use shader program.
glUseProgram(program);
// Update uniform value.
glUniform1f(uniforms[UNIFORM_TRANSLATE], (GLfloat)transY);
transY += 0.075f;
// Update attribute values.
glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, squareVertices);
glEnableVertexAttribArray(ATTRIB_VERTEX);
glVertexAttribPointer(ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, 1, 0, squareColors);
glEnableVertexAttribArray(ATTRIB_COLOR);
// Validate program before drawing. This is a good check, but only really necessary in a debug build.
// DEBUG macro must be defined in your debug configurations if that's not already the case.
#if defined(DEBUG)
if (![self validateProgram:program]) {
NSLog(@"Failed to validate program: %d", program);
return;
}
#endif
} else {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, (GLfloat)(sinf(transY)/2.0f), 0.0f);
transY += 0.075f;
glVertexPointer(2, GL_FLOAT, 0, squareVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
glEnableClientState(GL_COLOR_ARRAY);
}
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
static int count = 0;
count++;
if( count > 50 ) {
display( false );
}
[(EAGLView *)self.view presentFramebuffer];
}
- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file
{
GLint status;
const GLchar *source;
source = (GLchar *)[[NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil] UTF8String];
if (!source)
{
NSLog(@"Failed to load vertex shader");
return FALSE;
}
*shader = glCreateShader(type);
glShaderSource(*shader, 1, &source, NULL);
glCompileShader(*shader);
#if defined(DEBUG)
GLint logLength;
glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 0)
{
GLchar *log = (GLchar *)malloc(logLength);
glGetShaderInfoLog(*shader, logLength, &logLength, log);
NSLog(@"Shader compile log:\n%s", log);
free(log);
}
#endif
glGetShaderiv(*shader, GL_COMPILE_STATUS, &status);
if (status == 0)
{
glDeleteShader(*shader);
return FALSE;
}
return TRUE;
}
- (BOOL)linkProgram:(GLuint)prog
{
GLint status;
glLinkProgram(prog);
#if defined(DEBUG)
GLint logLength;
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 0)
{
GLchar *log = (GLchar *)malloc(logLength);
glGetProgramInfoLog(prog, logLength, &logLength, log);
NSLog(@"Program link log:\n%s", log);
free(log);
}
#endif
glGetProgramiv(prog, GL_LINK_STATUS, &status);
if (status == 0)
return FALSE;
return TRUE;
}
- (BOOL)validateProgram:(GLuint)prog
{
GLint logLength, status;
glValidateProgram(prog);
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 0)
{
GLchar *log = (GLchar *)malloc(logLength);
glGetProgramInfoLog(prog, logLength, &logLength, log);
NSLog(@"Program validate log:\n%s", log);
free(log);
}
glGetProgramiv(prog, GL_VALIDATE_STATUS, &status);
if (status == 0)
return FALSE;
return TRUE;
}
- (BOOL)loadShaders
{
GLuint vertShader, fragShader;
NSString *vertShaderPathname, *fragShaderPathname;
// Create shader program.
program = glCreateProgram();
// Create and compile vertex shader.
vertShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"vsh"];
if (![self compileShader:&vertShader type:GL_VERTEX_SHADER file:vertShaderPathname])
{
NSLog(@"Failed to compile vertex shader");
return FALSE;
}
// Create and compile fragment shader.
fragShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"fsh"];
if (![self compileShader:&fragShader type:GL_FRAGMENT_SHADER file:fragShaderPathname])
{
NSLog(@"Failed to compile fragment shader");
return FALSE;
}
// Attach vertex shader to program.
glAttachShader(program, vertShader);
// Attach fragment shader to program.
glAttachShader(program, fragShader);
// Bind attribute locations.
// This needs to be done prior to linking.
glBindAttribLocation(program, ATTRIB_VERTEX, "position");
glBindAttribLocation(program, ATTRIB_COLOR, "color");
// Link program.
if (![self linkProgram:program])
{
NSLog(@"Failed to link program: %d", program);
if (vertShader)
{
glDeleteShader(vertShader);
vertShader = 0;
}
if (fragShader)
{
glDeleteShader(fragShader);
fragShader = 0;
}
if (program)
{
glDeleteProgram(program);
program = 0;
}
return FALSE;
}
// Get uniform locations.
uniforms[UNIFORM_TRANSLATE] = glGetUniformLocation(program, "translate");
// Release vertex and fragment shaders.
if (vertShader)
glDeleteShader(vertShader);
if (fragShader)
glDeleteShader(fragShader);
return TRUE;
}
@end

View file

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,16 @@
/* Copyright (c) 2006-2007 Christopher J. W. Lloyd
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 THE AUTHORS OR COPYRIGHT HOLDERS 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. */
#import <Cocoa/Cocoa.h>
@interface RGLOpenGLContext : NSOpenGLContext {
}
-(void)makeCurrentContext;
@end

View file

@ -0,0 +1,13 @@
#import "RGLOpenGLContext.h"
void RegalMakeCurrent( CGLContextObj ctxobj );
@implementation RGLOpenGLContext
-(void)makeCurrentContext {
[super makeCurrentContext];
RegalMakeCurrent( CGLGetCurrentContext() );
}
@end

View file

@ -0,0 +1,16 @@
//
// GlesView.h
// gles
//
// Created by Cass Everitt on 3/15/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
//#import "RGLOpenGL.h"
#import <Cocoa/Cocoa.h>
@interface GlesView : NSOpenGLView {
}
- (void)render;
@end

View file

@ -0,0 +1,83 @@
//
// GlesView.mm
// gles
//
// Created by Cass Everitt on 3/15/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "RegalView.h"
#import "RGLOpenGLContext.h"
#include "render.h"
#include <stdio.h>
@implementation GlesView
bool resized = false;
NSTimer *timer = nil;
- (id)initWithCoder:(NSCoder *)aDecoder {
[super initWithCoder: aDecoder];
NSOpenGLPixelFormatAttribute attr[] = {
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy, // pick this
//NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, // or this
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFAColorSize, 32,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAStencilSize, 0,
0
};
NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
[self setPixelFormat: fmt];
RGLOpenGLContext *rglCtx = [[RGLOpenGLContext alloc] initWithFormat:fmt shareContext:nil];
[self setOpenGLContext: rglCtx];
[rglCtx setView:self];
timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector (render) userInfo:nil repeats:YES];
resized = false;
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
if( resized == false ) {
return;
}
display( true );
[[self openGLContext] flushBuffer];
}
- (void) render {
[self setNeedsDisplay:YES];
}
- (void)viewDidMoveToWindow
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowResized:) name:NSWindowDidResizeNotification
object:[self window]];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)windowResized:(NSNotification *)notification;
{
NSRect rect = [[[self window] contentView] frame];
NSRect crect = NSRectFromCGRect( CGRectMake( 0, 0, rect.size.width, rect.size.height ) );
[self setFrame: crect];
[self lockFocus];
reshape( rect.size.width, rect.size.height );
resized = true;
[self unlockFocus];
}
@end

View file

@ -0,0 +1,14 @@
//
// main.mm
// gles
//
// Created by Cass Everitt on 3/15/11.
// Copyright 2011. All rights reserved, suckers.
//
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>nv.icns</string>
<key>CFBundleIdentifier</key>
<string>com.nvidia.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View file

@ -0,0 +1,17 @@
//
// glesAppDelegate.h
// gles
//
// Created by Cass Everitt on 3/15/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface glesAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
}
@property (assign) IBOutlet NSWindow *window;
@end

View file

@ -0,0 +1,19 @@
//
// glesAppDelegate.m
// gles
//
// Created by Cass Everitt on 3/15/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "minimal_osxAppDelegate.h"
@implementation glesAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}
@end

View file

@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'gles' target in the 'gles' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

Binary file not shown.

View file

@ -0,0 +1,246 @@
/*
* render.cpp
* gles
*
* Created by Cass Everitt on 3/16/11.
* Copyright 2011 __MyCompanyName__. All rights reserved.
*
*/
#include <GL/Regal.h>
#include "render.h"
#include <cstdio>
#include <cmath>
#ifndef M_PI
#define M_PI 3.141572654
#endif
GLenum texunit = GL_TEXTURE1;
struct Torus {
float circleRadius;
float tubeRadius;
Torus( float c, float t ) : circleRadius( c ), tubeRadius( t ) {}
void Vertex( float u, float v ) {
float theta = u * 2.0 * M_PI;
float rho = v * 2.0 * M_PI;
float x = cos( theta ) * ( circleRadius + cos( rho ) * tubeRadius );
float y = sin( theta ) * ( circleRadius + cos( rho ) * tubeRadius );
float z = sin( rho ) * tubeRadius;
float nx = cos( rho ) * cos(theta);
float ny = cos( rho ) * sin(theta);
float nz = sin( rho );
glNormal3f( nx, ny, nz );
glMultiTexCoord2f( texunit, u, v );
glVertex3f( x, y, z );
}
};
static void drawAnObject() {
Torus t( 0.7f, 0.2f );
int I = 30;
int J = 30;
glColor3f( 0.8, 0.8, 0.8 );
for(int j = 0; j < J / 2 - 1; j++) {
float v0 = (j+0)/(J-1.0f);
float v1 = (j+1)/(J-1.0f);
glBegin( GL_TRIANGLE_STRIP );
for(int i = 0; i < I; i++) {
float u = i/(I-1.0);
t.Vertex( u, v1 );
t.Vertex( u, v0 );
}
glEnd();
}
}
int width;
int height;
void reshape( int w, int h ) {
width = w;
height = h;
float a = float(w)/float(h);
glViewport(0, 0, width, height);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
if( a > 1 ) {
glFrustum( -0.1 * a, 0.1 * a, -0.1, 0.1, 0.1, 100.0 );
} else {
glFrustum( -0.1, 0.1, -0.1 / a, 0.1 / a, 0.1, 100.0 );
}
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0, 0, -2 );
}
static void regalerr( GLenum err ) {
const char * errstr = NULL;
switch( err ) {
case GL_INVALID_ENUM: errstr = "INVALID ENUM"; break;
case GL_INVALID_OPERATION: errstr = "INVALID OPERATION"; break;
case GL_INVALID_VALUE: errstr = "INVALID VALUE"; break;
default:
fprintf( stderr, "Got a GL error: %d!\n", err );
break;
}
if( errstr ) {
fprintf( stderr, "Got a GL error: %s\n", errstr );
}
;
}
GLuint tex;
void init();
void init() {
glGenTextures( 1, &tex );
GLubyte pix[] = {
0x60, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x00, 0xff,
0x80, 0x80, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0x80, 0x80, 0x80, 0xff, 0x00, 0x80, 0x80, 0xff,
0x00, 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0xff, 0x80, 0x00, 0xff, 0xff, 0x00, 0x00, 0x80, 0xff
};
glTextureImage2DEXT( tex, GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix );
glTextureParameteriEXT( tex, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTextureParameteriEXT( tex, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glBindMultiTextureEXT( texunit, GL_TEXTURE_2D, tex );
GLfloat mat_specular[] = { 0.0, 0.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 0.2, 1.0 };
GLfloat light_atten[] = { 1.0, 1.0, 1.0 };
GLfloat light_diffuse[] = { 10.0, 10.0, 10.0, 10.0 };
GLfloat light_specular[] = { 10.0, 10.0, 10.0, 10.0 };
GLfloat light_spotdir[] = { -0.1, -0.1, -1.0f };
GLfloat light_spotcut[] = { 30 };
GLfloat light_spotexp[] = { 3 };
glClearColor (0.0, 0.0, 0.0, 0.0);
//glShadeModel (GL_SMOOTH);
glMatrixPushEXT( GL_MODELVIEW );
glMatrixLoadIdentityEXT( GL_MODELVIEW );
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
//glMaterialfv(GL_BACK, GL_SHININESS, mat_shininess);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightf( GL_LIGHT0, GL_LINEAR_ATTENUATION, light_atten[1] );
glLightf( GL_LIGHT0, GL_QUADRATIC_ATTENUATION, light_atten[2] );
glLightfv( GL_LIGHT0, GL_DIFFUSE, light_diffuse );
glLightfv( GL_LIGHT0, GL_SPECULAR, light_specular );
glLightfv( GL_LIGHT0, GL_SPOT_DIRECTION, light_spotdir );
glLightfv( GL_LIGHT0, GL_SPOT_CUTOFF, light_spotcut );
glLightfv( GL_LIGHT0, GL_SPOT_EXPONENT, light_spotexp );
//GLfloat light_ambient[] = { 0.0, -1.0, 0.0, 0.0 };
//glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glMatrixPopEXT( GL_MODELVIEW );
glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE );
glLightModelf( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR );
glEnable( GL_COLOR_MATERIAL ) ;
glColorMaterial( GL_BACK, GL_SPECULAR );
glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glFogi( GL_FOG_MODE, GL_LINEAR );
glFogf( GL_FOG_START, 2.0f );
glFogf( GL_FOG_END, 4.0f );
GLfloat fog_color[] = { 1.0, 1.0, 0.0, 0.0 };
glFogfv( GL_FOG_COLOR, fog_color );
glEnable( GL_CLIP_PLANE3 );
GLdouble clip[] = { 1, 1, -1, 0 };
glClipPlane( GL_CLIP_PLANE3, clip );
}
void display( bool clear ) {
static float r = 0.0f;
static int count = 0;
if( count == 0 ) {
init();
}
#if 1
if( count == 0 ) {
RegalSetErrorCallback( regalerr );
} else if( count == 11 ) {
RegalSetErrorCallback( NULL );
}
count++;
#endif
glUseProgram( 0 );
if( clear ) {
glClearDepth( 1.0 );
glClearColor( r / 400.f, 0, 0, 0);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
glEnable( GL_DEPTH_TEST );
for( int i = 0; i < 8; i++ ) {
glActiveTexture( GL_TEXTURE0 + i );
glDisable( GL_TEXTURE_2D );
}
glBindMultiTextureEXT( texunit, GL_TEXTURE_2D, tex );
glActiveTexture( texunit );
glEnable( GL_TEXTURE_2D );
float sc = 2.0f * fabs( ( count % 800 ) / 400.0f - 1.0f ) + 1.0f;
glMatrixLoadIdentityEXT( texunit );
glMatrixScalefEXT( texunit, sc, 1, 1 );
float osc = sc * 0.5f;
glEnable( GL_FOG );
if( ( count % 7 ) == 0 || ( count % 17 ) == 0 ) {
glDisable( GL_NORMALIZE );
glEnable( GL_RESCALE_NORMAL );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glRotatef( count, -1, 1, 0 );
glScalef( osc, osc, osc );
drawAnObject();
glPopMatrix();
} else {
glEnable( GL_NORMALIZE );
glDisable( GL_RESCALE_NORMAL );
glMultiTexEnviEXT( texunit, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glMatrixPushEXT( GL_MODELVIEW );
glMatrixRotatefEXT( GL_MODELVIEW, count, -1, 1, 0 );
glMatrixScalefEXT( GL_MODELVIEW, osc, osc, osc );
drawAnObject();
glMatrixPopEXT( GL_MODELVIEW );
}
r += 1.0f;
if( r > 399 ) {
r = 0.0f;
}
//printf( "Draw with r=%f\n", r );
}

View file

@ -0,0 +1,13 @@
/*
* render.h
* gles
*
* Created by Cass Everitt on 3/16/11.
* Copyright 2011 __MyCompanyName__. All rights reserved.
*
*/
#pragma once
void reshape( int w, int h );
void display( bool clear );

View file

@ -0,0 +1,154 @@
/* An example of the minimal Win32 & OpenGL program. It only works in
16 bit color modes or higher (since it doesn't create a
palette). */
#include <windows.h> /* must include this before GL/gl.h */
#include <stdio.h>
void makeCurrent( HDC hdc, HGLRC hglrc );
void reshape(int x, int y);
void display();
LONG WINAPI
WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static PAINTSTRUCT ps;
switch(uMsg) {
case WM_PAINT:
display();
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
return 0;
case WM_SIZE:
reshape(LOWORD(lParam), HIWORD(lParam));
PostMessage(hWnd, WM_PAINT, 0, 0);
return 0;
case WM_CHAR:
switch (wParam) {
case 27: /* ESC key */
PostQuitMessage(0);
break;
}
return 0;
case WM_CLOSE:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
HWND
CreateOpenGLWindow(char* title, int x, int y, int width, int height,
BYTE type, DWORD flags)
{
int pf;
HDC hDC;
HWND hWnd;
WNDCLASS wc;
PIXELFORMATDESCRIPTOR pfd;
static HINSTANCE hInstance = 0;
/* only register the window class once - use hInstance as a flag. */
if (!hInstance) {
hInstance = GetModuleHandle(NULL);
wc.style = CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "OpenGL";
if (!RegisterClass(&wc)) {
MessageBox(NULL, "RegisterClass() failed: "
"Cannot register window class.", "Error", MB_OK);
return NULL;
}
}
hWnd = CreateWindow("OpenGL", title, WS_OVERLAPPEDWINDOW |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
x, y, width, height, NULL, NULL, hInstance, NULL);
if (hWnd == NULL) {
MessageBox(NULL, "CreateWindow() failed: Cannot create a window.",
"Error", MB_OK);
return NULL;
}
hDC = GetDC(hWnd);
/* there is no guarantee that the contents of the stack that become
the pfd are zeroed, therefore _make sure_ to clear these bits. */
memset(&pfd, 0, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | flags;
pfd.iPixelType = type;
pfd.cColorBits = 32;
pf = ChoosePixelFormat(hDC, &pfd);
if (pf == 0) {
MessageBox(NULL, "ChoosePixelFormat() failed: "
"Cannot find a suitable pixel format.", "Error", MB_OK);
return 0;
}
if (SetPixelFormat(hDC, pf, &pfd) == FALSE) {
MessageBox(NULL, "SetPixelFormat() failed: "
"Cannot set format specified.", "Error", MB_OK);
return 0;
}
DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
ReleaseDC(hWnd, hDC);
return hWnd;
}
int APIENTRY
WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
LPSTR lpszCmdLine, int nCmdShow)
{
HDC hDC; /* device context */
HGLRC hRC; /* opengl context */
HWND hWnd; /* window */
MSG msg; /* message */
HMODULE h = LoadLibrary( "opengl32.dll" );
typedef HGLRC (WINAPI *CreateCtx)(HDC);
CreateCtx cctx = (CreateCtx)GetProcAddress( h, "wglCreateContext" );
hWnd = CreateOpenGLWindow("minimal", 0, 0, 256, 256, PFD_TYPE_RGBA, 0);
if (hWnd == NULL)
exit(1);
hDC = GetDC(hWnd);
hRC = cctx(hDC);
makeCurrent(hDC, hRC);
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, hWnd, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
makeCurrent(NULL, NULL);
ReleaseDC(hWnd, hDC);
wglDeleteContext(hRC);
DestroyWindow(hWnd);
return msg.wParam;
}

View file

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minimal", "minimal.vcproj", "{63ED3C86-6842-445D-B34E-B82836C962D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63ED3C86-6842-445D-B34E-B82836C962D1}.Debug|Win32.ActiveCfg = Debug|Win32
{63ED3C86-6842-445D-B34E-B82836C962D1}.Debug|Win32.Build.0 = Debug|Win32
{63ED3C86-6842-445D-B34E-B82836C962D1}.Release|Win32.ActiveCfg = Release|Win32
{63ED3C86-6842-445D-B34E-B82836C962D1}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,211 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="minimal"
ProjectGUID="{63ED3C86-6842-445D-B34E-B82836C962D1}"
RootNamespace="minimal"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(SolutionDir)/../../../gen"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
CommandLine=""
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="regal.lib glu32.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="$(SolutionDir)/../../win32/Debug/"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="$(SolutionDir)/../../../gen"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="regal.lib glu32.lib"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\minimal.cpp"
>
</File>
<File
RelativePath="..\src\render.cpp"
>
</File>
<File
RelativePath="..\src\render.h"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\..\gen\Regal.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

11
examples/tiger/ReadMe.txt Normal file
View file

@ -0,0 +1,11 @@
nvpr_tiger
An NV_path_rendering example to draw the classic PostScript tiger.
Rotate and zooming is centered where you first left mouse click.
Hold down Ctrl at left mouse click to JUST SCALE.
Hold down Shift at left mouse click to JUST ROTATE.
Use middle mouse button to slide (translate).

305
examples/tiger/nvpr_tiger.c Normal file
View file

@ -0,0 +1,305 @@
/* nvpr_tiger.c - render classic PostScript tiger with NV_path_rendering */
// Copyright (c) NVIDIA Corporation. All rights reserved.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/RegalGLEW.h>
#include <GL/Regal.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/RegalGLUT.h>
#endif
#include "tiger.h"
#include "xform.h"
const char *programName = "nvpr_tiger";
int stroking = 1,
filling = 1;
/* Scaling and rotation state. */
int anchor_x = 0,
anchor_y = 0; /* Anchor for rotation and scaling. */
int scale_y = 0,
rotate_x = 0; /* Prior (x,y) location for scaling (vertical) or rotation (horizontal)? */
int zooming = 0; /* Are we zooming currently? */
int scaling = 0; /* Are we scaling (zooming) currently? */
/* Sliding (translation) state. */
float slide_x = 0,
slide_y = 0; /* Prior (x,y) location for sliding. */
int sliding = 0; /* Are we sliding currently? */
unsigned int path_count;
int canvas_width = 640, canvas_height = 480;
Transform3x2 model,
view;
static void fatalError(const char *message)
{
fprintf(stderr, "%s: %s\n", programName, message);
exit(1);
}
void initGraphics()
{
/* Use an orthographic path-to-clip-space transform to map the
[0..640]x[0..480] range of the star's path coordinates to the [-1..1]
clip space cube: */
glMatrixLoadIdentityEXT(GL_PROJECTION);
glMatrixOrthoEXT(GL_PROJECTION, 0, canvas_width, canvas_height, 0, -1, 1);
glMatrixLoadIdentityEXT(GL_MODELVIEW);
/* Before rendering to a window with a stencil buffer, clear the stencil
buffer to zero and the color buffer to blue: */
glClearStencil(0);
glClearColor(0.1, 0.3, 0.6, 0.0);
initTiger();
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_NOTEQUAL, 0, 0x1F);
glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
}
void initModelAndViewMatrices()
{
float tmp[2][3];
scale(model, 0.9, 0.9);
translate(tmp, 270, 160); /* magic values to get tiger centered */
mul(model, model, tmp);
translate(view, 0, 0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glMatrixPushEXT(GL_MODELVIEW); {
Transform3x2 mat;
mul(mat, view, model);
MatrixLoadToGL(mat);
drawTigerRange(filling, stroking, 0, path_count);
} glMatrixPopEXT(GL_MODELVIEW);
glutSwapBuffers();
}
float window_width, window_height;
static void reshape(int w, int h)
{
glViewport(0,0, w,h);
window_width = w;
window_height = h;
}
void keyboard(unsigned char c, int x, int y)
{
switch (c) {
case 27: /* Esc quits */
exit(0);
return;
case 13: /* Enter redisplays */
break;
case 's':
stroking = !stroking;
break;
case 'f':
filling = !filling;
break;
case 'r':
initModelAndViewMatrices();
break;
case '+':
path_count++;
break;
case '-':
path_count--;
break;
default:
return;
}
glutPostRedisplay();
}
void mouse(int button, int state, int mouse_space_x, int mouse_space_y)
{
if (button == GLUT_LEFT_BUTTON) {
if (state == GLUT_DOWN) {
anchor_x = mouse_space_x;
anchor_y = mouse_space_y;
rotate_x = mouse_space_x;
scale_y = mouse_space_y;
if (!(glutGetModifiers() & GLUT_ACTIVE_CTRL)) {
scaling = 1;
} else {
scaling = 0;
}
if (!(glutGetModifiers() & GLUT_ACTIVE_SHIFT)) {
zooming = 1;
} else {
zooming = 0;
}
} else {
zooming = 0;
scaling = 0;
}
}
if (button == GLUT_MIDDLE_BUTTON) {
if (state == GLUT_DOWN) {
slide_y = mouse_space_y;
slide_x = mouse_space_x;
sliding = 1;
} else {
sliding = 0;
}
}
}
void motion(int mouse_space_x, int mouse_space_y)
{
if (zooming || scaling) {
Transform3x2 t, r, s, m;
float angle = 0;
float zoom = 1;
if (scaling) {
angle = 0.3 * (rotate_x - mouse_space_x) * canvas_width/window_width;
}
if (zooming) {
zoom = pow(1.003, (mouse_space_y - scale_y) * canvas_height/window_height);
}
translate(t, anchor_x* canvas_width/window_width, anchor_y* canvas_height/window_height);
rotate(r, angle);
scale(s, zoom, zoom);
mul(r, r, s);
mul(m, t, r);
translate(t, -anchor_x* canvas_width/window_width, -anchor_y* canvas_height/window_height);
mul(m, m, t);
mul(view, m, view);
rotate_x = mouse_space_x;
scale_y = mouse_space_y;
glutPostRedisplay();
}
if (sliding) {
float m[2][3];
float x_offset = (mouse_space_x - slide_x) * canvas_width/window_width;
float y_offset = (mouse_space_y - slide_y) * canvas_height/window_height;
translate(m, x_offset, y_offset);
mul(view, m, view);
slide_y = mouse_space_y;
slide_x = mouse_space_x;
glutPostRedisplay();
}
}
static void menu(int choice)
{
keyboard(choice, 0, 0);
}
int main(int argc, char **argv)
{
GLenum status;
GLboolean hasDSA;
int samples = 0;
int i;
glutInitWindowSize(canvas_width, canvas_height);
glutInit(&argc, argv);
for (i=1; i<argc; i++) {
if (argv[i][0] == '-') {
int value = atoi(argv[i]+1);
if (value >= 1) {
samples = value;
continue;
}
}
fprintf(stderr, "usage: %s [-#]\n where # is the number of samples/pixel\n",
programName);
exit(1);
}
if (samples > 0) {
char buffer[200];
if (samples == 1)
samples = 0;
printf("requesting %d samples\n", samples);
sprintf(buffer, "rgb stencil~4 double samples~%d", samples);
glutInitDisplayString(buffer);
} else {
/* Request a double-buffered window with at least 4 stencil bits and
8 samples per pixel. */
#if 0
glutInitDisplayString("rgb stencil~4 double samples~8");
#else
glutInitDisplayString("rgb stencil~4 double");
#endif
}
glutCreateWindow("Classic PostScript tiger NV_path_rendering example");
// Regal workaround for OSX GLUT
#ifdef __APPLE__
extern void *CGLGetCurrentContext(void);
RegalMakeCurrent(CGLGetCurrentContext());
#endif
printf("vendor: %s\n", glGetString(GL_VENDOR));
printf("version: %s\n", glGetString(GL_VERSION));
printf("renderer: %s\n", glGetString(GL_RENDERER));
printf("samples per pixel = %d\n", glutGet(GLUT_WINDOW_NUM_SAMPLES));
printf("Executable: %d bit\n", (int)(8*sizeof(int *)));
printf("\n");
printf("Use left mouse button to scale/zoom (vertical, up/down) and rotate (right=clockwise, left=ccw)\n");
printf("Rotate and zooming is centered where you first left mouse click\n");
printf("Hold down Ctrl at left mouse click to JUST SCALE\n");
printf("Hold down Shift at left mouse click to JUST ROTATE\n");
printf("\n");
printf("Use middle mouse button to slide (translate)\n");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMotionFunc(motion);
initModelAndViewMatrices();
glutCreateMenu(menu);
glutAddMenuEntry("[f] Toggle filling", 'f');
glutAddMenuEntry("[s] Toggle stroking", 's');
glutAddMenuEntry("[r] Reset view", 'r');
glutAddMenuEntry("[Esc] Quit", 27);
glutAttachMenu(GLUT_RIGHT_BUTTON);
status = glewInit();
if (status != GLEW_OK) {
fatalError("OpenGL Extension Wrangler (GLEW) failed to initialize");
}
hasDSA = glewIsSupported("GL_EXT_direct_state_access");
if (!hasDSA) {
fatalError("OpenGL implementation doesn't support GL_EXT_direct_state_access (you should be using NVIDIA GPUs...)");
}
if (!glewIsSupported("GL_NV_path_rendering")) {
fatalError("required NV_path_rendering OpenGL extension is not present");
}
initGraphics();
path_count = getTigerPathCount();
glutMainLoop();
return 0;
}

135
examples/tiger/tiger.c Normal file
View file

@ -0,0 +1,135 @@
/* tiger.c - draw classic PostScript tiger */
// Copyright (c) NVIDIA Corporation. All rights reserved.
#include <string.h>
#include <math.h>
#include <GL/RegalGLEW.h>
static const unsigned int tiger_path_count = 240;
const char *tiger_path[240] = {
#include "tiger_paths.h"
};
static const struct TigerStyle {
GLuint fill_color;
GLuint stroke_color;
GLfloat stroke_width;
} tiger_style[240] = {
#include "tiger_style.h"
};
static GLuint tiger_path_base;
void initTiger()
{
unsigned int i;
tiger_path_base = glGenPathsNV(tiger_path_count);
for (i=0; i<tiger_path_count; i++) {
const char *svg_str = tiger_path[i];
size_t svg_len = strlen(tiger_path[i]);
GLfloat stroke_width = (GLfloat) fabs(tiger_style[i].stroke_width);
glPathStringNV(tiger_path_base+i, GL_PATH_FORMAT_SVG_NV,
(GLsizei)svg_len, svg_str);
glPathParameterfNV(tiger_path_base+i, GL_PATH_STROKE_WIDTH_NV, stroke_width);
}
}
static void sendColor(GLuint color)
{
GLubyte red = (color>> 16)&0xFF,
green = (color >> 8)&0xFF,
blue = (color >> 0)&0xFF;
glColor3ub(red, green, blue);
}
static void drawTigerLayer(int layer, int filling, int stroking)
{
const struct TigerStyle *style = &tiger_style[layer];
GLuint fill_color = style->fill_color;
GLuint stroke_color = style->stroke_color;
GLfloat stroke_width = style->stroke_width;
// Should this path be filled?
if (filling && stroke_width >= 0) {
sendColor(fill_color);
glStencilFillPathNV(tiger_path_base+layer, GL_COUNT_UP_NV, 0x1F);
glCoverFillPathNV(tiger_path_base+layer, GL_BOUNDING_BOX_NV);
} else {
// Negative stroke_width means "stroke only" (no fill)
}
// Should this path be stroked?
if (stroking && stroke_width != 0) {
const GLint reference = 0x1;
sendColor(stroke_color);
glStencilStrokePathNV(tiger_path_base+layer, reference, 0x1F);
glCoverStrokePathNV(tiger_path_base+layer, GL_BOUNDING_BOX_NV);
} else {
// Zero stroke widths means "fill only" (no stroke)
}
}
void drawTiger(int filling, int stroking)
{
unsigned int i;
for (i=0; i<tiger_path_count; i++) {
drawTigerLayer(i, filling, stroking);
}
}
void drawTigerRange(int filling, int stroking, unsigned int start, unsigned int end)
{
unsigned int i;
if (end > tiger_path_count) {
end = tiger_path_count;
}
for (i=start; i<end; i++) {
drawTigerLayer(i, filling, stroking);
}
}
static int use_dlist = 1;
void tigerDlistUsage(int b)
{
use_dlist = b;
}
void renderTiger(int filling, int stroking)
{
if (use_dlist) {
static int beenhere = 0;
int dlist = !!filling*2 + !!stroking + 1;
if (!beenhere) {
int i;
for (i=0; i<4; i++) {
glNewList(i+1, GL_COMPILE); {
int filling = !!(i&2);
int stroking = !!(i&1);
drawTiger(filling, stroking);
} glEndList();
}
beenhere = 1;
}
glCallList(dlist);
} else {
drawTiger(filling, stroking);
}
}
GLuint getTigerBasePath()
{
return tiger_path_base;
}
unsigned int getTigerPathCount()
{
return tiger_path_count;
}

18
examples/tiger/tiger.h Normal file
View file

@ -0,0 +1,18 @@
/* tiger.h - draw classic PostScript tiger */
#ifdef __cplusplus
extern "C" {
#endif
extern void initTiger();
extern void drawTiger(int filling, int stroking);
extern void drawTigerRange(int filling, int stroking, unsigned int start, unsigned int end);
extern void renderTiger(int filling, int stroking);
extern void tigerDlistUsage(int b);
extern unsigned int getTigerPathCount();
extern GLuint getTigerBasePath();
#ifdef __cplusplus
}
#endif

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,242 @@
/* style information for classic PostScript tiger paths */
/* 1st=0xRRGGBB fill color, 2nd=0xRRGGBB stroke color, 3rd=stroke width (0 means fill only, negative means only stroke, positive means fill+stroke) */
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 0.172f},
{0xffffff, 0x000000, 1},
{0xcc7226, 0x000000, 1},
{0xcc7226, 0x0, 0},
{0xe87f3a, 0x0, 0},
{0xea8c4d, 0x0, 0},
{0xec9961, 0x0, 0},
{0xeea575, 0x0, 0},
{0xf1b288, 0x0, 0},
{0xf3bf9c, 0x0, 0},
{0xf5ccb0, 0x0, 0},
{0xf8d8c4, 0x0, 0},
{0xfae5d7, 0x0, 0},
{0xfcf2eb, 0x0, 0},
{0xffffff, 0x0, 0},
{0x000000, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0xe5668c, 0x0, 0},
{0xb23259, 0x0, 0},
{0xa5264c, 0x0, 0},
{0xff727f, 0x000000, 1},
{0xffffcc, 0x000000, 0.5f},
{0xcc3f4c, 0x0, 0},
{0x0,0xa51926,-2},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0x0, 0xa5264c, -2},
{0x0, 0xa5264c, -2},
{0xffffcc, 0x000000, 0.5f},
{0x0, 0xa5264c, -2},
{0x0, 0xa5264c, -2},
{0xb2b2b2, 0x0, 0},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0x000000, 0x0, 0},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xffffcc, 0x000000, 0.5f},
{0xe5e5b2, 0x0, 0},
{0xe5e5b2, 0x0, 0},
{0xcc7226, 0x0, 0},
{0xea8e51, 0x0, 0},
{0xefaa7c, 0x0, 0},
{0xf4c6a8, 0x0, 0},
{0xf9e2d3, 0x0, 0},
{0xffffff, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0x99cc32, 0x0, 0},
{0x659900, 0x0, 0},
{0xffffff, 0x0, 0},
{0x000000, 0x0, 0},
{0xcc7226, 0x0, 0},
{0xffffff, 0x0, 0},
{0xeb955c, 0x0, 0},
{0xf2b892, 0x0, 0},
{0xf8dcc8, 0x0, 0},
{0xffffff, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0x99cc32, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x323232, 0x0, 0},
{0x666666, 0x0, 0},
{0x999999, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xffffff, 0x0, 0},
{0x992600, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0xcc7226, 0x0, 0},
{0xcc7226, 0x0, 0},
{0xcc7226, 0x0, 0},
{0xcc7226, 0x0, 0},
{0xcc7226, 0x0, 0},
{0xcc7226, 0x0, 0},
{0x000000, 0x0, 0},
{0x0,0x4c0000,-2},
{0x0,0x4c0000,-2},
{0x0,0x4c0000,-2},
{0x0,0x4c0000,-2},
{0x000000, 0x0, 0},
{0x4c0000, 0x0, 0},
{0x99cc32, 0x0, 0},
{0x659900, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0xe59999, 0x0, 0},
{0xb26565, 0x0, 0},
{0x992600, 0x0, 0},
{0xffffff, 0x0, 0},
{0x992600, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0xffffff, 0x0, 0},
{0xffffff, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x992600, 0x0, 0},
{0x992600, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xcccccc, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0xffffff, 0x000000, 0.1f},
{0x000000, 0x0, 0},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0xffffff, 0x000000, 0.1f},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0x000000, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0xcccccc, 0x0, 0},
{0x0, 0x000000, -1.0f},
{0x0, 0x000000, -1.0f},
{0x0, 0x000000, -1.0f},
{0x0, 0x000000, -1.0f},

137
examples/tiger/xform.c Normal file
View file

@ -0,0 +1,137 @@
/* xform.c - C transform routines for path rendering */
// Copyright (c) NVIDIA Corporation. All rights reserved.
#include <math.h>
#include <GL/RegalGLEW.h>
#include "xform.h"
void identity(Transform3x2 dst)
{
dst[0][0] = 1;
dst[0][1] = 0;
dst[0][2] = 0;
dst[1][0] = 0;
dst[1][1] = 1;
dst[1][2] = 0;
}
void mul(Transform3x2 dst, Transform3x2 a, Transform3x2 b)
{
Transform3x2 result;
result[0][0] = a[0][0]*b[0][0] + a[0][1]*b[1][0];
result[0][1] = a[0][0]*b[0][1] + a[0][1]*b[1][1];
result[0][2] = a[0][0]*b[0][2] + a[0][1]*b[1][2] + a[0][2];
result[1][0] = a[1][0]*b[0][0] + a[1][1]*b[1][0];
result[1][1] = a[1][0]*b[0][1] + a[1][1]*b[1][1];
result[1][2] = a[1][0]*b[0][2] + a[1][1]*b[1][2] + a[1][2];
dst[0][0] = result[0][0];
dst[0][1] = result[0][1];
dst[0][2] = result[0][2];
dst[1][0] = result[1][0];
dst[1][1] = result[1][1];
dst[1][2] = result[1][2];
}
void translate(Transform3x2 dst, float x, float y)
{
dst[0][0] = 1;
dst[0][1] = 0;
dst[0][2] = x;
dst[1][0] = 0;
dst[1][1] = 1;
dst[1][2] = y;
}
void scale(Transform3x2 dst, float x, float y)
{
dst[0][0] = x;
dst[0][1] = 0;
dst[0][2] = 0;
dst[1][0] = 0;
dst[1][1] = y;
dst[1][2] = 0;
}
void rotate(Transform3x2 dst, float angle)
{
float radians = angle*3.14159f/180.0f,
s = (float)sin(radians),
c = (float)cos(radians);
dst[0][0] = c;
dst[0][1] = -s;
dst[0][2] = 0;
dst[1][0] = s;
dst[1][1] = c;
dst[1][2] = 0;
}
void ortho(Transform3x2 dst, float l, float r, float b, float t)
{
dst[0][0] = 2/(r-l);
dst[0][1] = 0;
dst[0][2] = -(r+l)/(r-l);
dst[1][0] = 0;
dst[1][1] = 2/(t-b);
dst[1][2] = -(t+b)/(t-b);
}
void inverse_ortho(Transform3x2 dst, float l, float r, float b, float t)
{
dst[0][0] = (r-l)/2;
dst[0][1] = 0;
dst[0][2] = (r+l)/2;
dst[1][0] = 0;
dst[1][1] = (t-b)/2;
dst[1][2] = (t+b)/2;
}
void xform(float dst[2], Transform3x2 a, const float v[2])
{
float result[2];
result[0] = a[0][0]*v[0] + a[0][1]*v[1] + a[0][2];
result[1] = a[1][0]*v[0] + a[1][1]*v[1] + a[1][2];
dst[0] = result[0];
dst[1] = result[1];
}
void MatrixLoadToGL(Transform3x2 m)
{
GLfloat mm[16]; /* Column-major OpenGL-style 4x4 matrix. */
/* First column. */
mm[0] = m[0][0];
mm[1] = m[1][0];
mm[2] = 0;
mm[3] = 0;
/* Second column. */
mm[4] = m[0][1];
mm[5] = m[1][1];
mm[6] = 0;
mm[7] = 0;
/* Third column. */
mm[8] = 0;
mm[9] = 0;
mm[10] = 1;
mm[11] = 0;
/* Fourth column. */
mm[12] = m[0][2];
mm[13] = m[1][2];
mm[14] = 0;
mm[15] = 1;
glMatrixLoadfEXT(GL_MODELVIEW, &mm[0]);
}

28
examples/tiger/xform.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef XFORM_H
#define XFORM_H
/* xform.h - C transform routines for path rendering */
#ifdef __cplusplus
extern "C" {
#endif
typedef float Transform3x2[2][3];
extern void identity(Transform3x2 dst);
extern void mul(Transform3x2 dst, Transform3x2 a, Transform3x2 b);
extern void translate(Transform3x2 dst, float x, float y);
extern void scale(Transform3x2 dst, float x, float y);
extern void rotate(Transform3x2 dst, float angle);
extern void ortho(Transform3x2 dst, float l, float r, float b, float t);
extern void inverse_ortho(Transform3x2 dst, float l, float r, float b, float t);
extern void xform(float dst[2], Transform3x2 a, const float v[2]);
extern void MatrixLoadToGL(Transform3x2 m);
#ifdef __cplusplus
}
#endif
#endif /* XFORM_H */

20211
include/GL/Regal.h Normal file

File diff suppressed because it is too large Load diff

16270
include/GL/RegalGLEW.h Normal file

File diff suppressed because it is too large Load diff

665
include/GL/RegalGLUT.h Normal file
View file

@ -0,0 +1,665 @@
#ifndef __glut_h__
#define __glut_h__
/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */
/* This program is freely distributable without licensing fees and is
provided without guarantee or warrantee expressed or implied. This
program is -not- in the public domain. */
#if defined(_WIN32)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
# include <windows.h>
#endif
#include <GL/Regal.h>
#include <GL/glu.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA
in your compile preprocessor options. */
# if defined(_MSC_VER) && !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA)
# pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
/* To enable automatic SGI OpenGL for Windows library usage for GLUT,
define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */
# ifdef GLUT_USE_SGI_OPENGL
# pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */
# pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */
# pragma comment (lib, "glut.lib") /* link with Win32 GLUT for SGI OpenGL lib */
# else
# pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
# pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */
# pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */
# endif
# endif
/* To disable supression of annoying warnings about floats being promoted
to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor
options. */
# if defined(_MSC_VER) && !defined(GLUT_NO_WARNING_DISABLE)
# pragma warning (disable:4244) /* Disable bogus VC++ 4.2 conversion warnings. */
# pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
# endif
/* Win32 has an annoying issue where there are multiple C run-time
libraries (CRTs). If the executable is linked with a different CRT
from the GLUT DLL, the GLUT DLL will not share the same CRT static
data seen by the executable. In particular, atexit callbacks registered
in the executable will not be called if GLUT calls its (different)
exit routine). GLUT is typically built with the
"/MD" option (the CRT with multithreading DLL support), but the Visual
C++ linker default is "/ML" (the single threaded CRT).
One workaround to this issue is requiring users to always link with
the same CRT as GLUT is compiled with. That requires users supply a
non-standard option. GLUT 3.7 has its own built-in workaround where
the executable's "exit" function pointer is covertly passed to GLUT.
GLUT then calls the executable's exit function pointer to ensure that
any "atexit" calls registered by the application are called if GLUT
needs to exit.
Note that the __glut*WithExit routines should NEVER be called directly.
To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
/* XXX This is from Win32's <process.h> */
# if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__cdecl)
/* Define __cdecl for non-Microsoft compilers. */
# define __cdecl
# define GLUT_DEFINED___CDECL
# endif
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
#include <stdlib.h>
#endif
/* GLUT callback calling convention for Win32. */
# define GLUTCALLBACK __cdecl
/* for callback/function pointer defs */
# define GLUTAPIENTRYV __cdecl
/* glut-win32 specific macros, defined to prevent collision with
and redifinition of Windows system defs, also removes requirement of
pretty much any standard windows header from this file */
#if (_MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
# define GLUTAPIENTRY __stdcall
#else
# define GLUTAPIENTRY
#endif
/* GLUT API entry point declarations for Win32. */
#if (defined(BUILD_GLUT32) || defined(GLUT_BUILDING_LIB)) && !defined(GLUT_STATIC)
# define GLUTAPI __declspec(dllexport)
#elif !defined(GLUT_STATIC)
# define GLUTAPI __declspec(dllimport)
#else
# define GLUTAPI extern
#endif
#elif defined(__GNUC__)
# define GLUTAPIENTRY
# define GLUTAPIENTRYV
# define GLUTCALLBACK
# define GLUTAPI extern __attribute__((visibility("default")))
#else
/* Define GLUTAPIENTRY and GLUTCALLBACK to nothing */
# define GLUTAPIENTRY
# define GLUTAPIENTRYV
# define GLUTCALLBACK
# define GLUTAPI extern
#endif
/**
GLUT API revision history:
GLUT_API_VERSION is updated to reflect incompatible GLUT
API changes (interface changes, semantic changes, deletions,
or additions).
GLUT_API_VERSION=1 First public release of GLUT. 11/29/94
GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling,
extension. Supports new input devices like tablet, dial and button
box, and Spaceball. Easy to query OpenGL extensions.
GLUT_API_VERSION=3 glutMenuStatus added.
GLUT_API_VERSION=4 glutInitDisplayString, glutWarpPointer,
glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic
video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc,
glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat,
glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!).
GLUT_API_VERSION=5 glutGetProcAddress (added by BrianP)
**/
#ifndef GLUT_API_VERSION /* allow this to be overriden */
#define GLUT_API_VERSION 5
#endif
/**
GLUT implementation revision history:
GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT
API revisions and implementation revisions (ie, bug fixes).
GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of
GLUT Xlib-based implementation. 11/29/94
GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of
GLUT Xlib-based implementation providing GLUT version 2
interfaces.
GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95
GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95
GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95
GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96
GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner
and video resize. 1/3/97
GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines.
GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release.
GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling.
GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support.
GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface.
GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa <GL/glut.h>
**/
#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */
#define GLUT_XLIB_IMPLEMENTATION 15
#endif
/* Display mode bit masks. */
#define GLUT_RGB 0
#define GLUT_RGBA GLUT_RGB
#define GLUT_INDEX 1
#define GLUT_SINGLE 0
#define GLUT_DOUBLE 2
#define GLUT_ACCUM 4
#define GLUT_ALPHA 8
#define GLUT_DEPTH 16
#define GLUT_STENCIL 32
#if (GLUT_API_VERSION >= 2)
#define GLUT_MULTISAMPLE 128
#define GLUT_STEREO 256
#endif
#if (GLUT_API_VERSION >= 3)
#define GLUT_LUMINANCE 512
#endif
/* Mouse buttons. */
#define GLUT_LEFT_BUTTON 0
#define GLUT_MIDDLE_BUTTON 1
#define GLUT_RIGHT_BUTTON 2
/* Mouse button state. */
#define GLUT_DOWN 0
#define GLUT_UP 1
#if (GLUT_API_VERSION >= 2)
/* function keys */
#define GLUT_KEY_F1 1
#define GLUT_KEY_F2 2
#define GLUT_KEY_F3 3
#define GLUT_KEY_F4 4
#define GLUT_KEY_F5 5
#define GLUT_KEY_F6 6
#define GLUT_KEY_F7 7
#define GLUT_KEY_F8 8
#define GLUT_KEY_F9 9
#define GLUT_KEY_F10 10
#define GLUT_KEY_F11 11
#define GLUT_KEY_F12 12
/* directional keys */
#define GLUT_KEY_LEFT 100
#define GLUT_KEY_UP 101
#define GLUT_KEY_RIGHT 102
#define GLUT_KEY_DOWN 103
#define GLUT_KEY_PAGE_UP 104
#define GLUT_KEY_PAGE_DOWN 105
#define GLUT_KEY_HOME 106
#define GLUT_KEY_END 107
#define GLUT_KEY_INSERT 108
#endif
/* Entry/exit state. */
#define GLUT_LEFT 0
#define GLUT_ENTERED 1
/* Menu usage state. */
#define GLUT_MENU_NOT_IN_USE 0
#define GLUT_MENU_IN_USE 1
/* Visibility state. */
#define GLUT_NOT_VISIBLE 0
#define GLUT_VISIBLE 1
/* Window status state. */
#define GLUT_HIDDEN 0
#define GLUT_FULLY_RETAINED 1
#define GLUT_PARTIALLY_RETAINED 2
#define GLUT_FULLY_COVERED 3
/* Color index component selection values. */
#define GLUT_RED 0
#define GLUT_GREEN 1
#define GLUT_BLUE 2
/* Layers for use. */
#define GLUT_NORMAL 0
#define GLUT_OVERLAY 1
#if defined(_WIN32) || defined (GLUT_IMPORT_LIB)
/* Stroke font constants (use these in GLUT program). */
#define GLUT_STROKE_ROMAN ((void*)0)
#define GLUT_STROKE_MONO_ROMAN ((void*)1)
/* Bitmap font constants (use these in GLUT program). */
#define GLUT_BITMAP_9_BY_15 ((void*)2)
#define GLUT_BITMAP_8_BY_13 ((void*)3)
#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4)
#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5)
#if (GLUT_API_VERSION >= 3)
#define GLUT_BITMAP_HELVETICA_10 ((void*)6)
#define GLUT_BITMAP_HELVETICA_12 ((void*)7)
#define GLUT_BITMAP_HELVETICA_18 ((void*)8)
#endif
#else
/* Stroke font opaque addresses (use constants instead in source code). */
GLUTAPI void *glutStrokeRoman;
GLUTAPI void *glutStrokeMonoRoman;
/* Stroke font constants (use these in GLUT program). */
#define GLUT_STROKE_ROMAN (&glutStrokeRoman)
#define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman)
/* Bitmap font opaque addresses (use constants instead in source code). */
GLUTAPI void *glutBitmap9By15;
GLUTAPI void *glutBitmap8By13;
GLUTAPI void *glutBitmapTimesRoman10;
GLUTAPI void *glutBitmapTimesRoman24;
GLUTAPI void *glutBitmapHelvetica10;
GLUTAPI void *glutBitmapHelvetica12;
GLUTAPI void *glutBitmapHelvetica18;
/* Bitmap font constants (use these in GLUT program). */
#define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15)
#define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13)
#define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10)
#define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24)
#if (GLUT_API_VERSION >= 3)
#define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10)
#define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12)
#define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18)
#endif
#endif
/* glutGet parameters. */
#define GLUT_WINDOW_X 100
#define GLUT_WINDOW_Y 101
#define GLUT_WINDOW_WIDTH 102
#define GLUT_WINDOW_HEIGHT 103
#define GLUT_WINDOW_BUFFER_SIZE 104
#define GLUT_WINDOW_STENCIL_SIZE 105
#define GLUT_WINDOW_DEPTH_SIZE 106
#define GLUT_WINDOW_RED_SIZE 107
#define GLUT_WINDOW_GREEN_SIZE 108
#define GLUT_WINDOW_BLUE_SIZE 109
#define GLUT_WINDOW_ALPHA_SIZE 110
#define GLUT_WINDOW_ACCUM_RED_SIZE 111
#define GLUT_WINDOW_ACCUM_GREEN_SIZE 112
#define GLUT_WINDOW_ACCUM_BLUE_SIZE 113
#define GLUT_WINDOW_ACCUM_ALPHA_SIZE 114
#define GLUT_WINDOW_DOUBLEBUFFER 115
#define GLUT_WINDOW_RGBA 116
#define GLUT_WINDOW_PARENT 117
#define GLUT_WINDOW_NUM_CHILDREN 118
#define GLUT_WINDOW_COLORMAP_SIZE 119
#if (GLUT_API_VERSION >= 2)
#define GLUT_WINDOW_NUM_SAMPLES 120
#define GLUT_WINDOW_STEREO 121
#endif
#if (GLUT_API_VERSION >= 3)
#define GLUT_WINDOW_CURSOR 122
#endif
#define GLUT_SCREEN_WIDTH 200
#define GLUT_SCREEN_HEIGHT 201
#define GLUT_SCREEN_WIDTH_MM 202
#define GLUT_SCREEN_HEIGHT_MM 203
#define GLUT_MENU_NUM_ITEMS 300
#define GLUT_DISPLAY_MODE_POSSIBLE 400
#define GLUT_INIT_WINDOW_X 500
#define GLUT_INIT_WINDOW_Y 501
#define GLUT_INIT_WINDOW_WIDTH 502
#define GLUT_INIT_WINDOW_HEIGHT 503
#define GLUT_INIT_DISPLAY_MODE 504
#if (GLUT_API_VERSION >= 2)
#define GLUT_ELAPSED_TIME 700
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
#define GLUT_WINDOW_FORMAT_ID 123
#endif
#if (GLUT_API_VERSION >= 2)
/* glutDeviceGet parameters. */
#define GLUT_HAS_KEYBOARD 600
#define GLUT_HAS_MOUSE 601
#define GLUT_HAS_SPACEBALL 602
#define GLUT_HAS_DIAL_AND_BUTTON_BOX 603
#define GLUT_HAS_TABLET 604
#define GLUT_NUM_MOUSE_BUTTONS 605
#define GLUT_NUM_SPACEBALL_BUTTONS 606
#define GLUT_NUM_BUTTON_BOX_BUTTONS 607
#define GLUT_NUM_DIALS 608
#define GLUT_NUM_TABLET_BUTTONS 609
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
#define GLUT_DEVICE_IGNORE_KEY_REPEAT 610
#define GLUT_DEVICE_KEY_REPEAT 611
#define GLUT_HAS_JOYSTICK 612
#define GLUT_OWNS_JOYSTICK 613
#define GLUT_JOYSTICK_BUTTONS 614
#define GLUT_JOYSTICK_AXES 615
#define GLUT_JOYSTICK_POLL_RATE 616
#endif
#if (GLUT_API_VERSION >= 3)
/* glutLayerGet parameters. */
#define GLUT_OVERLAY_POSSIBLE 800
#define GLUT_LAYER_IN_USE 801
#define GLUT_HAS_OVERLAY 802
#define GLUT_TRANSPARENT_INDEX 803
#define GLUT_NORMAL_DAMAGED 804
#define GLUT_OVERLAY_DAMAGED 805
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
/* glutVideoResizeGet parameters. */
#define GLUT_VIDEO_RESIZE_POSSIBLE 900
#define GLUT_VIDEO_RESIZE_IN_USE 901
#define GLUT_VIDEO_RESIZE_X_DELTA 902
#define GLUT_VIDEO_RESIZE_Y_DELTA 903
#define GLUT_VIDEO_RESIZE_WIDTH_DELTA 904
#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 905
#define GLUT_VIDEO_RESIZE_X 906
#define GLUT_VIDEO_RESIZE_Y 907
#define GLUT_VIDEO_RESIZE_WIDTH 908
#define GLUT_VIDEO_RESIZE_HEIGHT 909
#endif
/* glutUseLayer parameters. */
#define GLUT_NORMAL 0
#define GLUT_OVERLAY 1
/* glutGetModifiers return mask. */
#define GLUT_ACTIVE_SHIFT 1
#define GLUT_ACTIVE_CTRL 2
#define GLUT_ACTIVE_ALT 4
/* glutSetCursor parameters. */
/* Basic arrows. */
#define GLUT_CURSOR_RIGHT_ARROW 0
#define GLUT_CURSOR_LEFT_ARROW 1
/* Symbolic cursor shapes. */
#define GLUT_CURSOR_INFO 2
#define GLUT_CURSOR_DESTROY 3
#define GLUT_CURSOR_HELP 4
#define GLUT_CURSOR_CYCLE 5
#define GLUT_CURSOR_SPRAY 6
#define GLUT_CURSOR_WAIT 7
#define GLUT_CURSOR_TEXT 8
#define GLUT_CURSOR_CROSSHAIR 9
/* Directional cursors. */
#define GLUT_CURSOR_UP_DOWN 10
#define GLUT_CURSOR_LEFT_RIGHT 11
/* Sizing cursors. */
#define GLUT_CURSOR_TOP_SIDE 12
#define GLUT_CURSOR_BOTTOM_SIDE 13
#define GLUT_CURSOR_LEFT_SIDE 14
#define GLUT_CURSOR_RIGHT_SIDE 15
#define GLUT_CURSOR_TOP_LEFT_CORNER 16
#define GLUT_CURSOR_TOP_RIGHT_CORNER 17
#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18
#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19
/* Inherit from parent window. */
#define GLUT_CURSOR_INHERIT 100
/* Blank cursor. */
#define GLUT_CURSOR_NONE 101
/* Fullscreen crosshair (if available). */
#define GLUT_CURSOR_FULL_CROSSHAIR 102
#endif
/* GLUT initialization sub-API. */
GLUTAPI void GLUTAPIENTRY glutInit(int *argcp, char **argv);
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
GLUTAPI void GLUTAPIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
#ifndef GLUT_BUILDING_LIB
#define glutInit(__argcp, __argv) __glutInitWithExit(__argcp, __argv, exit)
#endif
#endif
GLUTAPI void GLUTAPIENTRY glutInitDisplayMode(unsigned int mode);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
GLUTAPI void GLUTAPIENTRY glutInitDisplayString(const char *string);
#endif
GLUTAPI void GLUTAPIENTRY glutInitWindowPosition(int x, int y);
GLUTAPI void GLUTAPIENTRY glutInitWindowSize(int width, int height);
GLUTAPI void GLUTAPIENTRY glutMainLoop(void);
/* GLUT window sub-API. */
GLUTAPI int GLUTAPIENTRY glutCreateWindow(const char *title);
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
GLUTAPI int GLUTAPIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
#ifndef GLUT_BUILDING_LIB
#define glutCreateWindow(__title) __glutCreateWindowWithExit(__title, exit)
#endif
#endif
GLUTAPI int GLUTAPIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height);
GLUTAPI void GLUTAPIENTRY glutDestroyWindow(int win);
GLUTAPI void GLUTAPIENTRY glutPostRedisplay(void);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
GLUTAPI void GLUTAPIENTRY glutPostWindowRedisplay(int win);
#endif
GLUTAPI void GLUTAPIENTRY glutSwapBuffers(void);
GLUTAPI int GLUTAPIENTRY glutGetWindow(void);
GLUTAPI void GLUTAPIENTRY glutSetWindow(int win);
GLUTAPI void GLUTAPIENTRY glutSetWindowTitle(const char *title);
GLUTAPI void GLUTAPIENTRY glutSetIconTitle(const char *title);
GLUTAPI void GLUTAPIENTRY glutPositionWindow(int x, int y);
GLUTAPI void GLUTAPIENTRY glutReshapeWindow(int width, int height);
GLUTAPI void GLUTAPIENTRY glutPopWindow(void);
GLUTAPI void GLUTAPIENTRY glutPushWindow(void);
GLUTAPI void GLUTAPIENTRY glutIconifyWindow(void);
GLUTAPI void GLUTAPIENTRY glutShowWindow(void);
GLUTAPI void GLUTAPIENTRY glutHideWindow(void);
#if (GLUT_API_VERSION >= 3)
GLUTAPI void GLUTAPIENTRY glutFullScreen(void);
GLUTAPI void GLUTAPIENTRY glutSetCursor(int cursor);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
GLUTAPI void GLUTAPIENTRY glutWarpPointer(int x, int y);
#endif
/* GLUT overlay sub-API. */
GLUTAPI void GLUTAPIENTRY glutEstablishOverlay(void);
GLUTAPI void GLUTAPIENTRY glutRemoveOverlay(void);
GLUTAPI void GLUTAPIENTRY glutUseLayer(GLenum layer);
GLUTAPI void GLUTAPIENTRY glutPostOverlayRedisplay(void);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
GLUTAPI void GLUTAPIENTRY glutPostWindowOverlayRedisplay(int win);
#endif
GLUTAPI void GLUTAPIENTRY glutShowOverlay(void);
GLUTAPI void GLUTAPIENTRY glutHideOverlay(void);
#endif
/* GLUT menu sub-API. */
GLUTAPI int GLUTAPIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int));
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
GLUTAPI int GLUTAPIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int));
#ifndef GLUT_BUILDING_LIB
#define glutCreateMenu(__func) __glutCreateMenuWithExit(__func, exit)
#endif
#endif
GLUTAPI void GLUTAPIENTRY glutDestroyMenu(int menu);
GLUTAPI int GLUTAPIENTRY glutGetMenu(void);
GLUTAPI void GLUTAPIENTRY glutSetMenu(int menu);
GLUTAPI void GLUTAPIENTRY glutAddMenuEntry(const char *label, int value);
GLUTAPI void GLUTAPIENTRY glutAddSubMenu(const char *label, int submenu);
GLUTAPI void GLUTAPIENTRY glutChangeToMenuEntry(int item, const char *label, int value);
GLUTAPI void GLUTAPIENTRY glutChangeToSubMenu(int item, const char *label, int submenu);
GLUTAPI void GLUTAPIENTRY glutRemoveMenuItem(int item);
GLUTAPI void GLUTAPIENTRY glutAttachMenu(int button);
GLUTAPI void GLUTAPIENTRY glutDetachMenu(int button);
/* GLUT window callback sub-API. */
GLUTAPI void GLUTAPIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void));
GLUTAPI void GLUTAPIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height));
GLUTAPI void GLUTAPIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
GLUTAPI void GLUTAPIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
GLUTAPI void GLUTAPIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
GLUTAPI void GLUTAPIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
GLUTAPI void GLUTAPIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state));
GLUTAPI void GLUTAPIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state));
GLUTAPI void GLUTAPIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void));
GLUTAPI void GLUTAPIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value);
GLUTAPI void GLUTAPIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state));
#if (GLUT_API_VERSION >= 2)
GLUTAPI void GLUTAPIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
GLUTAPI void GLUTAPIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
GLUTAPI void GLUTAPIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
GLUTAPI void GLUTAPIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state));
GLUTAPI void GLUTAPIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state));
GLUTAPI void GLUTAPIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value));
GLUTAPI void GLUTAPIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
GLUTAPI void GLUTAPIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
#if (GLUT_API_VERSION >= 3)
GLUTAPI void GLUTAPIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y));
GLUTAPI void GLUTAPIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void));
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
GLUTAPI void GLUTAPIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state));
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
GLUTAPI void GLUTAPIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
GLUTAPI void GLUTAPIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
GLUTAPI void GLUTAPIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval);
#endif
#endif
#endif
/* GLUT color index sub-API. */
GLUTAPI void GLUTAPIENTRY glutSetColor(int ndx, GLfloat red, GLfloat green, GLfloat blue);
GLUTAPI GLfloat GLUTAPIENTRY glutGetColor(int ndx, int component);
GLUTAPI void GLUTAPIENTRY glutCopyColormap(int win);
/* GLUT state retrieval sub-API. */
GLUTAPI int GLUTAPIENTRY glutGet(GLenum type);
GLUTAPI int GLUTAPIENTRY glutDeviceGet(GLenum type);
#if (GLUT_API_VERSION >= 2)
/* GLUT extension support sub-API */
GLUTAPI int GLUTAPIENTRY glutExtensionSupported(const char *name);
#endif
#if (GLUT_API_VERSION >= 3)
GLUTAPI int GLUTAPIENTRY glutGetModifiers(void);
GLUTAPI int GLUTAPIENTRY glutLayerGet(GLenum type);
#endif
#if (GLUT_API_VERSION >= 5)
typedef void (*GLUTproc)();
GLUTAPI GLUTproc GLUTAPIENTRY glutGetProcAddress(const char *procName);
#endif
/* GLUT font sub-API */
GLUTAPI void GLUTAPIENTRY glutBitmapCharacter(void *font, int character);
GLUTAPI int GLUTAPIENTRY glutBitmapWidth(void *font, int character);
GLUTAPI void GLUTAPIENTRY glutStrokeCharacter(void *font, int character);
GLUTAPI int GLUTAPIENTRY glutStrokeWidth(void *font, int character);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
GLUTAPI int GLUTAPIENTRY glutBitmapLength(void *font, const unsigned char *string);
GLUTAPI int GLUTAPIENTRY glutStrokeLength(void *font, const unsigned char *string);
#endif
/* GLUT pre-built models sub-API */
GLUTAPI void GLUTAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
GLUTAPI void GLUTAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
GLUTAPI void GLUTAPIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
GLUTAPI void GLUTAPIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
GLUTAPI void GLUTAPIENTRY glutWireCube(GLdouble size);
GLUTAPI void GLUTAPIENTRY glutSolidCube(GLdouble size);
GLUTAPI void GLUTAPIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
GLUTAPI void GLUTAPIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
GLUTAPI void GLUTAPIENTRY glutWireDodecahedron(void);
GLUTAPI void GLUTAPIENTRY glutSolidDodecahedron(void);
GLUTAPI void GLUTAPIENTRY glutWireTeapot(GLdouble size);
GLUTAPI void GLUTAPIENTRY glutSolidTeapot(GLdouble size);
GLUTAPI void GLUTAPIENTRY glutWireOctahedron(void);
GLUTAPI void GLUTAPIENTRY glutSolidOctahedron(void);
GLUTAPI void GLUTAPIENTRY glutWireTetrahedron(void);
GLUTAPI void GLUTAPIENTRY glutSolidTetrahedron(void);
GLUTAPI void GLUTAPIENTRY glutWireIcosahedron(void);
GLUTAPI void GLUTAPIENTRY glutSolidIcosahedron(void);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
/* GLUT video resize sub-API. */
GLUTAPI int GLUTAPIENTRY glutVideoResizeGet(GLenum param);
GLUTAPI void GLUTAPIENTRY glutSetupVideoResizing(void);
GLUTAPI void GLUTAPIENTRY glutStopVideoResizing(void);
GLUTAPI void GLUTAPIENTRY glutVideoResize(int x, int y, int width, int height);
GLUTAPI void GLUTAPIENTRY glutVideoPan(int x, int y, int width, int height);
/* GLUT debugging sub-API. */
GLUTAPI void GLUTAPIENTRY glutReportErrors(void);
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
/* GLUT device control sub-API. */
/* glutSetKeyRepeat modes. */
#define GLUT_KEY_REPEAT_OFF 0
#define GLUT_KEY_REPEAT_ON 1
#define GLUT_KEY_REPEAT_DEFAULT 2
/* Joystick button masks. */
#define GLUT_JOYSTICK_BUTTON_A 1
#define GLUT_JOYSTICK_BUTTON_B 2
#define GLUT_JOYSTICK_BUTTON_C 4
#define GLUT_JOYSTICK_BUTTON_D 8
GLUTAPI void GLUTAPIENTRY glutIgnoreKeyRepeat(int ignore);
GLUTAPI void GLUTAPIENTRY glutSetKeyRepeat(int repeatMode);
GLUTAPI void GLUTAPIENTRY glutForceJoystickFunc(void);
/* GLUT game mode sub-API. */
/* glutGameModeGet. */
#define GLUT_GAME_MODE_ACTIVE 0
#define GLUT_GAME_MODE_POSSIBLE 1
#define GLUT_GAME_MODE_WIDTH 2
#define GLUT_GAME_MODE_HEIGHT 3
#define GLUT_GAME_MODE_PIXEL_DEPTH 4
#define GLUT_GAME_MODE_REFRESH_RATE 5
#define GLUT_GAME_MODE_DISPLAY_CHANGED 6
GLUTAPI void GLUTAPIENTRY glutGameModeString(const char *string);
GLUTAPI int GLUTAPIENTRY glutEnterGameMode(void);
GLUTAPI void GLUTAPIENTRY glutLeaveGameMode(void);
GLUTAPI int GLUTAPIENTRY glutGameModeGet(GLenum mode);
#endif
#ifdef __cplusplus
}
#endif
#endif /* __glut_h__ */

1599
include/GL/RegalGLXEW.h Normal file

File diff suppressed because it is too large Load diff

1385
include/GL/RegalWGLEW.h Normal file

File diff suppressed because it is too large Load diff

16270
src/glew/include/GL/glew.h Normal file

File diff suppressed because it is too large Load diff

1599
src/glew/include/GL/glxew.h Normal file

File diff suppressed because it is too large Load diff

1385
src/glew/include/GL/wglew.h Normal file

File diff suppressed because it is too large Load diff

16143
src/glew/src/glew.c Normal file

File diff suppressed because it is too large Load diff

9475
src/glew/src/glewinfo.c Normal file

File diff suppressed because it is too large Load diff

1178
src/glew/src/visualinfo.c Normal file

File diff suppressed because it is too large Load diff

88
src/glu/glu.def Normal file
View file

@ -0,0 +1,88 @@
;DESCRIPTION 'Mesa GLU (OpenGL work-alike) for Win32'
VERSION 5.1
;
; Module definition file for GLU (GLU32.DLL)
;
; Note: The GLU functions use the STDCALL
; function calling convention. Microsoft's
; GLU32 uses this convention and so must the
; Mesa GLU32 so that the Mesa DLL can be used
; as a drop-in replacement.
;
; The linker exports STDCALL entry points with
; 'decorated' names; e.g., _glBegin@0, where the
; trailing number is the number of bytes of
; parameter data pushed onto the stack. The
; callee is responsible for popping this data
; off the stack, usually via a RETF n instruction.
;
; However, the Microsoft GLU32.DLL does not export
; the decorated names, even though the calling convention
; is STDCALL. So, this module definition file is
; needed to force the Mesa GLU32.DLL to export the
; symbols in the same manner as the Microsoft DLL.
; Were it not for this problem, this file would not
; be needed (for the glu* functions) since the entry
; points are compiled with dllexport declspec.
;
EXPORTS
gluBeginCurve
gluBeginPolygon
gluBeginSurface
gluBeginTrim
gluBuild1DMipmapLevels
gluBuild1DMipmaps
gluBuild2DMipmapLevels
gluBuild2DMipmaps
gluBuild3DMipmapLevels
gluBuild3DMipmaps
gluCheckExtension
gluCylinder
gluDeleteNurbsRenderer
gluDeleteQuadric
gluDeleteTess
gluDisk
gluEndCurve
gluEndPolygon
gluEndSurface
gluEndTrim
gluErrorString
gluGetNurbsProperty
gluGetString
gluGetTessProperty
gluLoadSamplingMatrices
gluLookAt
gluNewNurbsRenderer
gluNewQuadric
gluNewTess
gluNextContour
gluNurbsCallback
gluNurbsCallbackData
gluNurbsCallbackDataEXT
gluNurbsCurve
gluNurbsProperty
gluNurbsSurface
gluOrtho2D
gluPartialDisk
gluPerspective
gluPickMatrix
gluProject
gluPwlCurve
gluQuadricCallback
gluQuadricDrawStyle
gluQuadricNormals
gluQuadricOrientation
gluQuadricTexture
gluScaleImage
gluSphere
gluTessBeginContour
gluTessBeginPolygon
gluTessCallback
gluTessEndContour
gluTessEndPolygon
gluTessNormal
gluTessProperty
gluTessVertex
gluUnProject
gluUnProject4

357
src/glu/include/GL/glu.h Normal file
View file

@ -0,0 +1,357 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
#ifndef __glu_h__
#define __glu_h__
#include <GL/Regal.h>
#if REGAL_SYS_WGL
# define REGALGLU_CALL __stdcall
#else
# define REGALGLU_CALL
#endif
#ifdef _WIN32
# if REGALGLU_DECL_EXPORT
# define REGALGLU_DECL
# else
# define REGALGLU_DECL __declspec(dllimport)
# endif
#elif defined(__GNUC__) && __GNUC__>=4
# if REGALGLU_DECL_EXPORT
# define REGALGLU_DECL __attribute__ ((visibility("default")))
# else
# define REGALGLU_DECL
# endif
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# if REGALGLU_DECL_EXPORT
# define REGALGLU_DECL __global
# else
# define REGALGLU_DECL
# endif
#else
# define REGALGLU_DECL
#endif
#ifndef REGALGLU_CALLP
#define REGALGLU_CALLP REGALGLU_CALL *
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************/
/* Extensions */
#define GLU_EXT_object_space_tess 1
#define GLU_EXT_nurbs_tessellator 1
/* Boolean */
#define GLU_FALSE 0
#define GLU_TRUE 1
/* Version */
#define GLU_VERSION_1_1 1
#define GLU_VERSION_1_2 1
#define GLU_VERSION_1_3 1
/* StringName */
#define GLU_VERSION 100800
#define GLU_EXTENSIONS 100801
/* ErrorCode */
#define GLU_INVALID_ENUM 100900
#define GLU_INVALID_VALUE 100901
#define GLU_OUT_OF_MEMORY 100902
#define GLU_INCOMPATIBLE_GL_VERSION 100903
#define GLU_INVALID_OPERATION 100904
/* NurbsDisplay */
/* GLU_FILL */
#define GLU_OUTLINE_POLYGON 100240
#define GLU_OUTLINE_PATCH 100241
/* NurbsCallback */
#define GLU_NURBS_ERROR 100103
#define GLU_ERROR 100103
#define GLU_NURBS_BEGIN 100164
#define GLU_NURBS_BEGIN_EXT 100164
#define GLU_NURBS_VERTEX 100165
#define GLU_NURBS_VERTEX_EXT 100165
#define GLU_NURBS_NORMAL 100166
#define GLU_NURBS_NORMAL_EXT 100166
#define GLU_NURBS_COLOR 100167
#define GLU_NURBS_COLOR_EXT 100167
#define GLU_NURBS_TEXTURE_COORD 100168
#define GLU_NURBS_TEX_COORD_EXT 100168
#define GLU_NURBS_END 100169
#define GLU_NURBS_END_EXT 100169
#define GLU_NURBS_BEGIN_DATA 100170
#define GLU_NURBS_BEGIN_DATA_EXT 100170
#define GLU_NURBS_VERTEX_DATA 100171
#define GLU_NURBS_VERTEX_DATA_EXT 100171
#define GLU_NURBS_NORMAL_DATA 100172
#define GLU_NURBS_NORMAL_DATA_EXT 100172
#define GLU_NURBS_COLOR_DATA 100173
#define GLU_NURBS_COLOR_DATA_EXT 100173
#define GLU_NURBS_TEXTURE_COORD_DATA 100174
#define GLU_NURBS_TEX_COORD_DATA_EXT 100174
#define GLU_NURBS_END_DATA 100175
#define GLU_NURBS_END_DATA_EXT 100175
/* NurbsError */
#define GLU_NURBS_ERROR1 100251
#define GLU_NURBS_ERROR2 100252
#define GLU_NURBS_ERROR3 100253
#define GLU_NURBS_ERROR4 100254
#define GLU_NURBS_ERROR5 100255
#define GLU_NURBS_ERROR6 100256
#define GLU_NURBS_ERROR7 100257
#define GLU_NURBS_ERROR8 100258
#define GLU_NURBS_ERROR9 100259
#define GLU_NURBS_ERROR10 100260
#define GLU_NURBS_ERROR11 100261
#define GLU_NURBS_ERROR12 100262
#define GLU_NURBS_ERROR13 100263
#define GLU_NURBS_ERROR14 100264
#define GLU_NURBS_ERROR15 100265
#define GLU_NURBS_ERROR16 100266
#define GLU_NURBS_ERROR17 100267
#define GLU_NURBS_ERROR18 100268
#define GLU_NURBS_ERROR19 100269
#define GLU_NURBS_ERROR20 100270
#define GLU_NURBS_ERROR21 100271
#define GLU_NURBS_ERROR22 100272
#define GLU_NURBS_ERROR23 100273
#define GLU_NURBS_ERROR24 100274
#define GLU_NURBS_ERROR25 100275
#define GLU_NURBS_ERROR26 100276
#define GLU_NURBS_ERROR27 100277
#define GLU_NURBS_ERROR28 100278
#define GLU_NURBS_ERROR29 100279
#define GLU_NURBS_ERROR30 100280
#define GLU_NURBS_ERROR31 100281
#define GLU_NURBS_ERROR32 100282
#define GLU_NURBS_ERROR33 100283
#define GLU_NURBS_ERROR34 100284
#define GLU_NURBS_ERROR35 100285
#define GLU_NURBS_ERROR36 100286
#define GLU_NURBS_ERROR37 100287
/* NurbsProperty */
#define GLU_AUTO_LOAD_MATRIX 100200
#define GLU_CULLING 100201
#define GLU_SAMPLING_TOLERANCE 100203
#define GLU_DISPLAY_MODE 100204
#define GLU_PARAMETRIC_TOLERANCE 100202
#define GLU_SAMPLING_METHOD 100205
#define GLU_U_STEP 100206
#define GLU_V_STEP 100207
#define GLU_NURBS_MODE 100160
#define GLU_NURBS_MODE_EXT 100160
#define GLU_NURBS_TESSELLATOR 100161
#define GLU_NURBS_TESSELLATOR_EXT 100161
#define GLU_NURBS_RENDERER 100162
#define GLU_NURBS_RENDERER_EXT 100162
/* NurbsSampling */
#define GLU_OBJECT_PARAMETRIC_ERROR 100208
#define GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208
#define GLU_OBJECT_PATH_LENGTH 100209
#define GLU_OBJECT_PATH_LENGTH_EXT 100209
#define GLU_PATH_LENGTH 100215
#define GLU_PARAMETRIC_ERROR 100216
#define GLU_DOMAIN_DISTANCE 100217
/* NurbsTrim */
#define GLU_MAP1_TRIM_2 100210
#define GLU_MAP1_TRIM_3 100211
/* QuadricDrawStyle */
#define GLU_POINT 100010
#define GLU_LINE 100011
#define GLU_FILL 100012
#define GLU_SILHOUETTE 100013
/* QuadricCallback */
/* GLU_ERROR */
/* QuadricNormal */
#define GLU_SMOOTH 100000
#define GLU_FLAT 100001
#define GLU_NONE 100002
/* QuadricOrientation */
#define GLU_OUTSIDE 100020
#define GLU_INSIDE 100021
/* TessCallback */
#define GLU_TESS_BEGIN 100100
#define GLU_BEGIN 100100
#define GLU_TESS_VERTEX 100101
#define GLU_VERTEX 100101
#define GLU_TESS_END 100102
#define GLU_END 100102
#define GLU_TESS_ERROR 100103
#define GLU_TESS_EDGE_FLAG 100104
#define GLU_EDGE_FLAG 100104
#define GLU_TESS_COMBINE 100105
#define GLU_TESS_BEGIN_DATA 100106
#define GLU_TESS_VERTEX_DATA 100107
#define GLU_TESS_END_DATA 100108
#define GLU_TESS_ERROR_DATA 100109
#define GLU_TESS_EDGE_FLAG_DATA 100110
#define GLU_TESS_COMBINE_DATA 100111
/* TessContour */
#define GLU_CW 100120
#define GLU_CCW 100121
#define GLU_INTERIOR 100122
#define GLU_EXTERIOR 100123
#define GLU_UNKNOWN 100124
/* TessProperty */
#define GLU_TESS_WINDING_RULE 100140
#define GLU_TESS_BOUNDARY_ONLY 100141
#define GLU_TESS_TOLERANCE 100142
/* TessError */
#define GLU_TESS_ERROR1 100151
#define GLU_TESS_ERROR2 100152
#define GLU_TESS_ERROR3 100153
#define GLU_TESS_ERROR4 100154
#define GLU_TESS_ERROR5 100155
#define GLU_TESS_ERROR6 100156
#define GLU_TESS_ERROR7 100157
#define GLU_TESS_ERROR8 100158
#define GLU_TESS_MISSING_BEGIN_POLYGON 100151
#define GLU_TESS_MISSING_BEGIN_CONTOUR 100152
#define GLU_TESS_MISSING_END_POLYGON 100153
#define GLU_TESS_MISSING_END_CONTOUR 100154
#define GLU_TESS_COORD_TOO_LARGE 100155
#define GLU_TESS_NEED_COMBINE_CALLBACK 100156
/* TessWinding */
#define GLU_TESS_WINDING_ODD 100130
#define GLU_TESS_WINDING_NONZERO 100131
#define GLU_TESS_WINDING_POSITIVE 100132
#define GLU_TESS_WINDING_NEGATIVE 100133
#define GLU_TESS_WINDING_ABS_GEQ_TWO 100134
/*************************************************************/
#ifdef __cplusplus
class GLUnurbs;
class GLUquadric;
class GLUtesselator;
#else
typedef struct GLUnurbs GLUnurbs;
typedef struct GLUquadric GLUquadric;
typedef struct GLUtesselator GLUtesselator;
#endif
typedef GLUnurbs GLUnurbsObj;
typedef GLUquadric GLUquadricObj;
typedef GLUtesselator GLUtesselatorObj;
typedef GLUtesselator GLUtriangulatorObj;
#define GLU_TESS_MAX_COORD 1.0e150
/* Internal convenience typedefs */
typedef void (REGALGLU_CALLP _GLUfuncptr)(void);
REGALGLU_DECL void REGALGLU_CALL gluBeginCurve (GLUnurbs* nurb);
REGALGLU_DECL void REGALGLU_CALL gluBeginPolygon (GLUtesselator* tess);
REGALGLU_DECL void REGALGLU_CALL gluBeginSurface (GLUnurbs* nurb);
REGALGLU_DECL void REGALGLU_CALL gluBeginTrim (GLUnurbs* nurb);
REGALGLU_DECL GLint REGALGLU_CALL gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
REGALGLU_DECL GLint REGALGLU_CALL gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data);
REGALGLU_DECL GLint REGALGLU_CALL gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
REGALGLU_DECL GLint REGALGLU_CALL gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
REGALGLU_DECL GLint REGALGLU_CALL gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
REGALGLU_DECL GLint REGALGLU_CALL gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
REGALGLU_DECL GLboolean REGALGLU_CALL gluCheckExtension (const GLubyte *extName, const GLubyte *extString);
REGALGLU_DECL void REGALGLU_CALL gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks);
REGALGLU_DECL void REGALGLU_CALL gluDeleteNurbsRenderer (GLUnurbs* nurb);
REGALGLU_DECL void REGALGLU_CALL gluDeleteQuadric (GLUquadric* quad);
REGALGLU_DECL void REGALGLU_CALL gluDeleteTess (GLUtesselator* tess);
REGALGLU_DECL void REGALGLU_CALL gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops);
REGALGLU_DECL void REGALGLU_CALL gluEndCurve (GLUnurbs* nurb);
REGALGLU_DECL void REGALGLU_CALL gluEndPolygon (GLUtesselator* tess);
REGALGLU_DECL void REGALGLU_CALL gluEndSurface (GLUnurbs* nurb);
REGALGLU_DECL void REGALGLU_CALL gluEndTrim (GLUnurbs* nurb);
REGALGLU_DECL const GLubyte * REGALGLU_CALL gluErrorString (GLenum error);
REGALGLU_DECL void REGALGLU_CALL gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data);
REGALGLU_DECL const GLubyte * REGALGLU_CALL gluGetString (GLenum name);
REGALGLU_DECL void REGALGLU_CALL gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data);
REGALGLU_DECL void REGALGLU_CALL gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view);
REGALGLU_DECL void REGALGLU_CALL gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ);
REGALGLU_DECL GLUnurbs* REGALGLU_CALL gluNewNurbsRenderer (void);
REGALGLU_DECL GLUquadric* REGALGLU_CALL gluNewQuadric (void);
REGALGLU_DECL GLUtesselator* REGALGLU_CALL gluNewTess (void);
REGALGLU_DECL void REGALGLU_CALL gluNextContour (GLUtesselator* tess, GLenum type);
REGALGLU_DECL void REGALGLU_CALL gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc);
REGALGLU_DECL void REGALGLU_CALL gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData);
REGALGLU_DECL void REGALGLU_CALL gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData);
REGALGLU_DECL void REGALGLU_CALL gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type);
REGALGLU_DECL void REGALGLU_CALL gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value);
REGALGLU_DECL void REGALGLU_CALL gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type);
REGALGLU_DECL void REGALGLU_CALL gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
REGALGLU_DECL void REGALGLU_CALL gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep);
REGALGLU_DECL void REGALGLU_CALL gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
REGALGLU_DECL void REGALGLU_CALL gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport);
REGALGLU_DECL GLint REGALGLU_CALL gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ);
REGALGLU_DECL void REGALGLU_CALL gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type);
REGALGLU_DECL void REGALGLU_CALL gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc);
REGALGLU_DECL void REGALGLU_CALL gluQuadricDrawStyle (GLUquadric* quad, GLenum draw);
REGALGLU_DECL void REGALGLU_CALL gluQuadricNormals (GLUquadric* quad, GLenum normal);
REGALGLU_DECL void REGALGLU_CALL gluQuadricOrientation (GLUquadric* quad, GLenum orientation);
REGALGLU_DECL void REGALGLU_CALL gluQuadricTexture (GLUquadric* quad, GLboolean texture);
REGALGLU_DECL GLint REGALGLU_CALL gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut);
REGALGLU_DECL void REGALGLU_CALL gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks);
REGALGLU_DECL void REGALGLU_CALL gluTessBeginContour (GLUtesselator* tess);
REGALGLU_DECL void REGALGLU_CALL gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data);
REGALGLU_DECL void REGALGLU_CALL gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
REGALGLU_DECL void REGALGLU_CALL gluTessEndContour (GLUtesselator* tess);
REGALGLU_DECL void REGALGLU_CALL gluTessEndPolygon (GLUtesselator* tess);
REGALGLU_DECL void REGALGLU_CALL gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
REGALGLU_DECL void REGALGLU_CALL gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data);
REGALGLU_DECL void REGALGLU_CALL gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data);
REGALGLU_DECL GLint REGALGLU_CALL gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ);
REGALGLU_DECL GLint REGALGLU_CALL gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW);
#ifdef __cplusplus
}
#endif
#endif /* __glu_h__ */

89
src/glu/include/gluos.h Normal file
View file

@ -0,0 +1,89 @@
/*
** gluos.h - operating system dependencies for GLU
**
*/
#ifdef __VMS
#ifdef __cplusplus
#pragma message disable nocordel
#pragma message disable codeunreachable
#pragma message disable codcauunr
#endif
#endif
#ifdef __WATCOMC__
/* Disable *lots* of warnings to get a clean build. I can't be bothered fixing the
* code at the moment, as it is pretty ugly.
*/
#pragma warning 7 10
#pragma warning 13 10
#pragma warning 14 10
#pragma warning 367 10
#pragma warning 379 10
#pragma warning 726 10
#pragma warning 836 10
#endif
#ifdef BUILD_FOR_SNAP
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#elif defined(_WIN32)
#include <stdlib.h> /* For _MAX_PATH definition */
#include <stdio.h>
#include <malloc.h>
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#define NOGDI
#define NOIME
#define NOMINMAX
#ifdef __MINGW64_VERSION_MAJOR
#undef _WIN32_WINNT
#endif
#ifndef _WIN32_WINNT
/* XXX: Workaround a bug in mingw-w64's headers when NOGDI is set and
* _WIN32_WINNT >= 0x0600 */
#define _WIN32_WINNT 0x0400
#endif
#ifndef STRICT
#define STRICT 1
#endif
#include <windows.h>
/* Disable warnings */
#if defined(_MSC_VER)
#pragma warning(disable : 4101)
#pragma warning(disable : 4244)
#pragma warning(disable : 4761)
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1300
#pragma comment(linker, "/OPT:NOWIN98")
#endif
#ifndef WINGDIAPI
#define WINGDIAPI
#endif
#elif defined(__OS2__)
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#define WINGDIAPI
#else
/* Disable Microsoft-specific keywords */
#define GLAPIENTRY
#define WINGDIAPI
#endif

View file

@ -0,0 +1,54 @@
#!gmake
#
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: The application programming interfaces
# established by SGI in conjunction with the Original Code are The
# OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
# April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
# 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
# Window System(R) (Version 1.3), released October 19, 1998. This software
# was created using the OpenGL(R) version 1.2.1 Sample Implementation
# published by SGI, but has not been independently verified as being
# compliant with the OpenGL(R) version 1.2.1 Specification.
#
# $Date$ $Revision$
# $Header: //depot/main/gfx/lib/glu/libnurbs/GNUmakefile#7 $
COMMONPREF = standard
include $(ROOT)/usr/include/make/commondefs
SUBDIRS = \
internals \
interface \
nurbtess \
$(NULL)
default $(ALLTARGS): $(_FORCE)
$(SUBDIRS_MAKERULE)
distoss:
$(MAKE) $(COMMONPREF)$@
$(SUBDIRS_MAKERULE)
include $(COMMONRULES)

View file

@ -0,0 +1,43 @@
XCOMM License Applicability. Except to the extent portions of this file are
XCOMM made subject to an alternative license as permitted in the SGI Free
XCOMM Software License B, Version 1.1 (the "License"), the contents of this
XCOMM file are subject only to the provisions of the License. You may not use
XCOMM this file except in compliance with the License. You may obtain a copy
XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
XCOMM
XCOMM http://oss.sgi.com/projects/FreeB
XCOMM
XCOMM Note that, as provided in the License, the Software is distributed on an
XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
XCOMM
XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
XCOMM Copyright in any portions created by third parties is as indicated
XCOMM elsewhere herein. All Rights Reserved.
XCOMM
XCOMM Additional Notice Provisions: The application programming interfaces
XCOMM established by SGI in conjunction with the Original Code are The
XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
XCOMM published by SGI, but has not been independently verified as being
XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
XCOMM
#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
SUBDIRS = \
internals \
interface \
nurbtess
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))

View file

@ -0,0 +1,75 @@
#!gmake
#
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: The application programming interfaces
# established by SGI in conjunction with the Original Code are The
# OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
# April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
# 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
# Window System(R) (Version 1.3), released October 19, 1998. This software
# was created using the OpenGL(R) version 1.2.1 Sample Implementation
# published by SGI, but has not been independently verified as being
# compliant with the OpenGL(R) version 1.2.1 Specification.
#
# $Date$ $Revision$
# $Header: //depot/main/gfx/lib/glu/libnurbs/interface/GNUmakefile#8 $
include $(ROOT)/usr/include/make/commondefs
TARGET = libinterface.a
TARGETS = $(TARGET)
LCXXDEFS = -DNDEBUG -DLIBRARYBUILD
LCXXINCS = -I. -I../../include -I../internals -I../nurbtess
HFILES = \
glcurveval.h \
glrenderer.h \
glsurfeval.h \
bezierPatch.h \
bezierEval.h \
bezierPatchMesh.h \
$(NULL)
CCFILES = \
glcurveval.cc \
glinterface.cc \
glrenderer.cc \
glsurfeval.cc \
insurfeval.cc \
bezierPatch.cc \
bezierEval.cc \
bezierPatchMesh.cc \
incurveeval.cc \
$(NULL)
default libs libs_install install: $(TARGET)
headers headers_install apps:
$(TARGET): $(OBJECTS)
$(AR) crl $@ $(OBJECTS);
include $(COMMONRULES)

View file

@ -0,0 +1,63 @@
XCOMM License Applicability. Except to the extent portions of this file are
XCOMM made subject to an alternative license as permitted in the SGI Free
XCOMM Software License B, Version 1.1 (the "License"), the contents of this
XCOMM file are subject only to the provisions of the License. You may not use
XCOMM this file except in compliance with the License. You may obtain a copy
XCOMM of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
XCOMM Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
XCOMM
XCOMM http://oss.sgi.com/projects/FreeB
XCOMM
XCOMM Note that, as provided in the License, the Software is distributed on an
XCOMM "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
XCOMM DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
XCOMM CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
XCOMM PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
XCOMM
XCOMM Original Code. The Original Code is: OpenGL Sample Implementation,
XCOMM Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
XCOMM Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
XCOMM Copyright in any portions created by third parties is as indicated
XCOMM elsewhere herein. All Rights Reserved.
XCOMM
XCOMM Additional Notice Provisions: The application programming interfaces
XCOMM established by SGI in conjunction with the Original Code are The
XCOMM OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
XCOMM April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
XCOMM 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
XCOMM Window System(R) (Version 1.3), released October 19, 1998. This software
XCOMM was created using the OpenGL(R) version 1.2.1 Sample Implementation
XCOMM published by SGI, but has not been independently verified as being
XCOMM compliant with the OpenGL(R) version 1.2.1 Specification.
XCOMM
#include <Library.tmpl>
OBJS = \
bezierEval.o \
bezierPatch.o \
bezierPatchMesh.o \
glcurveval.o \
glinterface.o \
glrenderer.o \
glsurfeval.o \
incurveeval.o \
insurfeval.o
INCLUDES = \
-I../internals \
-I../nurbtess \
-I../../include \
-I$(TOP)/include \
-I$(TOP)/include/GL
DEFINES = \
-DLIBRARYBUILD \
-DNDEBUG
NormalCplusplusObjectRule()
NormalLibraryTarget(interface, $(OBJS))
DependTarget()
CleanTarget()

View file

@ -0,0 +1,260 @@
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
*/
/*
*/
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "bezierEval.h"
#ifdef __WATCOMC__
#pragma warning 14 10
#endif
#define TOLERANCE 0.0001
#ifndef MAX_ORDER
#define MAX_ORDER 16
#endif
#ifndef MAX_DIMENSION
#define MAX_DIMENSION 4
#endif
static void normalize(float vec[3]);
static void crossProduct(float x[3], float y[3], float ret[3]);
#if 0 // UNUSED
static void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[]);
#endif
static float binomialCoefficients[8][8] = {
{1,0,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
{1,2,1,0,0,0,0,0},
{1,3,3,1,0,0,0,0},
{1,4,6,4,1,0,0,0},
{1,5,10,10,5,1,0,0},
{1,6,15,20,15,6,1,0},
{1,7,21,35,35,21,7,1}
};
void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[])
{
float uprime = (u-u0)/(u1-u0);
float *ctlptr = ctlpoints;
float oneMinusX = 1.0f-uprime;
float XPower = 1.0f;
int i,k;
for(k=0; k<dimension; k++)
retpoint[k] = (*(ctlptr + k));
for(i=1; i<order; i++){
ctlptr += stride;
XPower *= uprime;
for(k=0; k<dimension; k++) {
retpoint[k] = retpoint[k]*oneMinusX + ctlptr[k]* binomialCoefficients[order-1][i] * XPower;
}
}
}
#if 0 // UNUSED
/*order = degree +1 >=1.
*/
void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[])
{
float uprime = (u-u0)/(u1-u0);
float buf[MAX_ORDER][MAX_ORDER][MAX_DIMENSION];
float* ctlptr = ctlpoints;
int r, i,j;
for(i=0; i<order; i++) {
for(j=0; j<dimension; j++)
buf[0][i][j] = ctlptr[j];
ctlptr += stride;
}
for(r=1; r<order; r++){
for(i=0; i<order-r; i++) {
for(j=0; j<dimension; j++)
buf[r][i][j] = (1-uprime)*buf[r-1][i][j] + uprime*buf[r-1][i+1][j];
}
}
for(j=0; j<dimension; j++)
retpoint[j] = buf[order-1][0][j];
}
#endif
/*order = degree +1 >=1.
*/
void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[])
{
int i,k;
float width = u1-u0;
float *ctlptr = ctlpoints;
float buf[MAX_ORDER][MAX_DIMENSION];
if(order == 1){
for(k=0; k<dimension; k++)
retDer[k]=0;
}
for(i=0; i<order-1; i++){
for(k=0; k<dimension; k++) {
buf[i][k] = (ctlptr[stride+k] - ctlptr[k])*(order-1)/width;
}
ctlptr += stride;
}
bezierCurveEval(u0, u1, order-1, (float*) buf, MAX_DIMENSION, dimension, u, retDer);
}
void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[])
{
int i,k,r;
float *ctlptr = ctlpoints;
float width=u1-u0;
float buf[MAX_ORDER][MAX_ORDER][MAX_DIMENSION];
if(der<0) der=0;
for(i=0; i<order; i++){
for(k=0; k<dimension; k++){
buf[0][i][k] = ctlptr[k];
}
ctlptr += stride;
}
for(r=1; r<=der; r++){
for(i=0; i<order-r; i++){
for(k=0; k<dimension; k++){
buf[r][i][k] = (buf[r-1][i+1][k] - buf[r-1][i][k])*(order-r)/width;
}
}
}
bezierCurveEval(u0, u1, order-der, (float *) (buf[der]), MAX_DIMENSION, dimension, u, retDer);
}
/*the Bezier bivarite polynomial is:
* sum[i:0,uorder-1][j:0,vorder-1] { ctlpoints[i*ustride+j*vstride] * B(i)*B(j)
* where B(i) and B(j) are basis functions
*/
void bezierSurfEvalDerGen(int uder, int vder, float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[])
{
int i;
float newPoints[MAX_ORDER][MAX_DIMENSION];
for(i=0; i<uorder; i++){
bezierCurveEvalDerGen(vder, v0, v1, vorder, ctlpoints+ustride*i, vstride, dimension, v, newPoints[i]);
}
bezierCurveEvalDerGen(uder, u0, u1, uorder, (float *) newPoints, MAX_DIMENSION, dimension, u, ret);
}
/*division by w is performed*/
void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[])
{
bezierSurfEvalDerGen(0, 0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, ret);
if(dimension == 4) /*homogeneous*/{
ret[0] /= ret[3];
ret[1] /= ret[3];
ret[2] /= ret[3];
}
}
void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float retNormal[])
{
float partialU[4];
float partialV[4];
assert(dimension>=3 && dimension <=4);
bezierSurfEvalDerGen(1,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialU);
bezierSurfEvalDerGen(0,1, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialV);
if(dimension == 3){/*inhomogeneous*/
crossProduct(partialU, partialV, retNormal);
normalize(retNormal);
return;
}
else { /*homogeneous*/
float val[4]; /*the point coordinates (without derivative)*/
float newPartialU[MAX_DIMENSION];
float newPartialV[MAX_DIMENSION];
int i;
bezierSurfEvalDerGen(0,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, val);
for(i=0; i<=2; i++){
newPartialU[i] = partialU[i] * val[3] - val[i] * partialU[3];
newPartialV[i] = partialV[i] * val[3] - val[i] * partialV[3];
}
crossProduct(newPartialU, newPartialV, retNormal);
normalize(retNormal);
}
}
/*if size is 0, then nothing is done*/
static void normalize(float vec[3])
{
float size = (float)sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
if(size < TOLERANCE)
{
#ifdef DEBUG
fprintf(stderr, "Warning: in oglBSpline.c normal is 0\n");
#endif
return;
}
else {
vec[0] = vec[0]/size;
vec[1] = vec[1]/size;
vec[2] = vec[2]/size;
}
}
static void crossProduct(float x[3], float y[3], float ret[3])
{
ret[0] = x[1]*y[2] - y[1]*x[2];
ret[1] = x[2]*y[0] - y[2]*x[0];
ret[2] = x[0]*y[1] - y[0]*x[1];
}

View file

@ -0,0 +1,48 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
/*
*/
#ifndef _BEZIEREVAL_H
#define _BEZIEREVAL_H
void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retpoint[]);
void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[]);
void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride, int dimension, float u, float retDer[]);
void bezierSurfEvalDerGen(int uder, int vder, float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[]);
void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[]);
void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float retNormal[]);
#endif

View file

@ -0,0 +1,206 @@
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
*/
/*
*/
#include "gluos.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <GL/glu.h> /*for drawing bzier patch*/
#include "bezierPatch.h"
#include "bezierEval.h"
/*
*allocate an instance of bezierPatch. The control points are unknown. But
*the space of this array is allocated with size of
* uorder*vorder*dimension
*
*/
bezierPatch* bezierPatchMake(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension)
{
bezierPatch* ret = (bezierPatch*) malloc(sizeof(bezierPatch));
assert(ret);
ret->umin = umin;
ret->vmin = vmin;
ret->umax = umax;
ret->vmax = vmax;
ret->uorder = uorder;
ret->vorder = vorder;
ret->dimension = dimension;
ret->ctlpoints = (float*) malloc(sizeof(float) * dimension * uorder * vorder);
assert(ret->ctlpoints);
ret->next = NULL;
return ret;
}
bezierPatch* bezierPatchMake2(float umin, float vmin, float umax, float vmax, int uorder, int vorder, int dimension, int ustride, int vstride, float* ctlpoints)
{
bezierPatch* ret = (bezierPatch*) malloc(sizeof(bezierPatch));
assert(ret);
ret->umin = umin;
ret->vmin = vmin;
ret->umax = umax;
ret->vmax = vmax;
ret->uorder = uorder;
ret->vorder = vorder;
ret->dimension = dimension;
ret->ctlpoints = (float*) malloc(sizeof(float) * dimension * uorder * vorder);
assert(ret->ctlpoints);
/*copy the control points there*/
int the_ustride = vorder * dimension;
int the_vstride = dimension;
for(int i=0; i<uorder; i++)
for(int j=0; j<vorder; j++)
for(int k=0; k<dimension; k++)
ret->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
ret->next = NULL;
return ret;
}
/*
*deallocate the space as allocated by Make
*/
void bezierPatchDelete(bezierPatch *b)
{
free(b->ctlpoints);
free(b);
}
/*delete the whole linked list
*/
void bezierPatchDeleteList(bezierPatch *b)
{
bezierPatch *temp;
while (b != NULL) {
temp = b;
b = b->next;
bezierPatchDelete(temp);
}
}
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b)
{
b->next = list;
return b;
}
/*print the data stored in this patch*/
void bezierPatchPrint(bezierPatch *b)
{
printf("bezierPatch:\n");
printf("umin,umax=(%f,%f), (vmin, vmax)=(%f,%f)\n", b->umin, b->umax, b->vmin, b->vmax);
printf("uorder=%i, vorder=%i\n", b->uorder, b->vorder);
printf("idmension = %i\n", b->dimension);
}
/*print the whole list*/
void bezierPatchPrintList(bezierPatch *list)
{
bezierPatch* temp;
for(temp=list; temp != NULL; temp = temp->next)
bezierPatchPrint(temp);
}
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[])
{
if( u >= b->umin && u<= b->umax
&& v >= b->vmin && v<= b->vmax)
{
bezierSurfEval(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
}
else if(b->next != NULL)
bezierPatchEval(b->next, u,v, ret);
else
bezierSurfEval(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
}
/*the returned normal is normlized
*/
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float ret[])
{
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
if( u >= b->umin && u<= b->umax
&& v >= b->vmin && v<= b->vmax)
{
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
}
else if(b->next != NULL)
bezierPatchEvalNormal(b->next, u,v, ret);
else
bezierSurfEvalNormal(b->umin, b->umax, b->uorder, b->vmin, b->vmax, b->vorder, b->dimension, b->ctlpoints, b->dimension * b->vorder, b->dimension, u, v, ret);
}
void bezierPatchDraw(bezierPatch *bpatch, int u_reso, int v_reso)
{
if(bpatch->dimension == 3)
glMap2f(GL_MAP2_VERTEX_3, bpatch->umin, bpatch->umax, 3*bpatch->vorder, bpatch->uorder, bpatch->vmin, bpatch->vmax,3, bpatch->vorder, (GLfloat*) bpatch->ctlpoints);
else
glMap2f(GL_MAP2_VERTEX_4, bpatch->umin, bpatch->umax, 4*bpatch->vorder, bpatch->uorder, bpatch->vmin, bpatch->vmax,3, bpatch->vorder, (GLfloat*) bpatch->ctlpoints);
glMapGrid2f(u_reso, bpatch->umin, bpatch->umax,
v_reso, bpatch->vmin, bpatch->vmax);
glEvalMesh2(GL_LINE, 0, u_reso, 0, v_reso);
}
void bezierPatchListDraw(bezierPatch *list, int u_reso, int v_reso)
{
bezierPatch *temp;
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glColor3f(1,0,0);
#ifdef DEBUG
printf("mapmap\n");
#endif
for(temp = list; temp != NULL; temp = temp->next)
bezierPatchDraw(temp, u_reso, v_reso);
}

View file

@ -0,0 +1,104 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
/*
*/
#ifndef _BEZIERPATCH_H
#define _BEZIERPATCH_H
typedef struct bezierPatch{
float umin, vmin, umax, vmax;
int uorder; /*order= degree + 1*/
int vorder;
/*
*the control points are stored in a one dimensional array.
*the surface is defined as:
* s(u,v) = sum_{i,j} P(i,j) * B_i(u) * B_j(v).
*where P(i,j) are the control points, B_i(.) are Bezier
*basis functions.
*Each control point can have dimension 3 or 4: (x,y,z,w).
*The components of P(i,j) are stored in a one dimensional
*array:
* ctlpoints[]
*in the order of:
* P[0,0], P[0,1], ..., P[0,vorder-1],
* P[1,0], P[1,1], ..., P[1,vorder-1],
* ...
* P[uorder-1,0], P[uorder-1,1], ..., P[uorder-1,vorder-1].
*/
int dimension;
float* ctlpoints;
/*
*in case we have to manage multiple bezierPatches.
*/
struct bezierPatch *next;
} bezierPatch;
#ifdef __cplusplus
extern "C" {
#endif
bezierPatch* bezierPatchMake(float umin, float vmin, float umax, float vmax, int urder, int vorder, int dimension);
bezierPatch* bezierPatchMake2(float umin, float vmin, float umax, float vmax, int urder, int vorder, int dimension, int ustride, int vstride, float *ctlpoints);
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b);
void bezierPatchDelete(bezierPatch *b);
void bezierPatchDeleteList(bezierPatch *b);
void bezierPatchPrint(bezierPatch *b);
void bezierPatchPrintList(bezierPatch *list);
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[]);
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float retNormal[]);
void bezierPatchEval(bezierPatch *b, float u, float v, float ret[]);
void bezierPatchEvalNormal(bezierPatch *b, float u, float v, float ret[]);
void bezierPatchDraw(bezierPatch *bpatch, int u_reso, int v_reso);
void bezierPatchListDraw(bezierPatch *list, int u_reso, int v_reso);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,610 @@
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
*/
/*
*/
#include "gluos.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <GL/Regal.h>
#include "bezierEval.h"
#include "bezierPatchMesh.h"
static int isDegenerate(float A[2], float B[2], float C[2]);
void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips)
{
int i,j,k;
k=0;
/*k is the index of the first component of the current vertex*/
for(i=0; i<num_strips; i++)
{
glBegin(type_array[i]);
for(j=0; j<length_array[i]; j++)
{
glNormal3fv(normal_array+k);
glVertex3fv(vertex_array+k);
k += 3;
}
glEnd();
}
}
void bezierPatchMeshListDelDeg(bezierPatchMesh* list)
{
bezierPatchMesh* temp;
for(temp=list; temp != NULL; temp = temp->next)
{
bezierPatchMeshDelDeg(temp);
}
}
void bezierPatchMeshListDelete(bezierPatchMesh *list)
{
if(list == NULL) return;
bezierPatchMeshListDelete(list->next);
bezierPatchMeshDelete(list);
}
bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list)
{
bezierPatchMesh* ret=NULL;
bezierPatchMesh* temp;
bezierPatchMesh* nextone;
for(temp = list; temp != NULL; temp = nextone)
{
nextone = temp->next;
ret=bezierPatchMeshListInsert(ret, temp);
}
return ret;
}
/*maptype is either GL_MAP2_VERTEX_3 or GL_MAP2_VERTEX_4
*/
bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints, int size_UVarray, int size_length_array)
{
int i,j,k;
int dimension;
int the_ustride;
int the_vstride;
if(maptype == GL_MAP2_VERTEX_3) dimension = 3;
else if (maptype==GL_MAP2_VERTEX_4) dimension = 4;
else {
fprintf(stderr, "error in inMap2f, maptype=%i is wrong, maptype,map is invalid\n", maptype);
return NULL;
}
bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
assert(ret);
ret->bpatch_normal = NULL;
ret->bpatch_color = NULL;
ret->bpatch_texcoord = NULL;
ret->bpatch = bezierPatchMake(umin, vmin, umax, vmax, uorder, vorder, dimension);
/*copy the control points there*/
the_ustride = vorder * dimension;
the_vstride = dimension;
for(i=0; i<uorder; i++)
for(j=0; j<vorder; j++)
for(k=0; k<dimension; k++)
ret->bpatch->ctlpoints[i * the_ustride + j*the_vstride+k] = ctlpoints[i*ustride+j*vstride+k];
ret->size_UVarray = size_UVarray;
ret->size_length_array = size_length_array;
ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
assert(ret->UVarray);
ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
assert(ret->length_array);
ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
assert(ret->type_array);
ret->index_UVarray = 0;
ret->index_length_array = 0;
ret->vertex_array = NULL;
ret->normal_array = NULL;
ret->color_array = NULL;
ret->texcoord_array = NULL;
ret->next = NULL;
return ret;
}
bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array)
{
bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
assert(ret);
ret->bpatch = NULL;
ret->bpatch_normal = NULL;
ret->bpatch_color = NULL;
ret->bpatch_texcoord = NULL;
ret->size_UVarray = size_UVarray;
ret->size_length_array = size_length_array;
ret->UVarray = (float*) malloc(sizeof(float) * size_UVarray);
assert(ret->UVarray);
ret->length_array = (int *)malloc(sizeof(int) * size_length_array);
assert(ret->length_array);
ret->type_array = (GLenum *)malloc(sizeof(GLenum) * size_length_array);
assert(ret->type_array);
ret->index_UVarray = 0;
ret->index_length_array = 0;
ret->vertex_array = NULL;
ret->normal_array = NULL;
ret->color_array = NULL;
ret->texcoord_array = NULL;
ret->next = NULL;
return ret;
}
void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints)
{
switch(maptype){
case GL_MAP2_VERTEX_3:
bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
break;
case GL_MAP2_VERTEX_4:
bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4,ustride, vstride, ctlpoints );
break;
case GL_MAP2_NORMAL:
bpm->bpatch_normal = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
break;
case GL_MAP2_INDEX:
bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
break;
case GL_MAP2_COLOR_4:
bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
break;
case GL_MAP2_TEXTURE_COORD_1:
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
break;
case GL_MAP2_TEXTURE_COORD_2:
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 2, ustride, vstride, ctlpoints);
break;
case GL_MAP2_TEXTURE_COORD_3:
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
break;
case GL_MAP2_TEXTURE_COORD_4:
bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
break;
default:
fprintf(stderr, "error in bezierPatchMeshPutPatch, maptype=%i is wrong, maptype,map is invalid\n", maptype);
}
}
/*delete everything including the arrays. So if you want to output the
*pointers of the arrays, you should not use this function to deallocate space.
*you should dealocate manually
*/
void bezierPatchMeshDelete(bezierPatchMesh *bpm)
{
if(bpm->bpatch != NULL)
bezierPatchDelete(bpm->bpatch);
if(bpm->bpatch_normal != NULL)
bezierPatchDelete(bpm->bpatch_normal);
if(bpm->bpatch_color != NULL)
bezierPatchDelete(bpm->bpatch_color);
if(bpm->bpatch_texcoord != NULL)
bezierPatchDelete(bpm->bpatch_texcoord);
free(bpm->UVarray);
free(bpm->length_array);
free(bpm->vertex_array);
free(bpm->normal_array);
free(bpm->type_array);
free(bpm);
}
/*begin a strip
*type is the primitive type:
*/
void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type)
{
bpm->counter = 0;
bpm->type = type;
}
/*signal the end of the current strip*/
void bezierPatchMeshEndStrip(bezierPatchMesh *bpm)
{
int i;
/*if there are no vertices in this strip, then nothing needs to be done*/
if(bpm->counter == 0) return;
/*if the length_array is full, it should be expanded*/
if(bpm->index_length_array >= bpm->size_length_array)
{
int *temp = (int*) malloc(sizeof(int) * (bpm->size_length_array*2 + 1));
assert(temp);
GLenum *temp_type = (GLenum*) malloc(sizeof(GLenum) * (bpm->size_length_array*2 + 1));
assert(temp_type);
/*update the size*/
bpm->size_length_array = bpm->size_length_array*2 + 1;
/*copy*/
for(i=0; i<bpm->index_length_array; i++)
{
temp[i] = bpm->length_array[i];
temp_type[i] = bpm->type_array[i];
}
/*deallocate old array*/
free(bpm->length_array);
free(bpm->type_array);
/*point to the new array which is twice as bigger*/
bpm->length_array = temp;
bpm->type_array = temp_type;
}
bpm->type_array[bpm->index_length_array] = bpm->type;
bpm->length_array[bpm->index_length_array++] = bpm->counter;
}
/*insert (u,v) */
void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v)
{
int i;
/*if the UVarray is full, it should be expanded*/
if(bpm->index_UVarray+1 >= bpm->size_UVarray)
{
float *temp = (float*) malloc(sizeof(float) * (bpm->size_UVarray * 2 + 2));
assert(temp);
/*update the size*/
bpm->size_UVarray = bpm->size_UVarray*2 + 2;
/*copy*/
for(i=0; i<bpm->index_UVarray; i++)
{
temp[i] = bpm->UVarray[i];
}
/*deallocate old array*/
free(bpm->UVarray);
/*pointing to the new arrays*/
bpm->UVarray = temp;
}
/*insert the new UV*/
bpm->UVarray[bpm->index_UVarray] = u;
bpm->index_UVarray++;
bpm->UVarray[bpm->index_UVarray] = v;
bpm->index_UVarray++;
/*update counter: one more vertex*/
bpm->counter++;
}
void bezierPatchMeshPrint(bezierPatchMesh *bpm)
{
int i;
printf("the bezier patch is\n");
bezierPatchPrint(bpm->bpatch);
printf("index_length_array= %i\n", bpm->index_length_array);
printf("size_length_array =%i\n", bpm->size_length_array);
printf("index_UVarray =%i\n", bpm->index_UVarray);
printf("size_UVarray =%i\n", bpm->size_UVarray);
printf("UVarray is\n");
for(i=0; i<bpm->index_UVarray; i++)
printf("%f ", bpm->UVarray[i]);
printf("length_array is\n");
for(i=0; i<bpm->index_length_array; i++)
printf("%i ", bpm->length_array[i]);
printf("\n");
}
/*insert a new patch in front of the current linked list and return the new list*/
bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm)
{
bpm->next=list;
return bpm;
}
/*print all the patches*/
void bezierPatchMeshListPrint(bezierPatchMesh* list)
{
bezierPatchMesh *temp;
for(temp = list; temp != NULL; temp = temp->next)
{
bezierPatchMeshPrint(temp);
}
}
int bezierPatchMeshListTotalStrips(bezierPatchMesh* list)
{
int sum=0;
bezierPatchMesh *temp;
for(temp=list; temp != NULL; temp = temp->next)
{
sum += temp->index_length_array;
}
return sum;
}
int bezierPatchMeshListTotalVert(bezierPatchMesh* list)
{
int sum=0;
bezierPatchMesh *temp;
for(temp=list; temp != NULL; temp = temp->next)
{
sum += temp->index_UVarray;
}
return sum/2;
}
int bezierPatchMeshListNumTriangles(bezierPatchMesh* list)
{
int sum=0;
bezierPatchMesh* temp;
for(temp=list; temp != NULL; temp = temp->next)
{
sum += bezierPatchMeshNumTriangles(temp);
}
return sum;
}
int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm)
{
int i;
int sum=0;
for(i=0; i<bpm->index_length_array; i++)
{
switch(bpm->type_array[i])
{
case GL_TRIANGLES:
sum += bpm->length_array[i]/3;
break;
case GL_TRIANGLE_FAN:
if(bpm->length_array[i] > 2)
sum += bpm->length_array[i]-2;
break;
case GL_TRIANGLE_STRIP:
if(bpm->length_array[i] > 2)
sum += bpm->length_array[i]-2;
break;
case GL_QUAD_STRIP:
if(bpm->length_array[i]>2)
sum += (bpm->length_array[i]-2);
break;
default:
fprintf(stderr,"error in bezierPatchMeshListNumTriangles, type invalid\n");
}
}
return sum;
}
/*delete degenerate triangles*/
void bezierPatchMeshDelDeg(bezierPatchMesh* bpm)
{
if(bpm == NULL) return;
int i,j,k;
int *new_length_array;
GLenum *new_type_array;
int index_new_length_array;
float *new_UVarray;
int index_new_UVarray;
new_length_array = (int*)malloc(sizeof(int) * bpm->index_length_array);
assert(new_length_array);
new_type_array = (GLenum*)malloc(sizeof(GLenum) * bpm->index_length_array);
assert(new_length_array);
new_UVarray = (float*) malloc(sizeof(float) * bpm->index_UVarray);
assert(new_UVarray);
index_new_length_array = 0;
index_new_UVarray=0;
k=0;
for(i=0; i<bpm->index_length_array; i++){
/*(if not degenerate, we have to copy*/
if( (bpm->length_array[i] != 3) || (!isDegenerate(bpm->UVarray+k, bpm->UVarray+k+2, bpm->UVarray+k+4)))
{
for(j=0; j<2* bpm->length_array[i]; j++)
new_UVarray[index_new_UVarray++] = bpm->UVarray[k++];
new_length_array[index_new_length_array] = bpm->length_array[i];
new_type_array[index_new_length_array] = bpm->type_array[i];
index_new_length_array++;
}
else
{
k += 6;
}
}
free(bpm->UVarray);
free(bpm->length_array);
free(bpm->type_array);
bpm->UVarray=new_UVarray;
bpm->length_array=new_length_array;
bpm->type_array=new_type_array;
bpm->index_UVarray = index_new_UVarray;
bpm->index_length_array = index_new_length_array;
}
/*(u,v) to XYZ
*the xyz and normals are stored in vertex_array,
*and normal_array. the spaces of both are allocated here
*/
void bezierPatchMeshEval(bezierPatchMesh* bpm)
{
int i,j,k,l;
float u,v;
float u0 = bpm->bpatch->umin;
float u1 = bpm->bpatch->umax;
int uorder = bpm->bpatch->uorder;
float v0 = bpm->bpatch->vmin;
float v1 = bpm->bpatch->vmax;
int vorder = bpm->bpatch->vorder;
int dimension = bpm->bpatch->dimension;
int ustride = dimension * vorder;
int vstride = dimension;
float *ctlpoints = bpm->bpatch->ctlpoints;
bpm->vertex_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
assert(bpm->vertex_array);
bpm->normal_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
assert(bpm->normal_array);
k=0;
l=0;
for(i=0; i<bpm->index_length_array; i++)
{
for(j=0; j<bpm->length_array[i]; j++)
{
u = bpm->UVarray[k];
v = bpm->UVarray[k+1];
bezierSurfEval(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->vertex_array+l);
bezierSurfEvalNormal(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->normal_array+l);
k += 2;
l += 3;
}
}
}
void bezierPatchMeshListEval(bezierPatchMesh* list)
{
bezierPatchMesh* temp;
for(temp = list; temp != NULL; temp = temp->next)
{
bezierPatchMeshEval(temp);
}
}
void bezierPatchMeshDraw(bezierPatchMesh* bpm)
{
int i,j,k;
k=0;
/*k is the index of the first component of the current vertex*/
for(i=0; i<bpm->index_length_array; i++)
{
glBegin(bpm->type_array[i]);
for(j=0; j<bpm->length_array[i]; j++)
{
glNormal3fv(bpm->normal_array+k);
glVertex3fv(bpm->vertex_array+k);
k+= 3;
}
glEnd();
}
}
void bezierPatchMeshListDraw(bezierPatchMesh* list)
{
bezierPatchMesh* temp;
for(temp = list; temp != NULL; temp = temp->next)
{
bezierPatchMeshDraw(temp);
}
}
void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips)
{
int i,j,k,l;
bezierPatchMesh *temp;
int total_num_vertices = bezierPatchMeshListTotalVert(list);
(*vertex_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
assert(*vertex_array);
(*normal_array) = (float *) malloc(sizeof(float) * total_num_vertices*3);
assert(*normal_array);
*num_strips = bezierPatchMeshListTotalStrips(list);
*length_array = (int*) malloc(sizeof(int) * (*num_strips));
assert(*length_array);
*type_array = (GLenum*) malloc(sizeof(GLenum) * (*num_strips));
assert(*type_array);
k=0;
l=0;
for(temp = list; temp != NULL; temp = temp->next)
{
int x=0;
for(i=0; i<temp->index_length_array; i++)
{
for(j=0; j<temp->length_array[i]; j++)
{
(*vertex_array)[k] = temp->vertex_array[x];
(*vertex_array)[k+1] = temp->vertex_array[x+1];
(*vertex_array)[k+2] = temp->vertex_array[x+2];
(*normal_array)[k] = temp->normal_array[x];
(*normal_array)[k+1] = temp->normal_array[x+1];
(*normal_array)[k+2] = temp->normal_array[x+2];
x += 3;
k += 3;
}
(*type_array)[l] = temp->type_array[i];
(*length_array)[l++] = temp->length_array[i];
}
}
}
static int isDegenerate(float A[2], float B[2], float C[2])
{
if( (A[0] == B[0] && A[1]==B[1]) ||
(A[0] == C[0] && A[1]==C[1]) ||
(B[0] == C[0] && B[1]==C[1])
)
return 1;
else
return 0;
}

View file

@ -0,0 +1,121 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
/*
*/
#ifndef _BEZIERPATCHMESH_H
#define _BEZIERPATCHMESH_H
#include <GL/Regal.h>
#include "bezierPatch.h"
typedef struct bezierPatchMesh{
bezierPatch *bpatch; /*vertex*/
bezierPatch *bpatch_normal;
bezierPatch *bpatch_texcoord; /*s,t,r,q*/
bezierPatch *bpatch_color; /*RGBA*/
float *UVarray; /*all UV components of all vertices of all strips*/
int *length_array; /*[i] is the number of vertices in the ith strip*/
GLenum *type_array; /*[i] is the type of the ith primitive*/
/*to support dynamic insertion*/
int size_UVarray;
int index_UVarray;
int size_length_array;
int index_length_array;
int counter; /*track the current strip size*/
GLenum type; /*track the current type: 0: GL_TRIANGLES, 1: GL_TRIANGLE_STRIP*/
/*we eventually want to evaluate from (u,v) to (x,y,z) and draw them*/
float *vertex_array; /*each vertex contains three components*/
float *normal_array; /*each normal contains three components*/
float *color_array;
float *texcoord_array;
/*in case we need a linked list*/
struct bezierPatchMesh *next;
} bezierPatchMesh;
#ifdef __cplusplus
extern "C" {
#endif
bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints, int size_UVarray, int size_length_array);
/*initilize patches to be null*/
bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array);
void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints);
void bezierPatchMeshDelete(bezierPatchMesh *bpm);
void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type);
void bezierPatchMeshEndStrip(bezierPatchMesh *bpm);
void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v);
void bezierPatchMeshPrint(bezierPatchMesh *bpm);
bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm);
void bezierPatchMeshListPrint(bezierPatchMesh* list);
int bezierPatchMeshListTotalStrips(bezierPatchMesh* list);
int bezierPatchMeshListTotalVert(bezierPatchMesh* list);
int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm);
int bezierPatchMeshListNumTriangles(bezierPatchMesh* list);
void bezierPatchMeshDelDeg(bezierPatchMesh* bpm);
void bezierPatchMeshEval(bezierPatchMesh* bpm);
void bezierPatchMeshDraw(bezierPatchMesh* bpm);
void bezierPatchMeshListDraw(bezierPatchMesh* list);
void bezierPatchMeshListEval(bezierPatchMesh* list);
void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips);
void bezierPatchMeshListDelDeg(bezierPatchMesh* list);
void bezierPatchMeshListDelete(bezierPatchMesh *list);
bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list);
void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,402 @@
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
*/
/*
* glcurveval.c++
*
*/
/* Polynomial Evaluator Interface */
#include "gluos.h"
#include "glimports.h"
#include "glrenderer.h"
#include "glcurveval.h"
#include "nurbsconsts.h"
OpenGLCurveEvaluator::OpenGLCurveEvaluator(void)
{
//no default callback functions
beginCallBackN = NULL;
endCallBackN = NULL;
vertexCallBackN = NULL;
normalCallBackN = NULL;
colorCallBackN = NULL;
texcoordCallBackN = NULL;
beginCallBackData = NULL;
endCallBackData = NULL;
vertexCallBackData = NULL;
normalCallBackData = NULL;
colorCallBackData = NULL;
texcoordCallBackData = NULL;
userData = NULL;
vertex_flag = 0;
normal_flag = 0;
color_flag = 0;
texcoord_flag = 0;
em_vertex.uprime = -1.0;
em_normal.uprime = -1.0;
em_color.uprime = -1.0;
em_texcoord.uprime = -1.0;
output_triangles = 0; // don't output triangles by default
}
OpenGLCurveEvaluator::~OpenGLCurveEvaluator(void)
{
}
/* added nonsense to avoid the warning messages at compile time */
void
OpenGLCurveEvaluator::addMap(CurveMap *m)
{
m = m;
}
void
OpenGLCurveEvaluator::range1f(long type, REAL *from, REAL *to)
{
type = type;
from = from;
to = to;
}
void
OpenGLCurveEvaluator::domain1f(REAL ulo, REAL uhi)
{
ulo = ulo;
uhi = uhi;
}
void
OpenGLCurveEvaluator::bgnline(void)
{
if(output_triangles)
beginCallBack(GL_LINE_STRIP, userData);
else
glBegin((GLenum) GL_LINE_STRIP);
}
void
OpenGLCurveEvaluator::endline(void)
{
if(output_triangles)
endCallBack(userData);
else
glEnd();
}
/*---------------------------------------------------------------------------
* disable - turn off a curve map
*---------------------------------------------------------------------------
*/
void
OpenGLCurveEvaluator::disable(long type)
{
glDisable((GLenum) type);
}
/*---------------------------------------------------------------------------
* enable - turn on a curve map
*---------------------------------------------------------------------------
*/
void
OpenGLCurveEvaluator::enable(long type)
{
glEnable((GLenum) type);
}
/*-------------------------------------------------------------------------
* mapgrid1f - define a lattice of points with origin and offset
*-------------------------------------------------------------------------
*/
void
OpenGLCurveEvaluator::mapgrid1f(long nu, REAL u0, REAL u1)
{
if(output_triangles)
{
global_grid_u0 = u0;
global_grid_u1 = u1;
global_grid_nu = (int) nu;
}
else
glMapGrid1f((GLint) nu, (GLfloat) u0, (GLfloat) u1);
}
/*-------------------------------------------------------------------------
* bgnmap1 - preamble to curve definition and evaluations
*-------------------------------------------------------------------------
*/
void
OpenGLCurveEvaluator::bgnmap1f(long)
{
if(output_triangles)
{
//initialized so that no maps are set initially
vertex_flag = 0;
normal_flag = 0;
color_flag = 0;
texcoord_flag = 0;
//no need to worry about gl states when doing callback
}
else
glPushAttrib((GLbitfield) GL_EVAL_BIT);
}
/*-------------------------------------------------------------------------
* endmap1 - postamble to a curve map
*-------------------------------------------------------------------------
*/
void
OpenGLCurveEvaluator::endmap1f(void)
{
if(output_triangles)
{
}
else
glPopAttrib();
}
/*-------------------------------------------------------------------------
* map1f - pass a desription of a curve map
*-------------------------------------------------------------------------
*/
void
OpenGLCurveEvaluator::map1f(
long type, /* map type */
REAL ulo, /* lower parametric bound */
REAL uhi, /* upper parametric bound */
long stride, /* distance to next point in REALS */
long order, /* parametric order */
REAL *pts /* control points */
)
{
if(output_triangles)
{
int dimension = 0;
int which = 0;
switch(type){
case GL_MAP1_VERTEX_3:
which = 0;
dimension = 3;
break;
case GL_MAP1_VERTEX_4:
which=0;
dimension = 4;
break;
case GL_MAP1_INDEX:
which=2;
dimension = 1;
break;
case GL_MAP1_COLOR_4:
which=2;
dimension = 4;
break;
case GL_MAP1_NORMAL:
which=1;
dimension = 3;
break;
case GL_MAP1_TEXTURE_COORD_1:
which=3;
dimension = 1;
break;
case GL_MAP1_TEXTURE_COORD_2:
which=3;
dimension = 2;
break;
case GL_MAP1_TEXTURE_COORD_3:
which=3;
dimension = 3;
break;
case GL_MAP1_TEXTURE_COORD_4:
which=3;
dimension = 4;
break;
}
inMap1f(which, dimension, ulo, uhi, stride, order, pts);
}
else
glMap1f((GLenum) type, (GLfloat) ulo, (GLfloat) uhi, (GLint) stride,
(GLint) order, (const GLfloat *) pts);
}
/*-------------------------------------------------------------------------
* mapmesh1f - evaluate a mesh of points on lattice
*-------------------------------------------------------------------------
*/
void OpenGLCurveEvaluator::mapmesh1f(long style, long from, long to)
{
if(output_triangles)
{
inMapMesh1f((int) from, (int) to);
}
else
{
switch(style) {
default:
case N_MESHFILL:
case N_MESHLINE:
glEvalMesh1((GLenum) GL_LINE, (GLint) from, (GLint) to);
break;
case N_MESHPOINT:
glEvalMesh1((GLenum) GL_POINT, (GLint) from, (GLint) to);
break;
}
}
}
/*-------------------------------------------------------------------------
* evalpoint1i - evaluate a point on a curve
*-------------------------------------------------------------------------
*/
void OpenGLCurveEvaluator::evalpoint1i(long i)
{
glEvalPoint1((GLint) i);
}
/*-------------------------------------------------------------------------
* evalcoord1f - evaluate a point on a curve
*-------------------------------------------------------------------------
*/
void OpenGLCurveEvaluator::evalcoord1f(long, REAL u)
{
glEvalCoord1f((GLfloat) u);
}
void
#ifdef _WIN32
OpenGLCurveEvaluator::putCallBack(GLenum which, void (REGALGLU_CALL *fn)())
#else
OpenGLCurveEvaluator::putCallBack(GLenum which, _GLUfuncptr fn)
#endif
{
switch(which)
{
case GLU_NURBS_BEGIN:
beginCallBackN = (void (REGALGLU_CALL *) (GLenum)) fn;
break;
case GLU_NURBS_END:
endCallBackN = (void (REGALGLU_CALL *) (void)) fn;
break;
case GLU_NURBS_VERTEX:
vertexCallBackN = (void (REGALGLU_CALL *) (const GLfloat*)) fn;
break;
case GLU_NURBS_NORMAL:
normalCallBackN = (void (REGALGLU_CALL *) (const GLfloat*)) fn;
break;
case GLU_NURBS_COLOR:
colorCallBackN = (void (REGALGLU_CALL *) (const GLfloat*)) fn;
break;
case GLU_NURBS_TEXTURE_COORD:
texcoordCallBackN = (void (REGALGLU_CALL *) (const GLfloat*)) fn;
break;
case GLU_NURBS_BEGIN_DATA:
beginCallBackData = (void (REGALGLU_CALL *) (GLenum, void*)) fn;
break;
case GLU_NURBS_END_DATA:
endCallBackData = (void (REGALGLU_CALL *) (void*)) fn;
break;
case GLU_NURBS_VERTEX_DATA:
vertexCallBackData = (void (REGALGLU_CALL *) (const GLfloat*, void*)) fn;
break;
case GLU_NURBS_NORMAL_DATA:
normalCallBackData = (void (REGALGLU_CALL *) (const GLfloat*, void*)) fn;
break;
case GLU_NURBS_COLOR_DATA:
colorCallBackData = (void (REGALGLU_CALL *) (const GLfloat*, void*)) fn;
break;
case GLU_NURBS_TEXTURE_COORD_DATA:
texcoordCallBackData = (void (REGALGLU_CALL *) (const GLfloat*, void*)) fn;
break;
}
}
void
OpenGLCurveEvaluator::beginCallBack(GLenum which, void *data)
{
if(beginCallBackData)
beginCallBackData(which, data);
else if(beginCallBackN)
beginCallBackN(which);
}
void
OpenGLCurveEvaluator::endCallBack(void *data)
{
if(endCallBackData)
endCallBackData(data);
else if(endCallBackN)
endCallBackN();
}
void
OpenGLCurveEvaluator::vertexCallBack(const GLfloat *vert, void* data)
{
if(vertexCallBackData)
vertexCallBackData(vert, data);
else if(vertexCallBackN)
vertexCallBackN(vert);
}
void
OpenGLCurveEvaluator::normalCallBack(const GLfloat *normal, void* data)
{
if(normalCallBackData)
normalCallBackData(normal, data);
else if(normalCallBackN)
normalCallBackN(normal);
}
void
OpenGLCurveEvaluator::colorCallBack(const GLfloat *color, void* data)
{
if(colorCallBackData)
colorCallBackData(color, data);
else if(colorCallBackN)
colorCallBackN(color);
}
void
OpenGLCurveEvaluator::texcoordCallBack(const GLfloat *texcoord, void* data)
{
if(texcoordCallBackData)
texcoordCallBackData(texcoord, data);
else if(texcoordCallBackN)
texcoordCallBackN(texcoord);
}

View file

@ -0,0 +1,157 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
/*
* glcurveval.h
*
*/
#ifndef __gluglcurveval_h_
#define __gluglcurveval_h_
#include "gluos.h"
#include <GL/Regal.h>
#include <GL/glu.h>
#include "basiccrveval.h"
class CurveMap;
/*for internal evaluator callback stuff*/
#ifndef IN_MAX_BEZIER_ORDER
#define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
#endif
#ifndef IN_MAX_DIMENSION
#define IN_MAX_DIMENSION 4
#endif
typedef struct curveEvalMachine{
REAL uprime; //cached previously evaluated uprime
int k; //the dimension
REAL u1;
REAL u2;
int ustride;
int uorder;
REAL ctlpoints[IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
REAL ucoeff[IN_MAX_BEZIER_ORDER];//cache the polynomial values
} curveEvalMachine;
class OpenGLCurveEvaluator : public BasicCurveEvaluator {
public:
OpenGLCurveEvaluator(void);
virtual ~OpenGLCurveEvaluator(void);
void range1f(long, REAL *, REAL *);
void domain1f(REAL, REAL);
void addMap(CurveMap *);
void enable(long);
void disable(long);
void bgnmap1f(long);
void map1f(long, REAL, REAL, long, long, REAL *);
void mapgrid1f(long, REAL, REAL);
void mapmesh1f(long, long, long);
void evalpoint1i(long);
void evalcoord1f(long, REAL);
void endmap1f(void);
void bgnline(void);
void endline(void);
void put_vertices_call_back(int flag)
{
output_triangles = flag;
}
#ifdef _WIN32
void putCallBack(GLenum which, void (REGALGLU_CALL *fn)() );
#else
void putCallBack(GLenum which, _GLUfuncptr fn );
#endif
void set_callback_userData(void *data)
{
userData = data;
}
/*------------------begin for curveEvalMachine------------*/
curveEvalMachine em_vertex;
curveEvalMachine em_normal;
curveEvalMachine em_color;
curveEvalMachine em_texcoord;
int vertex_flag; //whether there is a vertex map or not
int normal_flag; //whether there is a normal map or not
int color_flag; //whether there is a color map or not
int texcoord_flag; //whether there is a texture map or not
REAL global_grid_u0;
REAL global_grid_u1;
int global_grid_nu;
void inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
int dimension,
REAL ulower,
REAL uupper,
int ustride,
int uorder,
REAL *ctlpoints);
void inPreEvaluate(int order, REAL vprime, REAL *coeff);
void inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint);
void inDoEvalCoord1(REAL u);
void inMapMesh1f(int umin, int umax);
void (REGALGLU_CALL *beginCallBackN) (GLenum type);
void (REGALGLU_CALL *endCallBackN) (void);
void (REGALGLU_CALL *vertexCallBackN) (const GLfloat *vert);
void (REGALGLU_CALL *normalCallBackN) (const GLfloat *normal);
void (REGALGLU_CALL *colorCallBackN) (const GLfloat *color);
void (REGALGLU_CALL *texcoordCallBackN) (const GLfloat *texcoord);
void (REGALGLU_CALL *beginCallBackData) (GLenum type, void* data);
void (REGALGLU_CALL *endCallBackData) (void* data);
void (REGALGLU_CALL *vertexCallBackData) (const GLfloat *vert, void* data);
void (REGALGLU_CALL *normalCallBackData) (const GLfloat *normal, void* data);
void (REGALGLU_CALL *colorCallBackData) (const GLfloat *color, void* data);
void (REGALGLU_CALL *texcoordCallBackData) (const GLfloat *texcoord, void* data);
void* userData; //the opaque pointer for Data callback functions
void beginCallBack(GLenum type, void* data);
void endCallBack(void* data);
void vertexCallBack(const GLfloat *vert, void *data);
void normalCallBack(const GLfloat *normal, void* data);
void colorCallBack(const GLfloat *color, void* data);
void texcoordCallBack(const GLfloat *texcoord, void* data);
/*------------------end for curveEvalMachine------------*/
private:
int output_triangles; //true 1; false 0
};
#endif /* __gluglcurveval_h_ */

View file

@ -0,0 +1,42 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
/*
* glimports.h
*
*/
#ifndef __gluimports_h_
#define __gluimports_h_
#include "mystdlib.h"
#include "mystdio.h"
#endif /* __gluimports_h_ */

View file

@ -0,0 +1,469 @@
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
*/
/*
*/
#include "gluos.h"
#include <GL/Regal.h>
#include <GL/glu.h>
#include <stdio.h>
#include "glimports.h"
#include "glrenderer.h"
#include "nurbsconsts.h"
//#define DOWN_LOAD_NURBS
#ifdef DOWN_LOAD_NURBS
#include "oglTrimNurbs.h"
static int surfcount = 0;
static oglTrimNurbs* otn = NULL;
nurbSurf* tempNurb = NULL;
oglTrimLoops* tempTrim = NULL;
#endif
//for LOD
extern "C" {void glu_LOD_eval_list(GLUnurbs *nurb, int level);}
void glu_LOD_eval_list(GLUnurbs *nurb, int level)
{
nurb->LOD_eval_list(level);
}
GLUnurbs * REGALGLU_CALL
gluNewNurbsRenderer(void)
{
GLUnurbs *t;
t = new GLUnurbs();
return t;
}
void REGALGLU_CALL
gluDeleteNurbsRenderer(GLUnurbs *r)
{
delete r;
}
extern "C"
void REGALGLU_CALL
gluDeleteNurbsTessellatorEXT(GLUnurbsObj *r)
{
delete r;
}
void REGALGLU_CALL
gluBeginSurface(GLUnurbs *r)
{
#ifdef DOWN_LOAD_NURBS
surfcount++;
tempTrim = OTL_make(10,10);
#endif
r->bgnsurface(0);
}
void REGALGLU_CALL
gluBeginCurve(GLUnurbs *r)
{
r->bgncurve(0);
}
void REGALGLU_CALL
gluEndCurve(GLUnurbs *r)
{
r->endcurve();
}
void REGALGLU_CALL
gluEndSurface(GLUnurbs *r)
{
#ifdef DOWN_LOAD_NURBS
if(surfcount == 1)
otn = OTN_make(1);
OTN_insert(otn, tempNurb, tempTrim);
if(surfcount >= 1)
{
#ifdef DEBUG
printf("write file\n");
#endif
OTN_write(otn, "out.otn");
}
#endif
r->endsurface();
}
void REGALGLU_CALL
gluBeginTrim(GLUnurbs *r)
{
#ifdef DOWN_LOAD_NURBS
OTL_bgnTrim(tempTrim);
#endif
r->bgntrim();
}
void REGALGLU_CALL
gluEndTrim(GLUnurbs *r)
{
#ifdef DOWN_LOAD_NURBS
OTL_endTrim(tempTrim);
#endif
r->endtrim();
}
void REGALGLU_CALL
gluPwlCurve(GLUnurbs *r, GLint count, INREAL array[],
GLint stride, GLenum type)
{
#ifdef DOWN_LOAD_NURBS
OTL_pwlCurve(tempTrim, count, array, stride, type);
#endif
int realType;
switch(type) {
case GLU_MAP1_TRIM_2:
realType = N_P2D;
break;
case GLU_MAP1_TRIM_3:
realType = N_P2DR;
break;
default:
realType = type;
break;
}
r->pwlcurve(count, array, sizeof(INREAL) * stride, realType);
}
void REGALGLU_CALL
gluNurbsCurve(GLUnurbs *r, GLint nknots, INREAL knot[], GLint stride,
INREAL ctlarray[], GLint order, GLenum type)
{
#ifdef DOWN_LOAD_NURBS
OTL_nurbsCurve(tempTrim, nknots, knot, stride, ctlarray, order, type);
#endif
int realType;
switch(type) {
case GLU_MAP1_TRIM_2:
realType = N_P2D;
break;
case GLU_MAP1_TRIM_3:
realType = N_P2DR;
break;
default:
realType = type;
break;
}
r->nurbscurve(nknots, knot, sizeof(INREAL) * stride, ctlarray, order,
realType);
}
void REGALGLU_CALL
gluNurbsSurface(GLUnurbs *r, GLint sknot_count, GLfloat *sknot,
GLint tknot_count, GLfloat *tknot,
GLint s_stride, GLint t_stride,
GLfloat *ctlarray, GLint sorder, GLint torder,
GLenum type)
{
#ifdef DOWN_LOAD_NURBS
{
int dimension;
switch(type){
case GL_MAP2_VERTEX_3:
dimension = 3;
break;
case GL_MAP2_VERTEX_4:
dimension = 4;
break;
default:
fprintf(stderr, "error in glinterface.c++, type no implemented\n");
exit(1);
}
tempNurb = nurbSurfMake(sknot_count, sknot,
tknot_count, tknot,
sorder, torder,
dimension,
ctlarray,
s_stride, t_stride);
}
#endif
r->nurbssurface(sknot_count, sknot, tknot_count, tknot,
sizeof(INREAL) * s_stride, sizeof(INREAL) * t_stride,
ctlarray, sorder, torder, type);
}
void REGALGLU_CALL
gluLoadSamplingMatrices(GLUnurbs *r, const GLfloat modelMatrix[16],
const GLfloat projMatrix[16],
const GLint viewport[4])
{
r->useGLMatrices(modelMatrix, projMatrix, viewport);
}
void REGALGLU_CALL
gluNurbsProperty(GLUnurbs *r, GLenum property, GLfloat value)
{
GLfloat nurbsValue;
switch (property) {
case GLU_AUTO_LOAD_MATRIX:
r->setautoloadmode(value);
return;
case GLU_CULLING:
if (value != 0.0) {
nurbsValue = N_CULLINGON;
} else {
nurbsValue = N_NOCULLING;
}
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, nurbsValue);
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLING, nurbsValue);
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLING, nurbsValue);
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLING, nurbsValue);
return;
case GLU_SAMPLING_METHOD:
if (value == GLU_PATH_LENGTH) {
nurbsValue = N_PATHLENGTH;
} else if (value == GLU_PARAMETRIC_ERROR) {
nurbsValue = N_PARAMETRICDISTANCE;
} else if (value == GLU_DOMAIN_DISTANCE) {
nurbsValue = N_DOMAINDISTANCE;
r->set_is_domain_distance_sampling(1); //optimzing untrimmed case
} else if (value == GLU_OBJECT_PARAMETRIC_ERROR) {
nurbsValue = N_OBJECTSPACE_PARA;
r->setautoloadmode( 0.0 );
r->setSamplingMatrixIdentity();
} else if (value == GLU_OBJECT_PATH_LENGTH) {
nurbsValue = N_OBJECTSPACE_PATH;
r->setautoloadmode( 0.0 );
r->setSamplingMatrixIdentity();
} else {
r->postError(GLU_INVALID_VALUE);
return;
}
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
return;
case GLU_SAMPLING_TOLERANCE:
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, value);
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, value);
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, value);
return;
case GLU_PARAMETRIC_TOLERANCE:
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, value);
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, value);
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, value);
return;
case GLU_DISPLAY_MODE:
if (value == GLU_FILL) {
nurbsValue = N_FILL;
} else if (value == GLU_OUTLINE_POLYGON) {
nurbsValue = N_OUTLINE_POLY;
} else if (value == GLU_OUTLINE_PATCH) {
nurbsValue = N_OUTLINE_PATCH;
} else {
r->postError(GLU_INVALID_VALUE);
return;
}
r->setnurbsproperty(N_DISPLAY, nurbsValue);
break;
case GLU_U_STEP:
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, value);
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, value);
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, value);
//added for optimizing untrimmed case
r->set_domain_distance_u_rate(value);
break;
case GLU_V_STEP:
r->setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, value);
r->setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, value);
r->setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
r->setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, value);
//added for optimizing untrimmed case
r->set_domain_distance_v_rate(value);
break;
case GLU_NURBS_MODE:
if(value == GLU_NURBS_RENDERER)
r->put_callbackFlag(0);
else if(value == GLU_NURBS_TESSELLATOR)
r->put_callbackFlag(1);
else
r->postError(GLU_INVALID_ENUM);
break;
default:
r->postError(GLU_INVALID_ENUM);
return;
}
}
void REGALGLU_CALL
gluGetNurbsProperty(GLUnurbs *r, GLenum property, GLfloat *value)
{
GLfloat nurbsValue;
switch(property) {
case GLU_AUTO_LOAD_MATRIX:
if (r->getautoloadmode()) {
*value = GL_TRUE;
} else {
*value = GL_FALSE;
}
break;
case GLU_CULLING:
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, &nurbsValue);
if (nurbsValue == N_CULLINGON) {
*value = GL_TRUE;
} else {
*value = GL_FALSE;
}
break;
case GLU_SAMPLING_METHOD:
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, value);
if(*value == N_PATHLENGTH)
*value = GLU_PATH_LENGTH;
else if(*value == N_PARAMETRICDISTANCE)
*value = GLU_PARAMETRIC_ERROR;
else if(*value == N_DOMAINDISTANCE)
*value = GLU_DOMAIN_DISTANCE;
else if(*value == N_OBJECTSPACE_PATH)
*value = GLU_OBJECT_PATH_LENGTH;
else if(*value == N_OBJECTSPACE_PARA)
*value = GLU_OBJECT_PARAMETRIC_ERROR;
break;
case GLU_SAMPLING_TOLERANCE:
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
break;
case GLU_PARAMETRIC_TOLERANCE:
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
break;
case GLU_U_STEP:
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
break;
case GLU_V_STEP:
r->getnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
break;
case GLU_DISPLAY_MODE:
r->getnurbsproperty(N_DISPLAY, &nurbsValue);
if (nurbsValue == N_FILL) {
*value = GLU_FILL;
} else if (nurbsValue == N_OUTLINE_POLY) {
*value = GLU_OUTLINE_POLYGON;
} else {
*value = GLU_OUTLINE_PATCH;
}
break;
case GLU_NURBS_MODE:
if(r->is_callback())
*value = GLU_NURBS_TESSELLATOR;
else
*value = GLU_NURBS_RENDERER;
break;
default:
r->postError(GLU_INVALID_ENUM);
return;
}
}
extern "C" void REGALGLU_CALL
gluNurbsCallback(GLUnurbs *r, GLenum which, _GLUfuncptr fn )
{
switch (which) {
case GLU_NURBS_BEGIN:
case GLU_NURBS_END:
case GLU_NURBS_VERTEX:
case GLU_NURBS_NORMAL:
case GLU_NURBS_TEXTURE_COORD:
case GLU_NURBS_COLOR:
case GLU_NURBS_BEGIN_DATA:
case GLU_NURBS_END_DATA:
case GLU_NURBS_VERTEX_DATA:
case GLU_NURBS_NORMAL_DATA:
case GLU_NURBS_TEXTURE_COORD_DATA:
case GLU_NURBS_COLOR_DATA:
r->putSurfCallBack(which, fn);
break;
case GLU_NURBS_ERROR:
r->errorCallback = (void (REGALGLU_CALL *)( GLenum e )) fn;
break;
default:
r->postError(GLU_INVALID_ENUM);
return;
}
}
extern "C"
void REGALGLU_CALL
gluNurbsCallbackDataEXT(GLUnurbs* r, void* userData)
{
r->setNurbsCallbackData(userData);
}
extern "C"
void REGALGLU_CALL
gluNurbsCallbackData(GLUnurbs* r, void* userData)
{
gluNurbsCallbackDataEXT(r,userData);
}

View file

@ -0,0 +1,301 @@
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
*/
/*
*/
#include "gluos.h"
#include "glimports.h"
#include "glrenderer.h"
GLUnurbs::GLUnurbs()
: NurbsTessellator(curveEvaluator, surfaceEvaluator)
{
redefineMaps();
defineMap(GL_MAP2_NORMAL, 0, 3);
defineMap(GL_MAP1_NORMAL, 0, 3);
defineMap(GL_MAP2_TEXTURE_COORD_1, 0, 1);
defineMap(GL_MAP1_TEXTURE_COORD_1, 0, 1);
defineMap(GL_MAP2_TEXTURE_COORD_2, 0, 2);
defineMap(GL_MAP1_TEXTURE_COORD_2, 0, 2);
defineMap(GL_MAP2_TEXTURE_COORD_3, 0, 3);
defineMap(GL_MAP1_TEXTURE_COORD_3, 0, 3);
defineMap(GL_MAP2_TEXTURE_COORD_4, 1, 4);
defineMap(GL_MAP1_TEXTURE_COORD_4, 1, 4);
defineMap(GL_MAP2_VERTEX_4, 1, 4);
defineMap(GL_MAP1_VERTEX_4, 1, 4);
defineMap(GL_MAP2_VERTEX_3, 0, 3);
defineMap(GL_MAP1_VERTEX_3, 0, 3);
defineMap(GL_MAP2_COLOR_4, 0, 4);
defineMap(GL_MAP1_COLOR_4, 0, 4);
defineMap(GL_MAP2_INDEX, 0, 1);
defineMap(GL_MAP1_INDEX, 0, 1);
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, (float) N_PATHLENGTH);
setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, (float) 50.0);
setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, (float) 50.0);
setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, (float) 50.0);
setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, (float) 50.0);
setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, (float) 0.50);
setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, (float) 0.50);
setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, (float) 0.50);
setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, (float) 0.50);
setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, (float) 100.0);
setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, (float) 100.0);
setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, (float) 100.0);
setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, (float) 100.0);
//added for optimizing untrimmed case
set_domain_distance_u_rate(100.0);
setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, (float) 100.0);
setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, (float) 100.0);
setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, (float) 100.0);
setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, (float) 100.0);
//added for optimizing untrimmed case
set_domain_distance_v_rate(100.0);
set_is_domain_distance_sampling(0); //since the default is path_length
//default autoloadmode is true
autoloadmode = 1;
//default callbackFlag is 0
callbackFlag = 0;
errorCallback = NULL;
}
void
GLUnurbs::bgnrender(void)
{
if (autoloadmode) {
loadGLMatrices();
}
}
void
GLUnurbs::endrender(void)
{
}
void
GLUnurbs::errorHandler(int i)
{
int gluError;
gluError = i + (GLU_NURBS_ERROR1 - 1);
postError( gluError );
}
void
GLUnurbs::loadGLMatrices(void)
{
GLfloat vmat[4][4];
GLint viewport[4];
grabGLMatrix((GLfloat (*)[4]) vmat);
loadCullingMatrix((GLfloat (*)[4]) vmat);
::glGetIntegerv((GLenum) GL_VIEWPORT, (GLint *) viewport);
loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
}
void
GLUnurbs::useGLMatrices(const GLfloat modelMatrix[16],
const GLfloat projMatrix[16],
const GLint viewport[4])
{
GLfloat vmat[4][4];
multmatrix4d(vmat, (const GLfloat (*)[4]) modelMatrix,
(const GLfloat (*)[4]) projMatrix);
loadCullingMatrix((GLfloat (*)[4]) vmat);
loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
}
/*--------------------------------------------------------------------------
* grabGLMatrix
*--------------------------------------------------------------------------
*/
void
GLUnurbs::grabGLMatrix(GLfloat vmat[4][4])
{
GLfloat m1[4][4], m2[4][4];
::glGetFloatv((GLenum) GL_MODELVIEW_MATRIX, (GLfloat *) &(m1[0][0]));
::glGetFloatv((GLenum) GL_PROJECTION_MATRIX, (GLfloat *) &(m2[0][0]));
multmatrix4d((GLfloat (*)[4]) vmat,
(const GLfloat (*)[4]) m1, (const GLfloat (*)[4]) m2);
}
//for object space tesselation: view independent
void
GLUnurbs::setSamplingMatrixIdentity( void )
{
INREAL smat[4][4] = {
{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{0,0,0,1}
};
const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
const long cstride = 1;
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
cstride);
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
cstride);
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
cstride);
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
cstride);
}
void
GLUnurbs::loadSamplingMatrix(const GLfloat vmat[4][4],
const GLint viewport[4])
{
/* rescale the mapping to correspond to pixels in x/y */
REAL xsize = 0.5 * (REAL) (viewport[2]);
REAL ysize = 0.5 * (REAL) (viewport[3]);
INREAL smat[4][4];
smat[0][0] = vmat[0][0] * xsize;
smat[1][0] = vmat[1][0] * xsize;
smat[2][0] = vmat[2][0] * xsize;
smat[3][0] = vmat[3][0] * xsize;
smat[0][1] = vmat[0][1] * ysize;
smat[1][1] = vmat[1][1] * ysize;
smat[2][1] = vmat[2][1] * ysize;
smat[3][1] = vmat[3][1] * ysize;
smat[0][2] = 0.0;
smat[1][2] = 0.0;
smat[2][2] = 0.0;
smat[3][2] = 0.0;
smat[0][3] = vmat[0][3];
smat[1][3] = vmat[1][3];
smat[2][3] = vmat[2][3];
smat[3][3] = vmat[3][3];
const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
const long cstride = 1;
setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
cstride);
setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
cstride);
setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
cstride);
setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
cstride);
}
void
GLUnurbs::loadCullingMatrix(GLfloat vmat[4][4])
{
INREAL cmat[4][4];
cmat[0][0] = vmat[0][0];
cmat[0][1] = vmat[0][1];
cmat[0][2] = vmat[0][2];
cmat[0][3] = vmat[0][3];
cmat[1][0] = vmat[1][0];
cmat[1][1] = vmat[1][1];
cmat[1][2] = vmat[1][2];
cmat[1][3] = vmat[1][3];
cmat[2][0] = vmat[2][0];
cmat[2][1] = vmat[2][1];
cmat[2][2] = vmat[2][2];
cmat[2][3] = vmat[2][3];
cmat[3][0] = vmat[3][0];
cmat[3][1] = vmat[3][1];
cmat[3][2] = vmat[3][2];
cmat[3][3] = vmat[3][3];
const long rstride = sizeof(cmat[0]) / sizeof(cmat[0][0]);
const long cstride = 1;
setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
cstride);
setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
cstride);
//added for curves by zl
setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
cstride);
setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
cstride);
}
/*---------------------------------------------------------------------
* A = B * MAT ; transform a 4d vector through a 4x4 matrix
*---------------------------------------------------------------------
*/
void
GLUnurbs::transform4d(GLfloat A[4], GLfloat B[4], GLfloat mat[4][4])
{
A[0] = B[0]*mat[0][0] + B[1]*mat[1][0] + B[2]*mat[2][0] + B[3]*mat[3][0];
A[1] = B[0]*mat[0][1] + B[1]*mat[1][1] + B[2]*mat[2][1] + B[3]*mat[3][1];
A[2] = B[0]*mat[0][2] + B[1]*mat[1][2] + B[2]*mat[2][2] + B[3]*mat[3][2];
A[3] = B[0]*mat[0][3] + B[1]*mat[1][3] + B[2]*mat[2][3] + B[3]*mat[3][3];
}
/*---------------------------------------------------------------------
* new = [left][right] ; multiply two matrices together
*---------------------------------------------------------------------
*/
void
GLUnurbs::multmatrix4d (GLfloat n[4][4], const GLfloat left[4][4],
const GLfloat right[4][4])
{
transform4d ((GLfloat *) n[0],(GLfloat *) left[0],(GLfloat (*)[4]) right);
transform4d ((GLfloat *) n[1],(GLfloat *) left[1],(GLfloat (*)[4]) right);
transform4d ((GLfloat *) n[2],(GLfloat *) left[2],(GLfloat (*)[4]) right);
transform4d ((GLfloat *) n[3],(GLfloat *) left[3],(GLfloat (*)[4]) right);
}

View file

@ -0,0 +1,146 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
/*
* glrenderer.h
*
*/
#ifndef __gluglrenderer_h_
#define __gluglrenderer_h_
#include <GL/Regal.h>
#include <GL/glu.h>
#include "nurbstess.h"
#include "glsurfeval.h"
#include "glcurveval.h"
extern "C" {
typedef void (REGALGLU_CALL *errorCallbackType)( GLenum );
}
class GLUnurbs : public NurbsTessellator {
public:
GLUnurbs( void );
void loadGLMatrices( void );
void useGLMatrices( const GLfloat modelMatrix[16],
const GLfloat projMatrix[16],
const GLint viewport[4] );
void setSamplingMatrixIdentity( void );
void errorHandler( int );
void bgnrender( void );
void endrender( void );
void setautoloadmode( INREAL value )
{
if (value) autoloadmode = GL_TRUE;
else autoloadmode = GL_FALSE;
}
GLboolean getautoloadmode( void ) { return autoloadmode; }
errorCallbackType errorCallback;
void postError( int which )
{ if (errorCallback) (errorCallback)( (GLenum)which ); }
#ifdef _WIN32
void putSurfCallBack(GLenum which, void (REGALGLU_CALL *fn)() )
#else
void putSurfCallBack(GLenum which, _GLUfuncptr fn )
#endif
{
curveEvaluator.putCallBack(which, fn);
surfaceEvaluator.putCallBack(which, fn);
}
int get_vertices_call_back()
{
return surfaceEvaluator.get_vertices_call_back();
}
void put_vertices_call_back(int flag)
{
surfaceEvaluator.put_vertices_call_back(flag);
}
int get_callback_auto_normal()
{
return surfaceEvaluator.get_callback_auto_normal();
}
void put_callback_auto_normal(int flag)
{
surfaceEvaluator.put_callback_auto_normal(flag);
}
void setNurbsCallbackData(void* userData)
{
curveEvaluator.set_callback_userData(userData);
surfaceEvaluator.set_callback_userData(userData);
}
//for LOD
void LOD_eval_list(int level)
{
surfaceEvaluator.LOD_eval_list(level);
}
//NEWCALLBACK
int is_callback()
{
return callbackFlag;
}
void put_callbackFlag(int flag)
{
callbackFlag = flag;
surfaceEvaluator.put_vertices_call_back(flag);
curveEvaluator.put_vertices_call_back(flag);
}
private:
GLboolean autoloadmode;
OpenGLSurfaceEvaluator surfaceEvaluator;
OpenGLCurveEvaluator curveEvaluator;
void loadSamplingMatrix( const GLfloat vmat[4][4],
const GLint viewport[4] );
void loadCullingMatrix( GLfloat vmat[4][4] );
static void grabGLMatrix( GLfloat vmat[4][4] );
static void transform4d( GLfloat A[4], GLfloat B[4],
GLfloat mat[4][4] );
static void multmatrix4d( GLfloat n[4][4], const GLfloat left[4][4],
const GLfloat right[4][4] );
int callbackFlag;
};
#endif /* __gluglrenderer_h_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,404 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
/*
* glsurfeval.h
*
*/
#ifndef __gluglsurfeval_h_
#define __gluglsurfeval_h_
#include "basicsurfeval.h"
#include "bezierPatchMesh.h" //in case output triangles
#include <GL/Regal.h>
#include <GL/glu.h>
class SurfaceMap;
class OpenGLSurfaceEvaluator;
class StoredVertex;
#define TYPECOORD 1
#define TYPEPOINT 2
/* Cache up to 3 vertices from tmeshes */
#define VERTEX_CACHE_SIZE 3
/*for internal evaluator callback stuff*/
#ifndef IN_MAX_BEZIER_ORDER
#define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
#endif
#ifndef IN_MAX_DIMENSION
#define IN_MAX_DIMENSION 4
#endif
typedef struct surfEvalMachine{
REAL uprime;//cached previusly evaluated uprime.
REAL vprime;
int k; /*the dimension*/
REAL u1;
REAL u2;
int ustride;
int uorder;
REAL v1;
REAL v2;
int vstride;
int vorder;
REAL ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
REAL ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
REAL vcoeff[IN_MAX_BEZIER_ORDER];
REAL ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
REAL vcoeffDeriv[IN_MAX_BEZIER_ORDER];
} surfEvalMachine;
class StoredVertex {
public:
StoredVertex() { type = 0; coord[0] = 0; coord[1] = 0; point[0] = 0; point[1] = 0; }
~StoredVertex(void) {}
void saveEvalCoord(REAL x, REAL y)
{coord[0] = x; coord[1] = y; type = TYPECOORD; }
void saveEvalPoint(long x, long y)
{point[0] = x; point[1] = y; type = TYPEPOINT; }
void invoke(OpenGLSurfaceEvaluator *eval);
private:
int type;
REAL coord[2];
long point[2];
};
class OpenGLSurfaceEvaluator : public BasicSurfaceEvaluator {
public:
OpenGLSurfaceEvaluator();
virtual ~OpenGLSurfaceEvaluator( void );
void polymode( long style );
void range2f( long, REAL *, REAL * );
void domain2f( REAL, REAL, REAL, REAL );
void addMap( SurfaceMap * ) { }
void enable( long );
void disable( long );
void bgnmap2f( long );
void map2f( long, REAL, REAL, long, long,
REAL, REAL, long, long, REAL * );
void mapgrid2f( long, REAL, REAL, long, REAL, REAL );
void mapmesh2f( long, long, long, long, long );
void evalcoord2f( long, REAL, REAL );
void evalpoint2i( long, long );
void endmap2f( void );
void bgnline( void );
void endline( void );
void bgnclosedline( void );
void endclosedline( void );
void bgntmesh( void );
void swaptmesh( void );
void endtmesh( void );
void bgnqstrip( void );
void endqstrip( void );
void bgntfan( void );
void endtfan( void );
void evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
int n_lower, REAL v_lower, REAL* lower_val);
void evalVStrip(int n_left, REAL u_left, REAL* left_val,
int n_right, REAL u_right, REAL* right_val);
void coord2f( REAL, REAL );
void point2i( long, long );
void newtmeshvert( REAL, REAL );
void newtmeshvert( long, long );
#ifdef _WIN32
void putCallBack(GLenum which, void (REGALGLU_CALL *fn)() );
#else
void putCallBack(GLenum which, _GLUfuncptr fn );
#endif
int get_vertices_call_back()
{
return output_triangles;
}
void put_vertices_call_back(int flag)
{
output_triangles = flag;
}
void put_callback_auto_normal(int flag)
{
callback_auto_normal = flag;
}
int get_callback_auto_normal()
{
return callback_auto_normal;
}
void set_callback_userData(void* data)
{
userData = data;
}
/**************begin for LOD_eval_list***********/
void LOD_eval_list(int level);
private:
StoredVertex *vertexCache[VERTEX_CACHE_SIZE];
int tmeshing;
int which;
int vcount;
GLint gl_polygon_mode[2];/*to save and restore so that
*no side effect
*/
bezierPatchMesh *global_bpm; //for output triangles
int output_triangles; //true 1 or false 0
void (REGALGLU_CALL *beginCallBackN) (GLenum type);
void (REGALGLU_CALL *endCallBackN) (void);
void (REGALGLU_CALL *vertexCallBackN) (const GLfloat *vert);
void (REGALGLU_CALL *normalCallBackN) (const GLfloat *normal);
void (REGALGLU_CALL *colorCallBackN) (const GLfloat *color);
void (REGALGLU_CALL *texcoordCallBackN) (const GLfloat *texcoord);
void (REGALGLU_CALL *beginCallBackData) (GLenum type, void* data);
void (REGALGLU_CALL *endCallBackData) (void* data);
void (REGALGLU_CALL *vertexCallBackData) (const GLfloat *vert, void* data);
void (REGALGLU_CALL *normalCallBackData) (const GLfloat *normal, void* data);
void (REGALGLU_CALL *colorCallBackData) (const GLfloat *color, void* data);
void (REGALGLU_CALL *texcoordCallBackData) (const GLfloat *texcoord, void* data);
void beginCallBack (GLenum type, void* data);
void endCallBack (void* data);
void vertexCallBack (const GLfloat *vert, void* data);
void normalCallBack (const GLfloat *normal, void* data);
void colorCallBack (const GLfloat *color, void* data);
void texcoordCallBack (const GLfloat *texcoord, void* data);
void* userData; //the opaque pointer for Data callback functions.
/*LOD evaluation*/
void LOD_triangle(REAL A[2], REAL B[2], REAL C[2],
int level);
void LOD_eval(int num_vert, REAL* verts, int type, int level);
int LOD_eval_level; //set by LOD_eval_list()
/*************begin for internal evaluators*****************/
/*the following global variables are only defined in this file.
*They are used to cache the precomputed Bezier polynomial values.
*These calues may be used consecutively in which case we don't have
*recompute these values again.
*/
int global_uorder; /*store the uorder in the previous evaluation*/
int global_vorder; /*store the vorder in the previous evaluation*/
REAL global_uprime;
REAL global_vprime;
REAL global_vprime_BV;
REAL global_uprime_BU;
int global_uorder_BV; /*store the uorder in the previous evaluation*/
int global_vorder_BV; /*store the vorder in the previous evaluation*/
int global_uorder_BU; /*store the uorder in the previous evaluation*/
int global_vorder_BU; /*store the vorder in the previous evaluation*/
REAL global_ucoeff[IN_MAX_BEZIER_ORDER]; /*cache the polynomial values*/
REAL global_vcoeff[IN_MAX_BEZIER_ORDER];
REAL global_ucoeffDeriv[IN_MAX_BEZIER_ORDER]; /*cache the polynomial derivatives*/
REAL global_vcoeffDeriv[IN_MAX_BEZIER_ORDER];
REAL global_BV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
REAL global_PBV[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
REAL global_BU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
REAL global_PBU[IN_MAX_BEZIER_ORDER][IN_MAX_DIMENSION];
REAL* global_baseData;
int global_ev_k; /*the dimension*/
REAL global_ev_u1;
REAL global_ev_u2;
int global_ev_ustride;
int global_ev_uorder;
REAL global_ev_v1;
REAL global_ev_v2;
int global_ev_vstride;
int global_ev_vorder;
REAL global_ev_ctlPoints[IN_MAX_BEZIER_ORDER*IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
REAL global_grid_u0;
REAL global_grid_u1;
int global_grid_nu;
REAL global_grid_v0;
REAL global_grid_v1;
int global_grid_nv;
/*functions*/
void inDoDomain2WithDerivs(int k, REAL u, REAL v,
REAL u1, REAL u2, int uorder,
REAL v1, REAL v2, int vorder,
REAL *baseData,
REAL *retPoint, REAL *retdu, REAL *retdv);
void inPreEvaluate(int order, REAL vprime, REAL *coeff);
void inPreEvaluateWithDeriv(int order, REAL vprime, REAL *coeff, REAL *coeffDeriv);
void inComputeFirstPartials(REAL *p, REAL *pu, REAL *pv);
void inComputeNormal2(REAL *pu, REAL *pv, REAL *n);
void inDoEvalCoord2(REAL u, REAL v,
REAL *retPoint, REAL *retNormal);
void inDoEvalCoord2NOGE(REAL u, REAL v,
REAL *retPoint, REAL *retNormal);
void inMap2f(int k,
REAL ulower,
REAL uupper,
int ustride,
int uorder,
REAL vlower,
REAL vupper,
int vstride,
int vorder,
REAL *ctlPoints);
void inMapGrid2f(int nu, REAL u0, REAL u1,
int nv, REAL v0, REAL v1);
void inEvalMesh2(int lowU, int lowV, int highU, int highV);
void inEvalPoint2(int i, int j);
void inEvalCoord2f(REAL u, REAL v);
void inEvalULine(int n_points, REAL v, REAL* u_vals,
int stride, REAL ret_points[][3], REAL ret_normals[][3]);
void inEvalVLine(int n_points, REAL u, REAL* v_vals,
int stride, REAL ret_points[][3], REAL ret_normals[][3]);
void inEvalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
int n_lower, REAL v_lower, REAL* lower_val
);
void inEvalVStrip(int n_left, REAL u_left, REAL* left_val, int n_right, REAL u_right, REAL* right_val);
void inPreEvaluateBV(int k, int uorder, int vorder, REAL vprime, REAL *baseData);
void inPreEvaluateBU(int k, int uorder, int vorder, REAL uprime, REAL *baseData);
void inPreEvaluateBV_intfac(REAL v )
{
inPreEvaluateBV(global_ev_k, global_ev_uorder, global_ev_vorder, (v-global_ev_v1)/(global_ev_v2-global_ev_v1), global_ev_ctlPoints);
}
void inPreEvaluateBU_intfac(REAL u)
{
inPreEvaluateBU(global_ev_k, global_ev_uorder, global_ev_vorder, (u-global_ev_u1)/(global_ev_u2-global_ev_u1), global_ev_ctlPoints);
}
void inDoDomain2WithDerivsBV(int k, REAL u, REAL v,
REAL u1, REAL u2, int uorder,
REAL v1, REAL v2, int vorder,
REAL *baseData,
REAL *retPoint, REAL* retdu, REAL *retdv);
void inDoDomain2WithDerivsBU(int k, REAL u, REAL v,
REAL u1, REAL u2, int uorder,
REAL v1, REAL v2, int vorder,
REAL *baseData,
REAL *retPoint, REAL* retdu, REAL *retdv);
void inDoEvalCoord2NOGE_BV(REAL u, REAL v,
REAL *retPoint, REAL *retNormal);
void inDoEvalCoord2NOGE_BU(REAL u, REAL v,
REAL *retPoint, REAL *retNormal);
void inBPMEval(bezierPatchMesh* bpm);
void inBPMListEval(bezierPatchMesh* list);
/*-------------begin for surfEvalMachine -------------*/
surfEvalMachine em_vertex;
surfEvalMachine em_normal;
surfEvalMachine em_color;
surfEvalMachine em_texcoord;
int auto_normal_flag; //whether to output normla or not in callback
//determined by GL_AUTO_NORMAL and callback_auto_normal
int callback_auto_normal; //GLU_CALLBACK_AUTO_NORMAL_EXT
int vertex_flag;
int normal_flag;
int color_flag;
int texcoord_flag;
void inMap2fEM(int which, //0:vert,1:norm,2:color,3:tex
int dimension,
REAL ulower,
REAL uupper,
int ustride,
int uorder,
REAL vlower,
REAL vupper,
int vstride,
int vorder,
REAL *ctlPoints);
void inDoDomain2WithDerivsEM(surfEvalMachine *em, REAL u, REAL v,
REAL *retPoint, REAL *retdu, REAL *retdv);
void inDoDomain2EM(surfEvalMachine *em, REAL u, REAL v,
REAL *retPoint);
void inDoEvalCoord2EM(REAL u, REAL v);
void inBPMEvalEM(bezierPatchMesh* bpm);
void inBPMListEvalEM(bezierPatchMesh* list);
/*-------------end for surfEvalMachine -------------*/
/*************end for internal evaluators*****************/
};
inline void StoredVertex::invoke(OpenGLSurfaceEvaluator *eval)
{
switch(type) {
case TYPECOORD:
eval->coord2f(coord[0], coord[1]);
break;
case TYPEPOINT:
eval->point2i(point[0], point[1]);
break;
default:
break;
}
}
#endif /* __gluglsurfeval_h_ */

Some files were not shown because too many files have changed in this diff Show more