Merge branch 'master' into glsl-pp-rework-2

Conflicts:
	progs/perf/drawoverhead.c
	progs/perf/teximage.c
	progs/perf/vbo.c
	progs/perf/vertexrate.c
	src/mesa/shader/slang/library/slang_common_builtin_gc.h
This commit is contained in:
Michal Krol 2009-12-12 16:48:32 +01:00
commit a3eb0f718e
1692 changed files with 874744 additions and 94119 deletions

View file

@ -182,7 +182,7 @@ ultrix-gcc:
# Rules for making release tarballs
VERSION=7.7-devel
VERSION=7.7-rc2
DIRECTORY = Mesa-$(VERSION)
LIB_NAME = MesaLib-$(VERSION)
DEMO_NAME = MesaDemos-$(VERSION)
@ -419,6 +419,12 @@ DEMO_FILES = \
$(DIRECTORY)/progs/demos/README \
$(DIRECTORY)/progs/fbdev/Makefile \
$(DIRECTORY)/progs/fbdev/glfbdevtest.c \
$(DIRECTORY)/progs/objviewer/*.[ch] \
$(DIRECTORY)/progs/objviewer/*.obj \
$(DIRECTORY)/progs/objviewer/*.mtl \
$(DIRECTORY)/progs/objviewer/*.rgb \
$(DIRECTORY)/progs/objviewer/Makefile \
$(DIRECTORY)/progs/objviewer/README.txt \
$(DIRECTORY)/progs/osdemos/Makefile \
$(DIRECTORY)/progs/osdemos/*.c \
$(DIRECTORY)/progs/xdemos/Makefile* \
@ -437,8 +443,7 @@ DEMO_FILES = \
$(DIRECTORY)/progs/windml/Makefile.ugl \
$(DIRECTORY)/progs/windml/*.c \
$(DIRECTORY)/progs/windml/*.bmp \
$(DIRECTORY)/progs/ggi/*.c \
$(DIRECTORY)/windows/VC7/progs/progs.sln
$(DIRECTORY)/progs/ggi/*.c
GLUT_FILES = \
$(DIRECTORY)/include/GL/glut.h \
@ -461,9 +466,7 @@ GLUT_FILES = \
$(DIRECTORY)/src/glut/mini/glut.pc.in \
$(DIRECTORY)/src/glut/directfb/Makefile \
$(DIRECTORY)/src/glut/directfb/NOTES \
$(DIRECTORY)/src/glut/directfb/*[ch] \
$(DIRECTORY)/windows/VC6/progs/glut/glut.dsp \
$(DIRECTORY)/windows/VC7/progs/glut/glut.vcproj
$(DIRECTORY)/src/glut/directfb/*[ch]
DEPEND_FILES = \
$(TOP)/src/mesa/depend \
@ -503,9 +506,11 @@ rm_depend:
touch $$dep ; \
done
lib_gz:
rm -f configs/current ; \
rm -f configs/autoconf ; \
rm_config:
rm -f configs/current
rm -f configs/autoconf
lib_gz: rm_config
cd .. ; \
tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
gzip $(LIB_NAME).tar ; \
@ -523,9 +528,7 @@ glut_gz:
gzip $(GLUT_NAME).tar ; \
mv $(GLUT_NAME).tar.gz $(DIRECTORY)
lib_bz2:
rm -f configs/current ; \
rm -f configs/autoconf ; \
lib_bz2: rm_config
cd .. ; \
tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
bzip2 $(LIB_NAME).tar ; \
@ -543,9 +546,7 @@ glut_bz2:
bzip2 $(GLUT_NAME).tar ; \
mv $(GLUT_NAME).tar.bz2 $(DIRECTORY)
lib_zip:
rm -f configs/current ; \
rm -f configs/autoconf ; \
lib_zip: rm_config
rm -f $(LIB_NAME).zip ; \
cd .. ; \
zip -qr $(LIB_NAME).zip $(LIB_FILES) ; \
@ -574,5 +575,7 @@ md5:
@-md5sum $(GLUT_NAME).tar.bz2
@-md5sum $(GLUT_NAME).zip
.PHONY: tarballs rm_depend lib_gz demo_gz glut_gz lib_bz2 demo_bz2 \
glut_bz2 lib_zip demo_zip glut_zip md5
.PHONY: tarballs rm_depend rm_config md5 \
lib_gz demo_gz glut_gz \
lib_bz2 demo_bz2 glut_bz2 \
lib_zip demo_zip glut_zip

View file

@ -32,10 +32,10 @@ import common
default_statetrackers = 'mesa'
if common.default_platform in ('linux', 'freebsd', 'darwin'):
default_drivers = 'softpipe,failover,i915simple,trace,identity,llvmpipe'
default_drivers = 'softpipe,failover,svga,i915,trace,identity,llvmpipe'
default_winsys = 'xlib'
elif common.default_platform in ('winddk',):
default_drivers = 'softpipe,i915simple,trace,identity'
default_drivers = 'softpipe,svga,i915,trace,identity'
default_winsys = 'all'
else:
default_drivers = 'all'
@ -46,9 +46,9 @@ common.AddOptions(opts)
opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
['mesa', 'python', 'xorg']))
opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300', 'identity', 'llvmpipe']))
['softpipe', 'failover', 'svga', 'i915', 'cell', 'trace', 'r300', 'identity', 'llvmpipe']))
opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
['xlib', 'intel', 'gdi', 'radeon']))
['xlib', 'vmware', 'intel', 'gdi', 'radeon']))
opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))

View file

@ -1,309 +0,0 @@
#!/usr/bin/env python
##########################################################################
#
# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
# 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, sub license, 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 (including the
# next paragraph) 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 NON-INFRINGEMENT.
# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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 sys
import optparse
import re
import struct
from gprof2dot import Call, Function, Profile
from gprof2dot import CALLS, SAMPLES, TIME, TIME_RATIO, TOTAL_TIME, TOTAL_TIME_RATIO
from gprof2dot import DotWriter, TEMPERATURE_COLORMAP
__version__ = '0.1'
class ParseError(Exception):
pass
class MsvcDemangler:
# http://www.kegel.com/mangle.html
def __init__(self, symbol):
self._symbol = symbol
self._pos = 0
def lookahead(self):
return self._symbol[self._pos]
def consume(self):
ret = self.lookahead()
self._pos += 1
return ret
def match(self, c):
if self.lookahead() != c:
raise ParseError
self.consume()
def parse(self):
self.match('?')
name = self.parse_name()
qualifications = self.parse_qualifications()
return '::'.join(qualifications + [name])
def parse_name(self):
if self.lookahead() == '?':
return self.consume() + self.consume()
else:
name = self.parse_id()
self.match('@')
return name
def parse_qualifications(self):
qualifications = []
while self.lookahead() != '@':
name = self.parse_id()
qualifications.append(name)
self.match('@')
return qualifications
def parse_id(self):
s = ''
while True:
c = self.lookahead()
if c.isalnum() or c in '_':
s += c
self.consume()
else:
break
return s
def demangle(name):
if name.startswith('_'):
name = name[1:]
idx = name.rfind('@')
if idx != -1 and name[idx+1:].isdigit():
name = name[:idx]
return name
if name.startswith('?'):
demangler = MsvcDemangler(name)
return demangler.parse()
return name
class Reader:
def __init__(self):
self.symbols = []
self.symbol_cache = {}
self.base_addr = None
def read_map(self, mapfile):
# See http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
last_addr = 0
last_name = 0
for line in file(mapfile, "rt"):
fields = line.split()
try:
section_offset, name, addr, type, lib_object = fields
except ValueError:
continue
if type != 'f':
continue
section, offset = section_offset.split(':')
addr = int(offset, 16)
self.symbols.append((addr, name))
last_addr = addr
last_name = name
# sort symbols
self.symbols.sort(key = lambda (addr, name): addr)
def lookup_addr(self, addr):
try:
return self.symbol_cache[addr]
except KeyError:
pass
tolerance = 4196
s, e = 0, len(self.symbols)
while s != e:
i = (s + e)//2
start_addr, name = self.symbols[i]
try:
end_addr, next_name = self.symbols[i + 1]
except IndexError:
end_addr = start_addr + tolerance
if addr < start_addr:
e = i
continue
if addr == end_addr:
return next_name, addr - start_addr
if addr > end_addr:
s = i
continue
return name, addr - start_addr
raise ValueError
def lookup_symbol(self, name):
for symbol_addr, symbol_name in self.symbols:
if name == symbol_name:
return symbol_addr
return 0
def read_data(self, data):
profile = Profile()
fp = file(data, "rb")
entry_format = "IIII"
entry_size = struct.calcsize(entry_format)
caller = None
caller_stack = []
while True:
entry = fp.read(entry_size)
if len(entry) < entry_size:
break
caller_addr, callee_addr, samples_lo, samples_hi = struct.unpack(entry_format, entry)
if caller_addr == 0 and callee_addr == 0:
continue
if self.base_addr is None:
ref_addr = self.lookup_symbol('___debug_profile_reference@0')
if ref_addr:
self.base_addr = (caller_addr - ref_addr) & ~(options.align - 1)
else:
self.base_addr = 0
sys.stderr.write('Base addr: %08x\n' % self.base_addr)
samples = (samples_hi << 32) | samples_lo
try:
caller_raddr = caller_addr - self.base_addr
caller_sym, caller_ofs = self.lookup_addr(caller_raddr)
try:
caller = profile.functions[caller_sym]
except KeyError:
caller_name = demangle(caller_sym)
caller = Function(caller_sym, caller_name)
profile.add_function(caller)
caller[CALLS] = 0
caller[SAMPLES] = 0
except ValueError:
caller = None
if not callee_addr:
if caller:
caller[SAMPLES] += samples
else:
callee_raddr = callee_addr - self.base_addr
callee_sym, callee_ofs = self.lookup_addr(callee_raddr)
try:
callee = profile.functions[callee_sym]
except KeyError:
callee_name = demangle(callee_sym)
callee = Function(callee_sym, callee_name)
profile.add_function(callee)
callee[CALLS] = samples
callee[SAMPLES] = 0
else:
callee[CALLS] += samples
if caller is not None:
try:
call = caller.calls[callee.id]
except KeyError:
call = Call(callee.id)
call[CALLS] = samples
caller.add_call(call)
else:
call[CALLS] += samples
if options.verbose:
if not callee_addr:
sys.stderr.write('%s+%u: %u\n' % (caller_sym, caller_ofs, samples))
else:
sys.stderr.write('%s+%u -> %s+%u: %u\n' % (caller_sym, caller_ofs, callee_sym, callee_ofs, samples))
# compute derived data
profile.validate()
profile.find_cycles()
profile.aggregate(SAMPLES)
profile.ratio(TIME_RATIO, SAMPLES)
profile.call_ratios(CALLS)
profile.integrate(TOTAL_TIME_RATIO, TIME_RATIO)
return profile
def main():
parser = optparse.OptionParser(
usage="\n\t%prog [options] [file] ...",
version="%%prog %s" % __version__)
parser.add_option(
'-a', '--align', metavar='NUMBER',
type="int", dest="align", default=16,
help="section alignment")
parser.add_option(
'-m', '--map', metavar='FILE',
type="string", dest="map",
help="map file")
parser.add_option(
'-b', '--base', metavar='FILE',
type="string", dest="base",
help="base addr")
parser.add_option(
'-n', '--node-thres', metavar='PERCENTAGE',
type="float", dest="node_thres", default=0.5,
help="eliminate nodes below this threshold [default: %default]")
parser.add_option(
'-e', '--edge-thres', metavar='PERCENTAGE',
type="float", dest="edge_thres", default=0.1,
help="eliminate edges below this threshold [default: %default]")
parser.add_option(
'-v', '--verbose',
action="count",
dest="verbose", default=0,
help="verbose output")
global options
(options, args) = parser.parse_args(sys.argv[1:])
reader = Reader()
if options.base is not None:
reader.base_addr = int(options.base, 16)
if options.map is not None:
reader.read_map(options.map)
for arg in args:
profile = reader.read_data(arg)
profile.prune(options.node_thres/100.0, options.edge_thres/100.0)
output = sys.stdout
dot = DotWriter(output)
colormap = TEMPERATURE_COLORMAP
dot.graph(profile, colormap)
if __name__ == '__main__':
main()

View file

@ -124,7 +124,7 @@ INSTALL_INC_DIR = $(includedir)
DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@
# Where libGL will look for DRI hardware drivers
DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@
# Xorg driver install directory (for xorg state-tracker)
XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@

View file

@ -9,7 +9,7 @@ CONFIG_NAME = default
# Version info
MESA_MAJOR=7
MESA_MINOR=7
MESA_MINOR=8
MESA_TINY=0
MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
@ -87,16 +87,16 @@ SRC_DIRS = glsl mesa gallium egl gallium/winsys glu glut/glx glew glw
GLU_DIRS = sgi
DRIVER_DIRS = x11 osmesa
# Which subdirs under $(TOP)/progs/ to enter:
PROGRAM_DIRS = demos redbook samples glsl xdemos
PROGRAM_DIRS = demos redbook samples glsl objviewer xdemos
# EGL directories
EGL_DRIVERS_DIRS = demo
# Gallium directories and
GALLIUM_DIRS = auxiliary drivers state_trackers
GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices
GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices vl
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace identity
GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 trace identity
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
GALLIUM_WINSYS_DIRS = xlib egl_xlib
GALLIUM_WINSYS_DRM_DIRS =

View file

@ -23,11 +23,11 @@ DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
X11_INCLUDES = -I/usr/X11R6/include
CFLAGS = -Wall -Wmissing-prototypes -Wdeclaration-after-statement \
$(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
$(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
-Wpointer-arith $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
$(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
$(X11_INCLUDES)
CXXFLAGS = -Wall -Wpointer-arith $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
$(DEFINES) $(X11_INCLUDES)
# Work around aliasing bugs - developers should comment this out
CFLAGS += -fno-strict-aliasing

View file

@ -4,5 +4,6 @@ include $(TOP)/configs/linux
CONFIG_NAME = linux-debug
OPT_FLAGS = -g -ansi -pedantic
OPT_FLAGS = -g
CFLAGS += -ansi -pedantic
DEFINES += -DDEBUG -DDEBUG_MATH

View file

@ -60,8 +60,8 @@ EGL_DRIVERS_DIRS = demo glx
DRIVER_DIRS = dri
WINDOW_SYSTEM = dri
GALLIUM_WINSYS_DIRS = drm
GALLIUM_WINSYS_DRM_DIRS = intel
GALLIUM_WINSYS_DRM_DIRS = vmware intel
GALLIUM_STATE_TRACKERS_DIRS = egl
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
savage sis tdfx trident unichrome ffb swrast
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \
savage sis tdfx unichrome ffb swrast

View file

@ -11,6 +11,6 @@ ARCH_FLAGS = -DDEBUG
#DRI_DIRS = i915tex i915
#DRI_DIRS = i965
#DRI_DIRS = radeon r200 r300
#DRI_DIRS = unichrome sis trident
#DRI_DIRS = unichrome sis
#DRI_DIRS = i810 mga r128 tdfx

View file

@ -68,5 +68,5 @@ WINDOW_SYSTEM=dri
# gamma are missing because they have not been converted to use the new
# interface.
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon s3v \
savage sis tdfx trident unichrome ffb
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \
savage sis tdfx unichrome ffb

View file

@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR([bin])
AC_CANONICAL_HOST
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.4.3
LIBDRM_REQUIRED=2.4.15
DRI2PROTO_REQUIRED=1.99.3
dnl Check for progs
@ -230,6 +230,8 @@ else
LIB_EXTENSION='dylib' ;;
cygwin* )
LIB_EXTENSION='dll' ;;
aix* )
LIB_EXTENSION='a' ;;
* )
LIB_EXTENSION='so' ;;
esac
@ -417,7 +419,7 @@ WINDOW_SYSTEM=""
GALLIUM_DIRS="auxiliary drivers state_trackers"
GALLIUM_WINSYS_DIRS=""
GALLIUM_WINSYS_DRM_DIRS=""
GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices"
GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices vl"
GALLIUM_DRIVERS_DIRS="softpipe failover trace identity"
GALLIUM_STATE_TRACKERS_DIRS=""
@ -647,6 +649,13 @@ AC_ARG_WITH([dri-driverdir],
[DRI_DRIVER_INSTALL_DIR="$withval"],
[DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
AC_SUBST([DRI_DRIVER_INSTALL_DIR])
dnl Extra search path for DRI drivers
AC_ARG_WITH([dri-searchpath],
[AS_HELP_STRING([--with-dri-searchpath=DIRS...],
[semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
[DRI_DRIVER_SEARCH_DIR="$withval"],
[DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
AC_SUBST([DRI_DRIVER_SEARCH_DIR])
dnl Direct rendering or just indirect rendering
AC_ARG_ENABLE([driglx-direct],
[AS_HELP_STRING([--disable-driglx-direct],
@ -766,8 +775,8 @@ if test "$mesa_driver" = dri; then
# default drivers
if test "x$DRI_DIRS" = "xyes"; then
DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon s3v \
savage sis tdfx trident unichrome ffb swrast"
DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
savage sis tdfx unichrome ffb swrast"
fi
DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
@ -1134,7 +1143,14 @@ yes)
GALLIUM_STATE_TRACKERS_DIRS=glx
;;
dri)
test "x$enable_egl" = xyes && GALLIUM_STATE_TRACKERS_DIRS=egl
GALLIUM_STATE_TRACKERS_DIRS="dri"
if test "x$enable_egl" = xyes; then
GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
fi
# Have only tested st/xorg on 1.6.0 servers
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0],
HAVE_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
HAVE_XORG="no")
;;
esac
;;
@ -1148,6 +1164,11 @@ yes)
if test "$tracker" = egl && test "x$enable_egl" != xyes; then
AC_MSG_ERROR([cannot build egl state tracker without EGL library])
fi
if test "$tracker" = xorg; then
PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
HAVE_XEXTPROTO_71="no")
fi
done
GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
;;
@ -1175,17 +1196,32 @@ AC_ARG_WITH([max-height],
[AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
)
dnl
dnl Gallium SVGA configuration
dnl
AC_ARG_ENABLE([gallium-svga],
[AS_HELP_STRING([--disable-gallium-svga],
[build gallium SVGA @<:@default=enabled@:>@])],
[enable_gallium_svga="$enableval"],
[enable_gallium_svga=yes])
if test "x$enable_gallium_svga" = xyes; then
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS vmware"
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
fi
dnl
dnl Gallium Intel configuration
dnl
AC_ARG_ENABLE([gallium-intel],
[AS_HELP_STRING([--disable-gallium-intel],
[build gallium intel @<:@default=enabled@:>@])],
[AS_HELP_STRING([--enable-gallium-intel],
[build gallium intel @<:@default=disabled@:>@])],
[enable_gallium_intel="$enableval"],
[enable_gallium_intel=yes])
[enable_gallium_intel=auto])
if test "x$enable_gallium_intel" = xyes; then
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel"
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915simple"
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
elif test "x$enable_gallium_intel" = xauto; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
fi
dnl

View file

@ -27,12 +27,6 @@ using the SDK with Visual Studio Express can be found at
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
If you are stuck using VC6 or VC7, you may start with these project
files, but you may need to modify them to reflect changes in the
Mesa source code tree. If you sucessfully update the project files,
please submit them to the author of this document so that they may
be included in the next distribution.
The project files to build the core Mesa library, Windows Mesa
drivers, OSMesa, and GLU are in the mesa directory. The project files
to build GLUT and some demo programs are in the progs directory.
@ -106,23 +100,6 @@ should build all the demos.
Build System Notes
----- ------ -----
VC6 (not actively supported)
---
Visual Studio 6 does not recognize files with the .cc extension as C++
language files, without a lot of unnatural tweaking. So, the VC6
build process uses custom build steps to compile these files in the
GLU library.
Two additional configurations are provided, Debug x86 and Release x86
that activate the shader code compilation by defining SLANG_86. It is
unknown if and how this works.
VC7 (not actively supported)
---
The above-mentioned .cc problem does not exist in this version.
VC8
---

View file

@ -28,6 +28,7 @@ Setting this variable automatically sets the MESA_TEX_PROG variable as well.
<li>MESA_EXTENSION_OVERRIDE - can be used to enable/disable extensions.
A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension
and disable the GL_EXT_bar extension.
<li>MESA_GLSL - <a href="shading.html#envvars">shading language options</a>
</ul>
<p>

View file

@ -35,14 +35,14 @@
<h3>1.1 Prerequisites for DRI and hardware acceleration</h3>
<p>
The following are required for DRI-based hardware acceleration with Mesa 7.3:
The following are required for DRI-based hardware acceleration with Mesa:
</p>
<ul>
<li><a href="http://xorg.freedesktop.org/releases/individual/proto/">dri2proto</a> version 1.99.3 or later
<li>Linux 2.6.28
<li><a href="http://dri.freedesktop.org/libdrm/" target="_parent">libDRM</a>
version 2.4.3 or later
version 2.4.15 or later
<li>Xorg server version 1.5 or later
</ul>
</p>

197
docs/libGL.txt Normal file
View file

@ -0,0 +1,197 @@
Introduction
------------
This document describes the implementation of the XFree86 4.0 libGL.so
library defined by the Linux/OpenGL Base specification found at
http://reality.sgi.com/opengl/linux/linuxbase.html.
The documentation is divided into two sections:
User's Guide
Driver Developer's Guide
Author: Brian Paul (brian@precisioninsight.com)
Date: February 2000
User's Guide
------------
Using libGL.so
The libGL.so library defines the gl- and glX-prefixed functions needed to
run OpenGL programs. OpenGL client applications should link with the
-lGL option to use it.
libGL.so serves two primary functions: GLX protocol generation for indirect
rendering and loading/management of hardware drivers for direct rendering.
When libGL.so initializes itself it uses the DRI to determine the
appropriate hardware driver for each screen on the local X display.
The hardware drivers are expected to be in the /usr/X11R6/lib/modules/dri/
directory. Drivers are named with the convention <name>_dri.so where
<name> is a driver such as "tdfx", "i810", "gamma", etc.
The LIBGL_DRIVERS_DIR environment variable may be used to specify a
different DRI modules directory, overriding /usr/X11R6/lib/modules/dri/.
This environment variable is ignored in setuid programs for security
reasons.
When libGL.so is unable to locate appropriate hardware drivers it will
fall back to using indirect GLX rendering.
To aid in solving problems, libGL.so will print diagnostic messages to
stderr if the LIBGL_DEBUG environment variable is defined.
libGL.so is thread safe. The overhead of thread safety for common,
single-thread clients is negligible. However, the overhead of thread
safety for multi-threaded clients is significant. Each GL API call
requires two calls to pthread_get_specific() which can noticably
impact performance. Warning: libGL.so is thread safe but individual
DRI drivers may not be. Please consult the documentation for a driver
to learn if it is thread safe.
Indirect Rendering
You can force indirect rendering mode by setting the LIBGL_ALWAYS_INDIRECT
environment variable. Hardware acceleration will not be used.
libGL.so Extensibility
libGL.so is designed to be extended without upgrading. That is,
drivers may install new OpenGL extension functions into libGL.so
without requiring libGL.so to be replaced. Clients of libGL.so should
use the glXGetProcAddressEXT() function to obtain the address of
functions by name. For more details of GLX_ARB_get_proc_address see
http://oss.sgi.com/projects/ogl-sample/registry/ARB/get_proc_address.spec
libGL.so is also designed with flexibility such that it may be used
with many generations of hardware drivers to come.
Driver Developer's Guide
------------------------
This section describes the requirements to make an XFree86 4.0
libGL.so-compatible hardware driver. It is not intended for end
users of libGL.so.
XFree86 source files
libGL.so is built inside XFree86 with sources found in xc/lib/GL/.
Specifically, libGL.so is built from:
xc/lib/GL/glx/*.c
xc/lib/dri/XF86dri.c
xc/lib/dri/dri_glx.c
xc/lib/GL/mesa/src/glapi.c
xc/lib/GL/mesa/src/glapitemp.h
xc/lib/GL/mesa/src/glapitable.h
xc/lib/GL/mesa/src/glapioffsets.h
xc/lib/GL/mesa/src/glapinoop.c
xc/lib/GL/mesa/src/glheader.h
xc/lib/GL/mesa/src/glthread.c
xc/lib/GL/mesa/src/glthread.h
xc/lib/GL/mesa/src/X86/glapi_x86.S
xc/lib/GL/mesa/src/X86/assyntax.h
Understand that the mesa/src/gl*.[ch] files are not tied to Mesa. They
have no dependencies on the rest of Mesa and are designed to be reusable
in a number of projects.
The glapi_x86.X and assyntax.h files implement x86-optimized dispatch
of GL functions. They are not required; C-based dispatch can be used
instead, with a slight performance penalty.
Driver loading and binding
When libGL.so initializes itself (via the __glXInitialize function) a
call is made to driCreateDisplay(). This function uses DRI facilities
to determine the driver file appropriate for each screen on the local
display. Each screen's driver is then opened with dlopen() and asked
for its __driCreateScreen() function. The pointers to the __driCreateScreen()
functions are kept in an array, indexed by screen number, in the
__DRIdisplayRec struct.
When a driver's __driCreateScreen() function is called, it must initialize
a __DRIscreenRec struct. This struct acts as the root of a tree of
function pointers which are called to create and destroy contexts and
drawables and perform all the operations needed by the GLX interface.
See the xc/lib/GL/glx/glxclient.h file for details.
Dynamic Extension Function Registration
In order to provide forward compatibility with future drivers, libGL.so
allows drivers to register new OpenGL extension functions which weren't
known when libGL.so was built.
The register_extensions() function in xc/lib/GL/dri/dri_glx.c is called
as soon as libGL.so is loaded. This is done with gcc's constructor
attribute. This mechanism will likely have to be changed for other compilers.
register_extensions() loops over all local displays and screens, determines
the DRI driver for each, and calls the driver's __driRegisterExtensions()
function, if present.
The __driRegisterExtensions() function can add new entrypoints to libGL
by calling:
GLboolean _glapi_add_entrypoint(const char *funcName, GLuint offset)
The parameters are the name of the function (such as "glFoobarEXT") and the
offset of the dispatch slot in the API dispatch table. The return value
indicates success (GL_TRUE) or failure (GL_FALSE).
_glapi_add_entrypoint() will synthesize entrypoint code in assembly
language. Assembly languages is required since parameter passing
can't be handled correctly using a C-based solution.
The address of the new entrypoint is obtained by calling the
glXGetProcAddressARB() function.
The dispatch offset number MUST be a number allocated by SGI in the same
manner in which new GL_* constants are allocated. Using an arbitrary
offset number will result in many problems.
Dispatch Management
When a GL context is made current, the driver must install its dispatch
table as the current dispatch table. This is done by calling
void _glapi_set_dispatch(struct _glapi_table *dispatch);
This will install the named dispatch table for the calling thread.
The current dispatch table for a thread can be obtained by calling
struct _glapi_table *_glapi_get_dispatch(void);
For higher performance in the common single-thread case, the global
variable _glapi_Dispatch will point to the current dispatch table.
This variable will be NULL when in multi-thread mode.
Context Management
libGL.so uses the XFree86 xthreads package to manage a thread-specific
current context pointer. See __glXGet/SetCurrentContext() in glext.c
Drivers may use the _glapi_set/get_context() functions to maintain
a private thread-specific context pointer.

View file

@ -10,6 +10,24 @@
<H1>News</H1>
<h2>November XX, 2009</h2>
<p>
<a href="relnotes-7.6.1.html">Mesa 7.6.1</a> is released. This is a bug-fix
release fixing issues found in the 7.6 release.
</p>
<h2>September 28, 2009</h2>
<p>
<a href="relnotes-7.6.html">Mesa 7.6</a> is released. This is a new feature
release. Those especially concerned about stability may want to wait for the
follow-on 7.6.1 bug-fix release.
</p>
<p>
<a href="relnotes-7.5.2.html">Mesa 7.5.2</a> is also released.
This is a stable release fixing bugs since the 7.5.1 release.
</p>
<h2>September 3, 2009</h2>
<p>

View file

@ -8,7 +8,7 @@
<body bgcolor="#eeeeee">
<H1>Mesa 7.5.2 Release Notes, (date tbd)</H1>
<H1>Mesa 7.5.2 Release Notes, 28 September 2009</H1>
<p>
Mesa 7.5.2 is a bug-fix release fixing issues found since the 7.5.1 release.
@ -31,7 +31,15 @@ for DRI hardware acceleration.
<h2>MD5 checksums</h2>
<pre>
tbd
43a90191dd9f76cd65dcc1ac91f3be70 MesaLib-7.5.2.tar.gz
94e47a499f1226803869c2e37a6a8e3a MesaLib-7.5.2.tar.bz2
1ecb822b567ad67a0617361d45206b67 MesaLib-7.5.2.zip
2718fdce7e075911d6147beb8f27104b MesaDemos-7.5.2.tar.gz
4e0f5ccd58afe21eddcd94327d926e86 MesaDemos-7.5.2.tar.bz2
f621f8c223b278d7c8e49a012d56ca25 MesaDemos-7.5.2.zip
83c16c1d6bcfcc3f97aab5d2fe430b4c MesaGLUT-7.5.2.tar.gz
e5d03bedae369ea3705783573bb33813 MesaGLUT-7.5.2.tar.bz2
e82ba28e00d653e6f437d32be8ca8481 MesaGLUT-7.5.2.zip
</pre>
@ -49,8 +57,11 @@ tbd
(such as bug 23946)
<li>glUseProgram() is now compiled into display lists (bug 23746).
<li>glUniform functions are now compiled into display lists
<li>Auto mipmap generation didn't work reliably with Gallium.
<li>Fixed random number usage in GLX code.
<li>Fixed invalid GL_OUT_OF_MEMORY error sometimes raised by glTexSubImage2D
when using Gallium.
</ul>
</body>
</html>

71
docs/relnotes-7.6.1.html Normal file
View file

@ -0,0 +1,71 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.6.1 Release Notes, (date tbd)</H1>
<p>
Mesa 7.6.1 is a bug-fix release fixing issues since version 7.6.
</p>
<p>
Mesa 7.6.1 implements the OpenGL 2.1 API, but the version reported by
glGetString(GL_VERSION) depends on the particular driver being used.
Some drivers don't support all the features required in OpenGL 2.1.
</p>
<p>
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
for DRI hardware acceleration.
</p>
<h2>MD5 checksums</h2>
<pre>
tbd
</pre>
<h2>New features</h2>
<ul>
<li>Upgraded GL/glext.h to version 56, GL/glxext.h to version 25,
GL/wglext.h to version 17
<li>New 3D driver, r600, for Radeon R6xx, R7xx hardware
</ul>
<h2>Bug fixes</h2>
<ul>
<li>Fixed crash caused by glXCopyContext() and glXDestroyContext(), bug 24217
<li>glXQueryContext(GLX_RENDER_TYPE) returned wrong values (bug 24211)
<li>GLSL sqrt(0) returned unpredictable results
<li>Fixed default texture binding bug when a bound texture was deleted.
<li>r300: Work around an issue with very large fragment programs on R500.
<li>Fake glXQueryDrawable() didn't return good values (bug 24320)
<li>Fixed AUX buffer breakage (bug 24426).
<li>Fixed locale-dependent float parsing bug in GLSL compiler (bug 24531)
<li>Fixed Gallium Cell driver compilation failure.
<li>Fixed glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) query so that
it returns the actual compressed format chosen.
<li>Fixed glBitmap bugs in Intel drivers.
<li>Fixed a number of Microsoft Visual Studio compilation problems.
<li>Fixed clipping / provoking vertex bugs in i965 driver.
<li>Assorted build fixes for AIX.
<li>Endianness fixes for the DRI swrast driver (bug 22767).</li>
<li>Point sprite fixes for i915/945 driver.
<li>Fixed assorted memory leaks (usually on error paths)
<li>Fixed some GLSL compiler bugs (ex: 25579)
</ul>
<h2>Changes</h2>
<ul>
<li>Removed old VC6, VC7 project files for Windows
</ul>
</body>
</html>

View file

@ -8,7 +8,7 @@
<body bgcolor="#eeeeee">
<H1>Mesa 7.6 Release Notes / date TBD</H1>
<H1>Mesa 7.6 Release Notes, 28 September 2009</H1>
<p>
Mesa 7.6 is a new development release.
@ -28,7 +28,15 @@ for DRI hardware acceleration.
<h2>MD5 checksums</h2>
<pre>
tbd
5ffa7d7abf8973f57a1bc4f813e6dade MesaLib-7.6.tar.gz
8c75f90cd0303cfac9e4b6d54f6759ca MesaLib-7.6.tar.bz2
27fcfd69708599c978cb34ba5cd363e1 MesaLib-7.6.zip
e7befb3ae604f591806194a4da445628 MesaDemos-7.6.tar.gz
0ede7adf217951acd90dbe4551210c07 MesaDemos-7.6.tar.bz2
ed9298409cf6613bc0964525ca4afc8a MesaDemos-7.6.zip
666955668e44ff14acf7d15dc78407d3 MesaGLUT-7.6.tar.gz
b8b59706f827d18d1b784a0ff98b4dc2 MesaGLUT-7.6.tar.bz2
c49c19c2bbef4f3b7f1389974dff25f4 MesaGLUT-7.6.zip
</pre>
@ -50,6 +58,8 @@ This was written by Zack Rusin at Tungsten Graphics.
<li>Rewritten radeon/r200/r300 driver using a buffer manager
<li>radeon/r200/r300 GL_EXT_framebuffer_object support when used with
kernel memory manager
<li>radeon/r200/r300 support for GL_ARB_occlusion_query</li>
<li>r300 driver supports OpenGL 1.5</li>
<li>r300 driver support for GL_EXT_vertex_array_bgra, GL_EXT_texture_sRGB
<li>i915/945 driver support for GL_ARB_point_sprite, GL_EXT_stencil_two_side
and GL_ATI_separate_stencil extensions
@ -70,10 +80,5 @@ This was written by Zack Rusin at Tungsten Graphics.
buffers (GLSL uniforms)
</ul>
<h2>Changes</h2>
<ul>
</ul>
</body>
</html>

View file

@ -34,20 +34,28 @@ tbd
<h2>New features</h2>
<ul>
<li>VMware "SVGA" Gallium driver. This is a Gallium3D driver which targets the
VMware virtual graphics device. It allows Linux OpenGL guest applications
to utilize the 3D graphics hardware of the host operating system.
<li>GL_ARB_draw_elements_base_vertex (supported in Intel i965 and software drivers)</li>
<li>GL_ARB_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
<li>GL_NV_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
<li>GL_ARB_provoking_vertex (same as GL_EXT_provoking_vertex)</li>
<li>Wavefront .obj file loader/viewer demo (progs/demos/objviewer)
</ul>
<h2>Bug fixes</h2>
<ul>
<li>Many assorted i965 driver fixes.
<li>Many r300-gallium driver fixes; this driver is now considered unstable-quality instead of experimental-quality.
</ul>
<h2>Changes</h2>
<ul>
<li>New Mesa texture/surface format infrastructure
<li>Removed some unused Mesa device driver hooks
</ul>
</body>

53
docs/relnotes-7.8.html Normal file
View file

@ -0,0 +1,53 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.8 Release Notes / date TBD</H1>
<p>
Mesa 7.8 is a new development release.
People who are concerned with stability and reliability should stick
with a previous release or wait for Mesa 7.8.1.
</p>
<p>
Mesa 7.8 implements the OpenGL 2.1 API, but the version reported by
glGetString(GL_VERSION) depends on the particular driver being used.
Some drivers don't support all the features required in OpenGL 2.1.
</p>
<p>
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
for DRI hardware acceleration.
</p>
<h2>MD5 checksums</h2>
<pre>
tbd
</pre>
<h2>New features</h2>
<ul>
<li>TBD
</ul>
<h2>Bug fixes</h2>
<ul>
<li>TBD
</ul>
<h2>Changes</h2>
<ul>
<li>TBD
</ul>
</body>
</html>

View file

@ -13,7 +13,9 @@ The release notes summarize what's new or changed in each Mesa release.
</p>
<UL>
<LI><A HREF="relnotes-7.8.html">7.8 release notes</A>
<LI><A HREF="relnotes-7.7.html">7.7 release notes</A>
<LI><A HREF="relnotes-7.6.1.html">7.6.1 release notes</A>
<LI><A HREF="relnotes-7.6.html">7.6 release notes</A>
<LI><A HREF="relnotes-7.5.2.html">7.5.2 release notes</A>
<LI><A HREF="relnotes-7.5.1.html">7.5.1 release notes</A>

View file

@ -39,7 +39,8 @@ Contents
<p>
The <b>MESA_GLSL</b> environment variable can be set to a comma-separated
list of keywords to control some aspects of the GLSL compiler:
list of keywords to control some aspects of the GLSL compiler and shader
execution. These are generally used for debugging.
</p>
<ul>
<li>dump - print GLSL shader code to stdout at link time
@ -49,6 +50,12 @@ list of keywords to control some aspects of the GLSL compiler:
<li>nopt - disable compiler optimizations
<li>opt - force compiler optimizations
<li>uniform - print message to stdout when glUniform is called
<li>nopvert - force vertex shaders to be a simple shader that just transforms
the vertex position with ftransform() and passes through the color and
texcoord[0] attributes.
<li>nopfrag - force fragment shader to be a simple shader that passes
through the color attribute.
<li>useprog - log glUseProgram calls to stderr
</ul>
<p>
Example: export MESA_GLSL=dump,nopt

View file

@ -33,8 +33,7 @@
- Pipe drivers:
- \ref softpipe
- \ref i915simple
- Simple 965 driver (brw_context.h, brw_winsys.h)
- \ref i915g
- Cell driver (cell_context.h, cell_winsys.h)
- \ref failover
@ -120,7 +119,7 @@
\sa sp_winsys.h
*/
/** \page i915simple Simple i915 Driver
/** \page i915g i915 Driver
The i915 Gallium3D Driver is an initial hardware driver implementation within
the Gallium3D driver architecture. We expect that once complete this driver
@ -163,7 +162,7 @@
The Draw module is effectively the part of \ref softpipe which is concerned with
vertex processing, split off into a separate module so that it can be reused
by drivers for rasterization-only hardware. As such it is also instantiated
by the \ref i915simple driver.
by the \ref i915g driver.
Additionally, there are cases in the Mesa OpenGL state_tracker where it is
required to obtain transformed vertices and yet it is anticipated that using

View file

@ -108,12 +108,20 @@
#define glBlendColorEXT MANGLE(BlendColorEXT)
#define glBlendColor MANGLE(BlendColor)
#define glBlendEquationEXT MANGLE(BlendEquationEXT)
#define glBlendEquationi MANGLE(BlendEquationi)
#define glBlendEquationIndexedAMD MANGLE(BlendEquationIndexedAMD)
#define glBlendEquation MANGLE(BlendEquation)
#define glBlendEquationSeparateATI MANGLE(BlendEquationSeparateATI)
#define glBlendEquationSeparateEXT MANGLE(BlendEquationSeparateEXT)
#define glBlendEquationSeparatei MANGLE(BlendEquationSeparatei)
#define glBlendEquationSeparateIndexedAMD MANGLE(BlendEquationSeparateIndexedAMD)
#define glBlendEquationSeparate MANGLE(BlendEquationSeparate)
#define glBlendFunci MANGLE(BlendFunci)
#define glBlendFuncIndexedAMD MANGLE(BlendFuncIndexedAMD)
#define glBlendFunc MANGLE(BlendFunc)
#define glBlendFuncSeparateEXT MANGLE(BlendFuncSeparateEXT)
#define glBlendFuncSeparatei MANGLE(BlendFuncSeparatei)
#define glBlendFuncSeparateIndexedAMD MANGLE(BlendFuncSeparateIndexedAMD)
#define glBlendFuncSeparateINGR MANGLE(BlendFuncSeparateINGR)
#define glBlendFuncSeparate MANGLE(BlendFuncSeparate)
#define glBlitFramebufferEXT MANGLE(BlitFramebufferEXT)
@ -148,6 +156,7 @@
#define glClientActiveTexture MANGLE(ClientActiveTexture)
#define glClientActiveVertexStreamATI MANGLE(ClientActiveVertexStreamATI)
#define glClientAttribDefaultEXT MANGLE(ClientAttribDefaultEXT)
#define glClientWaitSync MANGLE(ClientWaitSync)
#define glClipPlane MANGLE(ClipPlane)
#define glColor3b MANGLE(Color3b)
#define glColor3bv MANGLE(Color3bv)
@ -320,6 +329,7 @@
#define glDeleteRenderbuffersEXT MANGLE(DeleteRenderbuffersEXT)
#define glDeleteRenderbuffers MANGLE(DeleteRenderbuffers)
#define glDeleteShader MANGLE(DeleteShader)
#define glDeleteSync MANGLE(DeleteSync)
#define glDeleteTexturesEXT MANGLE(DeleteTexturesEXT)
#define glDeleteTextures MANGLE(DeleteTextures)
#define glDeleteTransformFeedbacksNV MANGLE(DeleteTransformFeedbacksNV)
@ -341,6 +351,7 @@
#define glDisableIndexedEXT MANGLE(DisableIndexedEXT)
#define glDisable MANGLE(Disable)
#define glDisableVariantClientStateEXT MANGLE(DisableVariantClientStateEXT)
#define glDisableVertexAttribAPPLE MANGLE(DisableVertexAttribAPPLE)
#define glDisableVertexAttribArrayARB MANGLE(DisableVertexAttribArrayARB)
#define glDisableVertexAttribArray MANGLE(DisableVertexAttribArray)
#define glDrawArraysEXT MANGLE(DrawArraysEXT)
@ -354,7 +365,9 @@
#define glDrawBuffers MANGLE(DrawBuffers)
#define glDrawElementArrayAPPLE MANGLE(DrawElementArrayAPPLE)
#define glDrawElementArrayATI MANGLE(DrawElementArrayATI)
#define glDrawElementsBaseVertex MANGLE(DrawElementsBaseVertex)
#define glDrawElementsInstancedARB MANGLE(DrawElementsInstancedARB)
#define glDrawElementsInstancedBaseVertex MANGLE(DrawElementsInstancedBaseVertex)
#define glDrawElementsInstancedEXT MANGLE(DrawElementsInstancedEXT)
#define glDrawElementsInstanced MANGLE(DrawElementsInstanced)
#define glDrawElements MANGLE(DrawElements)
@ -362,6 +375,7 @@
#define glDrawPixels MANGLE(DrawPixels)
#define glDrawRangeElementArrayAPPLE MANGLE(DrawRangeElementArrayAPPLE)
#define glDrawRangeElementArrayATI MANGLE(DrawRangeElementArrayATI)
#define glDrawRangeElementsBaseVertex MANGLE(DrawRangeElementsBaseVertex)
#define glDrawRangeElementsEXT MANGLE(DrawRangeElementsEXT)
#define glDrawRangeElements MANGLE(DrawRangeElements)
#define glDrawTransformFeedbackNV MANGLE(DrawTransformFeedbackNV)
@ -378,6 +392,7 @@
#define glEnableIndexedEXT MANGLE(EnableIndexedEXT)
#define glEnable MANGLE(Enable)
#define glEnableVariantClientStateEXT MANGLE(EnableVariantClientStateEXT)
#define glEnableVertexAttribAPPLE MANGLE(EnableVertexAttribAPPLE)
#define glEnableVertexAttribArrayARB MANGLE(EnableVertexAttribArrayARB)
#define glEnableVertexAttribArray MANGLE(EnableVertexAttribArray)
#define glEndConditionalRender MANGLE(EndConditionalRender)
@ -409,6 +424,7 @@
#define glExecuteProgramNV MANGLE(ExecuteProgramNV)
#define glExtractComponentEXT MANGLE(ExtractComponentEXT)
#define glFeedbackBuffer MANGLE(FeedbackBuffer)
#define glFenceSync MANGLE(FenceSync)
#define glFinalCombinerInputNV MANGLE(FinalCombinerInputNV)
#define glFinishAsyncSGIX MANGLE(FinishAsyncSGIX)
#define glFinishFenceAPPLE MANGLE(FinishFenceAPPLE)
@ -469,9 +485,11 @@
#define glFramebufferTextureEXT MANGLE(FramebufferTextureEXT)
#define glFramebufferTextureFaceARB MANGLE(FramebufferTextureFaceARB)
#define glFramebufferTextureFaceEXT MANGLE(FramebufferTextureFaceEXT)
#define glFramebufferTextureFace MANGLE(FramebufferTextureFace)
#define glFramebufferTextureLayerARB MANGLE(FramebufferTextureLayerARB)
#define glFramebufferTextureLayerEXT MANGLE(FramebufferTextureLayerEXT)
#define glFramebufferTextureLayer MANGLE(FramebufferTextureLayer)
#define glFramebufferTexture MANGLE(FramebufferTexture)
#define glFrameTerminatorGREMEDY MANGLE(FrameTerminatorGREMEDY)
#define glFrameZoomSGIX MANGLE(FrameZoomSGIX)
#define glFreeObjectBufferATI MANGLE(FreeObjectBufferATI)
@ -523,6 +541,7 @@
#define glGetBooleanIndexedvEXT MANGLE(GetBooleanIndexedvEXT)
#define glGetBooleani_v MANGLE(GetBooleani_v)
#define glGetBooleanv MANGLE(GetBooleanv)
#define glGetBufferParameteri64v MANGLE(GetBufferParameteri64v)
#define glGetBufferParameterivARB MANGLE(GetBufferParameterivARB)
#define glGetBufferParameteriv MANGLE(GetBufferParameteriv)
#define glGetBufferPointervARB MANGLE(GetBufferPointervARB)
@ -586,6 +605,8 @@
#define glGetImageTransformParameterivHP MANGLE(GetImageTransformParameterivHP)
#define glGetInfoLogARB MANGLE(GetInfoLogARB)
#define glGetInstrumentsSGIX MANGLE(GetInstrumentsSGIX)
#define glGetInteger64i_v MANGLE(GetInteger64i_v)
#define glGetInteger64v MANGLE(GetInteger64v)
#define glGetIntegerIndexedvEXT MANGLE(GetIntegerIndexedvEXT)
#define glGetIntegeri_v MANGLE(GetIntegeri_v)
#define glGetIntegerv MANGLE(GetIntegerv)
@ -615,6 +636,7 @@
#define glGetMinmaxParameterfv MANGLE(GetMinmaxParameterfv)
#define glGetMinmaxParameterivEXT MANGLE(GetMinmaxParameterivEXT)
#define glGetMinmaxParameteriv MANGLE(GetMinmaxParameteriv)
#define glGetMultisamplefv MANGLE(GetMultisamplefv)
#define glGetMultisamplefvNV MANGLE(GetMultisamplefvNV)
#define glGetMultiTexEnvfvEXT MANGLE(GetMultiTexEnvfvEXT)
#define glGetMultiTexEnvivEXT MANGLE(GetMultiTexEnvivEXT)
@ -642,6 +664,7 @@
#define glGetObjectBufferfvATI MANGLE(GetObjectBufferfvATI)
#define glGetObjectBufferivATI MANGLE(GetObjectBufferivATI)
#define glGetObjectParameterfvARB MANGLE(GetObjectParameterfvARB)
#define glGetObjectParameterivAPPLE MANGLE(GetObjectParameterivAPPLE)
#define glGetObjectParameterivARB MANGLE(GetObjectParameterivARB)
#define glGetOcclusionQueryivNV MANGLE(GetOcclusionQueryivNV)
#define glGetOcclusionQueryuivNV MANGLE(GetOcclusionQueryuivNV)
@ -698,6 +721,7 @@
#define glGetSharpenTexFuncSGIS MANGLE(GetSharpenTexFuncSGIS)
#define glGetStringi MANGLE(GetStringi)
#define glGetString MANGLE(GetString)
#define glGetSynciv MANGLE(GetSynciv)
#define glGetTexBumpParameterfvATI MANGLE(GetTexBumpParameterfvATI)
#define glGetTexBumpParameterivATI MANGLE(GetTexBumpParameterivATI)
#define glGetTexEnvfv MANGLE(GetTexEnvfv)
@ -715,6 +739,7 @@
#define glGetTexParameterIuivEXT MANGLE(GetTexParameterIuivEXT)
#define glGetTexParameterIuiv MANGLE(GetTexParameterIuiv)
#define glGetTexParameteriv MANGLE(GetTexParameteriv)
#define glGetTexParameterPointervAPPLE MANGLE(GetTexParameterPointervAPPLE)
#define glGetTextureImageEXT MANGLE(GetTextureImageEXT)
#define glGetTextureLevelParameterfvEXT MANGLE(GetTextureLevelParameterfvEXT)
#define glGetTextureLevelParameterivEXT MANGLE(GetTextureLevelParameterivEXT)
@ -825,12 +850,14 @@
#define glIsRenderbufferEXT MANGLE(IsRenderbufferEXT)
#define glIsRenderbuffer MANGLE(IsRenderbuffer)
#define glIsShader MANGLE(IsShader)
#define glIsSync MANGLE(IsSync)
#define glIsTextureEXT MANGLE(IsTextureEXT)
#define glIsTexture MANGLE(IsTexture)
#define glIsTransformFeedbackNV MANGLE(IsTransformFeedbackNV)
#define glIsVariantEnabledEXT MANGLE(IsVariantEnabledEXT)
#define glIsVertexArrayAPPLE MANGLE(IsVertexArrayAPPLE)
#define glIsVertexArray MANGLE(IsVertexArray)
#define glIsVertexAttribEnabledAPPLE MANGLE(IsVertexAttribEnabledAPPLE)
#define glLightEnviSGIX MANGLE(LightEnviSGIX)
#define glLightf MANGLE(Lightf)
#define glLightfv MANGLE(Lightfv)
@ -877,6 +904,10 @@
#define glMapObjectBufferATI MANGLE(MapObjectBufferATI)
#define glMapParameterfvNV MANGLE(MapParameterfvNV)
#define glMapParameterivNV MANGLE(MapParameterivNV)
#define glMapVertexAttrib1dAPPLE MANGLE(MapVertexAttrib1dAPPLE)
#define glMapVertexAttrib1fAPPLE MANGLE(MapVertexAttrib1fAPPLE)
#define glMapVertexAttrib2dAPPLE MANGLE(MapVertexAttrib2dAPPLE)
#define glMapVertexAttrib2fAPPLE MANGLE(MapVertexAttrib2fAPPLE)
#define glMaterialf MANGLE(Materialf)
#define glMaterialfv MANGLE(Materialfv)
#define glMateriali MANGLE(Materiali)
@ -907,9 +938,11 @@
#define glMatrixTranslatefEXT MANGLE(MatrixTranslatefEXT)
#define glMinmaxEXT MANGLE(MinmaxEXT)
#define glMinmax MANGLE(Minmax)
#define glMinSampleShading MANGLE(MinSampleShading)
#define glMultiDrawArraysEXT MANGLE(MultiDrawArraysEXT)
#define glMultiDrawArrays MANGLE(MultiDrawArrays)
#define glMultiDrawElementArrayAPPLE MANGLE(MultiDrawElementArrayAPPLE)
#define glMultiDrawElementsBaseVertex MANGLE(MultiDrawElementsBaseVertex)
#define glMultiDrawElementsEXT MANGLE(MultiDrawElementsEXT)
#define glMultiDrawElements MANGLE(MultiDrawElements)
#define glMultiDrawRangeElementArrayAPPLE MANGLE(MultiDrawRangeElementArrayAPPLE)
@ -1072,6 +1105,8 @@
#define glNormalStream3ivATI MANGLE(NormalStream3ivATI)
#define glNormalStream3sATI MANGLE(NormalStream3sATI)
#define glNormalStream3svATI MANGLE(NormalStream3svATI)
#define glObjectPurgeableAPPLE MANGLE(ObjectPurgeableAPPLE)
#define glObjectUnpurgeableAPPLE MANGLE(ObjectUnpurgeableAPPLE)
#define glOrtho MANGLE(Ortho)
#define glPassTexCoordATI MANGLE(PassTexCoordATI)
#define glPassThrough MANGLE(PassThrough)
@ -1162,6 +1197,7 @@
#define glProgramParameter4fvNV MANGLE(ProgramParameter4fvNV)
#define glProgramParameteriARB MANGLE(ProgramParameteriARB)
#define glProgramParameteriEXT MANGLE(ProgramParameteriEXT)
#define glProgramParameteri MANGLE(ProgramParameteri)
#define glProgramParameters4dvNV MANGLE(ProgramParameters4dvNV)
#define glProgramParameters4fvNV MANGLE(ProgramParameters4fvNV)
#define glProgramStringARB MANGLE(ProgramStringARB)
@ -1200,6 +1236,7 @@
#define glProgramUniformMatrix4x3fvEXT MANGLE(ProgramUniformMatrix4x3fvEXT)
#define glProgramVertexLimitNV MANGLE(ProgramVertexLimitNV)
#define glProvokingVertexEXT MANGLE(ProvokingVertexEXT)
#define glProvokingVertex MANGLE(ProvokingVertex)
#define glPushAttrib MANGLE(PushAttrib)
#define glPushClientAttribDefaultEXT MANGLE(PushClientAttribDefaultEXT)
#define glPushClientAttrib MANGLE(PushClientAttrib)
@ -1283,6 +1320,7 @@
#define glSampleCoverage MANGLE(SampleCoverage)
#define glSampleMapATI MANGLE(SampleMapATI)
#define glSampleMaskEXT MANGLE(SampleMaskEXT)
#define glSampleMaski MANGLE(SampleMaski)
#define glSampleMaskIndexedNV MANGLE(SampleMaskIndexedNV)
#define glSampleMaskSGIS MANGLE(SampleMaskSGIS)
#define glSamplePatternEXT MANGLE(SamplePatternEXT)
@ -1454,8 +1492,10 @@
#define glTexGeniv MANGLE(TexGeniv)
#define glTexImage1D MANGLE(TexImage1D)
#define glTexImage2D MANGLE(TexImage2D)
#define glTexImage2DMultisample MANGLE(TexImage2DMultisample)
#define glTexImage3DEXT MANGLE(TexImage3DEXT)
#define glTexImage3D MANGLE(TexImage3D)
#define glTexImage3DMultisample MANGLE(TexImage3DMultisample)
#define glTexImage4DSGIS MANGLE(TexImage4DSGIS)
#define glTexParameterf MANGLE(TexParameterf)
#define glTexParameterfv MANGLE(TexParameterfv)
@ -1487,6 +1527,7 @@
#define glTextureParameterIivEXT MANGLE(TextureParameterIivEXT)
#define glTextureParameterIuivEXT MANGLE(TextureParameterIuivEXT)
#define glTextureParameterivEXT MANGLE(TextureParameterivEXT)
#define glTextureRangeAPPLE MANGLE(TextureRangeAPPLE)
#define glTextureRenderbufferEXT MANGLE(TextureRenderbufferEXT)
#define glTextureSubImage1DEXT MANGLE(TextureSubImage1DEXT)
#define glTextureSubImage2DEXT MANGLE(TextureSubImage2DEXT)
@ -1828,6 +1869,7 @@
#define glVertexWeighthvNV MANGLE(VertexWeighthvNV)
#define glVertexWeightPointerEXT MANGLE(VertexWeightPointerEXT)
#define glViewport MANGLE(Viewport)
#define glWaitSync MANGLE(WaitSync)
#define glWeightbvARB MANGLE(WeightbvARB)
#define glWeightdvARB MANGLE(WeightdvARB)
#define glWeightfvARB MANGLE(WeightfvARB)

View file

@ -29,9 +29,9 @@ extern "C" {
*/
/* Header file version number, required by OpenGL ABI for Linux */
/* glext.h last updated $Date: 2009-08-03 02:13:51 -0700 (Mon, 03 Aug 2009) $ */
/* glext.h last updated $Date: 2009-09-24 13:55:03 -0700 (Thu, 24 Sep 2009) $ */
/* Current version at http://www.opengl.org/registry/ */
#define GL_GLEXT_VERSION 54
#define GL_GLEXT_VERSION 56
/* Function declaration macros - to move into glplatform.h */
@ -4236,7 +4236,7 @@ extern "C" {
#define GL_LUMINANCE16_SNORM 0x9019
#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A
#define GL_INTENSITY16_SNORM 0x901B
/* reuse GL_R_SNORM */
/* reuse GL_RED_SNORM */
/* reuse GL_RG_SNORM */
/* reuse GL_RGB_SNORM */
/* reuse GL_RGBA_SNORM */
@ -4311,6 +4311,88 @@ extern "C" {
#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16
#endif
#ifndef GL_APPLE_rgb_422
#define GL_RGB_422_APPLE 0x8A1F
/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */
/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */
#endif
#ifndef GL_NV_video_capture
#define GL_VIDEO_BUFFER_NV 0x9020
#define GL_VIDEO_BUFFER_BINDING_NV 0x9021
#define GL_FIELD_UPPER_NV 0x9022
#define GL_FIELD_LOWER_NV 0x9023
#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024
#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025
#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026
#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027
#define GL_VIDEO_BUFFER_PITCH_NV 0x9028
#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029
#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A
#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B
#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C
#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D
#define GL_PARTIAL_SUCCESS_NV 0x902E
#define GL_SUCCESS_NV 0x902F
#define GL_FAILURE_NV 0x9030
#define GL_YCBYCR8_422_NV 0x9031
#define GL_YCBAYCR8A_4224_NV 0x9032
#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033
#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034
#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035
#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036
#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037
#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038
#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039
#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A
#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B
#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C
#endif
#ifndef GL_NV_copy_image
#endif
#ifndef GL_EXT_separate_shader_objects
#define GL_ACTIVE_PROGRAM_EXT 0x8B8D
#endif
#ifndef GL_NV_parameter_buffer_object2
#endif
#ifndef GL_NV_shader_buffer_load
#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D
#define GL_GPU_ADDRESS_NV 0x8F34
#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35
#endif
#ifndef GL_NV_vertex_buffer_unified_memory
#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E
#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F
#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20
#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21
#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22
#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23
#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24
#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25
#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26
#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27
#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28
#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29
#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A
#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B
#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C
#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D
#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E
#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F
#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30
#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31
#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32
#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33
#endif
#ifndef GL_NV_texture_barrier
#endif
/*************************************************************/
@ -9245,6 +9327,136 @@ typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType,
#define GL_APPLE_row_bytes 1
#endif
#ifndef GL_APPLE_rgb_422
#define GL_APPLE_rgb_422 1
#endif
#ifndef GL_NV_video_capture
#define GL_NV_video_capture 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint);
GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint, GLuint, GLenum, GLintptrARB);
GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint, GLuint, GLenum, GLenum, GLuint);
GLAPI void APIENTRY glEndVideoCaptureNV (GLuint);
GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint, GLenum, GLint *);
GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint, GLuint, GLenum, GLint *);
GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint, GLuint, GLenum, GLfloat *);
GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint, GLuint, GLenum, GLdouble *);
GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint, GLuint *, GLuint64EXT *);
GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint, GLuint, GLenum, const GLint *);
GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint, GLuint, GLenum, const GLfloat *);
GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint, GLuint, GLenum, const GLdouble *);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params);
typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
#endif
#ifndef GL_NV_copy_image
#define GL_NV_copy_image 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glCopyImageSubDataNV (GLuint, GLenum, GLint, GLint, GLint, GLint, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif
#ifndef GL_EXT_separate_shader_objects
#define GL_EXT_separate_shader_objects 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glUseShaderProgramEXT (GLenum, GLuint);
GLAPI void APIENTRY glActiveProgramEXT (GLuint);
GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum, const GLchar *);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);
typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);
typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string);
#endif
#ifndef GL_NV_parameter_buffer_object2
#define GL_NV_parameter_buffer_object2 1
#endif
#ifndef GL_NV_shader_buffer_load
#define GL_NV_shader_buffer_load 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glMakeBufferResidentNV (GLenum, GLenum);
GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum);
GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum);
GLAPI void APIENTRY glNamedMakeBufferResidentNV (GLuint, GLenum);
GLAPI void APIENTRY glNamedMakeBufferNonResidentNV (GLuint);
GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint);
GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum, GLenum, GLuint64EXT *);
GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint, GLenum, GLuint64EXT *);
GLAPI void APIENTRY glGetIntegerui64vNV (GLenum, GLuint64EXT *);
GLAPI void APIENTRY glUniformui64NV (GLint, GLuint64EXT);
GLAPI void APIENTRY glUniformui64vNV (GLint, GLsizei, const GLuint64EXT *);
GLAPI void APIENTRY glGetUniformui64vNV (GLuint, GLint, GLuint64EXT *);
GLAPI void APIENTRY glProgramUniformui64NV (GLuint, GLint, GLuint64EXT);
GLAPI void APIENTRY glProgramUniformui64vNV (GLuint, GLint, GLsizei, const GLuint64EXT *);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);
typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);
typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);
typedef void (APIENTRYP PFNGLNAMEDMAKEBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);
typedef void (APIENTRYP PFNGLNAMEDMAKEBUFFERNONRESIDENTNVPROC) (GLuint buffer);
typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);
typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params);
typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params);
typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result);
typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);
typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params);
typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);
typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
#endif
#ifndef GL_NV_vertex_buffer_unified_memory
#define GL_NV_vertex_buffer_unified_memory 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glBufferAddressRangeNV (GLenum, GLuint, GLuint64EXT, GLsizeiptr);
GLAPI void APIENTRY glVertexFormatNV (GLint, GLenum, GLsizei);
GLAPI void APIENTRY glNormalFormatNV (GLenum, GLsizei);
GLAPI void APIENTRY glColorFormatNV (GLint, GLenum, GLsizei);
GLAPI void APIENTRY glIndexFormatNV (GLenum, GLsizei);
GLAPI void APIENTRY glTexCoordFormatNV (GLint, GLenum, GLsizei);
GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei);
GLAPI void APIENTRY glSecondaryColorFormatNV (GLint, GLenum, GLsizei);
GLAPI void APIENTRY glFogCoordFormatNV (GLenum, GLsizei);
GLAPI void APIENTRY glVertexAttribFormatNV (GLuint, GLint, GLenum, GLboolean, GLsizei);
GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint, GLint, GLenum, GLsizei);
GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum, GLuint, GLuint64EXT *);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);
typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);
typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);
typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);
typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
#endif
#ifndef GL_NV_texture_barrier
#define GL_NV_texture_barrier 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glTextureBarrierNV (void);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void);
#endif
#ifdef __cplusplus
}

