OpenCSG-1.3.2/ 0000755 0001750 0000144 00000000000 11665770320 012332 5 ustar fkirsch users OpenCSG-1.3.2/build.txt 0000644 0001750 0000144 00000001356 11665770270 014203 0 ustar fkirsch users Microsoft VC6 / VC 2003 .NET
----------------------------
Open OpenCSG.dsw / OpenCSG.sln
Set OpenCSGexample as active project
Compile and start example
Linux
-----
1) Just type 'make'. Maybe you must adjust the Makefiles in
the src/ and the example/ directory for sucessful compilation.
2) The OpenCSG library will have been build in lib/, GLEW in glew/lib/,
and the example "opencsgexample" will reside in the src/ directory.
To run the opencsg example, you must ensure that the GLEW and the
OpenCSG libs are in your LD_LIBRARY_PATH (e.G., one way to do this
is to copy them to /usr/local/lib and running "ldconfig -v").
Currently there is no automatic way for this.
Dev-C++ 5
---------
Open OpenCSG.dev
Compile and Run
OpenCSG-1.3.2/publications.html 0000644 0001750 0000144 00000013313 11665770270 015721 0 ustar fkirsch users
Florian Kirsch and Jürgen Döllner: Rendering Techniques for Hardware-Accelerated Image-Based CSG
Journal of WSCG, 12(2):221-228, 2004.
Abstract: Image-based CSG rendering algorithms for standard
graphics hardware rely on multipass rendering that includes reading and
writing large amounts of pixel data from and to the frame buffer.
Since the performance of this data path has hardly improved over the
last years, we describe new implementation techniques that efficiently
use modern graphics hardware.
1) The render-to-texture ability is used to temporarily store shape
visibility, avoiding the expensive copy of z-buffer content to external memory.
Shape visibility is encoded discretely instead of using depth values.
Hence, the technique is also not susceptible to artifacts in contrast to
previously described methods.
2) We present an image-based technique for calculating the depth complexity
of a CSG shape that avoids reading and analyzing pixel data from the
frame buffer.
Both techniques optimize various CSG rendering algorithms, namely the
Goldfeather and the layered Goldfeather algorithm, and the
Sequenced-Convex-Subtraction (SCS) algorithm. This way, these
image-based CSG algorithms now operate accelerated by graphics
hardware and, therefore, represent a significant improvement
towards real-time image-based CSG rendering for complex models.
Florian Kirsch and Jürgen Döllner: OpenCSG: A Library for Image-Based CSG Rendering
Proceedings of the FREENIX / Open Source Track, 2005 USENIX Annual Technical Conference, 129-140, 2005.
Abstract: We present the design and implementation of a real-time
3D graphics library for Constructive Solid Geometry (CSG).
This major approach of 3D modeling has not been supported
by real-time computer graphics until recently.
We describe two essential image-based CSG rendering
algorithms and an API that provides a compact access
to their complex functionality and implementation.
As an important feature, the CSG library seamlessly
integrates application-defined 3D shapes as primitives
of CSG operations to ensure high adaptability and openness.
We also outline optimization techniques to improve the
performance in the case of complex CSG models.
A number of use cases demonstrate potential applications of the library.
In my doctoral dissertation, I discuss how to integrate a variety of
different rendering algorithms, such as shadow mapping, reflection algorithms,
bump mapping, CSG rendering, etc., into a scene graph system. The goal
is to be able to use and combine several of those algorithms at the same time.
To simplify this task for the programmer using the scene graph, the
rendering effects are specified in the scene graph in a declarative way,
without notion of settings of the graphics hardware or of the required
rendering algorithms. Those are, consequently, derived internally
by the library for evaluating the scene graph.
In practice, this means that using this system I have combined all algorithms
provided by OpenCSG with different flavors of shadow mapping, stenciled
and textured reflections, environment mapping and bump mapping.
OpenCSG-1.3.2/changelog.txt 0000644 0001750 0000144 00000024133 11665770270 015031 0 ustar fkirsch users 02.12.2011
Release 1.3.2
29.11.2011
Changed: Favor EXT frame buffer object extension over pbuffers (due
to feedback from openscad users)
28.11.2011
Added: Version number to opencsg.h
27.11.2011
Added: MacOSX portibility fixes (thanks to Marius Kintel)
26.11.2011
Fixed: rendering artifacts at the border of primitives under Linux / ATI /
Gallium3D that were caused by linear filtering of the FBO texture.
Nearest filtering is required.
25.11.2011
Fixed: Quering width and heigth of a pbuffer under Linux / ATI / Gallium3D
driver always returned 0. The query should not be required, anyway.
14.11.2011
Added: Support ARB_texture_rectangle extension for FBO path. This extension
is used preferably instead of the former solution, that implicitely
required the ARB_texture_non_power_of_two extension without checking
for it.
Fixed: In case ARB_texture_rectangle is not available and also not
ARB_texture_non_power_of_two, the FBO is blown up to power-of-two,
as in the pbuffer case.
11.11.2011
Fixed: Perform 0-ptr checks if no occlusion query object can be created.
10.11.2011
Added: Support for ARB_occlusion_query2 extension in the Goldfeather /
occlusion query case.
05.09.2011
Fixed: For frame buffer objects, switch back to prior FBO instead of
disabling FBO (thanks to Marius Kintel for the bug report).
09.06.2010
Release 1.3.1
06.06.2010
License: Added special linking exception for CGAL.
07.02.2010
Release 1.3.0
27.01.2010
Added: Allow to chose explicitely between ARB and EXT frame buffer objects
Changed: In the automatic setting, ARB frame buffer objects have precedence
over pbuffers over EXT frame buffer objects now.
21.01.2010
Changed: made offscreen buffer methods Initialize() / Resize()
more intuitive. Initialize needs to be called only once after
offscreen buffer construction; after Resize() calling Initialize()
is not required anymore.
20.01.2010
Added: context management to allow MDI applications to use OpenCSG
in each OpenGL window even without shared OpenGL contexts.
This just maps a integer context identifier to a set of different
internal offscreen buffer objects for each context.
16.01.2010
Fixed: rendering error in SCS algorithm due to imprecise
float value provided to alpha test.
03.01.2010
Release 1.2.0
05.11.2009
Changed: frame buffer objects are now used by default
(instead of pbuffers)
03.08.2009
Added: support for ARB frame buffer objects (in addition
to EXT frame buffer objects)
22.07.2009
Fixed: uninitialized variable in framebuffer object path.
Might have caused the visibility transfer to fail.
19.07.2009
Release 1.1.1
19.07.2009
Fixed: bad performance behaviour of Batcher when called with
many primitives with standard bounding boxes.
07.02.2009
Fixed: removed -athlon-xp optimization in makefile, which was
not portable obviously, in particular for x64 platforms.
30.09.2007
Changed: made a default and a legacy render() function for
interface cleanup and more logical documentation in the
header file.
23.09.2007
Added: made depth bounds optimization configurable, default off.
15.08.2007
Fixed: stencil mask was not reset after doing the parity test.
Then, the stencil buffer was not fully reset in the next
glClear(GL_STENCIL_BUFFER_BIT). Bug only manifested in layered
Goldfeather algorithms with FBO.
08.08.2007
Added: Support for depth bounds extension for performance improvements.
Currently, standard Goldfeather and all SCS algorithms use this
functionality.
03.12.2006
Release 1.1.0
02.12.2006
Fixed: Free for mode string failed in debug mode in VC6, commented
out.
30.11.2006
Changed: Renamed setOptioni -> setOption, getOptioni -> getOption.
Changed: Refined offscreen buffer resizing.
29.11.2006
Fixed: Offscreen buffer resizing issue with alternating buffers
of the resolution (x1, y1) / (x2, y2) where x1>x2 but y1 1024x512 -> 512x1024 -> ... (and similar series)
06.11.2003
Added: Detection of GL_FRONT_FACE OpenGL setting. This means that
CSG rendering is now also correct if this setting is the
non-default clockwise setting.
04.11.2003
Fixed: Stenciling was not disabled in SCS algorithm when
subtracting no shapes. This could lead to obscure rendering
errors when rendering the next CSG shape.
02.11.2003
Added: Heuristic that makes the pbuffer smaller
if the size of the pbuffer has been bigger than necessary in
x- or y- direction for a certain number of render-calles.
This permits to use OpenCSG for CSG rendering in different
canvases with different sizes without constant expensive
resizing of the pbuffer for every frame.
01.10.2003
Fixed: linux: removed accidental linking against tcl/tk
23.09.2003
Release 0.9
OpenCSG-1.3.2/license.txt 0000644 0001750 0000144 00000044004 11665770270 014523 0 ustar fkirsch users
***************************************************************************
As a special exception, you have permission to link this library
with the CGAL library (http://www.cgal.org) and distribute executables,
as long as you follow the requirements of the GNU GPL in regard to
all of the software in the executable aside from CGAL.
***************************************************************************
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
OpenCSG-1.3.2/win32/ 0000755 0001750 0000144 00000000000 11665770270 013300 5 ustar fkirsch users OpenCSG-1.3.2/win32/OpenCSG.vcproj 0000644 0001750 0000144 00000024533 11665770270 015772 0 ustar fkirsch users
OpenCSG-1.3.2/win32/OpenCSG.dsp 0000644 0001750 0000144 00000013226 11665770270 015252 0 ustar fkirsch users # Microsoft Developer Studio Project File - Name="OpenCSG" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** NICHT BEARBEITEN **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=OpenCSG - Win32 Debug
!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
!MESSAGE
!MESSAGE NMAKE /f "OpenCSG.mak".
!MESSAGE
!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
!MESSAGE
!MESSAGE NMAKE /f "OpenCSG.mak" CFG="OpenCSG - Win32 Debug"
!MESSAGE
!MESSAGE Für die Konfiguration stehen zur Auswahl:
!MESSAGE
!MESSAGE "OpenCSG - Win32 Release" (basierend auf "Win32 (x86) Static Library")
!MESSAGE "OpenCSG - Win32 Debug" (basierend auf "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "OpenCSG - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I ".." /I "../include" /I "../glew/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "GLEW_STATIC" /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"../lib/OpenCSG.lib"
!ELSEIF "$(CFG)" == "OpenCSG - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "../include" /I "../glew/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "GLEW_STATIC" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"../lib/OpenCSGd.lib"
!ENDIF
# Begin Target
# Name "OpenCSG - Win32 Release"
# Name "OpenCSG - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\src\area.cpp
# End Source File
# Begin Source File
SOURCE=..\src\area.h
# End Source File
# Begin Source File
SOURCE=..\src\batch.cpp
# End Source File
# Begin Source File
SOURCE=..\src\batch.h
# End Source File
# Begin Source File
SOURCE=..\src\channelManager.cpp
# End Source File
# Begin Source File
SOURCE=..\src\channelManager.h
# End Source File
# Begin Source File
SOURCE=..\src\context.cpp
# End Source File
# Begin Source File
SOURCE=..\src\context.h
# End Source File
# Begin Source File
SOURCE=..\src\frameBufferObject.cpp
# End Source File
# Begin Source File
SOURCE=..\src\frameBufferObject.h
# End Source File
# Begin Source File
SOURCE=..\src\frameBufferObjectExt.cpp
# End Source File
# Begin Source File
SOURCE=..\src\frameBufferObjectExt.h
# End Source File
# Begin Source File
SOURCE=..\src\occlusionQuery.cpp
# End Source File
# Begin Source File
SOURCE=..\src\occlusionQuery.h
# End Source File
# Begin Source File
SOURCE=..\src\offscreenBuffer.cpp
# End Source File
# Begin Source File
SOURCE=..\src\offscreenBuffer.h
# End Source File
# Begin Source File
SOURCE=..\src\opencsgConfig.h
# End Source File
# Begin Source File
SOURCE=..\src\opencsgRender.cpp
# End Source File
# Begin Source File
SOURCE=..\src\opencsgRender.h
# End Source File
# Begin Source File
SOURCE=..\src\openglHelper.cpp
# End Source File
# Begin Source File
SOURCE=..\src\openglHelper.h
# End Source File
# Begin Source File
SOURCE=..\src\pBufferTexture.cpp
# End Source File
# Begin Source File
SOURCE=..\src\pBufferTexture.h
# End Source File
# Begin Source File
SOURCE=..\src\primitive.cpp
# End Source File
# Begin Source File
SOURCE=..\src\primitiveHelper.cpp
# End Source File
# Begin Source File
SOURCE=..\src\primitiveHelper.h
# End Source File
# Begin Source File
SOURCE=..\src\renderGoldfeather.cpp
# End Source File
# Begin Source File
SOURCE=..\src\renderSCS.cpp
# End Source File
# Begin Source File
SOURCE=..\RenderTexture\RenderTexture.cpp
# End Source File
# Begin Source File
SOURCE=..\RenderTexture\RenderTexture.h
# End Source File
# Begin Source File
SOURCE=..\src\scissorMemo.cpp
# End Source File
# Begin Source File
SOURCE=..\src\scissorMemo.h
# End Source File
# Begin Source File
SOURCE=..\src\settings.cpp
# End Source File
# Begin Source File
SOURCE=..\src\settings.h
# End Source File
# Begin Source File
SOURCE=..\src\stencilManager.cpp
# End Source File
# Begin Source File
SOURCE=..\src\stencilManager.h
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\include\opencsg.h
# End Source File
# End Group
# End Target
# End Project
OpenCSG-1.3.2/version.txt 0000644 0001750 0000144 00000000016 11665770270 014561 0 ustar fkirsch users OpenCSG-1.3.2
OpenCSG-1.3.2/OpenCSG.sln 0000644 0001750 0000144 00000004161 11665770270 014314 0 ustar fkirsch users Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenCSG", "win32\OpenCSG.vcproj", "{934506C1-ABD2-4D13-B1FF-35BB2985A60F}"
ProjectSection(ProjectDependencies) = postProject
{9E7140BE-2064-45BD-9492-0EF5BCD28B8E} = {9E7140BE-2064-45BD-9492-0EF5BCD28B8E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenCSGexample", "example\OpenCSGexample.vcproj", "{8B99F85D-6EF5-4F64-86A6-D1CBA2804169}"
ProjectSection(ProjectDependencies) = postProject
{9E7140BE-2064-45BD-9492-0EF5BCD28B8E} = {9E7140BE-2064-45BD-9492-0EF5BCD28B8E}
{934506C1-ABD2-4D13-B1FF-35BB2985A60F} = {934506C1-ABD2-4D13-B1FF-35BB2985A60F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glew_static", "glew\build\vc6\glew_static.vcproj", "{9E7140BE-2064-45BD-9492-0EF5BCD28B8E}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{934506C1-ABD2-4D13-B1FF-35BB2985A60F}.Debug.ActiveCfg = Debug|Win32
{934506C1-ABD2-4D13-B1FF-35BB2985A60F}.Debug.Build.0 = Debug|Win32
{934506C1-ABD2-4D13-B1FF-35BB2985A60F}.Release.ActiveCfg = Release|Win32
{934506C1-ABD2-4D13-B1FF-35BB2985A60F}.Release.Build.0 = Release|Win32
{8B99F85D-6EF5-4F64-86A6-D1CBA2804169}.Debug.ActiveCfg = Debug|Win32
{8B99F85D-6EF5-4F64-86A6-D1CBA2804169}.Debug.Build.0 = Debug|Win32
{8B99F85D-6EF5-4F64-86A6-D1CBA2804169}.Release.ActiveCfg = Release|Win32
{8B99F85D-6EF5-4F64-86A6-D1CBA2804169}.Release.Build.0 = Release|Win32
{9E7140BE-2064-45BD-9492-0EF5BCD28B8E}.Debug.ActiveCfg = Debug|Win32
{9E7140BE-2064-45BD-9492-0EF5BCD28B8E}.Debug.Build.0 = Debug|Win32
{9E7140BE-2064-45BD-9492-0EF5BCD28B8E}.Release.ActiveCfg = Release|Win32
{9E7140BE-2064-45BD-9492-0EF5BCD28B8E}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
OpenCSG-1.3.2/news.html 0000644 0001750 0000144 00000027121 11665770270 014203 0 ustar fkirsch users
OpenCSG - News
OpenCSG 1.3.2
is a maintenance release. It contains fixes for a number of errors
when setting up frame buffer objects or PBuffers with unusual combinations
of available OpenGL extensions. Furthermore, the calling application may
now render into a frame buffer object when calling OpenCSG. This failed
with former versions because OpenCSG did not switch back to the original
frame buffer object. The release also contains a couple of compilation fixes
for MacOS X.
09.06.2010: OpenCSG 1.3.1 released
OpenCSG 1.3.1
was mainly released for a slight change of the license: The GPL license
contains a special linking exception for the
CGAL library now. This means that
you are now allowed to link OpenCSG with CGAL and ship the binaries,
as long as you follow the requirements of the GPLv2 in regard to
all of the software in the executable aside from CGAL.
Aside from some dead code removed, there were no source code changes
in this release.
07.02.2010: OpenCSG 1.3.0 with support for MDI applications
OpenCSG 1.3.0
implements better support for applications having an multiple document
interface and, therefore, use OpenCSG in different OpenGL windows.
If the contexts of these windows are not shared, older versions of
OpenCSG render incorrectly, because internally allocated PBuffers
resp. frame buffer objects, that are not reallocated for each frame,
are not valid in the different OpenGL contexts.
To solve this, new functions for setting/getting an OpenCSG context
have been added. OpenGL resources are created and reused by the
render() function per context. By setting a
different OpenCSG context for each OpenGL window before using
OpenCSG, CSG rendering is performed correctly.
03.01.2010: OpenCSG 1.2.0 released
OpenCSG 1.2.0
contains fixes for CSG rendering using the frame buffer object extension.
In particular, it adds support for the ARB variant of this extension
(before, only the EXT variant was supported).
Since the new version now uses frame buffer objects
as default, in contrast to the pbuffer code path in former versions,
there is the potential possibility that the pbuffer path might
work ok, but the (now default) frame buffer object path would fail.
In that case, try to set the OffscreenSetting
to PBuffer using setOption().
OpenCSG 1.2.0 also contains a small API cleanup. Whilst the old
render() function taking three arguments is
still provided for backward compatibility, there is a new
render() function that only takes the list
of primitives to render as argument. The other two arguments
setting some rendering options are now consistently expected to be
set using the setOption() interface.
19.07.2009: OpenCSG 1.1.1 released
OpenCSG 1.1.1
is a maintenance release. Issues in the makefiles for Linux
and portability problems for 64-bit Linux have been resolved. Additionally,
a performance problem was fixed in the case of lots of CSG primitives
(several 10000s) with standard bounding boxes. Rendering this is slow
anyways, but before, the rendering time was dominated by the computation
time for generating the batches of primitives. This was, without bounding boxes,
wasted time, because the batches are trivial anyways.
03.12.2006: OpenCSG 1.1.0 with Frame Buffer Object Support
The most significant addition in OpenCSG-1.1.0 is the support of OpenGL frame buffer objects. This
change also led to the option setter and getter functions to control this
and all other rendering options. Additionally several bugs have been fixed,
for example in the heuristics that choses the offscreen buffer size and
rendering errors that occured on some low-end graphics hardware.
03.07.2005: FREENIX 2005 Paper on OpenCSG
Since some time, the paper is available for download at directly from
USENIX (which requires a USENIX account for some time), or
here, where also my talk can be downloaded.
18.12.2004: To appear: FREENIX 2005 Paper on OpenCSG
I am going to present the paper
OpenCSG: A Library for Image-Based CSG Rendering
on the FREENIX Track
of the USENIX Annual Technical Conference 2005
in Anaheim, Californien.
This paper contains a short description of the Goldfeather and the SCS algorithm. It then
explains how (and why so) the API of OpenCSG was designed, outlines the basic implementation
and problems encountered during the implementation. Finally it describes some examples of
its use.
04.12.2004: OpenCSG version 1.0.2 released
OpenCSG-1.0.2 provides a workspace
for the free, gcc-based Dev-C++ 5
compiler for Windows. Additionally it fixes two bugs, one in the
RenderTexture library, and one bug in the heuristic for choosing
the CSG rendering algorithm, which caused that, under circumstances,
a non-optimal rendering algorithm was used.
The settings of the OpenGL scissor test are now respected
(Former versions just ignored the settings of the scissor test.).
For certain cases, this can lead to a substantial performance gain.
Note that this change could, potentially, cause compatibility
problems in the unlikely case that your application uses the
scissor test when invoking CSG rendering, but actually does not want
scissoring to be active for CSG rendering. The bug fix for this
case is just to disable scissoring.
Besides, OpenCSG now uses the new
RenderTexture version 2 that has superseded the older version. As before,
I had to apply some minor patches to RenderTexture for correct functionality under
Linux.
The interface of OpenCSG has remained unchanged.
I have also updated some sections on the web and added a short FAQ section.
06.07.2004: Download problems are gone
The download problems have been resolved for some time now (as you probably guessed ...)
However, I have kept the download place for OpenCSG 1.0.0 here, because my bandwidth
currently seems to be sufficient.
23.05.2004: Download address of OpenCSG source has temporarily changed
Downloading OpenCSG has not been possible during the past few days due to server problems.
Therefore I have copied the version 1.0.0 temporarily onto this server, so it
is possible to download the current version of OpenCSG again.
Older versions of OpenCSG currently are not accessible in the moment.
Sorry for any inconveniences.
02.05.2004: OpenCSG version 1.0.0 released
OpenCSG-1.0.0 contains lots of improvements and additions:
The makefile system for Linux now compiles a shared library.
The makefiles have been derived by auto-generated makefiles from
qmake, but
of course, qmake (or Qt) is not required to compile OpenCSG.
Version 1.0.0 contains lots of further performance improvements in
case the bounding-box for shapes is set. This includes a performance
bug fix, i.e., formerly scissoring was set to non-optimal values.
Also, calculating the depth complexity now also considers the bounding
box values.
If available, the GL_TEXTURE_RECTANGLE_NV texture format is now
used even in case of power-of-two textures, because this format
appears to be generally faster.
The interface of OpenCSG has remained unchanged.
02.03.2004: OpenCSG version 0.9.2 released
OpenCSG-0.9.2 brings some improvements compared to former versions.
First, for occlusion queries the newer OpenGL-extension GL_ARB_occlusion_query
is now supported along with the former GL_NV_occlusion_query extension.
Second, OpenCSG comes with GLEW version 1.2.0 now.
Compared to former versions of OpenCSG, no external interfaces have been changed,
so your applications using OpenCSG should just continue to work with OpenCSG 0.9.2.
04.02.2004: Paper on rendering techniques in OpenCSG
I have presented the paper Rendering Techniques for Hardware-Accelerated Image-Based CSG
on the WSCG 2004 conference.
This paper describes the method that OpenCSG uses to transfer the depth information
in the temporary z-buffer into the main z-buffer using render-to-texture. The paper
describes also how occlusion queries can be used to speed up image-based CSG
rendering.
You can download my talk already;
The paper will be available online as soon as
it is published online by the WSCG.
22.11.2003: OpenCSG version 0.9.1 released
OpenCSG-0.9.1 contains a number of improvements and bug fixes.
New features include the ability to work also with the non-standard
clockwise front-face setting and performance improvements in the case
of constantly changing viewport sizes due to fewer resizes
of the internal pbuffer.
Upgrading from version 0.9 to 0.9.1 should be no problem, as the
external interface (and even the hidden internal interfaces)
have not changed.
OpenCSG-1.3.2/RenderTexture/ 0000755 0001750 0000144 00000000000 11665770270 015136 5 ustar fkirsch users OpenCSG-1.3.2/RenderTexture/RenderTexture.h 0000644 0001750 0000144 00000030502 11665770270 020107 0 ustar fkirsch users //------------------------------------------------------------------------------
// File : RenderTexture.h
//------------------------------------------------------------------------------
// Copyright (c) 2002-2004 Mark J. Harris
//---------------------------------------------------------------------------
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any
// damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any
// purpose, including commercial applications, and to alter it and
// redistribute it freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you
// must not claim that you wrote the original software. If you use
// this software in a product, an acknowledgment in the product
// documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and
// must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
// -----------------------------------------------------------------------------
// Credits:
// Original RenderTexture code: Mark J. Harris
// Original Render-to-depth-texture support: Thorsten Scheuermann
// Linux Copy-to-texture: Eric Werness
// Various Bug Fixes: Daniel (Redge) Sperl
// Bill Baxter
// Florian Kirsch
// Andrew Wood
// Deprecated Interface Removed: Florian Kirsch
//
// -----------------------------------------------------------------------------
/**
* @file RenderTexture.h
*
* Interface definition for class RenderTexture. A multi-format render to
* texture wrapper.
*/
#ifndef __RENDERTEXTURE2_HPP__
#define __RENDERTEXTURE2_HPP__
#ifndef __APPLE__
#include
#ifdef _WIN32
#include
#else
#include
#endif
#include
#include
/* The pixel format for the pbuffer is controlled by the mode string passed
* into the PBuffer constructor. This string can have the following attributes:
*
* To specify the pixel format, use the following syntax.
* =
* must match one of the following.
*
* r - r pixel format (for float buffer).
* rg - rg pixel format (for float buffer).
* rgb - rgb pixel format. 8 bit or 16/32 bit in float buffer mode
* rgba - same as "rgb alpha" string
*
* can either be a scalar--meaning the same bit depth for each
* channel-- or a 2-, 3-, 4-component vector matching the specified number of
* channels. Vector components should be comma separated. An optional 'f'
* suffix on the bit depth specifies float components. In this case
* must be either "32f" or "16f". If is empty, the default 8 bits per
* channel will be used.
* r=32f
* rg=16f
* rgb=8
* rgb=5,6,5
*
* The following other attributes are supported.
*
* depth=n - must have n-bit depth buffer, omit n for default (24 bits)
* stencil=n - must have n-bit stencil buffer, omit n for default (8 bits)
* samples=n - must support n-sample antialiasing (n can be 2 or 4)
* aux=n - must have n AUX buffers
* doublebuffer - must support double buffered rendering
* singlebuffer - do not support double buffered rendering
*
* tex2D
* texRECT
* texCUBE - must support binding pbuffer as texture to specified target
* - binding the depth buffer is also supported by specifying
* depthTex2D
* depthTexRECT
* depthTexCUBE
* - Both depth and color texture binding, may be specified, but
* the targets must match!
* For example: "tex2D depthTex2D" or "texRECT depthTexRECT"
*
* rtt
* ctt - These mutually exclusive options specify the update method used
* for render textures that support texture binding. "rtt"
* indicates that render to texture will be used to update the
* texture. "ctt" indicates that copy to texture will be used
* (i.e. glCopyTexSubImage2D()). "rtt" is the default if neither is
* specified, and one of the "tex*" options above is.
*
*
*---------------------------------------------------------------------------
*
* USAGE NOTES:
*
* * Texture Parameters:
* The default texture wrap mode is GL_CLAMP_TO_EDGE for all textures, and
* the default texture filtering modes (min and mag) are GL_NEAREST.
* To change these parameters, simply bind the RenderTexture (using the
* Bind() method), and set them the way you would for any GL texture object.
* The same goes for depth textures.
*
* * Enabling Mipmapping:
* This is similar to the texture parameters above. When "rtt" is specified
* in the mode string, "mipmap" must also be specified in order to enable
* a mipmapped pbuffer. Then, the mipmaps must be created by enabling the
* GL_SGIS_GENERATE_MIPMAP texture parameter in the same way as above, and
* the min filter mode must be set to a mipmap filter mode, as with any
* mipmapped texture object.
*
* * Enabling Anisotropic Filtering
* As with the texture parameters above, except as in the following code:
* glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, max);
* glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, );
*/
class RenderTexture
{
public: // enums
enum UpdateMode
{
RT_RENDER_TO_TEXTURE,
RT_COPY_TO_TEXTURE
};
public: // interface
// ctor / dtor
RenderTexture(const char *strMode="rgb tex2D");
~RenderTexture();
//! Call this once before use. Set bShare to true to share lists, textures,
//! and program objects between the render texture context and the
//! current active GL context.
bool Initialize(int width, int height,
bool shareObjects=true,
bool copyContext=false);
// !Change the render texture format.
bool Reset(const char* strMode,...);
// !Change the size of the render texture.
bool Resize(int width, int height);
// !Begin drawing to the texture. (i.e. use as "output" texture)
bool BeginCapture();
// !Ends drawing to 'current', begins drawing to this RenderTexture
bool BeginCapture(RenderTexture* current);
// !End drawing to the texture.
bool EndCapture();
// !Bind the texture to the active texture unit for use as an "input" texture
void Bind() const;
// !Bind the depth texture to the active texture unit for use as an "input" texture
void BindDepth() const;
// !Associate the RTT texture with 'iBuffer' (default is WGL_FRONT_LEFT_ARB)
bool BindBuffer( int iBuffer );
//! Enables the texture target appropriate for this render texture.
void EnableTextureTarget() const
{ if (_bInitialized) glEnable(_iTextureTarget); }
//! Disables the texture target appropriate for this render texture.
void DisableTextureTarget() const
{ if (_bInitialized) glDisable(_iTextureTarget); }
//! Returns the texture ID. Useful in Cg applications.
unsigned int GetTextureID() const { return _iTextureID; }
//! Returns the depth texture ID. Useful in Cg applications.
unsigned int GetDepthTextureID() const { return _iDepthTextureID; }
//! Returns the texture target this texture is bound to.
unsigned int GetTextureTarget() const { return _iTextureTarget; }
//! Conversion operator allows RenderTexture to be passed to GL calls
operator unsigned int()const{return _iTextureID;}
//! Returns the width of the offscreen buffer.
int GetWidth() const { return _iWidth; }
//! Returns the width of the offscreen buffer.
int GetHeight() const { return _iHeight; }
//! Returns the maximum S texture coordinate.
int GetMaxS() const { return IsRectangleTexture() ? _iWidth : 1; }
//! Returns the maximum T texture coordinate.
int GetMaxT() const { return IsRectangleTexture() ? _iHeight : 1; }
//! Returns the number of red bits allocated.
int GetRedBits() const { return _iNumColorBits[0]; }
//! Returns the number of green bits allocated.
int GetGreenBits() const { return _iNumColorBits[1]; }
//! Returns the number of blue bits allocated.
int GetBlueBits() const { return _iNumColorBits[2]; }
//! Returns the number of alpha bits allocated.
int GetAlphaBits() const { return _iNumColorBits[3]; }
//! Returns the number of depth bits allocated.
int GetDepthBits() const { return _iNumDepthBits; }
//! Returns the number of stencil bits allocated.
int GetStencilBits() const { return _iNumStencilBits; }
//! True if this RenderTexture has been properly initialized.
bool IsInitialized() const { return _bInitialized; }
//! True if this is a texture and not just an offscreen buffer.
bool IsTexture() const { return _bIsTexture; }
//! True if this is a depth texture and not just an offscreen buffer.
bool IsDepthTexture() const { return _bIsDepthTexture; }
//! True if this is a floating point buffer / texture.
bool IsFloatTexture() const { return _bFloat; }
//! True if this is a double-buffered pbuffer
bool IsDoubleBuffered() const { return _bDoubleBuffered; }
//! True if this texture has non-power-of-two dimensions.
bool IsRectangleTexture() const { return _bRectangle; }
//! True if this texture has non-power-of-two dimensions.
//! True if this pbuffer has a depth buffer.
bool HasDepth() const { return (_iNumDepthBits > 0); }
//! True if this pbuffer has a stencil buffer.
bool HasStencil() const { return (_iNumStencilBits > 0); }
//! True if this texture has mipmaps.
bool IsMipmapped() const { return _bMipmap; }
/**
* @fn IsPowerOfTwo(int n)
* @brief Returns true if /param n is an integer power of 2.
*
* Taken from Steve Baker's Cute Code Collection.
* http://www.sjbaker.org/steve/software/cute_code.html
*/
static bool IsPowerOfTwo(int n) { return ((n&(n-1))==0); }
protected: // methods
bool _Invalidate();
typedef std::pair KeyVal;
void _ParseModeString(const char *modeString,
std::vector &pixelFormatAttribs,
std::vector &pbufferAttribs);
std::vector _ParseBitVector(std::string bitVector);
KeyVal _GetKeyValuePair(std::string token);
bool _VerifyExtensions();
bool _InitializeTextures();
void _MaybeCopyBuffer();
bool _ReleaseBoundBuffers();
bool _MakeCurrent();
bool _BindDepthBuffer( ) const;
protected: // data
int _iWidth; // width of the pbuffer
int _iHeight; // height of the pbuffer
bool _bIsTexture;
bool _bIsDepthTexture;
bool _bHasARBDepthTexture; // [Redge]
UpdateMode _eUpdateMode;
bool _bInitialized;
unsigned int _iNumAuxBuffers;
bool _bIsBufferBound;
int _iCurrentBoundBuffer;
unsigned int _iNumComponents;
unsigned int _iNumColorBits[4];
unsigned int _iNumDepthBits;
unsigned int _iNumStencilBits;
bool _bFloat;
bool _bDoubleBuffered;
bool _bPowerOf2;
bool _bRectangle;
bool _bMipmap;
bool _bShareObjects;
bool _bCopyContext;
#ifdef _WIN32
HDC _hDC; // Handle to a device context.
HGLRC _hGLContext; // Handle to a GL context.
HPBUFFERARB _hPBuffer; // Handle to a pbuffer.
HDC _hPreviousDC;
HGLRC _hPreviousContext;
#else
Display *_pDisplay;
GLXContext _hGLContext;
GLXPbuffer _hPBuffer;
GLXDrawable _hPreviousDrawable;
GLXContext _hPreviousContext;
#endif
// Texture stuff
GLenum _iTextureTarget;
unsigned int _iTextureID;
unsigned int _iDepthTextureID;
unsigned short* _pPoorDepthTexture; // [Redge]
std::vector _pixelFormatAttribs;
std::vector _pbufferAttribs;
private:
// Using these could lead to some odd behavior
RenderTexture(const RenderTexture&);
RenderTexture& operator=(const RenderTexture&);
};
#endif // __APPLE__
#endif //__RENDERTEXTURE2_HPP__
OpenCSG-1.3.2/RenderTexture/TestRenderTexture.cpp 0000644 0001750 0000144 00000036056 11665770270 021314 0 ustar fkirsch users #include "RenderTexture.h"
#include
#ifdef USE_CG
#include
#endif
#include
#include
void Reshape(int w, int h);
#ifdef USE_CG
CGprogram textureProgram;
CGprogram passThroughProgram;
CGparameter textureParam;
CGcontext cgContext;
CGprofile cgProfile;
#else
GLuint iTextureProgram = 0;
GLuint iPassThroughProgram = 0;
#endif // USE_CG
RenderTexture *rt = NULL;
float rectAngle = 0;
float torusAngle = 0;
bool bTorusMotion = true;
bool bRectMotion = true;
bool bShowDepthTexture = false;
static const char *g_modeTestStrings[] =
{
"rgb tex2D",
"r=32f texRECT ctt aux=4",
"rgba tex2D depthTex2D",
"rgba=8 depthTexRECT ctt",
"rgba samples=4 tex2D ctt",
"rgba=8 tex2D mipmap",
"rgb=5,6,5 tex2D",
"rgba=16f texRECT",
"rgba=32f texRECT depthTexRECT",
"rgb=5,6,5 tex2D",
"rgba=16f texRECT depthTexRECT ctt",
"r=32f texRECT depth ctt",
"rgb double tex2D",
"r=32f texRECT ctt aux=4"
};
static int g_numModeTestStrings = sizeof(g_modeTestStrings) / sizeof(char*);
static int g_currentString = 0;
//---------------------------------------------------------------------------
// Function : PrintGLerror
// Description :
//---------------------------------------------------------------------------
void PrintGLerror( char *msg )
{
GLenum errCode;
const GLubyte *errStr;
if ((errCode = glGetError()) != GL_NO_ERROR)
{
errStr = gluErrorString(errCode);
fprintf(stderr,"OpenGL ERROR: %s: %s\n", errStr, msg);
}
}
#ifdef USE_CG
//---------------------------------------------------------------------------
// Function : cgErrorCallback
// Description :
//---------------------------------------------------------------------------
void cgErrorCallback()
{
CGerror lastError = cgGetError();
if(lastError)
{
printf("%s\n\n", cgGetErrorString(lastError));
printf("%s\n", cgGetLastListing(cgContext));
printf("Cg error, exiting...\n");
exit(0);
}
}
#endif // USE_CG
//---------------------------------------------------------------------------
// Function : CreateRenderTexture
// Description :
//---------------------------------------------------------------------------
RenderTexture* CreateRenderTexture(const char *initstr)
{
printf("\nCreating with init string: \"%s\"\n", initstr);
int texWidth = 256, texHeight = 256;
// Test deprecated interface
//RenderTexture *rt2 = new RenderTexture(texWidth, texHeight);
//if (!rt2->Initialize(true,false,false,false,false,8,8,8,0))
RenderTexture *rt2 = new RenderTexture();
rt2->Reset(initstr);
if (!rt2->Initialize(texWidth, texHeight))
{
fprintf(stderr, "RenderTexture Initialization failed!\n");
}
// for shadow mapping we still have to bind it and set the correct
// texture parameters using the SGI_shadow or ARB_shadow extension
// setup the rendering context for the RenderTexture
if (rt2->BeginCapture())
{
Reshape(texWidth, texHeight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glClearColor(0.2, 0.2, 0.2, 1);
rt2->EndCapture();
}
// enable linear filtering if available
if (rt2->IsTexture() || rt2->IsDepthTexture())
{
if (rt2->IsMipmapped())
{
// Enable trilinear filtering so we can see the mipmapping
if (rt2->IsTexture())
{
rt2->Bind();
glTexParameteri(rt2->GetTextureTarget(),
GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(rt2->GetTextureTarget(),
GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(rt2->GetTextureTarget(),
GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
}
if (rt2->IsDepthTexture())
{
rt2->BindDepth();
glTexParameteri(rt2->GetTextureTarget(),
GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(rt2->GetTextureTarget(),
GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(rt2->GetTextureTarget(),
GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
}
}
else if (!(rt2->IsRectangleTexture() || rt2->IsFloatTexture()))
{
if (rt2->IsTexture())
{
rt2->Bind();
glTexParameteri(rt2->GetTextureTarget(),
GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(rt2->GetTextureTarget(),
GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
if (rt2->IsDepthTexture())
{
rt2->BindDepth();
glTexParameteri(rt2->GetTextureTarget(),
GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(rt2->GetTextureTarget(),
GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
}
}
if (rt2->IsFloatTexture())
{
;
#ifdef USE_CG
printf("Initializing Cg...\n");
// Setup Cg
cgSetErrorCallback(cgErrorCallback);
cgContext = cgCreateContext();
cgGLSetManageTextureParameters(cgContext,CG_TRUE);
// get the best profile for this hardware
cgProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
assert(cgProfile != CG_PROFILE_UNKNOWN);
cgGLSetOptimalOptions(cgProfile);
// [Andrew Wood] - Used to refer to global rt RenderTexture & get previous value
const char* strTextureProgram = rt2->IsRectangleTexture() ?
"float4 main(half2 coords : TEX0,\n"
" uniform samplerRECT texture) : COLOR {\n"
" return f4texRECT(texture, coords); }\n"
:
"float4 main(half2 coords : TEX0,\n"
" uniform sampler2D texture) : COLOR {\n"
" return f4tex2D(texture, coords); }\n";
const char* strPassThroughProgram =
"float4 main(float4 color : COL0) : COLOR { return color; }\n";
textureProgram = cgCreateProgram(cgContext, CG_SOURCE,
strTextureProgram, cgProfile,
NULL, NULL);
if(textureProgram != NULL)
{
cgGLLoadProgram(textureProgram);
textureParam = cgGetNamedParameter(textureProgram, "texture");
assert(textureParam != NULL);
}
passThroughProgram = cgCreateProgram(cgContext, CG_SOURCE,
strPassThroughProgram,
cgProfile, NULL, NULL);
if(passThroughProgram != NULL)
{
cgGLLoadProgram(passThroughProgram);
}
#else
glGenProgramsARB(1, &iTextureProgram);
glGenProgramsARB(1, &iPassThroughProgram);
const char* strTextureProgram = rt2->IsRectangleTexture() ?
"!!ARBfp1.0\n"
"TEX result.color, fragment.texcoord[0], texture[0], RECT;\n"
"END\n"
:
"!!ARBfp1.0\n"
"TEX result.color, fragment.texcoord[0], texture[0], 2D;\n"
"END\n";
const char* strPassThroughProgram =
"!!ARBfp1.0\n"
"MOV result.color, fragment.color.primary;\n"
"END\n";
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, iTextureProgram);
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(strTextureProgram), strTextureProgram);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, iPassThroughProgram);
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(strPassThroughProgram),
strPassThroughProgram);
#endif // USE_CG
}
if (rt2->IsDepthTexture())
{
fprintf(stderr,
"\nPress the spacebar to toggle color / depth textures.\n");
if (!rt2->IsTexture())
bShowDepthTexture = true;
}
else
{
if (rt2->IsTexture())
bShowDepthTexture = false;
}
PrintGLerror("Create");
return rt2;
}
//---------------------------------------------------------------------------
// Function : DestroyRenderTexture
// Description :
//---------------------------------------------------------------------------
void DestroyRenderTexture(RenderTexture *rt2)
{
if (rt2->IsFloatTexture())
{
#ifdef USE_CG
cgDestroyProgram(textureProgram);
cgDestroyProgram(passThroughProgram);
cgDestroyContext(cgContext);
#else
glDeleteProgramsARB(1, &iTextureProgram);
glDeleteProgramsARB(1, &iPassThroughProgram);
#endif // USE_CG
}
delete rt2;
}
//---------------------------------------------------------------------------
// Function : Keyboard
// Description :
//---------------------------------------------------------------------------
void Keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 27:
case 'q':
exit(0);
break;
case ' ':
bShowDepthTexture = !bShowDepthTexture;
break;
case 13:
++g_currentString%=g_numModeTestStrings;
DestroyRenderTexture(rt);
rt = CreateRenderTexture(g_modeTestStrings[g_currentString]);
break;
case 't':
bTorusMotion = !bTorusMotion;
break;
case 'r':
bRectMotion = !bRectMotion;
break;
default:
return;
}
}
//---------------------------------------------------------------------------
// Function : Idle
// Description :
//---------------------------------------------------------------------------
void Idle()
{
// make sure we don't try to display nonexistent textures
if (!rt->IsDepthTexture())
bShowDepthTexture = false;
if (bRectMotion) rectAngle += 1;
if (bTorusMotion) torusAngle += 1;
glutPostRedisplay();
}
//---------------------------------------------------------------------------
// Function : Reshape
// Description :
//---------------------------------------------------------------------------
void Reshape(int w, int h)
{
if (h == 0) h = 1;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 1, 5.0);
}
//---------------------------------------------------------------------------
// Function : Display
// Description :
//---------------------------------------------------------------------------
void display()
{
if (rt->IsInitialized() && rt->BeginCapture())
{
if (rt->IsDoubleBuffered()) glDrawBuffer(GL_BACK);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glRotatef(torusAngle, 1, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,0);
if (rt->IsFloatTexture())
{
#ifdef USE_CG
cgGLBindProgram(passThroughProgram);
cgGLEnableProfile(cgProfile);
#else
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, iPassThroughProgram);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
#endif // USE_CG
}
glutSolidTorus(0.25, 1, 32, 64);
if (rt->IsFloatTexture())
{
#ifdef USE_CG
cgGLDisableProfile(cgProfile);
#else
glDisable(GL_FRAGMENT_PROGRAM_ARB);
#endif // USE_CG
}
glPopMatrix();
PrintGLerror("RT Update");
rt->EndCapture();
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1, 1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glRotatef(rectAngle / 10, 0, 1, 0);
if(bShowDepthTexture && rt->IsDepthTexture())
rt->BindDepth();
else if (rt->IsTexture()) {
#ifdef _WIN32
if (rt->IsDoubleBuffered()) rt->BindBuffer(WGL_BACK_LEFT_ARB);
#endif
rt->Bind();
}
#ifdef USE_CG
if (!bShowDepthTexture && rt->IsFloatTexture())
{
cgGLEnableProfile(cgProfile);
cgGLBindProgram(textureProgram);
cgGLSetTextureParameter(textureParam, rt->GetTextureID());
//cgGLEnableTextureParameter(textureParam);
}
else
{
rt->EnableTextureTarget();
}
#else
if (!bShowDepthTexture && rt->IsFloatTexture())
{
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, iTextureProgram);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glActiveTexture(GL_TEXTURE0_ARB);
}
rt->EnableTextureTarget();
#endif // USE_CG
int maxS = rt->GetMaxS();
int maxT = rt->GetMaxT();
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1, -1);
glTexCoord2f(maxS, 0); glVertex2f( 1, -1);
glTexCoord2f(maxS, maxT); glVertex2f( 1, 1);
glTexCoord2f(0, maxT); glVertex2f(-1, 1);
glEnd();
if (!bShowDepthTexture && rt->IsFloatTexture())
{
#ifdef USE_CG
//cgGLDisableTextureParameter(textureParam);
cgGLDisableProfile(cgProfile);
}
else
{
rt->DisableTextureTarget();
}
#else
glDisable(GL_FRAGMENT_PROGRAM_ARB);
}
rt->DisableTextureTarget();
#endif // USE_CG
glPopMatrix();
PrintGLerror("display");
glutSwapBuffers();
}
//---------------------------------------------------------------------------
// Function : main
// Description :
//---------------------------------------------------------------------------
int main()
{
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowPosition(50, 50);
glutInitWindowSize(512, 512);
glutCreateWindow("TestRenderTexture");
int err = glewInit();
if (GLEW_OK != err)
{
// problem: glewInit failed, something is seriously wrong
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
exit(-1);
}
glutDisplayFunc(display);
glutIdleFunc(Idle);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Keyboard);
Reshape(512, 512);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 2, 0, 0, 0, 0, 1, 0);
glDisable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_DEPTH_TEST);
glClearColor(0.4, 0.6, 0.8, 1);
rt = CreateRenderTexture(g_modeTestStrings[g_currentString]);
printf("Press Enter to change RenderTexture parameters.\n"
"Press 'r' to toggle the rectangle's motion.\n"
"Press 't' to toggle the torus' motion.\n");
glutMainLoop();
}
OpenCSG-1.3.2/RenderTexture/TestRenderTexture.dsp 0000644 0001750 0000144 00000014062 11665770270 021311 0 ustar fkirsch users # Microsoft Developer Studio Project File - Name="TestRenderTexture" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=TestRenderTexture - Win32 Cg Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "TestRenderTexture.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "TestRenderTexture.mak" CFG="TestRenderTexture - Win32 Cg Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "TestRenderTexture - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "TestRenderTexture - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE "TestRenderTexture - Win32 Cg Debug" (based on "Win32 (x86) Console Application")
!MESSAGE "TestRenderTexture - Win32 Cg Release" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "TestRenderTexture - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 glew32.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "TestRenderTexture - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "TestRenderTexture___Win32_Debug"
# PROP BASE Intermediate_Dir "TestRenderTexture___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 glew32.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ELSEIF "$(CFG)" == "TestRenderTexture - Win32 Cg Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "TestRenderTexture___Win32_Cg_Debug"
# PROP BASE Intermediate_Dir "TestRenderTexture___Win32_Cg_Debug"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "$(CG_INC_PATH)" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "USE_CG" /YX /FD /GZ /c
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 glew32.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 cg.lib cgGL.lib glew32.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"$(CG_LIB_PATH)"
!ELSEIF "$(CFG)" == "TestRenderTexture - Win32 Cg Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "TestRenderTexture___Win32_Cg_Release"
# PROP BASE Intermediate_Dir "TestRenderTexture___Win32_Cg_Release"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "$(CG_INC_PATH)" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "USE_CG" /YX /FD /c
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 glew32.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 cg.lib cgGL.lib glew32.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /libpath:"$(CG_LIB_PATH)"
!ENDIF
# Begin Target
# Name "TestRenderTexture - Win32 Release"
# Name "TestRenderTexture - Win32 Debug"
# Name "TestRenderTexture - Win32 Cg Debug"
# Name "TestRenderTexture - Win32 Cg Release"
# Begin Source File
SOURCE=.\RenderTexture.cpp
# End Source File
# Begin Source File
SOURCE=.\TestRenderTexture.cpp
# End Source File
# End Target
# End Project
OpenCSG-1.3.2/RenderTexture/Makefile 0000644 0001750 0000144 00000000614 11665770270 016577 0 ustar fkirsch users all: TestRenderTexture TestRenderTextureCg
TestRenderTexture: TestRenderTexture.cpp RenderTexture.cpp RenderTexture.h
g++ -g -o TestRenderTexture TestRenderTexture.cpp RenderTexture.cpp -lGL -lglut -lGLEW
TestRenderTextureCg: TestRenderTexture.cpp RenderTexture.cpp RenderTexture.h
g++ -g -DUSE_CG -o TestRenderTextureCg TestRenderTexture.cpp RenderTexture.cpp -lGL -lglut -lGLEW -lCg -lCgGL
OpenCSG-1.3.2/RenderTexture/RenderTexture.cpp 0000644 0001750 0000144 00000175471 11665770270 020461 0 ustar fkirsch users //---------------------------------------------------------------------------
// File : RenderTexture.cpp
//---------------------------------------------------------------------------
// Copyright (c) 2002-2004 Mark J. Harris
//---------------------------------------------------------------------------
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any
// damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any
// purpose, including commercial applications, and to alter it and
// redistribute it freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you
// must not claim that you wrote the original software. If you use
// this software in a product, an acknowledgment in the product
// documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and
// must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
// --------------------------------------------------------------------------
// Credits:
// Original RenderTexture class: Mark J. Harris
// Original Render to Depth Texture support: Thorsten Scheuermann
// Linux Copy-to-texture: Eric Werness
// Various Bug Fixes: Daniel (Redge) Sperl
// Bill Baxter
// Florian Kirsch
// Deprecated Interface Removed: Florian Kirsch
//
// --------------------------------------------------------------------------
/**
* @file RenderTexture.cpp
*
* Implementation of class RenderTexture. A multi-format render to
* texture wrapper.
*/
#ifndef __APPLE__
#ifdef _MSC_VER
#if _MSC_VER < 1300 // MSVC++ <= 6.0
#pragma warning(disable:4786)
#endif
#endif
#include "RenderTexture.h"
#include
#include
#include
#include
#include
#ifdef _WIN32
#pragma comment(lib, "gdi32.lib") // required for GetPixelFormat()
#endif
using namespace std;
//---------------------------------------------------------------------------
// Function : RenderTexture::RenderTexture
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::RenderTexture()
* @brief Mode-string-based Constructor.
*/
RenderTexture::RenderTexture(const char *strMode)
: _iWidth(-1),
_iHeight(-1),
_bIsTexture(false),
_bIsDepthTexture(false),
_bHasARBDepthTexture(true), // [Redge]
#ifdef _WIN32
_eUpdateMode(RT_RENDER_TO_TEXTURE),
#else
_eUpdateMode(RT_COPY_TO_TEXTURE),
#endif
_bInitialized(false),
_iNumAuxBuffers(0),
_bIsBufferBound(false),
_iCurrentBoundBuffer(0),
_iNumDepthBits(0),
_iNumStencilBits(0),
_bFloat(false),
_bDoubleBuffered(false),
_bPowerOf2(true),
_bRectangle(false),
_bMipmap(false),
_bShareObjects(false),
_bCopyContext(false),
#ifdef _WIN32
_hDC(NULL),
_hGLContext(NULL),
_hPBuffer(NULL),
_hPreviousDC(0),
_hPreviousContext(0),
#else
_pDisplay(NULL),
_hGLContext(NULL),
_hPBuffer(0),
_hPreviousDrawable(0),
_hPreviousContext(0),
#endif
_iTextureTarget(GL_NONE),
_iTextureID(0),
_iDepthTextureID(0),
_pPoorDepthTexture(0) // [Redge]
{
_iNumColorBits[0] = _iNumColorBits[1] =
_iNumColorBits[2] = _iNumColorBits[3] = 0;
#ifdef _WIN32
_pixelFormatAttribs.push_back(WGL_DRAW_TO_PBUFFER_ARB);
_pixelFormatAttribs.push_back(true);
_pixelFormatAttribs.push_back(WGL_SUPPORT_OPENGL_ARB);
_pixelFormatAttribs.push_back(true);
_pbufferAttribs.push_back(WGL_PBUFFER_LARGEST_ARB);
_pbufferAttribs.push_back(true);
#else
_pbufferAttribs.push_back(GLX_RENDER_TYPE_SGIX);
_pbufferAttribs.push_back(GLX_RGBA_BIT_SGIX);
_pbufferAttribs.push_back(GLX_DRAWABLE_TYPE_SGIX);
_pbufferAttribs.push_back(GLX_PBUFFER_BIT_SGIX);
#endif
_ParseModeString(strMode, _pixelFormatAttribs, _pbufferAttribs);
#ifdef _WIN32
_pixelFormatAttribs.push_back(0);
_pbufferAttribs.push_back(0);
#else
_pixelFormatAttribs.push_back(None);
#endif
}
//---------------------------------------------------------------------------
// Function : RenderTexture::~RenderTexture
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::~RenderTexture()
* @brief Destructor.
*/
RenderTexture::~RenderTexture()
{
_Invalidate();
}
//---------------------------------------------------------------------------
// Function : _wglGetLastError
// Description :
//---------------------------------------------------------------------------
/**
* @fn wglGetLastError()
* @brief Returns the last windows error generated.
*/
#ifdef _WIN32
void _wglGetLastError()
{
#ifdef _DEBUG
DWORD err = GetLastError();
switch(err)
{
case ERROR_INVALID_PIXEL_FORMAT:
fprintf(stderr,
"RenderTexture Win32 Error: ERROR_INVALID_PIXEL_FORMAT\n");
break;
case ERROR_NO_SYSTEM_RESOURCES:
fprintf(stderr,
"RenderTexture Win32 Error: ERROR_NO_SYSTEM_RESOURCES\n");
break;
case ERROR_INVALID_DATA:
fprintf(stderr,
"RenderTexture Win32 Error: ERROR_INVALID_DATA\n");
break;
case ERROR_INVALID_WINDOW_HANDLE:
fprintf(stderr,
"RenderTexture Win32 Error: ERROR_INVALID_WINDOW_HANDLE\n");
break;
case ERROR_RESOURCE_TYPE_NOT_FOUND:
fprintf(stderr,
"RenderTexture Win32 Error: ERROR_RESOURCE_TYPE_NOT_FOUND\n");
break;
case ERROR_SUCCESS:
// no error
break;
default:
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
fprintf(stderr, "RenderTexture Win32 Error %d: %s\n", err, lpMsgBuf);
LocalFree( lpMsgBuf );
break;
}
SetLastError(0);
#endif // _DEBUG
}
#endif
//---------------------------------------------------------------------------
// Function : PrintExtensionError
// Description :
//---------------------------------------------------------------------------
/**
* @fn PrintExtensionError( char* strMsg, ... )
* @brief Prints an error about missing OpenGL extensions.
*/
void PrintExtensionError( const char* strMsg, ... )
{
fprintf(stderr,
"Error: RenderTexture requires the following unsupported "
"OpenGL extensions: \n");
char strBuffer[512];
va_list args;
va_start(args, strMsg);
#ifdef _WIN32
_vsnprintf( strBuffer, 512, strMsg, args );
#else
vsnprintf( strBuffer, 512, strMsg, args );
#endif
va_end(args);
fprintf(stderr, strMsg);
}
//---------------------------------------------------------------------------
// Function : RenderTexture::Initialize
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::Initialize(int width, int height, bool shareObjects, bool copyContext);
* @brief Initializes the RenderTexture, sharing display lists and textures if specified.
*
* This function creates of the p-buffer. It can only be called once a GL
* context has already been created.
*/
bool RenderTexture::Initialize(int width, int height,
bool shareObjects /* = true */,
bool copyContext /* = false */)
{
assert(width > 0 && height > 0);
_iWidth = width; _iHeight = height;
_bPowerOf2 = IsPowerOfTwo(width) && IsPowerOfTwo(height);
_bShareObjects = shareObjects;
_bCopyContext = copyContext;
// Check if this is an NVXX GPU and verify necessary extensions.
if (!_VerifyExtensions())
return false;
if (_bInitialized)
_Invalidate();
#if _WIN32
// Get the current context.
HDC hdc = wglGetCurrentDC();
if (NULL == hdc)
_wglGetLastError();
HGLRC hglrc = wglGetCurrentContext();
if (NULL == hglrc)
_wglGetLastError();
int iFormat = 0;
unsigned int iNumFormats;
if (_bCopyContext)
{
// Get the pixel format for the on-screen window.
iFormat = GetPixelFormat(hdc);
if (iFormat == 0)
{
fprintf(stderr,
"RenderTexture Error: GetPixelFormat() failed.\n");
return false;
}
}
else
{
if (!wglChoosePixelFormatARB(hdc, &_pixelFormatAttribs[0], NULL,
1, &iFormat, &iNumFormats))
{
fprintf(stderr,
"RenderTexture Error: wglChoosePixelFormatARB() failed.\n");
_wglGetLastError();
return false;
}
if ( iNumFormats <= 0 )
{
fprintf(stderr,
"RenderTexture Error: Couldn't find a suitable "
"pixel format.\n");
_wglGetLastError();
return false;
}
}
// Create the p-buffer.
_hPBuffer = wglCreatePbufferARB(hdc, iFormat, _iWidth, _iHeight,
&_pbufferAttribs[0]);
if (!_hPBuffer)
{
fprintf(stderr,
"RenderTexture Error: wglCreatePbufferARB() failed.\n");
_wglGetLastError();
return false;
}
// Get the device context.
_hDC = wglGetPbufferDCARB( _hPBuffer);
if ( !_hDC )
{
fprintf(stderr,
"RenderTexture Error: wglGetGetPbufferDCARB() failed.\n");
_wglGetLastError();
return false;
}
// Create a gl context for the p-buffer.
if (_bCopyContext)
{
// Let's use the same gl context..
// Since the device contexts are compatible (i.e. same pixelformat),
// we should be able to use the same gl rendering context.
_hGLContext = hglrc;
}
else
{
_hGLContext = wglCreateContext( _hDC );
if ( !_hGLContext )
{
fprintf(stderr,
"RenderTexture Error: wglCreateContext() failed.\n");
_wglGetLastError();
return false;
}
}
// Share lists, texture objects, and program objects.
if( _bShareObjects )
{
if( !wglShareLists(hglrc, _hGLContext) )
{
fprintf(stderr,
"RenderTexture Error: wglShareLists() failed.\n");
_wglGetLastError();
return false;
}
}
// Determine the actual width and height we were able to create.
wglQueryPbufferARB( _hPBuffer, WGL_PBUFFER_WIDTH_ARB, &_iWidth );
wglQueryPbufferARB( _hPBuffer, WGL_PBUFFER_HEIGHT_ARB, &_iHeight );
_bInitialized = true;
// get the actual number of bits allocated:
int attrib = WGL_RED_BITS_ARB;
//int bits[6];
int value;
_iNumColorBits[0] =
(wglGetPixelFormatAttribivARB(_hDC, iFormat, 0, 1, &attrib, &value))
? value : 0;
attrib = WGL_GREEN_BITS_ARB;
_iNumColorBits[1] =
(wglGetPixelFormatAttribivARB(_hDC, iFormat, 0, 1, &attrib, &value))
? value : 0;
attrib = WGL_BLUE_BITS_ARB;
_iNumColorBits[2] =
(wglGetPixelFormatAttribivARB(_hDC, iFormat, 0, 1, &attrib, &value))
? value : 0;
attrib = WGL_ALPHA_BITS_ARB;
_iNumColorBits[3] =
(wglGetPixelFormatAttribivARB(_hDC, iFormat, 0, 1, &attrib, &value))
? value : 0;
attrib = WGL_DEPTH_BITS_ARB;
_iNumDepthBits =
(wglGetPixelFormatAttribivARB(_hDC, iFormat, 0, 1, &attrib, &value))
? value : 0;
attrib = WGL_STENCIL_BITS_ARB;
_iNumStencilBits =
(wglGetPixelFormatAttribivARB(_hDC, iFormat, 0, 1, &attrib, &value))
? value : 0;
attrib = WGL_DOUBLE_BUFFER_ARB;
_bDoubleBuffered =
(wglGetPixelFormatAttribivARB(_hDC, iFormat, 0, 1, &attrib, &value))
? (value?true:false) : false;
#else // !_WIN32
_pDisplay = glXGetCurrentDisplay();
GLXContext context = glXGetCurrentContext();
int screen = DefaultScreen(_pDisplay);
XVisualInfo *visInfo;
GLXFBConfigSGIX *fbConfigs;
int nConfigs;
// [Andrew Wood]
//Add in pbufferAttribs. Needed to choose pixel format. (Especially for floating point)
_pixelFormatAttribs.insert(_pixelFormatAttribs.begin(),
_pbufferAttribs.begin(),_pbufferAttribs.end());
// [/Andrew Wood]
fbConfigs = glXChooseFBConfigSGIX(_pDisplay, screen,
&_pixelFormatAttribs[0], &nConfigs);
if (nConfigs == 0 || !fbConfigs)
{
fprintf(stderr,
"RenderTexture Error: Couldn't find a suitable pixel format.\n");
return false;
}
// Pick the first returned format that will return a pbuffer
int i;
for (i=0;i_bInitialized)
{
fprintf(stderr,
"RenderTexture::BeginCapture(RenderTexture): 'current' texture is not initialized!\n");
return false;
}
// Sync current pbuffer with its CTT texture if necessary
current->_MaybeCopyBuffer();
// pass along the previous context so we can reset it when
// EndCapture() is called.
#ifdef _WIN32
_hPreviousDC = current->_hPreviousDC;
if (NULL == _hPreviousDC)
_wglGetLastError();
_hPreviousContext = current->_hPreviousContext;
if (NULL == _hPreviousContext)
_wglGetLastError();
#else
_hPreviousContext = current->_hPreviousContext;
_hPreviousDrawable = current->_hPreviousDrawable;
#endif
// Unbind textures before making context current
if (!_ReleaseBoundBuffers())
return false;
// Make the pbuffer context current
if (!_MakeCurrent())
return false;
// Rebind buffers of initial RenderTexture
current->BindBuffer(_iCurrentBoundBuffer);
current->_BindDepthBuffer();
return true;
}
//---------------------------------------------------------------------------
// Function : RenderTexture::Bind
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::Bind()
* @brief Binds RGB texture.
*/
void RenderTexture::Bind() const
{
if (_bInitialized && _bIsTexture)
{
glBindTexture(_iTextureTarget, _iTextureID);
}
}
//---------------------------------------------------------------------------
// Function : RenderTexture::BindDepth
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::BindDepth()
* @brief Binds depth texture.
*/
void RenderTexture::BindDepth() const
{
if (_bInitialized && _bIsDepthTexture)
{
glBindTexture(_iTextureTarget, _iDepthTextureID);
}
}
//---------------------------------------------------------------------------
// Function : RenderTexture::BindBuffer
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::BindBuffer()
* @brief Associate the RTT texture id with 'iBuffer' (e.g. WGL_FRONT_LEFT_ARB)
*/
bool RenderTexture::BindBuffer( int iBuffer )
{
// Must bind the texture too
if (_bInitialized && _bIsTexture)
{
glBindTexture(_iTextureTarget, _iTextureID);
#if _WIN32
if (RT_RENDER_TO_TEXTURE == _eUpdateMode && _bIsTexture &&
(!_bIsBufferBound || _iCurrentBoundBuffer != iBuffer))
{
if (FALSE == wglBindTexImageARB(_hPBuffer, iBuffer))
{
// WVB: WGL API considers binding twice to the same buffer
// to be an error. But we don't want to
//_wglGetLastError();
//return false;
SetLastError(0);
}
_bIsBufferBound = true;
_iCurrentBoundBuffer = iBuffer;
}
#endif
}
return true;
}
//---------------------------------------------------------------------------
// Function : RenderTexture::BindBuffer
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_BindDepthBuffer()
* @brief Associate the RTT depth texture id with the depth buffer
*/
bool RenderTexture::_BindDepthBuffer() const
{
#ifdef WIN32
if (_bInitialized && _bIsDepthTexture &&
RT_RENDER_TO_TEXTURE == _eUpdateMode)
{
glBindTexture(_iTextureTarget, _iDepthTextureID);
if (FALSE == wglBindTexImageARB(_hPBuffer, WGL_DEPTH_COMPONENT_NV))
{
_wglGetLastError();
return false;
}
}
#endif
return true;
}
//---------------------------------------------------------------------------
// Function : RenderTexture::_ParseModeString
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_ParseModeString()
* @brief Parses the user-specified mode string for RenderTexture parameters.
*/
void RenderTexture::_ParseModeString(const char *modeString,
vector &pfAttribs,
vector &pbAttribs)
{
if (!modeString || strcmp(modeString, "") == 0)
return;
_iNumComponents = 0;
#ifdef _WIN32
_eUpdateMode = RT_RENDER_TO_TEXTURE;
#else
_eUpdateMode = RT_COPY_TO_TEXTURE;
#endif
int iDepthBits = 0;
bool bHasStencil = false;
bool bBind2D = false;
bool bBindRECT = false;
bool bBindCUBE = false;
char *mode = strdup(modeString);
vector tokens;
char *buf = strtok(mode, " ");
while (buf != NULL)
{
tokens.push_back(buf);
buf = strtok(NULL, " ");
}
#ifndef _MSC_VER
// in debug mode, microsoft visual studio (6.0, 7.1 works apparently)
// assert that the heap is corrupt when this free is done. To be safe,
// just don't do it with these compilers (memory leak is negligable here)
free(mode);
#endif
for (unsigned int i = 0; i < tokens.size(); i++)
{
string token = tokens[i];
KeyVal kv = _GetKeyValuePair(token);
if (kv.first == "rgb" && (_iNumComponents <= 1))
{
if (kv.second.find("f") != kv.second.npos)
_bFloat = true;
vector bitVec = _ParseBitVector(kv.second);
if (bitVec.size() < 3) // expand the scalar to a vector
{
bitVec.push_back(bitVec[0]);
bitVec.push_back(bitVec[0]);
}
#ifdef _WIN32
pfAttribs.push_back(WGL_RED_BITS_ARB);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(WGL_GREEN_BITS_ARB);
pfAttribs.push_back(bitVec[1]);
pfAttribs.push_back(WGL_BLUE_BITS_ARB);
pfAttribs.push_back(bitVec[2]);
#else
pfAttribs.push_back(GLX_RED_SIZE);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(GLX_GREEN_SIZE);
pfAttribs.push_back(bitVec[1]);
pfAttribs.push_back(GLX_BLUE_SIZE);
pfAttribs.push_back(bitVec[2]);
#endif
_iNumComponents += 3;
continue;
}
else if (kv.first == "rgb")
fprintf(stderr,
"RenderTexture Warning: mistake in components definition "
"(rgb + %d).\n",
_iNumComponents);
if (kv.first == "rgba" && (_iNumComponents == 0))
{
if (kv.second.find("f") != kv.second.npos)
_bFloat = true;
vector bitVec = _ParseBitVector(kv.second);
if (bitVec.size() < 4) // expand the scalar to a vector
{
bitVec.push_back(bitVec[0]);
bitVec.push_back(bitVec[0]);
bitVec.push_back(bitVec[0]);
}
#ifdef _WIN32
pfAttribs.push_back(WGL_RED_BITS_ARB);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(WGL_GREEN_BITS_ARB);
pfAttribs.push_back(bitVec[1]);
pfAttribs.push_back(WGL_BLUE_BITS_ARB);
pfAttribs.push_back(bitVec[2]);
pfAttribs.push_back(WGL_ALPHA_BITS_ARB);
pfAttribs.push_back(bitVec[3]);
#else
pfAttribs.push_back(GLX_RED_SIZE);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(GLX_GREEN_SIZE);
pfAttribs.push_back(bitVec[1]);
pfAttribs.push_back(GLX_BLUE_SIZE);
pfAttribs.push_back(bitVec[2]);
pfAttribs.push_back(GLX_ALPHA_SIZE);
pfAttribs.push_back(bitVec[3]);
#endif
_iNumComponents = 4;
continue;
}
else if (kv.first == "rgba")
fprintf(stderr,
"RenderTexture Warning: mistake in components definition "
"(rgba + %d).\n",
_iNumComponents);
if (kv.first == "r" && (_iNumComponents <= 1))
{
if (kv.second.find("f") != kv.second.npos)
_bFloat = true;
vector bitVec = _ParseBitVector(kv.second);
#ifdef _WIN32
pfAttribs.push_back(WGL_RED_BITS_ARB);
pfAttribs.push_back(bitVec[0]);
#else
pfAttribs.push_back(GLX_RED_SIZE);
pfAttribs.push_back(bitVec[0]);
#endif
_iNumComponents++;
continue;
}
else if (kv.first == "r")
fprintf(stderr,
"RenderTexture Warning: mistake in components definition "
"(r + %d).\n",
_iNumComponents);
if (kv.first == "rg" && (_iNumComponents <= 1))
{
if (kv.second.find("f") != kv.second.npos)
_bFloat = true;
vector bitVec = _ParseBitVector(kv.second);
if (bitVec.size() < 2) // expand the scalar to a vector
{
bitVec.push_back(bitVec[0]);
}
#ifdef _WIN32
pfAttribs.push_back(WGL_RED_BITS_ARB);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(WGL_GREEN_BITS_ARB);
pfAttribs.push_back(bitVec[1]);
#else
pfAttribs.push_back(GLX_RED_SIZE);
pfAttribs.push_back(bitVec[0]);
pfAttribs.push_back(GLX_GREEN_SIZE);
pfAttribs.push_back(bitVec[1]);
#endif
_iNumComponents += 2;
continue;
}
else if (kv.first == "rg")
fprintf(stderr,
"RenderTexture Warning: mistake in components definition "
"(rg + %d).\n",
_iNumComponents);
if (kv.first == "depth")
{
if (kv.second == "")
iDepthBits = 24;
else
iDepthBits = strtol(kv.second.c_str(), 0, 10);
continue;
}
if (kv.first == "stencil")
{
bHasStencil = true;
#ifdef _WIN32
pfAttribs.push_back(WGL_STENCIL_BITS_ARB);
#else
pfAttribs.push_back(GLX_STENCIL_SIZE);
#endif
if (kv.second == "")
pfAttribs.push_back(8);
else
pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10));
continue;
}
if (kv.first == "samples")
{
#ifdef _WIN32
pfAttribs.push_back(WGL_SAMPLE_BUFFERS_ARB);
pfAttribs.push_back(1);
pfAttribs.push_back(WGL_SAMPLES_ARB);
pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10));
#else
pfAttribs.push_back(GLX_SAMPLE_BUFFERS_ARB);
pfAttribs.push_back(1);
pfAttribs.push_back(GLX_SAMPLES_ARB);
pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10));
#endif
continue;
}
if (kv.first == "doublebuffer" || kv.first == "double")
{
#ifdef _WIN32
pfAttribs.push_back(WGL_DOUBLE_BUFFER_ARB);
pfAttribs.push_back(true);
#else
pfAttribs.push_back(GLX_DOUBLEBUFFER);
pfAttribs.push_back(True);
#endif
continue;
}
// [Florian]
if (kv.first == "singlebuffer" || kv.first == "single")
{
#ifdef _WIN32
pfAttribs.push_back(WGL_DOUBLE_BUFFER_ARB);
pfAttribs.push_back(false);
#else
pfAttribs.push_back(GLX_DOUBLEBUFFER);
pfAttribs.push_back(False);
#endif
continue;
}
// [/Florian]
if (kv.first == "aux")
{
#ifdef _WIN32
pfAttribs.push_back(WGL_AUX_BUFFERS_ARB);
#else
pfAttribs.push_back(GLX_AUX_BUFFERS);
#endif
if (kv.second == "")
pfAttribs.push_back(0);
else
pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10));
continue;
}
if (token.find("tex") == 0)
{
_bIsTexture = true;
if ( (kv.first == "texRECT")
&& (GLEW_ARB_texture_rectangle || GLEW_EXT_texture_rectangle || GLEW_NV_texture_rectangle)
#ifdef _WIN32
&& (WGLEW_ATI_render_texture_rectangle || WGLEW_NV_render_texture_rectangle)
#endif
) {
_bRectangle = true;
bBindRECT = true;
}
else if (kv.first == "texCUBE")
{
bBindCUBE = true;
}
else
{
bBind2D = true;
}
continue;
}
if (token.find("depthTex") == 0)
{
_bIsDepthTexture = true;
if ((kv.first == "depthTexRECT") && GLEW_NV_texture_rectangle)
{
_bRectangle = true;
bBindRECT = true;
}
else if (kv.first == "depthTexCUBE")
{
bBindCUBE = true;
}
else
{
bBind2D = true;
}
continue;
}
if (kv.first == "mipmap")
{
_bMipmap = true;
continue;
}
if (kv.first == "rtt")
{
_eUpdateMode = RT_RENDER_TO_TEXTURE;
continue;
}
if (kv.first == "ctt")
{
_eUpdateMode = RT_COPY_TO_TEXTURE;
continue;
}
fprintf(stderr,
"RenderTexture Error: Unknown pbuffer attribute: %s\n",
token.c_str());
}
// Processing of some options must be last because of interactions.
// Check for inconsistent texture targets
if (_bIsTexture && _bIsDepthTexture && !(bBind2D ^ bBindRECT ^ bBindCUBE))
{
fprintf(stderr,
"RenderTexture Warning: Depth and Color texture targets "
"should match.\n");
}
// Apply default bit format if none specified
#ifdef _WIN32
if (0 == _iNumComponents)
{
pfAttribs.push_back(WGL_RED_BITS_ARB);
pfAttribs.push_back(8);
pfAttribs.push_back(WGL_GREEN_BITS_ARB);
pfAttribs.push_back(8);
pfAttribs.push_back(WGL_BLUE_BITS_ARB);
pfAttribs.push_back(8);
pfAttribs.push_back(WGL_ALPHA_BITS_ARB);
pfAttribs.push_back(8);
_iNumComponents = 4;
}
#endif
// Depth bits
if (_bIsDepthTexture && !iDepthBits)
iDepthBits = 24;
#ifdef _WIN32
pfAttribs.push_back(WGL_DEPTH_BITS_ARB);
#else
pfAttribs.push_back(GLX_DEPTH_SIZE);
#endif
pfAttribs.push_back(iDepthBits); // default
if (!bHasStencil)
{
#ifdef _WIN32
pfAttribs.push_back(WGL_STENCIL_BITS_ARB);
pfAttribs.push_back(0);
#else
pfAttribs.push_back(GLX_STENCIL_SIZE);
pfAttribs.push_back(0);
#endif
}
if (_iNumComponents < 4)
{
// Can't do this right now -- on NVIDIA drivers, currently get
// a non-functioning pbuffer if ALPHA_BITS=0 and
// WGL_BIND_TO_TEXTURE_RGB_ARB=true
//pfAttribs.push_back(WGL_ALPHA_BITS_ARB);
//pfAttribs.push_back(0);
}
#ifdef _WIN32
if (!WGLEW_NV_render_depth_texture && _bIsDepthTexture && (RT_RENDER_TO_TEXTURE == _eUpdateMode))
{
#if defined(DEBUG) || defined(_DEBUG)
fprintf(stderr, "RenderTexture Warning: No support found for "
"render to depth texture.\n");
#endif
_bIsDepthTexture = false;
}
#endif
if ((_bIsTexture || _bIsDepthTexture) &&
(RT_RENDER_TO_TEXTURE == _eUpdateMode))
{
#ifdef _WIN32
if (bBindRECT)
{
pbAttribs.push_back(WGL_TEXTURE_TARGET_ARB);
if (WGLEW_ATI_render_texture_rectangle)
pbAttribs.push_back(WGL_TEXTURE_RECTANGLE_ATI);
else if (WGLEW_NV_render_texture_rectangle)
pbAttribs.push_back(WGL_TEXTURE_RECTANGLE_NV);
}
else if (bBindCUBE)
{
pbAttribs.push_back(WGL_TEXTURE_TARGET_ARB);
pbAttribs.push_back(WGL_TEXTURE_CUBE_MAP_ARB);
}
else if (bBind2D)
{
pbAttribs.push_back(WGL_TEXTURE_TARGET_ARB);
pbAttribs.push_back(WGL_TEXTURE_2D_ARB);
}
if (_bMipmap)
{
pbAttribs.push_back(WGL_MIPMAP_TEXTURE_ARB);
pbAttribs.push_back(true);
}
#elif defined(DEBUG) || defined(_DEBUG)
printf("RenderTexture Error: Render to Texture not supported\n");
#endif
}
// Set the pixel type
if (_bFloat)
{
#ifdef _WIN32
if (WGLEW_NV_float_buffer)
{
pfAttribs.push_back(WGL_PIXEL_TYPE_ARB);
pfAttribs.push_back(WGL_TYPE_RGBA_ARB);
pfAttribs.push_back(WGL_FLOAT_COMPONENTS_NV);
pfAttribs.push_back(true);
}
else
{
pfAttribs.push_back(WGL_PIXEL_TYPE_ARB);
pfAttribs.push_back(WGL_TYPE_RGBA_FLOAT_ATI);
}
#else
if (GLXEW_NV_float_buffer)
{
pfAttribs.push_back(GLX_FLOAT_COMPONENTS_NV);
pfAttribs.push_back(1);
}
#endif
}
else
{
#ifdef _WIN32
pfAttribs.push_back(WGL_PIXEL_TYPE_ARB);
pfAttribs.push_back(WGL_TYPE_RGBA_ARB);
#endif
}
// Set up texture binding for render to texture
if (_bIsTexture && (RT_RENDER_TO_TEXTURE == _eUpdateMode))
{
#ifdef _WIN32
if (_bFloat)
{
if (WGLEW_NV_float_buffer)
{
switch(_iNumComponents)
{
case 1:
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_TEXTURE_FORMAT_ARB);
pbAttribs.push_back(WGL_TEXTURE_FLOAT_R_NV);
break;
case 2:
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_TEXTURE_FORMAT_ARB);
pbAttribs.push_back(WGL_TEXTURE_FLOAT_RG_NV);
break;
case 3:
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_TEXTURE_FORMAT_ARB);
pbAttribs.push_back(WGL_TEXTURE_FLOAT_RGB_NV);
break;
case 4:
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_TEXTURE_FORMAT_ARB);
pbAttribs.push_back(WGL_TEXTURE_FLOAT_RGBA_NV);
break;
default:
fprintf(stderr,
"RenderTexture Warning: Bad number of components "
"(r=1,rg=2,rgb=3,rgba=4): %d.\n",
_iNumComponents);
break;
}
}
else
{
if (4 == _iNumComponents)
{
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RGBA_ARB);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_TEXTURE_FORMAT_ARB);
pbAttribs.push_back(WGL_TEXTURE_RGBA_ARB);
}
else
{
// standard ARB_render_texture only supports 3 or 4 channels
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RGB_ARB);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_TEXTURE_FORMAT_ARB);
pbAttribs.push_back(WGL_TEXTURE_RGB_ARB);
}
}
}
else
{
switch(_iNumComponents)
{
case 3:
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RGB_ARB);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_TEXTURE_FORMAT_ARB);
pbAttribs.push_back(WGL_TEXTURE_RGB_ARB);
break;
case 4:
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RGBA_ARB);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_TEXTURE_FORMAT_ARB);
pbAttribs.push_back(WGL_TEXTURE_RGBA_ARB);
break;
default:
fprintf(stderr,
"RenderTexture Warning: Bad number of components "
"(r=1,rg=2,rgb=3,rgba=4): %d.\n", _iNumComponents);
break;
}
}
#elif defined(DEBUG) || defined(_DEBUG)
fprintf(stderr,
"RenderTexture Error: Render to Texture not supported in "
"Linux\n");
#endif
}
if (_bIsDepthTexture && (RT_RENDER_TO_TEXTURE == _eUpdateMode))
{
#ifdef _WIN32
if (_bRectangle)
{
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_DEPTH_TEXTURE_FORMAT_NV);
pbAttribs.push_back(WGL_TEXTURE_DEPTH_COMPONENT_NV);
}
else
{
pfAttribs.push_back(WGL_BIND_TO_TEXTURE_DEPTH_NV);
pfAttribs.push_back(true);
pbAttribs.push_back(WGL_DEPTH_TEXTURE_FORMAT_NV);
pbAttribs.push_back(WGL_TEXTURE_DEPTH_COMPONENT_NV);
}
#elif defined(DEBUG) || defined(_DEBUG)
printf("RenderTexture Error: Render to Texture not supported in "
"Linux\n");
#endif
}
}
//---------------------------------------------------------------------------
// Function : RenderTexture::_GetKeyValuePair
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_GetKeyValuePair()
* @brief Parses expressions of the form "X=Y" into a pair (X,Y).
*/
RenderTexture::KeyVal RenderTexture::_GetKeyValuePair(string token)
{
string::size_type pos = 0;
if ((pos = token.find("=")) != token.npos)
{
string key = token.substr(0, pos);
string value = token.substr(pos+1, token.length()-pos+1);
return KeyVal(key, value);
}
else
return KeyVal(token, "");
}
//---------------------------------------------------------------------------
// Function : RenderTexture::_ParseBitVector
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_ParseBitVector()
* @brief Parses expressions of the form "=r,g,b,a" into a vector: (r,g,b,a)
*/
vector RenderTexture::_ParseBitVector(string bitVector)
{
vector pieces;
vector bits;
if (bitVector == "")
{
bits.push_back(8); // if a depth isn't specified, use default 8 bits
return bits;
}
string::size_type pos = 0;
string::size_type nextpos = 0;
do
{
nextpos = bitVector.find_first_of(", \n", pos);
pieces.push_back(string(bitVector, pos, nextpos - pos));
pos = nextpos+1;
} while (nextpos != bitVector.npos );
for ( vector::iterator it = pieces.begin(); it != pieces.end(); it++)
{
bits.push_back(strtol(it->c_str(), 0, 10));
}
return bits;
}
//---------------------------------------------------------------------------
// Function : RenderTexture::_VerifyExtensions
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_VerifyExtensions()
* @brief Checks that the necessary extensions are available based on RT mode.
*/
bool RenderTexture::_VerifyExtensions()
{
#ifdef _WIN32
if (!WGLEW_ARB_pbuffer)
{
PrintExtensionError("WGL_ARB_pbuffer");
return false;
}
if (!WGLEW_ARB_pixel_format)
{
PrintExtensionError("WGL_ARB_pixel_format");
return false;
}
if (_eUpdateMode == RT_RENDER_TO_TEXTURE && !WGLEW_ARB_render_texture)
{
PrintExtensionError("WGL_ARB_render_texture");
return false;
}
if (_bRectangle && !(GLEW_ARB_texture_rectangle || GLEW_EXT_texture_rectangle || GLEW_NV_texture_rectangle))
{
PrintExtensionError("GLEW_ARB_texture_rectangle or GLEW_EXT_texture_rectangle or GL_NV_texture_rectangle");
return false;
}
if (_bFloat && !(GLEW_NV_float_buffer || WGLEW_ATI_pixel_format_float))
{
PrintExtensionError("GL_NV_float_buffer or GL_ATI_pixel_format_float");
return false;
}
if (_bFloat && _bIsTexture && !(GLEW_NV_float_buffer || GLEW_ATI_texture_float))
{
PrintExtensionError("NV_float_buffer or ATI_texture_float");
}
if (_bIsDepthTexture && !GLEW_ARB_depth_texture)
{
// [Redge]
#if defined(_DEBUG) | defined(DEBUG)
fprintf(stderr,
"RenderTexture Warning: "
"OpenGL extension GL_ARB_depth_texture not available.\n"
" Using glReadPixels() to emulate behavior.\n");
#endif
_bHasARBDepthTexture = false;
//PrintExtensionError("GL_ARB_depth_texture");
//return false;
// [/Redge]
}
SetLastError(0);
#else
if (!GLXEW_SGIX_pbuffer)
{
PrintExtensionError("GLX_SGIX_pbuffer");
return false;
}
if (!GLXEW_SGIX_fbconfig)
{
PrintExtensionError("GLX_SGIX_fbconfig");
return false;
}
if (_bIsDepthTexture && !GLEW_ARB_depth_texture)
{
PrintExtensionError("GL_ARB_depth_texture");
return false;
}
if (_bFloat && _bIsTexture && !GLXEW_NV_float_buffer)
{
PrintExtensionError("GLX_NV_float_buffer");
return false;
}
if (_eUpdateMode == RT_RENDER_TO_TEXTURE)
{
PrintExtensionError("Some GLX render texture extension: FIXME!");
return false;
}
#endif
return true;
}
//---------------------------------------------------------------------------
// Function : RenderTexture::_InitializeTextures
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_InitializeTextures()
* @brief Initializes the state of textures used by the RenderTexture.
*/
bool RenderTexture::_InitializeTextures()
{
// Determine the appropriate texture formats and filtering modes.
if (_bIsTexture || _bIsDepthTexture)
{
if (_bRectangle && (GLEW_ARB_texture_rectangle || GLEW_EXT_texture_rectangle || GLEW_NV_texture_rectangle))
_iTextureTarget = GL_TEXTURE_RECTANGLE_ARB;
else
_iTextureTarget = GL_TEXTURE_2D;
}
if (_bIsTexture)
{
glGenTextures(1, &_iTextureID);
glBindTexture(_iTextureTarget, _iTextureID);
// Use clamp to edge as the default texture wrap mode for all tex
glTexParameteri(_iTextureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(_iTextureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Use NEAREST as the default texture filtering mode.
glTexParameteri(_iTextureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(_iTextureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (RT_COPY_TO_TEXTURE == _eUpdateMode)
{
GLuint iInternalFormat;
GLuint iFormat;
if (_bFloat)
{
if (_bMipmap)
{
fprintf(stderr,
"RenderTexture Error: mipmapped float textures not "
"supported.\n");
return false;
}
switch(_iNumComponents)
{
case 1:
if (GLEW_NV_float_buffer)
{
iInternalFormat = (_iNumColorBits[0] > 16) ?
GL_FLOAT_R32_NV : GL_FLOAT_R16_NV;
}
else if (GLEW_ATI_texture_float)
{
iInternalFormat = (_iNumColorBits[0] > 16) ?
GL_LUMINANCE_FLOAT32_ATI :
GL_LUMINANCE_FLOAT16_ATI;
}
iFormat = GL_LUMINANCE;
break;
case 2:
if (GLEW_NV_float_buffer)
{
iInternalFormat = (_iNumColorBits[0] > 16) ?
GL_FLOAT_RG32_NV : GL_FLOAT_RG16_NV;
}
else if (GLEW_ATI_texture_float)
{
iInternalFormat = (_iNumColorBits[0] > 16) ?
GL_LUMINANCE_ALPHA_FLOAT32_ATI :
GL_LUMINANCE_ALPHA_FLOAT16_ATI;
}
iFormat = GL_LUMINANCE_ALPHA;
break;
case 3:
if (GLEW_NV_float_buffer)
{
iInternalFormat = (_iNumColorBits[0] > 16) ?
GL_FLOAT_RGB32_NV : GL_FLOAT_RGB16_NV;
}
else if (GLEW_ATI_texture_float)
{
iInternalFormat = (_iNumColorBits[0] > 16) ?
GL_RGB_FLOAT32_ATI : GL_RGB_FLOAT16_ATI;
}
iFormat = GL_RGB;
break;
case 4:
if (GLEW_NV_float_buffer)
{
iInternalFormat = (_iNumColorBits[0] > 16) ?
GL_FLOAT_RGBA32_NV : GL_FLOAT_RGBA16_NV;
}
else if (GLEW_ATI_texture_float)
{
iInternalFormat = (_iNumColorBits[0] > 16) ?
GL_RGBA_FLOAT32_ATI : GL_RGBA_FLOAT16_ATI;
}
iFormat = GL_RGBA;
break;
default:
printf("RenderTexture Error: "
"Invalid number of components: %d\n",
_iNumComponents);
return false;
}
}
else // non-float
{
if (4 == _iNumComponents)
{
iInternalFormat = GL_RGBA8;
iFormat = GL_RGBA;
}
else
{
iInternalFormat = GL_RGB8;
iFormat = GL_RGB;
}
}
// Allocate the texture image (but pass it no data for now).
glTexImage2D(_iTextureTarget, 0, iInternalFormat,
_iWidth, _iHeight, 0, iFormat, GL_FLOAT, NULL);
}
}
if (_bIsDepthTexture)
{
glGenTextures(1, &_iDepthTextureID);
glBindTexture(_iTextureTarget, _iDepthTextureID);
// Use clamp to edge as the default texture wrap mode for all tex
glTexParameteri(_iTextureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(_iTextureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Use NEAREST as the default texture filtering mode.
glTexParameteri(_iTextureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(_iTextureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (RT_COPY_TO_TEXTURE == _eUpdateMode)
{
// [Redge]
if (_bHasARBDepthTexture)
{
// Allocate the texture image (but pass it no data for now).
glTexImage2D(_iTextureTarget, 0, GL_DEPTH_COMPONENT,
_iWidth, _iHeight, 0, GL_DEPTH_COMPONENT,
GL_FLOAT, NULL);
}
else
{
// allocate memory for depth texture
// Since this is slow, we warn the user in debug mode. (above)
_pPoorDepthTexture = new unsigned short[_iWidth * _iHeight];
glTexImage2D(_iTextureTarget, 0, GL_LUMINANCE16,
_iWidth, _iHeight, 0, GL_LUMINANCE,
GL_UNSIGNED_SHORT, _pPoorDepthTexture);
}
// [/Redge]
}
}
return true;
}
//---------------------------------------------------------------------------
// Function : RenderTexture::_MaybeCopyBuffer
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_MaybeCopyBuffer()
* @brief Does the actual copying for RenderTextures with RT_COPY_TO_TEXTURE
*/
void RenderTexture::_MaybeCopyBuffer()
{
#ifdef _WIN32
if (RT_COPY_TO_TEXTURE == _eUpdateMode)
{
if (_bIsTexture)
{
glBindTexture(_iTextureTarget, _iTextureID);
glCopyTexSubImage2D(_iTextureTarget,
0, 0, 0, 0, 0, _iWidth, _iHeight);
}
if (_bIsDepthTexture)
{
glBindTexture(_iTextureTarget, _iDepthTextureID);
// HOW TO COPY DEPTH TEXTURE??? Supposedly this just magically works...
// [Redge]
if (_bHasARBDepthTexture)
{
glCopyTexSubImage2D(_iTextureTarget, 0, 0, 0, 0, 0,
_iWidth, _iHeight);
}
else
{
// no 'real' depth texture available, so behavior has to be emulated
// using glReadPixels (beware, this is (naturally) slow ...)
glReadPixels(0, 0, _iWidth, _iHeight, GL_DEPTH_COMPONENT,
GL_UNSIGNED_SHORT, _pPoorDepthTexture);
glTexImage2D(_iTextureTarget, 0, GL_LUMINANCE16,
_iWidth, _iHeight, 0, GL_LUMINANCE,
GL_UNSIGNED_SHORT, _pPoorDepthTexture);
}
// [/Redge]
}
}
#else
if (_bIsTexture)
{
glBindTexture(_iTextureTarget, _iTextureID);
glCopyTexSubImage2D(_iTextureTarget, 0, 0, 0, 0, 0, _iWidth, _iHeight);
}
if (_bIsDepthTexture)
{
glBindTexture(_iTextureTarget, _iDepthTextureID);
assert(_bHasARBDepthTexture);
glCopyTexSubImage2D(_iTextureTarget, 0, 0, 0, 0, 0, _iWidth, _iHeight);
}
#endif
}
//---------------------------------------------------------------------------
// Function : RenderTexture::_ReleaseBoundBuffers
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_ReleaseBoundBuffers()
* @brief Releases buffer bindings on RenderTextures with RT_RENDER_TO_TEXTURE
*/
bool RenderTexture::_ReleaseBoundBuffers()
{
#ifdef _WIN32
if (_bIsTexture && RT_RENDER_TO_TEXTURE == _eUpdateMode)
{
glBindTexture(_iTextureTarget, _iTextureID);
// release the pbuffer from the render texture object
if (0 != _iCurrentBoundBuffer && _bIsBufferBound)
{
if (FALSE == wglReleaseTexImageARB(_hPBuffer, _iCurrentBoundBuffer))
{
_wglGetLastError();
return false;
}
_bIsBufferBound = false;
}
}
if (_bIsDepthTexture && RT_RENDER_TO_TEXTURE == _eUpdateMode)
{
glBindTexture(_iTextureTarget, _iDepthTextureID);
// release the pbuffer from the render texture object
if (FALSE == wglReleaseTexImageARB(_hPBuffer, WGL_DEPTH_COMPONENT_NV))
{
_wglGetLastError();
return false;
}
}
#else
// textures can't be bound in Linux
#endif
return true;
}
//---------------------------------------------------------------------------
// Function : RenderTexture::_MakeCurrent
// Description :
//---------------------------------------------------------------------------
/**
* @fn RenderTexture::_MakeCurrent()
* @brief Makes the RenderTexture's context current
*/
bool RenderTexture::_MakeCurrent()
{
#ifdef _WIN32
// make the pbuffer's rendering context current.
if (FALSE == wglMakeCurrent( _hDC, _hGLContext))
{
_wglGetLastError();
return false;
}
#else
if (false == glXMakeCurrent(_pDisplay, _hPBuffer, _hGLContext))
{
return false;
}
#endif
return true;
}
#endif // __APPLE__
OpenCSG-1.3.2/RenderTexture/TestRenderTexture.dsw 0000644 0001750 0000144 00000001335 11665770270 021317 0 ustar fkirsch users Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "TestRenderTexture"=.\TestRenderTexture.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "UnitTestRenderTexture"=.\UnitTestRenderTexture.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
OpenCSG-1.3.2/glew/ 0000755 0001750 0000144 00000000000 11625454623 013271 5 ustar fkirsch users OpenCSG-1.3.2/glew/glew.pc.in 0000644 0001750 0000144 00000000343 11625454623 015160 0 ustar fkirsch users prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: glew
Description: The OpenGL Extension Wrangler library
Version: @version@
Cflags: -I${includedir} @cflags@
Libs: -L${libdir} -l@libname@
OpenCSG-1.3.2/glew/bin/ 0000755 0001750 0000144 00000000000 11625454622 014040 5 ustar fkirsch users OpenCSG-1.3.2/glew/LICENSE.txt 0000644 0001750 0000144 00000007325 11625454623 015123 0 ustar fkirsch users The OpenGL Extension Wrangler Library
Copyright (C) 2002-2007, Milan Ikits
Copyright (C) 2002-2007, Marcelo E. Magallon
Copyright (C) 2002, Lev Povalahev
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the author may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Mesa 3-D graphics library
Version: 7.0
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2007 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Materials.
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
OpenCSG-1.3.2/glew/lib/ 0000755 0001750 0000144 00000000000 11625454622 014036 5 ustar fkirsch users OpenCSG-1.3.2/glew/auto/ 0000755 0001750 0000144 00000000000 11625454623 014241 5 ustar fkirsch users OpenCSG-1.3.2/glew/auto/bin/ 0000755 0001750 0000144 00000000000 11625454623 015011 5 ustar fkirsch users OpenCSG-1.3.2/glew/auto/bin/make_struct_fun.pl 0000755 0001750 0000144 00000001477 11625454623 020553 0 ustar fkirsch users #!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon
## Copyright (C) 2002-2008, Milan Ikits
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
use strict;
use warnings;
do 'bin/make.pl';
# function pointer declaration
sub make_pfn_decl($%)
{
our $export;
return $export . " PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . ";";
}
my @extlist = ();
my %extensions = ();
our $export = shift;
if (@ARGV)
{
@extlist = @ARGV;
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
output_decls($functions, \&make_pfn_decl);
}
}
OpenCSG-1.3.2/glew/auto/bin/make_def_fun.pl 0000755 0001750 0000144 00000001450 11625454623 017754 0 ustar fkirsch users #!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon
## Copyright (C) 2002-2008, Milan Ikits
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
use strict;
use warnings;
do 'bin/make.pl';
# function pointer declaration
sub make_pfn_decl($%)
{
return "PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . " = NULL;";
}
my @extlist = ();
my %extensions = ();
our $type = shift;
if (@ARGV)
{
@extlist = @ARGV;
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
output_decls($functions, \&make_pfn_decl);
}
}
OpenCSG-1.3.2/glew/auto/bin/update_registry.sh 0000755 0001750 0000144 00000001663 11625454623 020570 0 ustar fkirsch users #!/bin/sh
##
## Copyright (C) 2002-2008, Marcelo E. Magallon
## Copyright (C) 2002-2008, Milan Ikits
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
set -e
if [ ! -d $1 ] ; then
mkdir $1
fi
cd $1
# wget used to return 0 (success), but more recent versions
# don't so we don't want to bail out in failure mode
# eventhough everything is fine.
set +e
wget \
--mirror \
--no-parent \
--no-host-directories \
--cut-dirs=2 \
--accept=txt,html \
$2
echo 'wget exit code: ' $?
exit 0
OpenCSG-1.3.2/glew/auto/bin/make.pl 0000755 0001750 0000144 00000010135 11625454623 016266 0 ustar fkirsch users ##
## Copyright (C) 2002-2008, Marcelo E. Magallon
## Copyright (C) 2002-2008, Milan Ikits
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
my %regex = (
extname => qr/^[A-Z][A-Za-z0-9_]+$/,
exturl => qr/^http.+$/,
function => qr/^(.+) ([a-z][a-z0-9_]*) \((.+)\)$/i,
token => qr/^([A-Z][A-Z0-9_x]*)\s+((?:0x)?[0-9A-Fa-f]+|[A-Z][A-Z0-9_]*)$/,
type => qr/^typedef\s+(.+)$/,
exact => qr/.*;$/,
);
# prefix function name with glew
sub prefixname($)
{
my $name = $_[0];
$name =~ s/^(.*?)gl/__$1glew/;
return $name;
}
# prefix function name with glew
sub prefix_varname($)
{
my $name = $_[0];
$name =~ s/^(.*?)GL(X*?)EW/__$1GL$2EW/;
return $name;
}
#---------------------------------------------------------------------------------------
sub make_exact($)
{
my $exact = $_[0];
$exact =~ s/(; |{)/$1\n/g;
return $exact;
}
sub make_separator($)
{
my $extname = $_[0];
my $l = length $extname;
my $s = (71 - $l)/2;
print "/* ";
my $j = 3;
for (my $i = 0; $i < $s; $i++)
{
print "-";
$j++;
}
print " $_[0] ";
$j += $l + 2;
while ($j < 76)
{
print "-";
$j++;
}
print " */\n\n";
}
#---------------------------------------------------------------------------------------
sub parse_ext($)
{
my $filename = shift;
my %functions = ();
my %tokens = ();
my @types = ();
my @exacts = ();
my $extname = ""; # Full extension name GL_FOO_extension
my $exturl = ""; # Info URL
my $extstring = ""; # Relevant extension string
open EXT, "<$filename" or return;
# As of GLEW 1.5.3 the first three lines _must_ be
# the extension name, the URL and the GL extension
# string (which might be different to the name)
#
# For example GL_NV_geometry_program4 is available
# iff GL_NV_gpu_program4 appears in the extension
# string.
#
# For core OpenGL versions, the third line should
# be blank.
#
# If the URL is unknown, the second line should be
# blank.
$extname = readline(*EXT);
$exturl = readline(*EXT);
$extstring = readline(*EXT);
chomp($extname);
chomp($exturl);
chomp($extstring);
while()
{
chomp;
if (s/^\s+//)
{
if (/$regex{exact}/)
{
push @exacts, $_;
}
elsif (/$regex{type}/)
{
push @types, $_;
}
elsif (/$regex{token}/)
{
my ($name, $value) = ($1, $2);
$tokens{$name} = $value;
}
elsif (/$regex{function}/)
{
my ($return, $name, $parms) = ($1, $2, $3);
$functions{$name} = {
rtype => $return,
parms => $parms,
};
} else {
print STDERR "'$_' matched no regex.\n";
}
}
}
close EXT;
return ($extname, $exturl, $extstring, \@types, \%tokens, \%functions, \@exacts);
}
sub output_tokens($$)
{
my ($tbl, $fnc) = @_;
if (keys %{$tbl})
{
local $, = "\n";
print "\n";
print map { &{$fnc}($_, $tbl->{$_}) } sort { hex ${$tbl}{$a} <=> hex ${$tbl}{$b} } keys %{$tbl};
print "\n";
} else {
print STDERR "no keys in table!\n";
}
}
sub output_types($$)
{
my ($tbl, $fnc) = @_;
if (scalar @{$tbl})
{
local $, = "\n";
print "\n";
print map { &{$fnc}($_) } sort @{$tbl};
print "\n";
}
}
sub output_decls($$)
{
my ($tbl, $fnc) = @_;
if (keys %{$tbl})
{
local $, = "\n";
print "\n";
print map { &{$fnc}($_, $tbl->{$_}) } sort keys %{$tbl};
print "\n";
}
}
sub output_exacts($$)
{
my ($tbl, $fnc) = @_;
if (scalar @{$tbl})
{
local $, = "\n";
print "\n";
print map { &{$fnc}($_) } sort @{$tbl};
print "\n";
}
}
OpenCSG-1.3.2/glew/auto/bin/make_str.pl 0000755 0001750 0000144 00000002624 11625454623 017162 0 ustar fkirsch users #!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon
## Copyright (C) 2002-2008, Milan Ikits
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
use strict;
use warnings;
do 'bin/make.pl';
my @extlist = ();
my %extensions = ();
if (@ARGV)
{
@extlist = @ARGV;
my $curexttype = "";
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my $exttype = $extname;
$exttype =~ s/(W*?)GL(X*?)_(.*?_)(.*)/$3/;
my $extrem = $extname;
$extrem =~ s/(W*?)GL(X*?)_(.*?_)(.*)/$4/;
my $extvar = $extname;
$extvar =~ s/(W*)GL(X*)_/$1GL$2EW_/;
if(!($exttype =~ $curexttype))
{
if(length($curexttype) > 0)
{
print " }\n";
}
print " if (_glewStrSame2(&pos, &len, (const GLubyte*)\"$exttype\", " . length($exttype) . "))\n";
print " {\n";
$curexttype = $exttype;
}
print "#ifdef $extname\n";
print " if (_glewStrSame3(&pos, &len, (const GLubyte*)\"$extrem\", ". length($extrem) . "))\n";
#print " return $extvar;\n";
print " {\n";
print " ret = $extvar;\n";
print " continue;\n";
print " }\n";
print "#endif\n";
}
print " }\n";
}
OpenCSG-1.3.2/glew/auto/bin/make_struct_var.pl 0000755 0001750 0000144 00000001366 11625454623 020550 0 ustar fkirsch users #!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon
## Copyright (C) 2002-2008, Milan Ikits
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
use strict;
use warnings;
do 'bin/make.pl';
my @extlist = ();
my %extensions = ();
our $export = shift;
if (@ARGV)
{
@extlist = @ARGV;
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
print $export . " GLboolean " . prefix_varname($extvar) . ";\n";
}
}
OpenCSG-1.3.2/glew/auto/bin/make_list.pl 0000755 0001750 0000144 00000003325 11625454623 017324 0 ustar fkirsch users #!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon
## Copyright (C) 2002-2008, Milan Ikits
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
use strict;
use warnings;
do 'bin/make.pl';
#---------------------------------------------------------------------------------------
# function pointer definition
sub make_init_call($%)
{
my $name = prefixname($_[0]);
return " r = r || (" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress(\"" . $name . "\")) == NULL;";
}
#---------------------------------------------------------------------------------------
my @extlist = ();
my %extensions = ();
if (@ARGV)
{
@extlist = @ARGV;
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
my $extpre = $extname;
$extpre =~ s/^(W?)GL(X?).*$/\l$1gl\l$2ew/;
#my $pextvar = prefix_varname($extvar);
print "#ifdef $extname\n";
if (length($extstring))
{
print " CONST_CAST(" . $extvar . ") = _glewSearchExtension(\"$extstring\", extStart, extEnd);\n";
}
if (keys %$functions)
{
if ($extname =~ /WGL_.*/)
{
print " if (glewExperimental || " . $extvar . "|| crippled) CONST_CAST(" . $extvar . ")= !_glewInit_$extname(GLEW_CONTEXT_ARG_VAR_INIT);\n";
}
else
{
print " if (glewExperimental || " . $extvar . ") CONST_CAST(" . $extvar . ") = !_glewInit_$extname(GLEW_CONTEXT_ARG_VAR_INIT);\n";
}
}
print "#endif /* $extname */\n";
}
}
OpenCSG-1.3.2/glew/auto/bin/make_html.pl 0000755 0001750 0000144 00000002556 11625454623 017322 0 ustar fkirsch users #!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon
## Copyright (C) 2002-2008, Milan Ikits
##
## This program is distributed under the terms and conditions of the GNU
## General Public License Version 2 as published by the Free Software
## Foundation or, at your option, any later version.
use strict;
use warnings;
do 'bin/make.pl';
#---------------------------------------------------------------------------------------
my @extlist = ();
my %extensions = ();
my $group = "";
my $cur_group = "";
if (@ARGV)
{
@extlist = @ARGV;
my $n = 1;
print "
\n";
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
$cur_group = $extname;
$cur_group =~ s/^(?:W?)GL(?:X?)_([A-Z0-9]+?)_.*$/$1/;
$extname =~ s/^(?:W?)GL(?:X?)_(.*)$/$1/;
if ($cur_group ne $group)
{
if ($group ne "")
{
print "