View file

@ -76,6 +76,7 @@
/* GLX 1.4 */
#define glXGetProcAddress mglXGetProcAddress
#define glXGetProcAddressARB mglXGetProcAddressARB
#endif

View file

@ -48,9 +48,9 @@ extern "C" {
/*************************************************************/
/* Header file version number, required by OpenGL ABI for Linux */
/* glxext.h last updated 2009/08/03 */
/* glxext.h last updated 2009/10/08 */
/* Current version at http://www.opengl.org/registry/ */
#define GLX_GLXEXT_VERSION 23
#define GLX_GLXEXT_VERSION 25
#ifndef GLX_VERSION_1_3
#define GLX_WINDOW_BIT 0x00000001
@ -382,6 +382,20 @@ extern "C" {
#ifndef GLX_NV_swap_group
#endif
#ifndef GLX_NV_video_capture
#define GLX_DEVICE_ID_NV 0x20CD
#define GLX_UNIQUE_ID_NV 0x20CE
#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
#endif
#ifndef GLX_EXT_swap_control
#define GLX_SWAP_INTERVAL_EXT 0x20F1
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
#endif
#ifndef GLX_NV_copy_image
#endif
/*************************************************************/
@ -415,6 +429,14 @@ typedef struct {
} GLXBufferClobberEventSGIX;
#endif
#ifndef GLX_NV_video_output
typedef unsigned int GLXVideoDeviceNV;
#endif
#ifndef GLX_NV_video_capture
typedef XID GLXVideoCaptureDeviceNV;
#endif
#ifndef GLEXT_64_TYPES_DEFINED
/* This code block is duplicated in glext.h, so must be protected */
#define GLEXT_64_TYPES_DEFINED
@ -827,14 +849,80 @@ typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawab
#ifndef GLX_NV_present_video
#define GLX_NV_present_video 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern unsigned int * glXEnumerateVideoDevicesNV (Display *, int, int *);
extern int glXBindVideoDeviceNV (Display *, unsigned int, unsigned int, const int *);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef unsigned int * ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);
typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
#endif
#ifndef GLX_NV_video_out
#define GLX_NV_video_out 1
#ifndef GLX_NV_video_output
#define GLX_NV_video_output 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXGetVideoDeviceNV (Display *, int, int, GLXVideoDeviceNV *);
extern int glXReleaseVideoDeviceNV (Display *, int, GLXVideoDeviceNV);
extern int glXBindVideoImageNV (Display *, GLXVideoDeviceNV, GLXPbuffer, int);
extern int glXReleaseVideoImageNV (Display *, GLXPbuffer);
extern int glXSendPbufferToVideoNV (Display *, GLXPbuffer, int, unsigned long *, GLboolean);
extern int glXGetVideoInfoNV (Display *, int, GLXVideoDeviceNV, unsigned long *, unsigned long *);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf);
typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif
#ifndef GLX_NV_swap_group
#define GLX_NV_swap_group 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Bool glXJoinSwapGroupNV (Display *, GLXDrawable, GLuint);
extern Bool glXBindSwapBarrierNV (Display *, GLuint, GLuint);
extern Bool glXQuerySwapGroupNV (Display *, GLXDrawable, GLuint *, GLuint *);
extern Bool glXQueryMaxSwapGroupsNV (Display *, int, GLuint *, GLuint *);
extern Bool glXQueryFrameCountNV (Display *, int, GLuint *);
extern Bool glXResetFrameCountNV (Display *, int);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group);
typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier);
typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count);
typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen);
#endif
#ifndef GLX_NV_video_capture
#define GLX_NV_video_capture 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXBindVideoCaptureDeviceNV (Display *, unsigned int, GLXVideoCaptureDeviceNV);
extern GLXVideoCaptureDeviceNV * glXEnumerateVideoCaptureDevicesNV (Display *, int, int *);
extern void glXLockVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV);
extern int glXQueryVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV, int, int *);
extern void glXReleaseVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements);
typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
#endif
#ifndef GLX_EXT_swap_control
#define GLX_EXT_swap_control 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXSwapIntervalEXT (Display *, GLXDrawable, int);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);
#endif
#ifndef GLX_NV_copy_image
#define GLX_NV_copy_image 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern void glXCopyImageSubDataNV (Display *, GLXContext, GLuint, GLenum, GLint, GLint, GLint, GLint, GLXContext, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif

View file

@ -48,9 +48,9 @@ extern "C" {
/*************************************************************/
/* Header file version number */
/* wglext.h last updated 2009/08/03 */
/* wglext.h last updated 2009/09/16 */
/* Current version at http://www.opengl.org/registry/ */
#define WGL_WGLEXT_VERSION 15
#define WGL_WGLEXT_VERSION 17
#ifndef WGL_ARB_buffer_region
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
@ -388,6 +388,14 @@ extern "C" {
#define WGL_GPU_NUM_SPI_AMD 0x21A8
#endif
#ifndef NV_video_capture
#define WGL_UNIQUE_ID_NV 0x20CE
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
#endif
#ifndef NV_copy_image
#endif
/*************************************************************/
@ -400,7 +408,7 @@ DECLARE_HANDLE(HPBUFFEREXT);
#ifndef WGL_NV_present_video
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
#endif
#ifndef WGL_NV_video_out
#ifndef WGL_NV_video_output
DECLARE_HANDLE(HPVIDEODEV);
#endif
#ifndef WGL_NV_gpu_affinity
@ -415,6 +423,9 @@ typedef struct _GPU_DEVICE {
RECT rcVirtualScreen;
} GPU_DEVICE, *PGPU_DEVICE;
#endif
#ifndef WGL_NV_video_capture
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
#endif
#ifndef WGL_ARB_buffer_region
#define WGL_ARB_buffer_region 1
@ -750,8 +761,8 @@ typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVide
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
#endif
#ifndef WGL_NV_video_out
#define WGL_NV_video_out 1
#ifndef WGL_NV_video_output
#define WGL_NV_video_output 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetVideoDeviceNV (HDC, int, HPVIDEODEV *);
extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV);
@ -826,6 +837,30 @@ typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
#ifndef WGL_NV_video_capture
#define WGL_NV_video_capture 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT, HVIDEOINPUTDEVICENV);
extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC, HVIDEOINPUTDEVICENV *);
extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV);
extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV, int, int *);
extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#endif
#ifndef WGL_NV_copy_image
#define WGL_NV_copy_image 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC, GLuint, GLenum, GLint, GLint, GLint, GLint, HGLRC, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif
#ifdef __cplusplus
}

1
progs/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.dSYM

View file

@ -15,7 +15,7 @@ message:
subdirs:
@for dir in $(SUBDIRS) ; do \
@list='$(SUBDIRS)'; for dir in $$list ; do \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE)) || exit 1 ; \
fi \
@ -25,7 +25,7 @@ subdirs:
install:
clean:
-@for dir in $(SUBDIRS) tests ; do \
@list='$(SUBDIRS)'; for dir in $$list tests ; do \
if [ -d $$dir ] ; then \
(cd $$dir && $(MAKE) clean) ; \
fi \

View file

@ -10,4 +10,5 @@ SConscript([
'vpglsl/SConscript',
'fp/SConscript',
'wgl/SConscript',
'perf/SConscript',
])

View file

@ -59,6 +59,8 @@ static GLboolean supportFBO = GL_FALSE;
static GLboolean supportSeamless = GL_FALSE;
static GLboolean seamless = GL_FALSE;
static GLuint TexObj = 0;
static GLint T0 = 0;
static GLint Frames = 0;
static struct {
@ -283,6 +285,20 @@ static void draw( void )
glPopMatrix();
glutSwapBuffers();
Frames++;
{
GLint t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 5000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = Frames / seconds;
printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
fflush(stdout);
T0 = t;
Frames = 0;
}
}
}

View file

@ -938,7 +938,14 @@ reshape(int width, int height)
static void
init_fbotexture()
{
static const GLenum depthFormats[] = {
GL_DEPTH_COMPONENT,
GL_DEPTH_COMPONENT16,
GL_DEPTH_COMPONENT32
};
static int numDepthFormats = sizeof(depthFormats) / sizeof(depthFormats[0]);
GLint i;
GLenum stat;
/* gen framebuffer id, delete it, do some assertions, just for testing */
glGenFramebuffersEXT(1, &MyFB);
@ -969,18 +976,31 @@ init_fbotexture()
/* make depth renderbuffer */
glGenRenderbuffersEXT(1, &DepthRB);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
TexWidth, TexHeight);
CheckError(__LINE__);
/* we may have to try several formats */
for (i = 0; i < numDepthFormats; i++) {
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormats[i],
TexWidth, TexHeight);
CheckError(__LINE__);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, DepthRB);
CheckError(__LINE__);
stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (stat == GL_FRAMEBUFFER_COMPLETE_EXT) {
break;
}
}
if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) {
fprintf(stderr, "Error: unable to get usable FBO combination!\n");
exit(1);
}
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
CheckError(__LINE__);
printf("Depth renderbuffer size = %d bits\n", i);
/* attach DepthRB to MyFB */
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, DepthRB);
CheckError(__LINE__);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
/*

View file

@ -15,8 +15,6 @@
#define DEPTH 5.0f
static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
static GLfloat camz;
static GLint fogMode;

View file

@ -353,6 +353,7 @@ MakeSphere(void)
glNewList(SphereList, GL_COMPILE);
gluSphere(obj, 2.0f, 10, 5);
glEndList();
gluDeleteQuadric(obj);
}
static void

View file

@ -133,6 +133,8 @@ initdlists(void)
glEndList();
}
gluDeleteQuadric(obj);
}
static void

View file

@ -887,5 +887,6 @@ int main(int argc, char **argv)
glutIdleFunc( idle_ );
glutDisplayFunc( draw );
glutMainLoop();
return 0;
}

View file

@ -27,6 +27,8 @@
#define ANIMATE 10
#define QUIT 100
static GLint T0 = 0;
static GLint Frames = 0;
static GLboolean Animate = GL_TRUE;
static GLint NumUnits = 1;
static GLboolean TexEnabled[8];
@ -105,6 +107,20 @@ static void Display( void )
glPopMatrix();
glutSwapBuffers();
Frames++;
{
GLint t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 5000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = Frames / seconds;
printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
fflush(stdout);
T0 = t;
Frames = 0;
}
}
}

View file

@ -245,6 +245,10 @@ loadImageTextures(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
free(texData3);
free(texData4);
free(image);
}
}

View file

@ -834,6 +834,8 @@ initdlists(void)
gluQuadricTexture(obj, GL_TRUE);
gluSphere(obj, SPHERE_RADIUS, 16, 16);
glEndList();
gluDeleteQuadric(obj);
}
int

View file

@ -57,7 +57,7 @@ Idle(void)
{
Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.02;
Yrot = glutGet(GLUT_ELAPSED_TIME) * 0.04;
//Zrot += 2.0;
/*Zrot += 2.0;*/
glutPostRedisplay();
}

View file

@ -34,14 +34,9 @@ TestScreens(EGLDisplay dpy)
* Print table of all available configurations.
*/
static void
PrintConfigs(EGLDisplay d)
PrintConfigs(EGLDisplay d, EGLConfig *configs, EGLint numConfigs)
{
EGLConfig *configs;
EGLint numConfigs, i;
eglGetConfigs(d, NULL, 0, &numConfigs);
configs = malloc(sizeof(*configs) *numConfigs);
eglGetConfigs(d, configs, numConfigs, &numConfigs);
EGLint i;
printf("Configurations:\n");
printf(" bf lv d st colorbuffer dp st supported \n");
@ -83,7 +78,6 @@ PrintConfigs(EGLDisplay d)
red, green, blue, alpha,
depth, stencil, surfString);
}
free(configs);
}
@ -94,7 +88,8 @@ main(int argc, char *argv[])
int maj, min;
EGLContext ctx;
EGLSurface pbuffer;
EGLConfig configs[10];
EGLConfig *configs;
EGLint numConfigs;
EGLBoolean b;
const EGLint pbufAttribs[] = {
EGL_WIDTH, 500,
@ -102,10 +97,7 @@ main(int argc, char *argv[])
EGL_NONE
};
/*
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
*/
EGLDisplay d = eglGetDisplay((EGLNativeDisplayType) "!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {
@ -116,7 +108,11 @@ main(int argc, char *argv[])
printf("EGL version = %d.%d\n", maj, min);
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
PrintConfigs(d);
eglGetConfigs(d, NULL, 0, &numConfigs);
configs = malloc(sizeof(*configs) *numConfigs);
eglGetConfigs(d, configs, numConfigs, &numConfigs);
PrintConfigs(d, configs, numConfigs);
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
if (ctx == EGL_NO_CONTEXT) {
@ -130,6 +126,8 @@ main(int argc, char *argv[])
return 0;
}
free(configs);
b = eglMakeCurrent(d, pbuffer, pbuffer, ctx);
if (!b) {
printf("make current failed\n");

View file

@ -7,6 +7,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <EGL/egl.h>
@ -119,10 +120,7 @@ main(int argc, char *argv[])
EGLScreenMESA screen;
EGLint count;
/*
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
*/
EGLDisplay d = eglGetDisplay((EGLNativeDisplayType) "!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {
@ -132,6 +130,11 @@ main(int argc, char *argv[])
printf("EGL version = %d.%d\n", maj, min);
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
if (!strstr(eglQueryString(d, EGL_EXTENSIONS),
"EGL_MESA_screen_surface")) {
printf("EGL_MESA_screen_surface is not supported\n");
exit(1);
}
eglGetConfigs(d, configs, 10, &numConfigs);
printf("Got %d EGL configs:\n", numConfigs);

View file

@ -11,6 +11,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@ -551,15 +552,6 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
}
}
#include "../../src/egl/main/egldisplay.h"
typedef struct fb_display
{
_EGLDisplay Base; /* base class/object */
void *pFB;
} fbDisplay;
int
main(int argc, char *argv[])
{
@ -571,16 +563,14 @@ main(int argc, char *argv[])
EGLModeMESA mode;
EGLint numConfigs, count;
EGLBoolean b;
const GLubyte *bitmap;
const EGLint screenAttribs[] = {
EGL_WIDTH, 1024,
EGL_HEIGHT, 768,
EGL_NONE
};
/*
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
*/
EGLDisplay d = eglGetDisplay("!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {
@ -590,6 +580,11 @@ main(int argc, char *argv[])
printf("EGL version = %d.%d\n", maj, min);
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
if (!strstr(eglQueryString(d, EGL_EXTENSIONS),
"EGL_MESA_screen_surface")) {
printf("EGL_MESA_screen_surface is not supported\n");
exit(1);
}
eglGetConfigs(d, configs, 10, &numConfigs);
eglGetScreensMESA(d, &screen, 1, &count);
@ -620,17 +615,24 @@ main(int argc, char *argv[])
Init();
Reshape(1024, 768);
/* some drivers crash when rendering to front buffer */
#if 0
glDrawBuffer( GL_FRONT );
glClearColor( 0, 1.0, 0, 1);
glClear( GL_COLOR_BUFFER_BIT );
#endif
doubleBuffer = 1;
glDrawBuffer( GL_BACK );
Draw(d, screen_surf);
sleep(2);
write_ppm("dump.ppm", ((struct fb_display *)_eglLookupDisplay(d))->pFB, 1024, 768);
/* TODO EGL_KHR_lock_surface */
bitmap = NULL;
if (bitmap)
write_ppm("dump.ppm", bitmap, 1024, 768);
eglDestroySurface(d, screen_surf);
eglDestroyContext(d, ctx);

View file

@ -274,10 +274,10 @@ draw(void)
static void
reshape(int width, int height)
{
glViewport(0, 0, (GLint) width, (GLint) height);
GLfloat h = (GLfloat) height / (GLfloat) width;
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
double st = current_time();
double ct = st;
int frames = 0;
GLfloat seconds, fps;
while (ct - st < ttr)
{
double tt = current_time();
@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
frames++;
}
GLfloat seconds = ct - st;
GLfloat fps = frames / seconds;
seconds = ct - st;
fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
}
@ -388,7 +390,7 @@ main(int argc, char *argv[])
}
/* DBR : Create EGL context/surface etc */
d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
assert(d);
if (!eglInitialize(d, &maj, &min)) {

View file

@ -147,8 +147,7 @@ int
main(int argc, char *argv[])
{
int maj, min;
//EGLDisplay d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
EGLDisplay d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (!eglInitialize(d, &maj, &min)) {
printf("eglinfo: eglInitialize failed\n");

View file

@ -55,7 +55,7 @@ main(int argc, char *argv[])
EGLint count, chosenMode;
EGLint width = 0, height = 0;
d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
assert(d);
if (!eglInitialize(d, &maj, &min)) {

View file

@ -127,12 +127,11 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
double st = current_time();
double ct = st;
int frames = 0;
GLfloat seconds, fps;
while (ct - st < ttr)
{
double tt = current_time();
double dt = tt - ct;
ct = tt;
ct = current_time();
draw();
@ -141,8 +140,8 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
frames++;
}
GLfloat seconds = ct - st;
GLfloat fps = frames / seconds;
seconds = ct - st;
fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
}
@ -174,7 +173,7 @@ int main(int argc, char *argv[])
}
/* DBR : Create EGL context/surface etc */
d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
assert(d);
if (!eglInitialize(d, &maj, &min)) {

View file

@ -274,10 +274,10 @@ draw(void)
static void
reshape(int width, int height)
{
glViewport(0, 0, (GLint) width, (GLint) height);
GLfloat h = (GLfloat) height / (GLfloat) width;
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
double st = current_time();
double ct = st;
int frames = 0;
GLfloat seconds, fps;
while (ct - st < ttr)
{
double tt = current_time();
@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
frames++;
}
GLfloat seconds = ct - st;
GLfloat fps = frames / seconds;
seconds = ct - st;
fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
}
@ -385,7 +387,7 @@ main(int argc, char *argv[])
}
/* DBR : Create EGL context/surface etc */
d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
assert(d);
if (!eglInitialize(d, &major, &minor)) {

View file

@ -95,9 +95,6 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
static GLint gear1, gear2, gear3;
static GLfloat angle = 0.0;
static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */
/*
*
* Draw a gear wheel. You'll probably want to call this function when
@ -327,122 +324,235 @@ init(void)
}
/*
* Create an RGB, double-buffered X window.
* Return the window and context handles.
*/
static void
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
const char *name,
int x, int y, int width, int height,
Window *winRet,
EGLContext *ctxRet,
EGLSurface *surfRet)
{
static const EGLint attribs[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
/*EGL_DOUBLEBUFFER,*/
EGL_DEPTH_SIZE, 1,
EGL_NONE
};
struct egl_manager {
EGLNativeDisplayType xdpy;
EGLNativeWindowType xwin;
EGLNativePixmapType xpix;
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
Window win;
XVisualInfo *visInfo, visTemplate;
int num_visuals;
EGLDisplay dpy;
EGLConfig conf;
EGLContext ctx;
EGLConfig config;
EGLint num_configs, vid;
scrnum = DefaultScreen( x_dpy );
root = RootWindow( x_dpy, scrnum );
EGLSurface win;
EGLSurface pix;
EGLSurface pbuf;
EGLBoolean verbose;
EGLint major, minor;
};
static struct egl_manager *
egl_manager_new(EGLNativeDisplayType xdpy, const EGLint *attrib_list,
EGLBoolean verbose)
{
struct egl_manager *eman;
const char *ver;
EGLint num_conf;
eman = calloc(1, sizeof(*eman));
if (!eman)
return NULL;
eman->verbose = verbose;
eman->xdpy = xdpy;
eman->dpy = eglGetDisplay(eman->xdpy);
if (eman->dpy == EGL_NO_DISPLAY) {
printf("eglGetDisplay() failed\n");
free(eman);
return NULL;
}
if (!eglInitialize(eman->dpy, &eman->major, &eman->minor)) {
printf("eglInitialize() failed\n");
free(eman);
return NULL;
}
ver = eglQueryString(eman->dpy, EGL_VERSION);
printf("EGL_VERSION = %s\n", ver);
if (!eglChooseConfig(eman->dpy, attrib_list, &eman->conf, 1, &num_conf) ||
!num_conf) {
printf("eglChooseConfig() failed\n");
eglTerminate(eman->dpy);
free(eman);
return NULL;
}
eman->ctx = eglCreateContext(eman->dpy, eman->conf, EGL_NO_CONTEXT, NULL);
if (eman->ctx == EGL_NO_CONTEXT) {
printf("eglCreateContext() failed\n");
eglTerminate(eman->dpy);
free(eman);
return NULL;
}
return eman;
}
static EGLBoolean
egl_manager_create_window(struct egl_manager *eman, const char *name,
EGLint w, EGLint h, EGLBoolean need_surface,
EGLBoolean fullscreen, const EGLint *attrib_list)
{
XVisualInfo vinfo_template, *vinfo = NULL;
EGLint val, num_vinfo;
Window root;
XSetWindowAttributes attrs;
unsigned long mask;
EGLint x = 0, y = 0;
if (!eglGetConfigAttrib(eman->dpy, eman->conf,
EGL_NATIVE_VISUAL_ID, &val)) {
printf("eglGetConfigAttrib() failed\n");
return EGL_FALSE;
}
if (val) {
vinfo_template.visualid = (VisualID) val;
vinfo = XGetVisualInfo(eman->xdpy, VisualIDMask, &vinfo_template, &num_vinfo);
}
/* try harder if window surface is not needed */
if (!vinfo && !need_surface &&
eglGetConfigAttrib(eman->dpy, eman->conf, EGL_BUFFER_SIZE, &val)) {
if (val == 32)
val = 24;
vinfo_template.depth = val;
vinfo = XGetVisualInfo(eman->xdpy, VisualDepthMask, &vinfo_template, &num_vinfo);
}
if (!vinfo) {
printf("XGetVisualInfo() failed\n");
return EGL_FALSE;
}
root = DefaultRootWindow(eman->xdpy);
if (fullscreen) {
x = 0; y = 0;
width = DisplayWidth( x_dpy, scrnum );
height = DisplayHeight( x_dpy, scrnum );
}
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
printf("Error: eglGetConfigAttrib() failed\n");
exit(1);
}
/* The X window visual must match the EGL config */
visTemplate.visualid = vid;
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
if (!visInfo) {
printf("Error: couldn't get X visual\n");
exit(1);
x = y = 0;
w = DisplayWidth(eman->xdpy, DefaultScreen(eman->xdpy));
h = DisplayHeight(eman->xdpy, DefaultScreen(eman->xdpy));
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
attr.override_redirect = fullscreen;
attrs.background_pixel = 0;
attrs.border_pixel = 0;
attrs.colormap = XCreateColormap(eman->xdpy, root, vinfo->visual, AllocNone);
attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
attrs.override_redirect = fullscreen;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
0, visInfo->depth, InputOutput,
visInfo->visual, mask, &attr );
eman->xwin = XCreateWindow(eman->xdpy, root, x, y, w, h,
0, vinfo->depth, InputOutput,
vinfo->visual, mask, &attrs);
XFree(vinfo);
/* set hints and properties */
{
XSizeHints sizehints;
sizehints.x = x;
sizehints.y = y;
sizehints.width = width;
sizehints.height = height;
sizehints.width = w;
sizehints.height = h;
sizehints.flags = USSize | USPosition;
XSetNormalHints(x_dpy, win, &sizehints);
XSetStandardProperties(x_dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
XSetNormalHints(eman->xdpy, eman->xwin, &sizehints);
XSetStandardProperties(eman->xdpy, eman->xwin, name, name,
None, (char **)NULL, 0, &sizehints);
}
eglBindAPI(EGL_OPENGL_API);
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
if (!ctx) {
printf("Error: glXCreateContext failed\n");
exit(1);
if (need_surface) {
eman->win = eglCreateWindowSurface(eman->dpy, eman->conf,
eman->xwin, attrib_list);
if (eman->win == EGL_NO_SURFACE) {
printf("eglCreateWindowSurface() failed\n");
XDestroyWindow(eman->xdpy, eman->xwin);
eman->xwin = None;
return EGL_FALSE;
}
}
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
XMapWindow(eman->xdpy, eman->xwin);
XFree(visInfo);
*winRet = win;
*ctxRet = ctx;
return EGL_TRUE;
}
static EGLBoolean
egl_manager_create_pixmap(struct egl_manager *eman, EGLNativeWindowType xwin,
EGLBoolean need_surface, const EGLint *attrib_list)
{
XWindowAttributes attrs;
if (!XGetWindowAttributes(eman->xdpy, xwin, &attrs)) {
printf("XGetWindowAttributes() failed\n");
return EGL_FALSE;
}
eman->xpix = XCreatePixmap(eman->xdpy, xwin,
attrs.width, attrs.height, attrs.depth);
if (need_surface) {
eman->pix = eglCreatePixmapSurface(eman->dpy, eman->conf,
eman->xpix, attrib_list);
if (eman->pix == EGL_NO_SURFACE) {
printf("eglCreatePixmapSurface() failed\n");
XFreePixmap(eman->xdpy, eman->xpix);
eman->xpix = None;
return EGL_FALSE;
}
}
return EGL_TRUE;
}
static EGLBoolean
egl_manager_create_pbuffer(struct egl_manager *eman, const EGLint *attrib_list)
{
eman->pbuf = eglCreatePbufferSurface(eman->dpy, eman->conf, attrib_list);
if (eman->pbuf == EGL_NO_SURFACE) {
printf("eglCreatePbufferSurface() failed\n");
return EGL_FALSE;
}
return EGL_TRUE;
}
static void
event_loop(Display *dpy, Window win,
EGLDisplay egl_dpy, EGLSurface egl_surf)
egl_manager_destroy(struct egl_manager *eman)
{
eglMakeCurrent(eman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(eman->dpy);
if (eman->xwin != None)
XDestroyWindow(eman->xdpy, eman->xwin);
if (eman->xpix != None)
XFreePixmap(eman->xdpy, eman->xpix);
free(eman);
}
static void
event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h)
{
GC gc = XCreateGC(eman->xdpy, eman->xwin, 0, NULL);
EGLint orig_w = w, orig_h = h;
if (surface_type == EGL_PBUFFER_BIT)
printf("there will be no screen update if "
"eglCopyBuffers() is not implemented\n");
while (1) {
while (XPending(dpy) > 0) {
while (XPending(eman->xdpy) > 0) {
XEvent event;
XNextEvent(dpy, &event);
XNextEvent(eman->xdpy, &event);
switch (event.type) {
case Expose:
case Expose:
/* we'll redraw below */
break;
case ConfigureNotify:
reshape(event.xconfigure.width, event.xconfigure.height);
break;
break;
case ConfigureNotify:
w = event.xconfigure.width;
h = event.xconfigure.height;
if (surface_type == EGL_WINDOW_BIT)
reshape(w, h);
break;
case KeyPress:
{
char buffer[10];
@ -476,6 +586,7 @@ event_loop(Display *dpy, Window win,
static int frames = 0;
static double tRot0 = -1.0, tRate0 = -1.0;
double dt, t = current_time();
int x, y;
if (tRot0 < 0.0)
tRot0 = t;
dt = t - tRot0;
@ -487,7 +598,25 @@ event_loop(Display *dpy, Window win,
angle -= 3600.0;
draw();
eglSwapBuffers(egl_dpy, egl_surf);
switch (surface_type) {
case EGL_WINDOW_BIT:
eglSwapBuffers(eman->dpy, eman->win);
break;
case EGL_PBUFFER_BIT:
eglWaitClient();
if (!eglCopyBuffers(eman->xdpy, eman->pbuf, eman->xpix))
break;
/* fall through */
case EGL_PIXMAP_BIT:
eglWaitClient();
for (x = 0; x < w; x += orig_w) {
for (y = 0; y < h; y += orig_h) {
XCopyArea(eman->xdpy, eman->xpix, eman->xwin, gc,
0, 0, orig_w, orig_h, x, y);
}
}
break;
}
frames++;
@ -503,6 +632,8 @@ event_loop(Display *dpy, Window win,
}
}
}
XFreeGC(eman->xdpy, gc);
}
@ -513,6 +644,8 @@ usage(void)
printf(" -display <displayname> set the display to run on\n");
printf(" -fullscreen run in fullscreen mode\n");
printf(" -info display OpenGL renderer info\n");
printf(" -pixmap use pixmap surface\n");
printf(" -pbuffer use pbuffer surface\n");
}
@ -521,15 +654,23 @@ main(int argc, char *argv[])
{
const int winWidth = 300, winHeight = 300;
Display *x_dpy;
Window win;
EGLSurface egl_surf;
EGLContext egl_ctx;
EGLDisplay egl_dpy;
char *dpyName = NULL;
struct egl_manager *eman;
EGLint attribs[] = {
EGL_SURFACE_TYPE, 0, /* filled later */
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_DEPTH_SIZE, 1,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_NONE
};
char win_title[] = "xeglgears (window/pixmap/pbuffer)";
EGLint surface_type = EGL_WINDOW_BIT;
GLboolean printInfo = GL_FALSE;
EGLint egl_major, egl_minor;
GLboolean fullscreen = GL_FALSE;
EGLBoolean ret;
int i;
const char *s;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display") == 0) {
@ -542,12 +683,21 @@ main(int argc, char *argv[])
else if (strcmp(argv[i], "-fullscreen") == 0) {
fullscreen = GL_TRUE;
}
else if (strcmp(argv[i], "-pixmap") == 0) {
surface_type = EGL_PIXMAP_BIT;
}
else if (strcmp(argv[i], "-pbuffer") == 0) {
surface_type = EGL_PBUFFER_BIT;
}
else {
usage();
return -1;
}
}
/* set surface type */
attribs[1] = surface_type;
x_dpy = XOpenDisplay(dpyName);
if (!x_dpy) {
printf("Error: couldn't open display %s\n",
@ -555,26 +705,60 @@ main(int argc, char *argv[])
return -1;
}
egl_dpy = eglGetDisplay(x_dpy);
if (!egl_dpy) {
printf("Error: eglGetDisplay() failed\n");
eglBindAPI(EGL_OPENGL_API);
eman = egl_manager_new(x_dpy, attribs, printInfo);
if (!eman) {
XCloseDisplay(x_dpy);
return -1;
}
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
printf("Error: eglInitialize() failed\n");
return -1;
snprintf(win_title, sizeof(win_title), "xeglgears (%s)",
(surface_type == EGL_WINDOW_BIT) ? "window" :
(surface_type == EGL_PIXMAP_BIT) ? "pixmap" : "pbuffer");
/* create surface(s) */
switch (surface_type) {
case EGL_WINDOW_BIT:
ret = egl_manager_create_window(eman, win_title, winWidth, winHeight,
EGL_TRUE, fullscreen, NULL);
if (ret)
ret = eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx);
break;
case EGL_PIXMAP_BIT:
ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight,
EGL_FALSE, fullscreen, NULL) &&
egl_manager_create_pixmap(eman, eman->xwin,
EGL_TRUE, NULL));
if (ret)
ret = eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx);
break;
case EGL_PBUFFER_BIT:
{
EGLint pbuf_attribs[] = {
EGL_WIDTH, winWidth,
EGL_HEIGHT, winHeight,
EGL_NONE
};
ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight,
EGL_FALSE, fullscreen, NULL) &&
egl_manager_create_pixmap(eman, eman->xwin,
EGL_FALSE, NULL) &&
egl_manager_create_pbuffer(eman, pbuf_attribs));
if (ret)
ret = eglMakeCurrent(eman->dpy, eman->pbuf, eman->pbuf, eman->ctx);
}
break;
default:
ret = EGL_FALSE;
break;
}
s = eglQueryString(egl_dpy, EGL_VERSION);
printf("EGL_VERSION = %s\n", s);
make_x_window(x_dpy, egl_dpy,
"glxgears", 0, 0, winWidth, winHeight,
&win, &egl_ctx, &egl_surf);
XMapWindow(x_dpy, win);
eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx);
if (!ret) {
egl_manager_destroy(eman);
XCloseDisplay(x_dpy);
return -1;
}
if (printInfo) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
@ -590,18 +774,13 @@ main(int argc, char *argv[])
*/
reshape(winWidth, winHeight);
event_loop(x_dpy, win, egl_dpy, egl_surf);
event_loop(eman, surface_type, winWidth, winHeight);
glDeleteLists(gear1, 1);
glDeleteLists(gear2, 1);
glDeleteLists(gear3, 1);
eglDestroyContext(egl_dpy, egl_ctx);
eglDestroySurface(egl_dpy, egl_surf);
eglTerminate(egl_dpy);
XDestroyWindow(x_dpy, win);
egl_manager_destroy(eman);
XCloseDisplay(x_dpy);
return 0;

View file

@ -17,6 +17,7 @@ SOURCES = \
tri-depth2.c \
tri-depthwrite.c \
tri-depthwrite2.c \
tri-inv.c \
tri-param.c \
fp-tri.c

View file

@ -197,7 +197,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -57,7 +57,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -59,7 +59,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -56,7 +56,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -54,7 +54,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -76,7 +76,7 @@ static void Key(unsigned char key, int x, int y)
case 27:
exit(1);
default:
return;
break;
}
glutPostRedisplay();

View file

@ -0,0 +1,47 @@
//
// Fragment shader for procedural bumps
//
// Authors: John Kessenich, Randi Rost
//
// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
//
// See 3Dlabs-License.txt for license information
//
// Texture mapping/modulation added by Brian Paul
//
varying vec3 LightDir;
varying vec3 EyeDir;
uniform float BumpDensity; // = 16.0
uniform float BumpSize; // = 0.15
uniform float SpecularFactor; // = 0.5
sampler2D Tex;
void main()
{
vec3 ambient = vec3(0.25);
vec3 litColor;
vec2 c = BumpDensity * gl_TexCoord[0].st;
vec2 p = fract(c) - vec2(0.5);
float d, f;
d = p.x * p.x + p.y * p.y;
f = inversesqrt(d + 1.0);
if (d >= BumpSize)
{ p = vec2(0.0); f = 1.0; }
vec3 SurfaceColor = texture2D(Tex, gl_TexCoord[0].st).xyz;
vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
litColor = SurfaceColor * (ambient + max(dot(normDelta, LightDir), 0.0));
vec3 reflectDir = reflect(LightDir, normDelta);
float spec = max(dot(EyeDir, reflectDir), 0.0);
spec *= SpecularFactor;
litColor = min(litColor + spec, vec3(1.0));
gl_FragColor = vec4(litColor, 1.0);
}

View file

@ -31,7 +31,7 @@ void main()
float iter;
// for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)
for (iter = 0.0; iter < 12 && r2 < 4.0; ++iter)
for (iter = 0.0; iter < 12.0 && r2 < 4.0; ++iter)
{
float tempreal = real;

View file

@ -15,7 +15,7 @@ LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
# using : to avoid APP_CC pointing to CC loop
CC := $(APP_CC)
CFLAGS += -I$(INCDIR)
CFLAGS := -I$(INCDIR) $(CFLAGS)
LDLIBS = $(LIBS)
PROG_SOURCES = \

View file

@ -12,15 +12,20 @@
#include <GL/glew.h>
#include <GL/glut.h>
#include "shaderutil.h"
#include "readtex.h"
static char *FragProgFile = "CH11-bumpmap.frag";
static char *FragTexProgFile = "CH11-bumpmaptex.frag";
static char *VertProgFile = "CH11-bumpmap.vert";
static char *TextureFile = "../images/tile.rgb";
/* program/shader objects */
static GLuint fragShader;
static GLuint fragTexShader;
static GLuint vertShader;
static GLuint program;
static GLuint texProgram;
static struct uniform_info Uniforms[] = {
@ -32,13 +37,26 @@ static struct uniform_info Uniforms[] = {
END_OF_UNIFORMS
};
static struct uniform_info TexUniforms[] = {
{ "LightPosition", 1, GL_FLOAT_VEC3, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
{ "Tex", 1, GL_INT, { 0, 0, 0, 0 }, -1 },
{ "BumpDensity", 1, GL_FLOAT, { 10.0, 0, 0, 0 }, -1 },
{ "BumpSize", 1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
{ "SpecularFactor", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
END_OF_UNIFORMS
};
static GLint win = 0;
static GLfloat xRot = 20.0f, yRot = 0.0f, zRot = 0.0f;
static GLuint tangentAttrib;
static GLint tangentAttrib;
static GLint tangentAttribTex;
static GLuint Texture;
static GLboolean Anim = GL_FALSE;
static GLboolean Textured = GL_FALSE;
static void
@ -135,6 +153,11 @@ Redisplay(void)
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
if (Textured)
glUseProgram(texProgram);
else
glUseProgram(program);
Cube(1.5);
glPopMatrix();
@ -163,8 +186,10 @@ static void
CleanUp(void)
{
glDeleteShader(fragShader);
glDeleteShader(fragTexShader);
glDeleteShader(vertShader);
glDeleteProgram(program);
glDeleteProgram(texProgram);
glutDestroyWindow(win);
}
@ -181,6 +206,9 @@ Key(unsigned char key, int x, int y)
Anim = !Anim;
glutIdleFunc(Anim ? Idle : NULL);
break;
case 't':
Textured = !Textured;
break;
case 'z':
zRot += step;
break;
@ -254,6 +282,26 @@ Init(void)
CheckError(__LINE__);
/*
* As above, but fragment shader also uses a texture map.
*/
fragTexShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragTexProgFile);
texProgram = LinkShaders(vertShader, fragTexShader);
glUseProgram(texProgram);
assert(glIsProgram(texProgram));
assert(glIsShader(fragTexShader));
SetUniformValues(texProgram, TexUniforms);
PrintUniforms(TexUniforms);
/*
* Load tex image.
*/
glGenTextures(1, &Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
LoadRGBMipmaps(TextureFile, GL_RGB);
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
glEnable(GL_DEPTH_TEST);
@ -268,10 +316,13 @@ ParseOptions(int argc, char *argv[])
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-fs") == 0) {
FragProgFile = argv[i+1];
FragProgFile = argv[++i];
}
else if (strcmp(argv[i], "-vs") == 0) {
VertProgFile = argv[i+1];
VertProgFile = argv[++i];
}
else if (strcmp(argv[i], "-t") == 0) {
TextureFile = argv[++i];
}
}
}

View file

@ -369,7 +369,7 @@ static void keyPress(unsigned char key, int x, int y)
case 27:
exit(0);
default:
return;
break;
}
glutPostRedisplay();
}

View file

@ -27,11 +27,15 @@ static GLuint SphereList, RectList, CurList;
static GLint win = 0;
static GLboolean anim = GL_TRUE;
static GLfloat xRot = 0.0f, yRot = 0.0f;
static GLint WinSize[2];
static GLint WinSizeUniform = -1;
static void
Redisplay(void)
{
glUniform2iv(WinSizeUniform, 1, WinSize);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
@ -55,6 +59,8 @@ Idle(void)
static void
Reshape(int width, int height)
{
WinSize[0] = width;
WinSize[1] = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@ -140,6 +146,7 @@ MakeSphere(void)
glNewList(SphereList, GL_COMPILE);
gluSphere(obj, 2.0f, 30, 15);
glEndList();
gluDeleteQuadric(obj);
}
@ -162,8 +169,10 @@ static void
Init(void)
{
static const char *fragShaderText =
"uniform ivec2 WinSize; \n"
"void main() {\n"
" gl_FragColor = abs(dFdy(gl_TexCoord[0])) * 50.0;\n"
" vec2 d = dFdy(gl_TexCoord[0].xy) * vec2(WinSize); \n"
" gl_FragColor = vec4(d.x, d.y, 0.0, 1.0);\n"
" // gl_FragColor = gl_TexCoord[0];\n"
"}\n";
static const char *vertShaderText =
@ -180,6 +189,7 @@ Init(void)
program = LinkShaders(vertShader, fragShader);
glUseProgram(program);
WinSizeUniform = glGetUniformLocation(program, "WinSize");
/*assert(glGetError() == 0);*/
@ -219,8 +229,10 @@ ParseOptions(int argc, char *argv[])
int
main(int argc, char *argv[])
{
WinSize[0] = WinSize[1] = 200;
glutInit(&argc, argv);
glutInitWindowSize(200, 200);
glutInitWindowSize(WinSize[0], WinSize[1]);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
win = glutCreateWindow(argv[0]);
glewInit();

View file

@ -22,22 +22,22 @@ static const char *FragShaderText[ 4 ] = {
"void main()\n"
"{\n"
" gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].w ) * 0.5 + 0.5;\n"
" gl_FragColor.a = 1;\n"
" gl_FragColor.a = 1.0;\n"
"}\n",
"void main()\n"
"{\n"
" gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xw ) * 0.5 + 0.5;\n"
" gl_FragColor.a = 1;\n"
" gl_FragColor.a = 1.0;\n"
"}\n",
"void main()\n"
"{\n"
" gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xyw ) * 0.5 + 0.5;\n"
" gl_FragColor.a = 1;\n"
" gl_FragColor.a = 1.0;\n"
"}\n",
"void main()\n"
"{\n"
" gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xyzw ) * 0.5 + 0.5;\n"
" gl_FragColor.a = 1;\n"
" gl_FragColor.a = 1.0;\n"
"}\n"
};
@ -125,6 +125,7 @@ Key(unsigned char key, int x, int y)
case 'a':
Anim = !Anim;
glutIdleFunc(Anim ? Idle : NULL);
break;
case 's':
Slice -= step;
break;
@ -193,7 +194,7 @@ LoadAndCompileShader(GLuint shader, const char *text)
GLchar log[1000];
GLsizei len;
glGetShaderInfoLog(shader, 1000, &len, log);
fprintf(stderr, "noise: problem compiling shader: %s\n", log);
fprintf(stderr, "multinoise: problem compiling shader: %s\n", log);
exit(1);
}
else {

View file

@ -369,12 +369,9 @@ InitPrograms(void)
static void
InitGL(void)
{
const char *version = (const char *) glGetString(GL_VERSION);
if (!ShadersSupported())
exit(1);
if (version[0] != '2' || version[1] != '.') {
printf("Warning: this program expects OpenGL 2.0\n");
/*exit(1);*/
}
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
printf("Usage:\n");
printf(" a - toggle arrays vs. immediate mode rendering\n");

View file

@ -28,7 +28,7 @@ static const char *FragShaderText =
" vec4 p;\n"
" p.xy = gl_TexCoord[0].xy;\n"
" p.z = Slice;\n"
" p.w = 0;\n"
" p.w = 0.0;\n"
" vec4 n = noise4(p * scale);\n"
" gl_FragColor = n * Scale + Bias;\n"
"}\n";
@ -119,6 +119,7 @@ Key(unsigned char key, int x, int y)
case 'a':
Anim = !Anim;
glutIdleFunc(Anim ? Idle : NULL);
break;
case 's':
Slice -= step;
break;

View file

@ -627,7 +627,7 @@ Init(void)
NumAttribs = GetAttribs(Program, Attribs);
PrintAttribs(Attribs);
//assert(glGetError() == 0);
/*assert(glGetError() == 0);*/
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);

View file

@ -16,6 +16,9 @@
#include <GL/glut.h>
#include "shaderutil.h"
#ifndef M_PI
#define M_PI 3.1415926535
#endif
static char *FragProgFile = "skinning.frag";
static char *VertProgFile = "skinning.vert";

View file

@ -14,6 +14,9 @@
#include <GL/glew.h>
#include <GL/glut.h>
#ifndef M_PI
#define M_PI 3.1415926535
#endif
static GLint WinWidth = 300, WinHeight = 300;
static GLint win = 0;
@ -307,8 +310,10 @@ MakeMipmap(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
////glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5);
/*
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5);
*/
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#undef SZ

View file

@ -400,11 +400,8 @@ InitPrograms(void)
static void
Init(GLboolean useImageFiles)
{
const char *version = (const char *) glGetString(GL_VERSION);
if (version[0] != '2' || version[1] != '.') {
printf("Warning: this program expects OpenGL 2.0\n");
/*exit(1);*/
if (!ShadersSupported()) {
exit(1);
}
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));

View file

@ -179,9 +179,9 @@ Init(void)
"\n"
"void main() {\n"
" vec2 p = gl_FragCoord.xy; \n"
" if (crs(v1 - v0, p - v0) >= 0 && \n"
" crs(v2 - v1, p - v1) >= 0 && \n"
" crs(v0 - v2, p - v2) >= 0) \n"
" if (crs(v1 - v0, p - v0) >= 0.0 && \n"
" crs(v2 - v1, p - v1) >= 0.0 && \n"
" crs(v0 - v2, p - v2) >= 0.0) \n"
" gl_FragColor = vec4(1.0); \n"
" else \n"
" gl_FragColor = vec4(0.5); \n"

View file

@ -16,6 +16,9 @@
#include <GL/glut.h>
#include "shaderutil.h"
#ifndef M_PI
#define M_PI 3.1415926535
#endif
static GLint WinWidth = 300, WinHeight = 300;
static char *FragProgFile = NULL;

View file

@ -0,0 +1,161 @@
# Exported from Wings 3D 0.99.03
# Top flaps
newmtl BottomWing
Ns 100.0
d 1.0
illum 2
Kd 1.0 0.0 0.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd TopBotMap.rgb
newmtl CompBall_auv
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd CompBall_auv.rgb
newmtl EngMat1
Ns 100.0
d 1.0
illum 2
Kd 0.334 0.334 0.334
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl EngMat2
Ns 100.0
d 1.0
illum 2
Kd 0.78688 0.78688 0.78688
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl Fuselage_auv
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 0.0 0.0 0.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd SidesMap.rgb
newmtl Glass
Ns 100.0
d 0.5
illum 2
#Kd 0.5533333333333333 1.0 1.0
Kd 1.0 1.0 1.0
#Ka 0.37333333333333335 0.68 1.0
Ka 0.0 0.0 0.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl Grip
Ns 100.0
d 1.0
illum 2
Kd 0.47386 0.47386 0.47386
Ka 0.6203799999999999 0.6203799999999999 0.6203799999999999
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl Interior
Ns 100.0
d 1.0
illum 2
Kd 0.70696 0.70696 0.70696
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl Prop
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 0.6266666666666667
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd PropMap.rgb
# Rudder
newmtl Sides
Ns 100.0
d 1.0
illum 2
Kd 1.0 0.0 0.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd SidesMap.rgb
newmtl TailHoriz
Ns 100.0
d 1.0
illum 2
Kd 1.0 0.0 0.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd TopBotMap.rgb
# Top wing, bot wing, fuselage
newmtl TopWing
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd TopBotMap.rgb
newmtl Wheels
Ns 100.0
d 1.0
illum 2
Kd 0.0 0.0 0.0
Ka 0.0 0.0 0.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd WheelsMap.rgb
newmtl cylinder58_auv
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd cylinder58_auv.rgb
newmtl default
Ns 100.0
d 1.0
illum 2
Kd 0.0 1.0 1.0
Ka 0.0 1.0 1.0
Ks 0.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl gage_auv
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd gage_auv.rgb

File diff suppressed because it is too large Load diff

83
progs/objviewer/Makefile Normal file
View file

@ -0,0 +1,83 @@
TOP = ../..
include $(TOP)/configs/current
INCDIR = $(TOP)/include
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) \
-l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
# using : to avoid APP_CC pointing to CC loop
CC := $(APP_CC)
CFLAGS := -I$(INCDIR) $(CFLAGS)
LDLIBS = $(LIBS)
SOURCES = \
glm.c \
glmdraw.c \
objview.c \
trackball.c \
skybox.c \
readtex.c \
shaderutil.c
HEADERS = \
extfuncs.h \
readtex.h \
shaderutil.h \
trackball.h
OBJS = $(SOURCES:.c=.o)
PROG = objview
.c.o:
$(CC) -c $(CFLAGS) $< -o $@
default: $(PROG)
$(PROG): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
$(OBJS): $(HEADERS)
### Extra dependencies
extfuncs.h: $(TOP)/progs/util/extfuncs.h
cp $< .
readtex.c: $(TOP)/progs/util/readtex.c
cp $< .
readtex.h: $(TOP)/progs/util/readtex.h
cp $< .
shaderutil.c: $(TOP)/progs/util/shaderutil.c
cp $< .
shaderutil.h: $(TOP)/progs/util/shaderutil.h
cp $< .
trackball.c: $(TOP)/progs/util/trackball.c
cp $< .
trackball.h: $(TOP)/progs/util/trackball.h
cp $< .
clean:
-rm -f $(PROG) $(OBJS)
-rm -f *.o *~
-rm -f extfuncs.h
-rm -f shaderutil.*
-rm -f trackball.*
-rm -f readtex.*
depend: $(SOURCES)
@$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDE_DIRS) $(SOURCES) \
> /dev/null 2>/dev/null
-include depend

View file

@ -0,0 +1,23 @@
This .obj viewer is based on the "smooth" program by Nate Robins
found in the Kilgard GLUT package.
The alpine sky box textures come from http://www.hazelwhorley.com/skyboxtex3_bitmaps.html
The bunny.obj and buddha.obj models come from Stanford.
The GreatLakesBiplaneHP.obj model comes from http://www.sharecg.com/v/25978/3D-Model/Great-Lakes-Biplane-Model
The bobcat.obj model comes from http://www.sharecg.com/v/24771/3D-Model/Bobcat,3d-studio-and-wavefront-objects
The .obj file reader code in glm.c isn't perfect. Not all .obj files are
parsed correctly. There are often mistakes in material-to-triangle assignments.
Mouse:
Left = rotate
Middle = scale
Right = menu
Keyboard:
See pop-up menu for keyboard shortcuts, or press 'h'.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,72 @@
# Exported from Wings 3D 0.99.00b
newmtl black
Ns 48.6667
d 1.00000
illum 2
Kd 1.00000e-3 1.00000e-3 1.00000e-3
Ka 1.00000 1.00000 1.00000
Ks 1.00000 1.00000 1.00000
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl blanco
Ns 100.000
d 1.00000
illum 2
Kd 1.00000 1.00000 1.00000
Ka 0.620380 0.620380 0.620380
Ks 0.806860 0.806860 0.806860
Ke 1.00000e-3 1.00000e-3 1.00000e-3
newmtl blue
Ns 100.000
d 1.00000
illum 2
Kd 0.105111 0.125293 0.366667
Ka 1.00000 1.00000 1.00000
Ks 1.00000 1.00000 1.00000
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl default
Ns 100.000
d 1.00000
illum 2
Kd 1.00000 1.00000 1.00000
Ka 1.00000 1.00000 1.00000
Ks 1.00000 1.00000 1.00000
Ka 0.10000 0.10000 0.10000
Ks 0.50000 0.50000 0.500000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl gre
Ns 100.000
d 1.00000
illum 2
Kd 0.200800 0.200800 0.200800
Ka 1.00000 1.00000 1.00000
Ks 1.00000 1.00000 1.00000
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl red
Ns 100.000
d 1.00000
illum 2
Kd 0.460000 0.00000e+0 0.00000e+0
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl rojo
Ns 100.000
d 1.00000
illum 2
Kd 0.700000 0.00000e+0 0.00000e+0
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 1.00000e-3 1.00000e-3 1.00000e-3

9251
progs/objviewer/bobcat.obj Normal file

File diff suppressed because it is too large Load diff

149990
progs/objviewer/buddha.obj Normal file

File diff suppressed because it is too large Load diff

104501
progs/objviewer/bunny.obj Normal file

File diff suppressed because it is too large Load diff

1917
progs/objviewer/glm.c Normal file

File diff suppressed because it is too large Load diff

287
progs/objviewer/glm.h Normal file
View file

@ -0,0 +1,287 @@
/*
* GLM library. Wavefront .obj file format reader/writer/manipulator.
*
* Written by Nate Robins, 1997.
* email: ndr@pobox.com
* www: http://www.pobox.com/~ndr
*/
#ifndef GLM_H
#define GLM_H
typedef unsigned int uint;
#ifndef M_PI
#define M_PI 3.14159265
#endif
/* defines */
#define GLM_NONE (0) /* render with only vertices */
#define GLM_FLAT (1 << 0) /* render with facet normals */
#define GLM_SMOOTH (1 << 1) /* render with vertex normals */
#define GLM_TEXTURE (1 << 2) /* render with texture coords */
#define GLM_COLOR (1 << 3) /* render with colors */
#define GLM_MATERIAL (1 << 4) /* render with materials */
/* structs */
/* GLMmaterial: Structure that defines a material in a model.
*/
typedef struct _GLMmaterial
{
char* name; /* name of material */
float diffuse[4]; /* diffuse component */
float ambient[4]; /* ambient component */
float specular[4]; /* specular component */
float emmissive[4]; /* emmissive component */
float shininess; /* specular exponent */
char *map_kd; /* diffuse texture map file */
uint texture_kd; /* diffuse texture map */
uint texture_ks; /* specular texture map */
int uDiffuse, uAmbient, uSpecular, uShininess, uDiffTex, uSpecTex;
uint prog;
} GLMmaterial;
/* GLMtriangle: Structure that defines a triangle in a model.
*/
typedef struct {
uint vindices[3]; /* array of triangle vertex indices */
uint nindices[3]; /* array of triangle normal indices */
uint tindices[3]; /* array of triangle texcoord indices*/
uint findex; /* index of triangle facet normal */
} GLMtriangle;
/* GLMgroup: Structure that defines a group in a model.
*/
typedef struct _GLMgroup {
char* name; /* name of this group */
uint numtriangles; /* number of triangles in this group */
uint* triangles; /* array of triangle indices */
uint material; /* index to material for group */
uint * triIndexes;
uint minIndex, maxIndex;
struct _GLMgroup* next; /* pointer to next group in model */
} GLMgroup;
/* GLMmodel: Structure that defines a model.
*/
typedef struct {
char* pathname; /* path to this model */
char* mtllibname; /* name of the material library */
uint numvertices; /* number of vertices in model */
float* vertices; /* array of vertices */
uint numnormals; /* number of normals in model */
float* normals; /* array of normals */
uint numtexcoords; /* number of texcoords in model */
float* texcoords; /* array of texture coordinates */
uint numfacetnorms; /* number of facetnorms in model */
float* facetnorms; /* array of facetnorms */
uint numtriangles; /* number of triangles in model */
GLMtriangle* triangles; /* array of triangles */
uint nummaterials; /* number of materials in model */
GLMmaterial* materials; /* array of materials */
uint numgroups; /* number of groups in model */
GLMgroup* groups; /* linked list of groups */
float position[3]; /* position of the model */
float scale;
uint vbo; /* OpenGL VBO for vertex data */
uint vertexSize; /* number of floats per vertex */
uint posOffset; /* offset of position within vertex, in bytes */
uint normOffset; /* offset of normal within vertex, in bytes */
uint texOffset; /* offset of texcoord within vertex, in bytes */
} GLMmodel;
/* public functions */
/* glmUnitize: "unitize" a model by translating it to the origin and
* scaling it to fit in a unit cube around the origin. Returns the
* scalefactor used.
*
* model - properly initialized GLMmodel structure
*/
float
glmUnitize(GLMmodel* model);
/* glmDimensions: Calculates the dimensions (width, height, depth) of
* a model.
*
* model - initialized GLMmodel structure
* dimensions - array of 3 floats (float dimensions[3])
*/
void
glmDimensions(GLMmodel* model, float* dimensions);
/* glmScale: Scales a model by a given amount.
*
* model - properly initialized GLMmodel structure
* scale - scalefactor (0.5 = half as large, 2.0 = twice as large)
*/
void
glmScale(GLMmodel* model, float scale);
/* glmReverseWinding: Reverse the polygon winding for all polygons in
* this model. Default winding is counter-clockwise. Also changes
* the direction of the normals.
*
* model - properly initialized GLMmodel structure
*/
void
glmReverseWinding(GLMmodel* model);
/* glmFacetNormals: Generates facet normals for a model (by taking the
* cross product of the two vectors derived from the sides of each
* triangle). Assumes a counter-clockwise winding.
*
* model - initialized GLMmodel structure
*/
void
glmFacetNormals(GLMmodel* model);
/* glmVertexNormals: Generates smooth vertex normals for a model.
* First builds a list of all the triangles each vertex is in. Then
* loops through each vertex in the the list averaging all the facet
* normals of the triangles each vertex is in. Finally, sets the
* normal index in the triangle for the vertex to the generated smooth
* normal. If the dot product of a facet normal and the facet normal
* associated with the first triangle in the list of triangles the
* current vertex is in is greater than the cosine of the angle
* parameter to the function, that facet normal is not added into the
* average normal calculation and the corresponding vertex is given
* the facet normal. This tends to preserve hard edges. The angle to
* use depends on the model, but 90 degrees is usually a good start.
*
* model - initialized GLMmodel structure
* angle - maximum angle (in degrees) to smooth across
*/
void
glmVertexNormals(GLMmodel* model, float angle);
/* glmLinearTexture: Generates texture coordinates according to a
* linear projection of the texture map. It generates these by
* linearly mapping the vertices onto a square.
*
* model - pointer to initialized GLMmodel structure
*/
void
glmLinearTexture(GLMmodel* model);
/* glmSpheremapTexture: Generates texture coordinates according to a
* spherical projection of the texture map. Sometimes referred to as
* spheremap, or reflection map texture coordinates. It generates
* these by using the normal to calculate where that vertex would map
* onto a sphere. Since it is impossible to map something flat
* perfectly onto something spherical, there is distortion at the
* poles. This particular implementation causes the poles along the X
* axis to be distorted.
*
* model - pointer to initialized GLMmodel structure
*/
void
glmSpheremapTexture(GLMmodel* model);
/* glmDelete: Deletes a GLMmodel structure.
*
* model - initialized GLMmodel structure
*/
void
glmDelete(GLMmodel* model);
/* glmReadOBJ: Reads a model description from a Wavefront .OBJ file.
* Returns a pointer to the created object which should be free'd with
* glmDelete().
*
* filename - name of the file containing the Wavefront .OBJ format data.
*/
GLMmodel*
glmReadOBJ(char* filename);
/* glmWriteOBJ: Writes a model description in Wavefront .OBJ format to
* a file.
*
* model - initialized GLMmodel structure
* filename - name of the file to write the Wavefront .OBJ format data to
* mode - a bitwise or of values describing what is written to the file
* GLM_NONE - write only vertices
* GLM_FLAT - write facet normals
* GLM_SMOOTH - write vertex normals
* GLM_TEXTURE - write texture coords
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
void
glmWriteOBJ(GLMmodel* model, char* filename, uint mode);
/* glmDraw: Renders the model to the current OpenGL context using the
* mode specified.
*
* model - initialized GLMmodel structure
* mode - a bitwise OR of values describing what is to be rendered.
* GLM_NONE - render with only vertices
* GLM_FLAT - render with facet normals
* GLM_SMOOTH - render with vertex normals
* GLM_TEXTURE - render with texture coords
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
void
glmDraw(GLMmodel* model, uint mode);
/* glmList: Generates and returns a display list for the model using
* the mode specified.
*
* model - initialized GLMmodel structure
* mode - a bitwise OR of values describing what is to be rendered.
* GLM_NONE - render with only vertices
* GLM_FLAT - render with facet normals
* GLM_SMOOTH - render with vertex normals
* GLM_TEXTURE - render with texture coords
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
uint
glmList(GLMmodel* model, uint mode);
/* glmWeld: eliminate (weld) vectors that are within an epsilon of
* each other.
*
* model - initialized GLMmodel structure
* epsilon - maximum difference between vertices
* ( 0.00001 is a good start for a unitized model)
*
*/
void
glmWeld(GLMmodel* model, float epsilon);
void
glmReIndex(GLMmodel *model);
void
glmMakeVBOs(GLMmodel *model);
void
glmDrawVBO(GLMmodel *model);
void
glmPrint(const GLMmodel *model);
void
glmShaderMaterial(GLMmaterial *mat);
void
glmLoadTextures(GLMmodel *model);
void
glmSpecularTexture(GLMmodel *model, uint cubeTex);
#endif /* GLM_H */

455
progs/objviewer/glmdraw.c Normal file
View file

@ -0,0 +1,455 @@
/* */
#define GL_GLEXT_PROTOTYPES
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "glm.h"
#include "readtex.h"
#include "shaderutil.h"
/* defines */
#define T(x) model->triangles[(x)]
/* glmDraw: Renders the model to the current OpenGL context using the
* mode specified.
*
* model - initialized GLMmodel structure
* mode - a bitwise OR of values describing what is to be rendered.
* GLM_NONE - render with only vertices
* GLM_FLAT - render with facet normals
* GLM_SMOOTH - render with vertex normals
* GLM_TEXTURE - render with texture coords
* GLM_COLOR - render with colors (color material)
* GLM_MATERIAL - render with materials
* GLM_COLOR and GLM_MATERIAL should not both be specified.
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
GLvoid
glmDraw(GLMmodel* model, GLuint mode)
{
GLuint i;
GLMgroup* group;
assert(model);
assert(model->vertices);
/* do a bit of warning */
if (mode & GLM_FLAT && !model->facetnorms) {
printf("glmDraw() warning: flat render mode requested "
"with no facet normals defined.\n");
mode &= ~GLM_FLAT;
}
if (mode & GLM_SMOOTH && !model->normals) {
printf("glmDraw() warning: smooth render mode requested "
"with no normals defined.\n");
mode &= ~GLM_SMOOTH;
}
if (mode & GLM_TEXTURE && !model->texcoords) {
printf("glmDraw() warning: texture render mode requested "
"with no texture coordinates defined.\n");
mode &= ~GLM_TEXTURE;
}
if (mode & GLM_FLAT && mode & GLM_SMOOTH) {
printf("glmDraw() warning: flat render mode requested "
"and smooth render mode requested (using smooth).\n");
mode &= ~GLM_FLAT;
}
if (mode & GLM_COLOR && !model->materials) {
printf("glmDraw() warning: color render mode requested "
"with no materials defined.\n");
mode &= ~GLM_COLOR;
}
if (mode & GLM_MATERIAL && !model->materials) {
printf("glmDraw() warning: material render mode requested "
"with no materials defined.\n");
mode &= ~GLM_MATERIAL;
}
if (mode & GLM_COLOR && mode & GLM_MATERIAL) {
printf("glmDraw() warning: color and material render mode requested "
"using only material mode\n");
mode &= ~GLM_COLOR;
}
if (mode & GLM_COLOR)
glEnable(GL_COLOR_MATERIAL);
if (mode & GLM_MATERIAL)
glDisable(GL_COLOR_MATERIAL);
glPushMatrix();
glTranslatef(model->position[0], model->position[1], model->position[2]);
glBegin(GL_TRIANGLES);
group = model->groups;
while (group) {
if (mode & GLM_MATERIAL) {
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,
model->materials[group->material].ambient);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
model->materials[group->material].diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,
model->materials[group->material].specular);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS,
model->materials[group->material].shininess);
}
if (mode & GLM_COLOR) {
glColor3fv(model->materials[group->material].diffuse);
}
for (i = 0; i < group->numtriangles; i++) {
if (mode & GLM_FLAT)
glNormal3fv(&model->facetnorms[3 * T(group->triangles[i]).findex]);
if (mode & GLM_SMOOTH)
glNormal3fv(&model->normals[3 * T(group->triangles[i]).nindices[0]]);
if (mode & GLM_TEXTURE)
glTexCoord2fv(&model->texcoords[2*T(group->triangles[i]).tindices[0]]);
glVertex3fv(&model->vertices[3 * T(group->triangles[i]).vindices[0]]);
#if 0
printf("%f %f %f\n",
model->vertices[3 * T(group->triangles[i]).vindices[0] + X],
model->vertices[3 * T(group->triangles[i]).vindices[0] + Y],
model->vertices[3 * T(group->triangles[i]).vindices[0] + Z]);
#endif
if (mode & GLM_SMOOTH)
glNormal3fv(&model->normals[3 * T(group->triangles[i]).nindices[1]]);
if (mode & GLM_TEXTURE)
glTexCoord2fv(&model->texcoords[2*T(group->triangles[i]).tindices[1]]);
glVertex3fv(&model->vertices[3 * T(group->triangles[i]).vindices[1]]);
#if 0
printf("%f %f %f\n",
model->vertices[3 * T(group->triangles[i]).vindices[1] + X],
model->vertices[3 * T(group->triangles[i]).vindices[1] + Y],
model->vertices[3 * T(group->triangles[i]).vindices[1] + Z]);
#endif
if (mode & GLM_SMOOTH)
glNormal3fv(&model->normals[3 * T(group->triangles[i]).nindices[2]]);
if (mode & GLM_TEXTURE)
glTexCoord2fv(&model->texcoords[2*T(group->triangles[i]).tindices[2]]);
glVertex3fv(&model->vertices[3 * T(group->triangles[i]).vindices[2]]);
#if 0
printf("%f %f %f\n",
model->vertices[3 * T(group->triangles[i]).vindices[2] + X],
model->vertices[3 * T(group->triangles[i]).vindices[2] + Y],
model->vertices[3 * T(group->triangles[i]).vindices[2] + Z]);
#endif
}
group = group->next;
}
glEnd();
glPopMatrix();
}
void
glmMakeVBOs(GLMmodel *model)
{
uint bytes, vertexFloats, i;
float *buffer;
vertexFloats = 3;
model->posOffset = 0;
if (model->numnormals > 0) {
assert(model->numnormals == model->numvertices);
model->normOffset = vertexFloats * sizeof(GLfloat);
vertexFloats += 3;
}
if (model->numtexcoords > 0) {
assert(model->numtexcoords == model->numvertices);
model->texOffset = vertexFloats * sizeof(GLfloat);
vertexFloats += 2;
}
model->vertexSize = vertexFloats;
bytes = (model->numvertices + 1) * vertexFloats * sizeof(float);
buffer = (float *) malloc(bytes);
for (i = 0; i < model->numvertices; i++) {
/* copy vertex pos */
uint j = 0;
buffer[i * vertexFloats + j++] = model->vertices[i * 3 + 0];
buffer[i * vertexFloats + j++] = model->vertices[i * 3 + 1];
buffer[i * vertexFloats + j++] = model->vertices[i * 3 + 2];
if (model->numnormals > 0) {
buffer[i * vertexFloats + j++] = model->normals[i * 3 + 0];
buffer[i * vertexFloats + j++] = model->normals[i * 3 + 1];
buffer[i * vertexFloats + j++] = model->normals[i * 3 + 2];
}
if (model->numtexcoords > 0) {
buffer[i * vertexFloats + j++] = model->texcoords[i * 2 + 0];
buffer[i * vertexFloats + j++] = model->texcoords[i * 2 + 1];
}
}
glGenBuffersARB(1, &model->vbo);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model->vbo);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, bytes, buffer, GL_STATIC_DRAW_ARB);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
free(buffer);
}
static void
_glmLoadTexture(GLMmaterial *mat)
{
if (mat->map_kd) {
GLint imgWidth, imgHeight;
GLenum imgFormat;
GLubyte *image = NULL;
glGenTextures(1, &mat->texture_kd);
image = LoadRGBImage( mat->map_kd, &imgWidth, &imgHeight, &imgFormat );
if (!image) {
/*fprintf(stderr, "Couldn't open texture %s\n", mat->map_kd);*/
free(mat->map_kd);
mat->map_kd = NULL;
mat->texture_kd = 0;
return;
}
if (0)
printf("load texture %s %d x %d\n", mat->map_kd, imgWidth, imgHeight);
glBindTexture(GL_TEXTURE_2D, mat->texture_kd);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, imgWidth, imgHeight,
imgFormat, GL_UNSIGNED_BYTE, image);
free(image);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
}
void
glmLoadTextures(GLMmodel *model)
{
uint i;
for (i = 0; i < model->nummaterials; i++) {
GLMmaterial *mat = &model->materials[i];
_glmLoadTexture(mat);
}
}
void
glmDrawVBO(GLMmodel *model)
{
GLMgroup* group;
assert(model->vbo);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model->vbo);
glVertexPointer(3, GL_FLOAT, model->vertexSize * sizeof(float),
(void *) model->posOffset);
glEnableClientState(GL_VERTEX_ARRAY);
if (model->numnormals > 0) {
glNormalPointer(GL_FLOAT, model->vertexSize * sizeof(float),
(void *) model->normOffset);
glEnableClientState(GL_NORMAL_ARRAY);
}
if (model->numtexcoords > 0) {
glTexCoordPointer(2, GL_FLOAT, model->vertexSize * sizeof(float),
(void *) model->texOffset);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
glPushMatrix();
glTranslatef(model->position[0], model->position[1], model->position[2]);
glScalef(model->scale, model->scale, model->scale);
for (group = model->groups; group; group = group->next) {
if (group->numtriangles > 0) {
glmShaderMaterial(&model->materials[group->material]);
glDrawRangeElements(GL_TRIANGLES,
group->minIndex, group->maxIndex,
3 * group->numtriangles,
GL_UNSIGNED_INT, group->triIndexes);
}
}
glPopMatrix();
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
/* glmList: Generates and returns a display list for the model using
* the mode specified.
*
* model - initialized GLMmodel structure
* mode - a bitwise OR of values describing what is to be rendered.
* GLM_NONE - render with only vertices
* GLM_FLAT - render with facet normals
* GLM_SMOOTH - render with vertex normals
* GLM_TEXTURE - render with texture coords
* GLM_COLOR - render with colors (color material)
* GLM_MATERIAL - render with materials
* GLM_COLOR and GLM_MATERIAL should not both be specified.
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
GLuint
glmList(GLMmodel* model, GLuint mode)
{
GLuint list;
list = glGenLists(1);
glNewList(list, GL_COMPILE);
glmDraw(model, mode);
glEndList();
return list;
}
static const char *VertexShader =
"varying vec3 normal; \n"
"void main() { \n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"
" normal = gl_NormalMatrix * gl_Normal; \n"
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
"} \n";
/**
* Two %s substitutions:
* diffuse texture? true/false
* specular texture? true/false
*/
static const char *TexFragmentShader =
"uniform vec4 ambient, diffuse, specular; \n"
"uniform vec4 ambientLight, diffuseLight, specularLight; \n"
"uniform float shininess; \n"
"uniform sampler2D diffTex; \n"
"uniform samplerCube specTex; \n"
"varying vec3 normal; \n"
"\n"
"void main() \n"
"{ \n"
" vec4 diffTerm, specTerm; \n"
" float dotProd = max(dot(gl_LightSource[0].position.xyz, \n"
" normalize(normal)), 0.0);\n"
" float dotProd2 = max(dot(-gl_LightSource[0].position.xyz, \n"
" normalize(normal)), 0.0);\n"
" dotProd += dotProd2; \n"
" \n"
" diffTerm = diffuse * diffuseLight * dotProd; \n"
" if (%s) \n"
" diffTerm *= texture2D(diffTex, gl_TexCoord[0].st); \n"
" \n"
" specTerm = specular * specularLight * pow(dotProd, shininess); \n"
" if (%s) \n"
" specTerm *= textureCube(specTex, normal); \n"
" \n"
" gl_FragColor = ambient * ambientLight + diffTerm + specTerm; \n"
"} \n";
void
glmShaderMaterial(GLMmaterial *mat)
{
static const float ambientLight[4] = { 0.1, 0.1, 0.1, 0.0 };
static const float diffuseLight[4] = { 0.75, 0.75, 0.75, 1.0 };
static const float specularLight[4] = { 1.0, 1.0, 1.0, 0.0 };
if (!mat->prog) {
/* make shader now */
char newShader[10000];
GLuint vs, fs;
const char *diffuseTex = mat->texture_kd ? "true" : "false";
const char *specularTex = mat->texture_ks ? "true" : "false";
GLint uAmbientLight, uDiffuseLight, uSpecularLight;
/* replace %d with 0 or 1 */
sprintf(newShader, TexFragmentShader, diffuseTex, specularTex);
if (0)
printf("===== new shader =====\n%s\n============\n", newShader);
vs = CompileShaderText(GL_VERTEX_SHADER, VertexShader);
fs = CompileShaderText(GL_FRAGMENT_SHADER, newShader);
mat->prog = LinkShaders(vs, fs);
assert(mat->prog);
glUseProgram(mat->prog);
mat->uAmbient = glGetUniformLocation(mat->prog, "ambient");
mat->uDiffuse = glGetUniformLocation(mat->prog, "diffuse");
mat->uSpecular = glGetUniformLocation(mat->prog, "specular");
mat->uShininess = glGetUniformLocation(mat->prog, "shininess");
mat->uDiffTex = glGetUniformLocation(mat->prog, "diffTex");
mat->uSpecTex = glGetUniformLocation(mat->prog, "specTex");
uAmbientLight = glGetUniformLocation(mat->prog, "ambientLight");
uDiffuseLight = glGetUniformLocation(mat->prog, "diffuseLight");
uSpecularLight = glGetUniformLocation(mat->prog, "specularLight");
glUniform4fv(mat->uAmbient, 1, mat->ambient);
glUniform4fv(mat->uDiffuse, 1, mat->diffuse);
glUniform4fv(mat->uSpecular, 1, mat->specular);
glUniform1f(mat->uShininess, mat->shininess);
glUniform1i(mat->uDiffTex, 0);
glUniform1i(mat->uSpecTex, 1);
glUniform4fv(uAmbientLight, 1, ambientLight);
glUniform4fv(uDiffuseLight, 1, diffuseLight);
glUniform4fv(uSpecularLight, 1, specularLight);
}
glActiveTexture(GL_TEXTURE1);
if (mat->texture_ks)
glBindTexture(GL_TEXTURE_CUBE_MAP, mat->texture_ks);
else
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
glActiveTexture(GL_TEXTURE0);
if (mat->texture_kd)
glBindTexture(GL_TEXTURE_2D, mat->texture_kd);
else
glBindTexture(GL_TEXTURE_2D, 0);
if (mat->diffuse[3] < 1.0) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else {
glDisable(GL_BLEND);
}
glUseProgram(mat->prog);
}
void
glmSpecularTexture(GLMmodel *model, uint cubeTex)
{
uint i;
for (i = 0; i < model->nummaterials; i++) {
model->materials[i].texture_ks = cubeTex;
}
}

515
progs/objviewer/objview.c Normal file
View file

@ -0,0 +1,515 @@
/*
* .obj file viewer based on "smooth" by Nate Robins, 1997
*
* Brian Paul
* 1 Oct 2009
*/
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include <GL/glew.h>
#include <GL/glut.h>
#include "glm.h"
#include "readtex.h"
#include "skybox.h"
#include "trackball.h"
static char *Model_file = NULL; /* name of the obect file */
static GLMmodel *Model;
static GLfloat Scale = 4.0; /* scaling factor */
static GLboolean Performance = GL_FALSE;
static GLboolean Stats = GL_FALSE;
static GLboolean Animate = GL_TRUE;
static GLuint SkyboxTex;
static GLboolean Skybox = GL_TRUE;
static GLboolean Cull = GL_TRUE;
static GLboolean WireFrame = GL_FALSE;
static GLenum FrontFace = GL_CCW;
static GLfloat Yrot = 0.0;
static GLint WinWidth = 1024, WinHeight = 768;
static GLuint NumInstances = 1;
typedef struct
{
float CurQuat[4];
float Distance;
/* When mouse is moving: */
GLboolean Rotating, Translating;
GLint StartX, StartY;
float StartDistance;
} ViewInfo;
static ViewInfo View;
static void
InitViewInfo(ViewInfo *view)
{
view->Rotating = GL_FALSE;
view->Translating = GL_FALSE;
view->StartX = view->StartY = 0;
view->Distance = 12.0;
view->StartDistance = 0.0;
view->CurQuat[0] = 0.0;
view->CurQuat[1] = 1.0;
view->CurQuat[2] = 0.0;
view->CurQuat[3] = 0.0;
}
/* text: general purpose text routine. draws a string according to
* format in a stroke font at x, y after scaling it by the scale
* specified (scale is in window-space (lower-left origin) pixels).
*
* x - position in x (in window-space)
* y - position in y (in window-space)
* scale - scale in pixels
* format - as in printf()
*/
static void
text(GLuint x, GLuint y, GLfloat scale, char* format, ...)
{
va_list args;
char buffer[255], *p;
GLfloat font_scale = 119.05 + 33.33;
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, glutGet(GLUT_WINDOW_WIDTH), 0, glutGet(GLUT_WINDOW_HEIGHT));
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glTranslatef(x, y, 0.0);
glScalef(scale/font_scale, scale/font_scale, scale/font_scale);
for(p = buffer; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopAttrib();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
static float
ComputeFPS(void)
{
static double t0 = -1.0;
static int frames = 0;
double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
static float fps = 0;
frames++;
if (t0 < 0.0) {
t0 = t;
fps = 0.0;
}
else if (t - t0 >= 4.0) {
fps = (frames / (t - t0) + 0.5);
t0 = t;
frames = 0;
return fps;
}
return 0.0;
}
static void
init_model(void)
{
float objScale;
/* read in the model */
Model = glmReadOBJ(Model_file);
objScale = glmUnitize(Model);
glmFacetNormals(Model);
if (Model->numnormals == 0) {
GLfloat smoothing_angle = 90.0;
printf("Generating normals.\n");
glmVertexNormals(Model, smoothing_angle);
}
glmLoadTextures(Model);
glmReIndex(Model);
glmMakeVBOs(Model);
if (0)
glmPrint(Model);
}
static void
init_skybox(void)
{
SkyboxTex = LoadSkyBoxCubeTexture("alpine_east.rgb",
"alpine_west.rgb",
"alpine_up.rgb",
"alpine_down.rgb",
"alpine_south.rgb",
"alpine_north.rgb");
glmSpecularTexture(Model, SkyboxTex);
}
static void
init_gfx(void)
{
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_NORMALIZE);
glClearColor(0.3, 0.3, 0.9, 0.0);
}
static void
reshape(int width, int height)
{
float ar = 0.5 * (float) width / (float) height;
WinWidth = width;
WinHeight = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -0.5, 0.5, 1.0, 300.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -3.0);
}
static void
Idle(void)
{
float q[4];
trackball(q, 100, 0, 99.99, 0);
add_quats(q, View.CurQuat, View.CurQuat);
glutPostRedisplay();
}
static void
display(void)
{
GLfloat rot[4][4];
float fps;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.0, 0.0, -View.Distance);
glRotatef(Yrot, 0, 1, 0);
build_rotmatrix(rot, View.CurQuat);
glMultMatrixf(&rot[0][0]);
glScalef(Scale, Scale, Scale );
glUseProgram(0);
if (Skybox)
DrawSkyBoxCubeTexture(SkyboxTex);
if (WireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (Cull)
glEnable(GL_CULL_FACE);
else
glDisable(GL_CULL_FACE);
if (NumInstances == 1) {
glmDrawVBO(Model);
}
else {
/* draw > 1 instance */
float dr = 360.0 / NumInstances;
float r;
for (r = 0.0; r < 360.0; r += dr) {
glPushMatrix();
glRotatef(r, 0, 1, 0);
glTranslatef(1.4, 0.0, 0.0);
glmDrawVBO(Model);
glPopMatrix();
}
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_CULL_FACE);
glPopMatrix();
if (Stats) {
glColor3f(1.0, 1.0, 1.0);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*1), 20, "%s",
Model->pathname);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*2), 20, "%d vertices",
Model->numvertices);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*3), 20, "%d triangles",
Model->numtriangles);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*4), 20, "%d normals",
Model->numnormals);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*5), 20, "%d texcoords",
Model->numtexcoords);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*6), 20, "%d groups",
Model->numgroups);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*7), 20, "%d materials",
Model->nummaterials);
}
glutSwapBuffers();
fps = ComputeFPS();
if (fps)
printf("%f FPS\n", fps);
}
static void
keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 'h':
printf("help\n\n");
printf("a - Toggle animation\n");
printf("d/D - Decrease/Incrase number of models\n");
printf("w - Toggle wireframe/filled\n");
printf("c - Toggle culling\n");
printf("n - Toggle facet/smooth normal\n");
printf("r - Reverse polygon winding\n");
printf("p - Toggle performance indicator\n");
printf("s - Toggle skybox\n");
printf("z/Z - Scale model smaller/larger\n");
printf("i - Show model info/stats\n");
printf("q/escape - Quit\n\n");
break;
case 'a':
Animate = !Animate;
if (Animate)
glutIdleFunc(Idle);
else
glutIdleFunc(NULL);
break;
case 'd':
if (NumInstances > 1)
NumInstances--;
break;
case 'D':
NumInstances++;
break;
case 'i':
Stats = !Stats;
break;
case 'p':
Performance = !Performance;
break;
case 'w':
WireFrame = !WireFrame;
break;
case 'c':
Cull = !Cull;
printf("Polygon culling: %d\n", Cull);
break;
case 'r':
if (FrontFace == GL_CCW)
FrontFace = GL_CW;
else
FrontFace = GL_CCW;
glFrontFace(FrontFace);
printf("Front face:: %s\n", FrontFace == GL_CCW ? "CCW" : "CW");
break;
case 's':
Skybox = !Skybox;
if (Skybox)
glmSpecularTexture(Model, SkyboxTex);
else
glmSpecularTexture(Model, 0);
break;
case 'z':
Scale *= 0.9;
break;
case 'Z':
Scale *= 1.1;
break;
case 'q':
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void
menu(int item)
{
keyboard((unsigned char)item, 0, 0);
}
/**
* Handle mouse button.
*/
static void
Mouse(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON) {
if (state == GLUT_DOWN) {
View.StartX = x;
View.StartY = y;
View.Rotating = GL_TRUE;
}
else if (state == GLUT_UP) {
View.Rotating = GL_FALSE;
}
}
else if (button == GLUT_MIDDLE_BUTTON) {
if (state == GLUT_DOWN) {
View.StartX = x;
View.StartY = y;
View.StartDistance = View.Distance;
View.Translating = GL_TRUE;
}
else if (state == GLUT_UP) {
View.Translating = GL_FALSE;
}
}
}
/**
* Handle mouse motion
*/
static void
Motion(int x, int y)
{
int i;
if (View.Rotating) {
float x0 = (2.0 * View.StartX - WinWidth) / WinWidth;
float y0 = (WinHeight - 2.0 * View.StartY) / WinHeight;
float x1 = (2.0 * x - WinWidth) / WinWidth;
float y1 = (WinHeight - 2.0 * y) / WinHeight;
float q[4];
trackball(q, x0, y0, x1, y1);
View.StartX = x;
View.StartY = y;
for (i = 0; i < 1; i++)
add_quats(q, View.CurQuat, View.CurQuat);
glutPostRedisplay();
}
else if (View.Translating) {
float dz = 0.02 * (y - View.StartY);
View.Distance = View.StartDistance + dz;
glutPostRedisplay();
}
}
static void
DoFeatureChecks(void)
{
char *version = (char *) glGetString(GL_VERSION);
if (version[0] == '1') {
/* check for individual extensions */
if (!glutExtensionSupported("GL_ARB_texture_cube_map")) {
printf("Sorry, GL_ARB_texture_cube_map is required.\n");
exit(1);
}
if (!glutExtensionSupported("GL_ARB_vertex_shader")) {
printf("Sorry, GL_ARB_vertex_shader is required.\n");
exit(1);
}
if (!glutExtensionSupported("GL_ARB_fragment_shader")) {
printf("Sorry, GL_ARB_fragment_shader is required.\n");
exit(1);
}
if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) {
printf("Sorry, GL_ARB_vertex_buffer_object is required.\n");
exit(1);
}
}
}
int
main(int argc, char** argv)
{
glutInitWindowSize(WinWidth, WinHeight);
glutInit(&argc, argv);
if (argc > 1) {
Model_file = argv[1];
}
if (!Model_file) {
fprintf(stderr, "usage: objview file.obj\n");
fprintf(stderr, "(using default bunny.obj)\n");
Model_file = "bunny.obj";
}
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutCreateWindow("objview");
glewInit();
DoFeatureChecks();
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(Mouse);
glutMotionFunc(Motion);
if (Animate)
glutIdleFunc(Idle);
glutCreateMenu(menu);
glutAddMenuEntry("[a] Toggle animate", 'a');
glutAddMenuEntry("[d] Fewer models", 'd');
glutAddMenuEntry("[D] More models", 'D');
glutAddMenuEntry("[w] Toggle wireframe/filled", 'w');
glutAddMenuEntry("[c] Toggle culling on/off", 'c');
glutAddMenuEntry("[r] Reverse polygon winding", 'r');
glutAddMenuEntry("[z] Scale model smaller", 'z');
glutAddMenuEntry("[Z] Scale model larger", 'Z');
glutAddMenuEntry("[p] Toggle performance indicator", 'p');
glutAddMenuEntry("[i] Show model stats", 'i');
glutAddMenuEntry("", 0);
glutAddMenuEntry("[q] Quit", 27);
glutAttachMenu(GLUT_RIGHT_BUTTON);
InitViewInfo(&View);
init_model();
init_skybox();
init_gfx();
glutMainLoop();
return 0;
}

187
progs/objviewer/skybox.c Normal file
View file

@ -0,0 +1,187 @@
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glew.h>
#include <GL/glu.h>
#include "readtex.h"
#include "skybox.h"
static int
load(GLenum target, const char *filename,
GLboolean flipTB, GLboolean flipLR)
{
GLint w, h;
GLenum format;
GLubyte *img = LoadRGBImage( filename, &w, &h, &format );
if (!img) {
printf("Error: couldn't load texture image %s\n", filename);
return 0;
}
assert(format == GL_RGB);
printf("Load cube face 0x%x: %s %d x %d\n", target, filename, w, h);
/* <sigh> the way the texture cube mapping works, we have to flip
* images to make things look right.
*/
if (flipTB) {
const int stride = 3 * w;
GLubyte temp[3*1024];
int i;
for (i = 0; i < h / 2; i++) {
memcpy(temp, img + i * stride, stride);
memcpy(img + i * stride, img + (h - i - 1) * stride, stride);
memcpy(img + (h - i - 1) * stride, temp, stride);
}
}
if (flipLR) {
const int stride = 3 * w;
GLubyte temp[3];
GLubyte *row;
int i, j;
for (i = 0; i < h; i++) {
row = img + i * stride;
for (j = 0; j < w / 2; j++) {
int k = w - j - 1;
temp[0] = row[j*3+0];
temp[1] = row[j*3+1];
temp[2] = row[j*3+2];
row[j*3+0] = row[k*3+0];
row[j*3+1] = row[k*3+1];
row[j*3+2] = row[k*3+2];
row[k*3+0] = temp[0];
row[k*3+1] = temp[1];
row[k*3+2] = temp[2];
}
}
}
gluBuild2DMipmaps(target, GL_RGB, w, h, format, GL_UNSIGNED_BYTE, img);
free(img);
return 1;
}
GLuint
LoadSkyBoxCubeTexture(const char *filePosX,
const char *fileNegX,
const char *filePosY,
const char *fileNegY,
const char *filePosZ,
const char *fileNegZ)
{
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
if (!load(GL_TEXTURE_CUBE_MAP_POSITIVE_X, filePosX, GL_TRUE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, fileNegX, GL_TRUE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, filePosY, 1+GL_FALSE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, fileNegY, 1+GL_FALSE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, filePosZ, GL_TRUE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, fileNegZ, GL_TRUE, GL_TRUE))
return 0;
return tex;
}
#define eps1 0.99
#define br 20.0 /* box radius */
void
DrawSkyBoxCubeTexture(GLuint tex)
{
struct vertex {
float x, y, z, s, t, r;
};
static const struct vertex verts[24] = {
/* +X side */
{ br, -br, -br, 1.0, -eps1, -eps1 },
{ br, -br, br, 1.0, -eps1, eps1 },
{ br, br, br, 1.0, eps1, eps1 },
{ br, br, -br, 1.0, eps1, -eps1 },
/* -X side */
{ -br, br, -br, -1.0, eps1, -eps1 },
{ -br, br, br, -1.0, eps1, eps1 },
{ -br, -br, br, -1.0, -eps1, eps1 },
{ -br, -br, -br, -1.0, -eps1, -eps1 },
/* +Y side */
{ br, br, -br, eps1, 1.0, -eps1 },
{ br, br, br, eps1, 1.0, eps1 },
{ -br, br, br, -eps1, 1.0, eps1 },
{ -br, br, -br, -eps1, 1.0, -eps1 },
/* -Y side */
{ -br, -br, -br, -eps1, -1.0, -eps1 },
{ -br, -br, br, -eps1, -1.0, eps1 },
{ br, -br, br, eps1, -1.0, eps1 },
{ br, -br, -br, eps1, -1.0, -eps1 },
/* +Z side */
{ br, -br, br, eps1, -eps1, 1.0 },
{ -br, -br, br, -eps1, -eps1, 1.0 },
{ -br, br, br, -eps1, eps1, 1.0 },
{ br, br, br, eps1, eps1, 1.0 },
/* -Z side */
{ br, br, -br, eps1, eps1, -1.0 },
{ -br, br, -br, -eps1, eps1, -1.0 },
{ -br, -br, -br, -eps1, -eps1, -1.0 },
{ br, -br, -br, eps1, -eps1, -1.0 },
};
static GLuint vbo = 0;
if (!vbo ) {
glGenBuffersARB(1, &vbo);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
GL_STATIC_DRAW_ARB);
}
else {
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glVertexPointer(3, GL_FLOAT, sizeof(struct vertex),
(void *) offsetof(struct vertex, x));
glTexCoordPointer(3, GL_FLOAT, sizeof(struct vertex),
(void *) offsetof(struct vertex, s));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
glEnable(GL_TEXTURE_CUBE_MAP);
glDisable(GL_BLEND);
glDrawArrays(GL_QUADS, 0, 24);
glDisable(GL_TEXTURE_CUBE_MAP);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}

18
progs/objviewer/skybox.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef SKYBOX_H
#define SKYBOX_H
extern GLuint
LoadSkyBoxCubeTexture(const char *filePosX,
const char *fileNegX,
const char *filePosY,
const char *fileNegY,
const char *filePosZ,
const char *fileNegZ);
extern void
DrawSkyBoxCubeTexture(GLuint tex);
#endif /* SKYBOX_H */

10
progs/perf/.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
copytex
drawoverhead
fbobind
fill
genmipmap
readpixels
swapbuffers
teximage
vbo
vertexrate

View file

@ -10,11 +10,17 @@ LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) \
# using : to avoid APP_CC pointing to CC loop
CC := $(APP_CC)
CFLAGS += -I$(INCDIR)
CFLAGS := -I$(INCDIR) $(CFLAGS)
LDLIBS = $(LIBS)
PROG_SOURCES = \
copytex.c \
drawoverhead.c \
fbobind.c \
fill.c \
genmipmap.c \
readpixels.c \
swapbuffers.c \
teximage.c \
vbo.c \
vertexrate.c \

32
progs/perf/SConscript Normal file
View file

@ -0,0 +1,32 @@
Import('env')
if not env['GLUT']:
Return()
env = env.Clone()
env.Prepend(LIBS = ['$GLUT_LIB'])
progs = [
'copytex',
'drawoverhead',
'fbobind',
'fill',
'genmipmap',
'readpixels',
'swapbuffers',
'teximage',
'vbo',
'vertexrate',
]
for prog in progs:
env.Program(
target = prog,
source = [
prog + '.c',
'common.c',
'glmain.c',
]
)

View file

@ -26,6 +26,32 @@
#include "common.h"
#include "glmain.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#if defined(_MSC_VER)
#define snprintf _snprintf
#endif
/* Need to add a fflush windows console with mingw, otherwise nothing
* shows up until program exit. May want to add logging here.
*/
void
perf_printf(const char *format, ...)
{
va_list ap;
va_start(ap, format);
fflush(stdout);
vfprintf(stdout, format, ap);
fflush(stdout);
va_end(ap);
}
/**
* Run function 'f' for enough iterations to reach a steady state.
@ -52,7 +78,7 @@ PerfMeasureRate(PerfRateFunc f)
subiters *= 2;
} while (t1 - t0 < 0.1 * minDuration);
}
/*printf("initial subIters = %u\n", subiters);*/
/*perf_printf("initial subIters = %u\n", subiters);*/
while (1) {
const double t0 = PerfGetTime();
@ -68,7 +94,7 @@ PerfMeasureRate(PerfRateFunc f)
rate = iters / (t1 - t0);
if (0)
printf("prevRate %f rate %f ratio %f iters %u\n",
perf_printf("prevRate %f rate %f ratio %f iters %u\n",
prevRate, rate, rate/prevRate, iters);
/* Try and speed the search up by skipping a few steps:
@ -86,8 +112,26 @@ PerfMeasureRate(PerfRateFunc f)
}
if (0)
printf("%s returning iters %u rate %f\n", __FUNCTION__, subiters, rate);
perf_printf("%s returning iters %u rate %f\n", __FUNCTION__, subiters, rate);
return rate;
}
/* Note static buffer, can only use once per printf.
*/
const char *
PerfHumanFloat( double d )
{
static char buf[80];
if (d > 1000000000.0)
snprintf(buf, sizeof(buf), "%.1f billion", d / 1000000000.0);
else if (d > 1000000.0)
snprintf(buf, sizeof(buf), "%.1f million", d / 1000000.0);
else if (d > 1000.0)
snprintf(buf, sizeof(buf), "%.1f thousand", d / 1000.0);
else
snprintf(buf, sizeof(buf), "%.1f", d);
return buf;
}

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