зеркало из https://github.com/mozilla/gecko-dev.git
Bug 801158 - Update ANGLE to r1561 - r=bjacob
This commit is contained in:
Родитель
bf5c3980b7
Коммит
c8c186ac5c
|
@ -0,0 +1,9 @@
|
|||
Debug
|
||||
Release
|
||||
*.sdf
|
||||
*.ncb
|
||||
*.suo
|
||||
*.vcproj.*
|
||||
*.vcxproj.user
|
||||
patches-*
|
||||
*.target.mk
|
|
@ -4,15 +4,29 @@
|
|||
# See the latter for an explanation.
|
||||
|
||||
# Names should be added to this file as
|
||||
# Name or Organization <email address>
|
||||
# The email address is not required for organizations.
|
||||
|
||||
TransGaming Inc.
|
||||
# Name or Organization
|
||||
# Email addresses for individuals are tracked elsewhere to avoid spam.
|
||||
|
||||
Google Inc.
|
||||
|
||||
TransGaming Inc.
|
||||
3DLabs Inc. Ltd.
|
||||
|
||||
Adobe Systems Inc.
|
||||
Autodesk, Inc.
|
||||
Cloud Party, Inc.
|
||||
Intel Corporation
|
||||
Mozilla Corporation
|
||||
Turbulenz
|
||||
Klarälvdalens Datakonsult AB
|
||||
|
||||
Jacek Caban <cjacek at gmail.com>
|
||||
Jacek Caban
|
||||
Mark Callow
|
||||
Ginn Chen
|
||||
James Hauxwell
|
||||
Sam Hocevar
|
||||
Pierre Leveille
|
||||
Jonathan Liu
|
||||
Boying Lu
|
||||
Aitor Moreno
|
||||
Yuri O'Donnell
|
||||
Josh Soref
|
||||
|
|
|
@ -17,9 +17,13 @@ Google Inc.
|
|||
Brent Austin
|
||||
Michael Bai
|
||||
John Bauman
|
||||
Peter Beverloo
|
||||
Steve Block
|
||||
Rachel Blum
|
||||
Eric Boren
|
||||
Henry Bridge
|
||||
Nat Duca
|
||||
Peter Kasting
|
||||
Vangelis Kokkevis
|
||||
Zhenyao Mo
|
||||
Daniel Nicoara
|
||||
|
@ -27,34 +31,43 @@ Google Inc.
|
|||
Alok Priyadarshi
|
||||
Kenneth Russell
|
||||
Brian Salomon
|
||||
Gregg Tavares
|
||||
Jeff Timanus
|
||||
Ben Vanik
|
||||
Adrienne Walker
|
||||
thestig@chromium.org
|
||||
|
||||
Adobe Systems Inc.
|
||||
Alexandru Chiculita
|
||||
Steve Minns
|
||||
Max Vujovic
|
||||
|
||||
Autodesk, Inc.
|
||||
Ranger Harke
|
||||
|
||||
Cloud Party, Inc.
|
||||
Conor Dickinson
|
||||
|
||||
Intel Corporation
|
||||
Jin Yang
|
||||
Andy Chen
|
||||
Josh Triplett
|
||||
|
||||
Klarälvdalens Datakonsult AB
|
||||
Milian Wolff
|
||||
|
||||
Mozilla Corp.
|
||||
Ehsan Akhgari
|
||||
Jeff Gilbert
|
||||
Mike Hommey
|
||||
Benoit Jacob
|
||||
Makoto Kato
|
||||
Vladimir Vukicevic
|
||||
|
||||
Apple Inc.
|
||||
David Kilzer
|
||||
Turbulenz
|
||||
Michael Braithwaite
|
||||
|
||||
Adobe Systems Inc.
|
||||
Alexandru Chiculita
|
||||
Max Vujovic
|
||||
|
||||
Cloud Party, Inc.
|
||||
Conor Dickinson
|
||||
|
||||
Aitor Moreno <aitormoreno at gmail.com>
|
||||
Jim Hauxwell <james at dattrax.co.uk>
|
||||
ddefrostt
|
||||
timeless
|
||||
Yore Apex
|
||||
Mark Callow
|
||||
Yuriy O'Donnell
|
||||
Sam Hocevar
|
||||
Pierre Leveille
|
||||
Jin Yang
|
||||
Ulrik Persson (ddefrostt)
|
||||
Mark Banner (standard8mbp)
|
||||
David Kilzer
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
Files in src/compiler/preprocessor are provided under the following license:
|
||||
|
||||
****************************************************************************
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
****************************************************************************
|
|
@ -1,18 +1,17 @@
|
|||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = angle
|
||||
LIBRARY_NAME = angle
|
||||
LIBXUL_LIBRARY = 1
|
||||
MODULE = angle
|
||||
LIBRARY_NAME = angle
|
||||
LIBXUL_LIBRARY = 1
|
||||
ifeq (WINNT,$(OS_TARGET))
|
||||
VISIBILITY_FLAGS =
|
||||
endif
|
||||
|
@ -20,104 +19,113 @@ endif
|
|||
EXPORTS_NAMESPACES = angle
|
||||
|
||||
EXPORTS_angle = \
|
||||
include/GLSLANG/ShaderLang.h \
|
||||
$(NULL)
|
||||
include/GLSLANG/ShaderLang.h \
|
||||
include/KHR/khrplatform.h \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += -I$(srcdir)/include -I$(srcdir)/src
|
||||
|
||||
VPATH += $(srcdir)/src
|
||||
VPATH += $(srcdir)/src/compiler
|
||||
VPATH += $(srcdir)/src/compiler/preprocessor
|
||||
VPATH += $(srcdir)/src/compiler/preprocessor/new
|
||||
VPATH += $(srcdir)/src/compiler/timing
|
||||
VPATH += $(srcdir)/src/compiler/depgraph
|
||||
|
||||
CPPSRCS = \
|
||||
Diagnostics.cpp \
|
||||
PreprocessorDiagnostics.cpp \
|
||||
DirectiveHandler.cpp \
|
||||
PreprocessorDirectiveHandler.cpp \
|
||||
DirectiveParser.cpp \
|
||||
ExpressionParser.cpp \
|
||||
Macro.cpp \
|
||||
MacroExpander.cpp \
|
||||
Tokenizer.cpp \
|
||||
InitializeParseContext.cpp \
|
||||
DependencyGraph.cpp \
|
||||
DependencyGraphBuilder.cpp \
|
||||
DependencyGraphOutput.cpp \
|
||||
DependencyGraphTraverse.cpp \
|
||||
RestrictFragmentShaderTiming.cpp \
|
||||
RestrictVertexShaderTiming.cpp \
|
||||
Compiler.cpp \
|
||||
DetectRecursion.cpp \
|
||||
InfoSink.cpp \
|
||||
Initialize.cpp \
|
||||
InitializeDll.cpp \
|
||||
Intermediate.cpp \
|
||||
intermOut.cpp \
|
||||
IntermTraverse.cpp \
|
||||
parseConst.cpp \
|
||||
ParseHelper.cpp \
|
||||
PoolAlloc.cpp \
|
||||
QualifierAlive.cpp \
|
||||
RemoveTree.cpp \
|
||||
ShaderLang.cpp \
|
||||
SymbolTable.cpp \
|
||||
VariableInfo.cpp \
|
||||
compilerdebug.cpp \
|
||||
util.cpp \
|
||||
ValidateLimitations.cpp \
|
||||
ForLoopUnroll.cpp \
|
||||
MapLongVariableNames.cpp \
|
||||
spooky.cpp \
|
||||
BuiltInFunctionEmulator.cpp \
|
||||
Input.cpp \
|
||||
Lexer.cpp \
|
||||
Preprocessor.cpp \
|
||||
Token.cpp \
|
||||
VariablePacker.cpp \
|
||||
$(NULL)
|
||||
|
||||
# flex/yacc generated files
|
||||
CPPSRCS += \
|
||||
glslang_lex.cpp \
|
||||
glslang_tab.cpp \
|
||||
$(NULL)
|
||||
|
||||
# GLSL translator backend
|
||||
CPPSRCS += \
|
||||
CodeGenGLSL.cpp \
|
||||
OutputGLSL.cpp \
|
||||
TranslatorGLSL.cpp \
|
||||
VersionGLSL.cpp \
|
||||
OutputESSL.cpp \
|
||||
OutputGLSLBase.cpp \
|
||||
TranslatorESSL.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
CPPSRCS += ossource_win.cpp $(NULL)
|
||||
else
|
||||
CPPSRCS += ossource_posix.cpp $(NULL)
|
||||
endif
|
||||
|
||||
CSRCS = \
|
||||
atom.c \
|
||||
cpp.c \
|
||||
cppstruct.c \
|
||||
memory.c \
|
||||
scanner.c \
|
||||
symbols.c \
|
||||
tokens.c \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -DANGLE_BUILD -DCOMPILER_IMPLEMENTATION
|
||||
|
||||
#these defines are from ANGLE's build_angle.gyp
|
||||
# The below is a rough translation of build_angle.gypi:
|
||||
DEFINES += -DANGLE_DISABLE_TRACE
|
||||
DEFINES += -DANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL0
|
||||
DEFINES += -DANGLE_USE_NEW_PREPROCESSOR=1
|
||||
|
||||
# Target: 'preprocessor'
|
||||
# src/compiler/preprocessor:
|
||||
VPATH += $(srcdir)/src/compiler/preprocessor
|
||||
CPPSRCS += \
|
||||
PreprocessorDiagnostics.cpp \
|
||||
PreprocessorDirectiveHandler.cpp \
|
||||
DirectiveParser.cpp \
|
||||
ExpressionParser.cpp \
|
||||
Input.cpp \
|
||||
Lexer.cpp \
|
||||
Macro.cpp \
|
||||
MacroExpander.cpp \
|
||||
Preprocessor.cpp \
|
||||
Token.cpp \
|
||||
Tokenizer.cpp \
|
||||
$(NULL)
|
||||
|
||||
# Target: 'translator_common'
|
||||
# Requires: 'preprocessor'
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/include \
|
||||
-I$(srcdir)/include/KHR \
|
||||
-I$(srcdir)/src
|
||||
|
||||
DEFINES += -DCOMPILER_IMPLEMENTATION
|
||||
|
||||
VPATH += $(srcdir)/src/compiler
|
||||
# src/compiler:
|
||||
CPPSRCS += \
|
||||
BuiltInFunctionEmulator.cpp \
|
||||
Compiler.cpp \
|
||||
compiler_debug.cpp \
|
||||
DetectRecursion.cpp \
|
||||
Diagnostics.cpp \
|
||||
DirectiveHandler.cpp \
|
||||
ForLoopUnroll.cpp \
|
||||
glslang_lex.cpp \
|
||||
glslang_tab.cpp \
|
||||
InfoSink.cpp \
|
||||
Initialize.cpp \
|
||||
InitializeDll.cpp \
|
||||
InitializeParseContext.cpp \
|
||||
Intermediate.cpp \
|
||||
intermOut.cpp \
|
||||
IntermTraverse.cpp \
|
||||
MapLongVariableNames.cpp \
|
||||
parseConst.cpp \
|
||||
ParseHelper.cpp \
|
||||
PoolAlloc.cpp \
|
||||
QualifierAlive.cpp \
|
||||
RemoveTree.cpp \
|
||||
spooky.cpp \
|
||||
SymbolTable.cpp \
|
||||
util.cpp \
|
||||
ValidateLimitations.cpp \
|
||||
VariableInfo.cpp \
|
||||
VariablePacker.cpp \
|
||||
$(NULL)
|
||||
|
||||
VPATH += $(srcdir)/src/compiler/depgraph
|
||||
# src/compiler/depgraph:
|
||||
CPPSRCS += \
|
||||
DependencyGraph.cpp \
|
||||
DependencyGraphBuilder.cpp \
|
||||
DependencyGraphOutput.cpp \
|
||||
DependencyGraphTraverse.cpp \
|
||||
$(NULL)
|
||||
|
||||
VPATH += $(srcdir)/src/compiler/timing
|
||||
# src/compiler/timing:
|
||||
CPPSRCS += \
|
||||
RestrictFragmentShaderTiming.cpp \
|
||||
RestrictVertexShaderTiming.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
CPPSRCS += ossource_win.cpp
|
||||
else
|
||||
CPPSRCS += ossource_posix.cpp
|
||||
endif
|
||||
|
||||
|
||||
# Target: 'translator_glsl'
|
||||
# Requires: 'translator_common'
|
||||
# src/compiler:
|
||||
CPPSRCS += \
|
||||
CodeGenGLSL.cpp \
|
||||
OutputESSL.cpp \
|
||||
OutputGLSLBase.cpp \
|
||||
OutputGLSL.cpp \
|
||||
ShaderLang.cpp \
|
||||
TranslatorESSL.cpp \
|
||||
TranslatorGLSL.cpp \
|
||||
VersionGLSL.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
# End gpy translation. Remainder of targets are in src/libEGL/Makefile.in and
|
||||
# src/libGLESv2/Makefile.in
|
||||
|
||||
ifdef MOZ_ANGLE_RENDERER
|
||||
|
||||
|
@ -136,3 +144,8 @@ endif
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
# We have to filter out -pedantic, because of
|
||||
# comma-at-end-of-enumerator list failures. We can try to get this fixed
|
||||
# upstream at some point.
|
||||
CXXFLAGS := $(filter-out -pedantic,$(CXXFLAGS))
|
||||
CFLAGS := $(filter-out -pedantic,$(CFLAGS))
|
||||
|
|
|
@ -1,45 +1,81 @@
|
|||
This is the ANGLE project, from http://code.google.com/p/angleproject/
|
||||
|
||||
Current revision: r1267
|
||||
Current revision: r1561
|
||||
|
||||
|
||||
== Applied local patches ==
|
||||
|
||||
In this order:
|
||||
|
||||
angle-renaming-debug.patch
|
||||
rename debug.h to compilerdebug.h to avoid conflict in our makefiles
|
||||
|
||||
angle-renaming-preprocessor-diagonostics.patch
|
||||
rename one of the two Diagnostics.cpp to avoid conflict in our makefiles
|
||||
|
||||
angle-renaming-preprocessor-directivehandler.patch
|
||||
rename one of the two DirectiveHandler.cpp to avoid conflict in our makefiles
|
||||
|
||||
angle-enforce-readpixels-spec.patch
|
||||
see bug 724476
|
||||
|
||||
angle-impl-read-bgra.patch
|
||||
see bug 724476
|
||||
|
||||
gfx/angle/angle-long-identifier-hash-spooky.patch
|
||||
see bug 676071
|
||||
|
||||
angle-abort-on-oom-in-preprocessor.patch
|
||||
see bug 680840. Probably not useful anymore now that we're on the new
|
||||
preprocessor, but it doesn't hurt to keep it around a bit longer.
|
||||
|
||||
angle-faceforward-emu.patch
|
||||
See bug 771406. Adds emulation for faceforward(float,float,float),
|
||||
which is needed to prevent crashing on Mac+Intel.
|
||||
|
||||
angle-r1278.patch
|
||||
Imports ANGLE r1278, which fixes ANGLE bug 350, a crasher.
|
||||
angle-build-stdcall-alias.patch:
|
||||
Fix an issue GCC has with linking to undecorated stdcalls.
|
||||
|
||||
angle-build-dedupe-debug-cpp-h.patch:
|
||||
Rename: "src/compiler/debug.{cpp,h}"
|
||||
To: "src/compiler/compiler_debug.{cpp,h}"
|
||||
Repair includes accordingly.
|
||||
|
||||
angle-build-dedupe-preproc-files.patch:
|
||||
Rename: "src/compiler/preprocessor/Diagnostics.cpp"
|
||||
To: "src/compiler/preprocessor/PreprocessorDiagnostics.cpp"
|
||||
Rename: "src/compiler/preprocessor/DirectiveHandler.cpp"
|
||||
To: "src/compiler/preprocessor/PreprocessorDirectiveHandler.cpp"
|
||||
|
||||
angle-long-ident-spooky-hash.patch:
|
||||
Use Spooky Hash for long identifier hashing. See bug 676071.
|
||||
|
||||
angle-faceforward-emu.patch:
|
||||
Adds emulation for faceforward(float,float,float), which is needed to
|
||||
prevent crashing on Mac+Intel. See bug 771406.
|
||||
|
||||
In addition to these patches, the Makefile.in files are ours, they're not present in
|
||||
upsteam ANGLE. Therefore, changes made to the Makefile.in files should not be stored
|
||||
in the local .patch files.
|
||||
|
||||
== How to update this ANGLE copy ==
|
||||
|
||||
== How to do a clean-slate upgrade ==
|
||||
1. Backup our moz-specific files:
|
||||
README.mozilla
|
||||
Makefile.in
|
||||
*.patch
|
||||
src/libEGL/Makefile.in
|
||||
src/libGLESv2/Makefile.in
|
||||
|
||||
2. $ rm -rf gfx/angle
|
||||
|
||||
3. Copy the folder containing the angle rev you want onto gfx/angle.
|
||||
$ svn export -r <rev> <src> <moz-central>/gfx/angle
|
||||
|
||||
4. Fold our moz-specific files into this new angle folder. (Makefiles, README)
|
||||
4a. Remove the unused directories. (test/, samples/, etc)
|
||||
|
||||
5. Clear out the "Applied Local Patches" section above, since we're going to
|
||||
repopulate it.
|
||||
|
||||
6. Re-apply the angle-build-*.patch files and record them above.
|
||||
|
||||
7. Update the Makefile.in files with the current deps from the .gyp(i) files.
|
||||
|
||||
8. Build. Fix things until it builds.
|
||||
|
||||
9. Reapply the rest of the .patch files and record them above.
|
||||
|
||||
10. Try runs and reviews!
|
||||
|
||||
|
||||
== Applying Diffs ==
|
||||
In general:
|
||||
$ patch -p1 -R < gfx/angle/angle-some-bug-fix.patch
|
||||
|
||||
SVN diffs however can be iffy. They don't seem to be completely compatible
|
||||
with `patch`. Be aware that you'll likely get rejects whenever a file is
|
||||
removed.
|
||||
|
||||
|
||||
|
||||
== How to do an incremental update ==
|
||||
Same general idea here, but instead of nuking the ANGLE dir, we're going to
|
||||
have to get a diff between revs from SVN, and deal with applying that. We
|
||||
also naturally have to peel off our local patches before we can apply a diff
|
||||
from upstream.
|
||||
|
||||
1. Unapply patches
|
||||
|
||||
|
@ -130,10 +166,10 @@ new patches that you need to add to get this update to work.
|
|||
You do not need a review for the ANGLE diff itself and for trivial updates of
|
||||
existing patches.
|
||||
|
||||
== Visual Studio Solution Files ==
|
||||
|
||||
== Visual Studio Solution Files ==
|
||||
Ignore these. We don't use them anymore. We use custom Makefiles.
|
||||
|
||||
== Generated parser code==
|
||||
|
||||
== Generated parser code==
|
||||
Don't bother about that anymore. The parser is now generated and included in the ANGLE svn repo.
|
||||
|
|
|
@ -1,732 +0,0 @@
|
|||
# HG changeset patch
|
||||
# Parent ef5d80327785b28df0bd778acc86f4987ba5a678
|
||||
|
||||
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
|
||||
--- a/gfx/angle/Makefile.in
|
||||
+++ b/gfx/angle/Makefile.in
|
||||
@@ -71,16 +71,17 @@ CPPSRCS = \
|
||||
ForLoopUnroll.cpp \
|
||||
MapLongVariableNames.cpp \
|
||||
spooky.cpp \
|
||||
BuiltInFunctionEmulator.cpp \
|
||||
Input.cpp \
|
||||
Lexer.cpp \
|
||||
Preprocessor.cpp \
|
||||
Token.cpp \
|
||||
+ VariablePacker.cpp \
|
||||
$(NULL)
|
||||
|
||||
# flex/yacc generated files
|
||||
CPPSRCS += \
|
||||
glslang_lex.cpp \
|
||||
glslang_tab.cpp \
|
||||
$(NULL)
|
||||
|
||||
diff --git a/gfx/angle/include/GLSLANG/ShaderLang.h b/gfx/angle/include/GLSLANG/ShaderLang.h
|
||||
--- a/gfx/angle/include/GLSLANG/ShaderLang.h
|
||||
+++ b/gfx/angle/include/GLSLANG/ShaderLang.h
|
||||
@@ -137,17 +137,20 @@ typedef enum {
|
||||
SH_TIMING_RESTRICTIONS = 0x0200,
|
||||
|
||||
// This flag prints the dependency graph that is used to enforce timing
|
||||
// restrictions on fragment shaders.
|
||||
// This flag only has an effect if all of the following are true:
|
||||
// - The shader spec is SH_WEBGL_SPEC.
|
||||
// - The compile options contain the SH_TIMING_RESTRICTIONS flag.
|
||||
// - The shader type is SH_FRAGMENT_SHADER.
|
||||
- SH_DEPENDENCY_GRAPH = 0x0400
|
||||
+ SH_DEPENDENCY_GRAPH = 0x0400,
|
||||
+
|
||||
+ // Enforce the GLSL 1.017 Appendix A section 7 packing restrictions.
|
||||
+ SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800,
|
||||
} ShCompileOptions;
|
||||
|
||||
//
|
||||
// Driver must call this first, once, before doing any other
|
||||
// compiler operations.
|
||||
// If the function succeeds, the return value is nonzero, else zero.
|
||||
//
|
||||
COMPILER_EXPORT int ShInitialize();
|
||||
diff --git a/gfx/angle/src/compiler/Compiler.cpp b/gfx/angle/src/compiler/Compiler.cpp
|
||||
--- a/gfx/angle/src/compiler/Compiler.cpp
|
||||
+++ b/gfx/angle/src/compiler/Compiler.cpp
|
||||
@@ -9,16 +9,17 @@
|
||||
#include "compiler/ForLoopUnroll.h"
|
||||
#include "compiler/Initialize.h"
|
||||
#include "compiler/InitializeParseContext.h"
|
||||
#include "compiler/MapLongVariableNames.h"
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/RenameFunction.h"
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/ValidateLimitations.h"
|
||||
+#include "compiler/VariablePacker.h"
|
||||
#include "compiler/depgraph/DependencyGraph.h"
|
||||
#include "compiler/depgraph/DependencyGraphOutput.h"
|
||||
#include "compiler/timing/RestrictFragmentShaderTiming.h"
|
||||
#include "compiler/timing/RestrictVertexShaderTiming.h"
|
||||
|
||||
bool isWebGLBasedSpec(ShShaderSpec spec)
|
||||
{
|
||||
return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC;
|
||||
@@ -108,16 +109,19 @@ TCompiler::TCompiler(ShShaderType type,
|
||||
TCompiler::~TCompiler()
|
||||
{
|
||||
ASSERT(longNameMap);
|
||||
longNameMap->Release();
|
||||
}
|
||||
|
||||
bool TCompiler::Init(const ShBuiltInResources& resources)
|
||||
{
|
||||
+ maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ?
|
||||
+ resources.MaxVertexUniformVectors :
|
||||
+ resources.MaxFragmentUniformVectors;
|
||||
TScopedPoolAllocator scopedAlloc(&allocator, false);
|
||||
|
||||
// Generate built-in symbol table.
|
||||
if (!InitBuiltInSymbolTable(resources))
|
||||
return false;
|
||||
InitExtensionBehavior(resources, extensionBehavior);
|
||||
|
||||
return true;
|
||||
@@ -187,18 +191,25 @@ bool TCompiler::compile(const char* cons
|
||||
builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root);
|
||||
|
||||
// Call mapLongVariableNames() before collectAttribsUniforms() so in
|
||||
// collectAttribsUniforms() we already have the mapped symbol names and
|
||||
// we could composite mapped and original variable names.
|
||||
if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES))
|
||||
mapLongVariableNames(root);
|
||||
|
||||
- if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS))
|
||||
+ if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) {
|
||||
collectAttribsUniforms(root);
|
||||
+ if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS) {
|
||||
+ success = enforcePackingRestrictions();
|
||||
+ if (!success) {
|
||||
+ infoSink.info.message(EPrefixError, "too many uniforms");
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
if (success && (compileOptions & SH_INTERMEDIATE_TREE))
|
||||
intermediate.outputTree(root);
|
||||
|
||||
if (success && (compileOptions & SH_OBJECT_CODE))
|
||||
translate(root);
|
||||
}
|
||||
|
||||
@@ -305,16 +316,22 @@ bool TCompiler::enforceVertexShaderTimin
|
||||
}
|
||||
|
||||
void TCompiler::collectAttribsUniforms(TIntermNode* root)
|
||||
{
|
||||
CollectAttribsUniforms collect(attribs, uniforms);
|
||||
root->traverse(&collect);
|
||||
}
|
||||
|
||||
+bool TCompiler::enforcePackingRestrictions()
|
||||
+{
|
||||
+ VariablePacker packer;
|
||||
+ return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
|
||||
+}
|
||||
+
|
||||
void TCompiler::mapLongVariableNames(TIntermNode* root)
|
||||
{
|
||||
ASSERT(longNameMap);
|
||||
MapLongVariableNames map(longNameMap);
|
||||
root->traverse(&map);
|
||||
}
|
||||
|
||||
int TCompiler::getMappedNameMaxLength() const
|
||||
diff --git a/gfx/angle/src/compiler/ShHandle.h b/gfx/angle/src/compiler/ShHandle.h
|
||||
--- a/gfx/angle/src/compiler/ShHandle.h
|
||||
+++ b/gfx/angle/src/compiler/ShHandle.h
|
||||
@@ -83,32 +83,37 @@ protected:
|
||||
// functionality mandated in GLSL 1.0 spec Appendix A.
|
||||
bool validateLimitations(TIntermNode* root);
|
||||
// Collect info for all attribs and uniforms.
|
||||
void collectAttribsUniforms(TIntermNode* root);
|
||||
// Map long variable names into shorter ones.
|
||||
void mapLongVariableNames(TIntermNode* root);
|
||||
// Translate to object code.
|
||||
virtual void translate(TIntermNode* root) = 0;
|
||||
+ // Returns true if, after applying the packing rules in the GLSL 1.017 spec
|
||||
+ // Appendix A, section 7, the shader does not use too many uniforms.
|
||||
+ bool enforcePackingRestrictions();
|
||||
// Returns true if the shader passes the restrictions that aim to prevent timing attacks.
|
||||
bool enforceTimingRestrictions(TIntermNode* root, bool outputGraph);
|
||||
// Returns true if the shader does not use samplers.
|
||||
bool enforceVertexShaderTimingRestrictions(TIntermNode* root);
|
||||
// Returns true if the shader does not use sampler dependent values to affect control
|
||||
// flow or in operations whose time can depend on the input values.
|
||||
bool enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph);
|
||||
// Get built-in extensions with default behavior.
|
||||
const TExtensionBehavior& getExtensionBehavior() const;
|
||||
|
||||
const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const;
|
||||
|
||||
private:
|
||||
ShShaderType shaderType;
|
||||
ShShaderSpec shaderSpec;
|
||||
|
||||
+ int maxUniformVectors;
|
||||
+
|
||||
// Built-in symbol table for the given language, spec, and resources.
|
||||
// It is preserved from compile-to-compile.
|
||||
TSymbolTable symbolTable;
|
||||
// Built-in extensions with default behavior.
|
||||
TExtensionBehavior extensionBehavior;
|
||||
|
||||
BuiltInFunctionEmulator builtInFunctionEmulator;
|
||||
|
||||
diff --git a/gfx/angle/src/compiler/VariableInfo.cpp b/gfx/angle/src/compiler/VariableInfo.cpp
|
||||
--- a/gfx/angle/src/compiler/VariableInfo.cpp
|
||||
+++ b/gfx/angle/src/compiler/VariableInfo.cpp
|
||||
@@ -133,16 +133,26 @@ void getUserDefinedVariableInfo(const TT
|
||||
const TType* fieldType = (*structure)[i].type;
|
||||
getVariableInfo(*fieldType,
|
||||
name + "." + fieldType->getFieldName(),
|
||||
mappedName + "." + fieldType->getFieldName(),
|
||||
infoList);
|
||||
}
|
||||
}
|
||||
|
||||
+TVariableInfo::TVariableInfo()
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+TVariableInfo::TVariableInfo(ShDataType type, int size)
|
||||
+ : type(type),
|
||||
+ size(size)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
CollectAttribsUniforms::CollectAttribsUniforms(TVariableInfoList& attribs,
|
||||
TVariableInfoList& uniforms)
|
||||
: mAttribs(attribs),
|
||||
mUniforms(uniforms)
|
||||
{
|
||||
}
|
||||
|
||||
// We are only interested in attribute and uniform variable declaration.
|
||||
diff --git a/gfx/angle/src/compiler/VariableInfo.h b/gfx/angle/src/compiler/VariableInfo.h
|
||||
--- a/gfx/angle/src/compiler/VariableInfo.h
|
||||
+++ b/gfx/angle/src/compiler/VariableInfo.h
|
||||
@@ -8,16 +8,19 @@
|
||||
#define COMPILER_VARIABLE_INFO_H_
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
#include "compiler/intermediate.h"
|
||||
|
||||
// Provides information about a variable.
|
||||
// It is currently being used to store info about active attribs and uniforms.
|
||||
struct TVariableInfo {
|
||||
+ TVariableInfo(ShDataType type, int size);
|
||||
+ TVariableInfo();
|
||||
+
|
||||
TPersistString name;
|
||||
TPersistString mappedName;
|
||||
ShDataType type;
|
||||
int size;
|
||||
};
|
||||
typedef std::vector<TVariableInfo> TVariableInfoList;
|
||||
|
||||
// Traverses intermediate tree to collect all attributes and uniforms.
|
||||
diff --git a/gfx/angle/src/compiler/VariablePacker.cpp b/gfx/angle/src/compiler/VariablePacker.cpp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gfx/angle/src/compiler/VariablePacker.cpp
|
||||
@@ -0,0 +1,297 @@
|
||||
+//
|
||||
+// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+//
|
||||
+#include "compiler/VariablePacker.h"
|
||||
+
|
||||
+#include <algorithm>
|
||||
+#include "compiler/ShHandle.h"
|
||||
+
|
||||
+namespace {
|
||||
+int GetSortOrder(ShDataType type)
|
||||
+{
|
||||
+ switch (type) {
|
||||
+ case SH_FLOAT_MAT4:
|
||||
+ return 0;
|
||||
+ case SH_FLOAT_MAT2:
|
||||
+ return 1;
|
||||
+ case SH_FLOAT_VEC4:
|
||||
+ case SH_INT_VEC4:
|
||||
+ case SH_BOOL_VEC4:
|
||||
+ return 2;
|
||||
+ case SH_FLOAT_MAT3:
|
||||
+ return 3;
|
||||
+ case SH_FLOAT_VEC3:
|
||||
+ case SH_INT_VEC3:
|
||||
+ case SH_BOOL_VEC3:
|
||||
+ return 4;
|
||||
+ case SH_FLOAT_VEC2:
|
||||
+ case SH_INT_VEC2:
|
||||
+ case SH_BOOL_VEC2:
|
||||
+ return 5;
|
||||
+ case SH_FLOAT:
|
||||
+ case SH_INT:
|
||||
+ case SH_BOOL:
|
||||
+ case SH_SAMPLER_2D:
|
||||
+ case SH_SAMPLER_CUBE:
|
||||
+ case SH_SAMPLER_EXTERNAL_OES:
|
||||
+ case SH_SAMPLER_2D_RECT_ARB:
|
||||
+ return 6;
|
||||
+ default:
|
||||
+ ASSERT(false);
|
||||
+ return 7;
|
||||
+ }
|
||||
+}
|
||||
+} // namespace
|
||||
+
|
||||
+int VariablePacker::GetNumComponentsPerRow(ShDataType type)
|
||||
+{
|
||||
+ switch (type) {
|
||||
+ case SH_FLOAT_MAT4:
|
||||
+ case SH_FLOAT_MAT2:
|
||||
+ case SH_FLOAT_VEC4:
|
||||
+ case SH_INT_VEC4:
|
||||
+ case SH_BOOL_VEC4:
|
||||
+ return 4;
|
||||
+ case SH_FLOAT_MAT3:
|
||||
+ case SH_FLOAT_VEC3:
|
||||
+ case SH_INT_VEC3:
|
||||
+ case SH_BOOL_VEC3:
|
||||
+ return 3;
|
||||
+ case SH_FLOAT_VEC2:
|
||||
+ case SH_INT_VEC2:
|
||||
+ case SH_BOOL_VEC2:
|
||||
+ return 2;
|
||||
+ case SH_FLOAT:
|
||||
+ case SH_INT:
|
||||
+ case SH_BOOL:
|
||||
+ case SH_SAMPLER_2D:
|
||||
+ case SH_SAMPLER_CUBE:
|
||||
+ case SH_SAMPLER_EXTERNAL_OES:
|
||||
+ case SH_SAMPLER_2D_RECT_ARB:
|
||||
+ return 1;
|
||||
+ default:
|
||||
+ ASSERT(false);
|
||||
+ return 5;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int VariablePacker::GetNumRows(ShDataType type)
|
||||
+{
|
||||
+ switch (type) {
|
||||
+ case SH_FLOAT_MAT4:
|
||||
+ return 4;
|
||||
+ case SH_FLOAT_MAT3:
|
||||
+ return 3;
|
||||
+ case SH_FLOAT_MAT2:
|
||||
+ return 1;
|
||||
+ case SH_FLOAT_VEC4:
|
||||
+ case SH_INT_VEC4:
|
||||
+ case SH_BOOL_VEC4:
|
||||
+ case SH_FLOAT_VEC3:
|
||||
+ case SH_INT_VEC3:
|
||||
+ case SH_BOOL_VEC3:
|
||||
+ case SH_FLOAT_VEC2:
|
||||
+ case SH_INT_VEC2:
|
||||
+ case SH_BOOL_VEC2:
|
||||
+ case SH_FLOAT:
|
||||
+ case SH_INT:
|
||||
+ case SH_BOOL:
|
||||
+ case SH_SAMPLER_2D:
|
||||
+ case SH_SAMPLER_CUBE:
|
||||
+ case SH_SAMPLER_EXTERNAL_OES:
|
||||
+ case SH_SAMPLER_2D_RECT_ARB:
|
||||
+ return 1;
|
||||
+ default:
|
||||
+ ASSERT(false);
|
||||
+ return 100000;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+struct TVariableInfoComparer {
|
||||
+ bool operator()(const TVariableInfo& lhs, const TVariableInfo& rhs) const
|
||||
+ {
|
||||
+ int lhsSortOrder = GetSortOrder(lhs.type);
|
||||
+ int rhsSortOrder = GetSortOrder(rhs.type);
|
||||
+ if (lhsSortOrder != rhsSortOrder) {
|
||||
+ return lhsSortOrder < rhsSortOrder;
|
||||
+ }
|
||||
+ // Sort by largest first.
|
||||
+ return lhs.size > rhs.size;
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+unsigned VariablePacker::makeColumnFlags(int column, int numComponentsPerRow)
|
||||
+{
|
||||
+ return ((kColumnMask << (kNumColumns - numComponentsPerRow)) &
|
||||
+ kColumnMask) >> column;
|
||||
+}
|
||||
+
|
||||
+void VariablePacker::fillColumns(int topRow, int numRows, int column, int numComponentsPerRow)
|
||||
+{
|
||||
+ unsigned columnFlags = makeColumnFlags(column, numComponentsPerRow);
|
||||
+ for (int r = 0; r < numRows; ++r) {
|
||||
+ int row = topRow + r;
|
||||
+ ASSERT((rows_[row] & columnFlags) == 0);
|
||||
+ rows_[row] |= columnFlags;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+bool VariablePacker::searchColumn(int column, int numRows, int* destRow, int* destSize)
|
||||
+{
|
||||
+ ASSERT(destRow);
|
||||
+
|
||||
+ for (; topNonFullRow_ < maxRows_ && rows_[topNonFullRow_] == kColumnMask;
|
||||
+ ++topNonFullRow_) {
|
||||
+ }
|
||||
+
|
||||
+ for (; bottomNonFullRow_ >= 0 && rows_[bottomNonFullRow_] == kColumnMask;
|
||||
+ --bottomNonFullRow_) {
|
||||
+ }
|
||||
+
|
||||
+ if (bottomNonFullRow_ - topNonFullRow_ + 1 < numRows) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ unsigned columnFlags = makeColumnFlags(column, 1);
|
||||
+ int topGoodRow = 0;
|
||||
+ int smallestGoodTop = -1;
|
||||
+ int smallestGoodSize = maxRows_ + 1;
|
||||
+ int bottomRow = bottomNonFullRow_ + 1;
|
||||
+ bool found = false;
|
||||
+ for (int row = topNonFullRow_; row <= bottomRow; ++row) {
|
||||
+ bool rowEmpty = row < bottomRow ? ((rows_[row] & columnFlags) == 0) : false;
|
||||
+ if (rowEmpty) {
|
||||
+ if (!found) {
|
||||
+ topGoodRow = row;
|
||||
+ found = true;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (found) {
|
||||
+ int size = row - topGoodRow;
|
||||
+ if (size >= numRows && size < smallestGoodSize) {
|
||||
+ smallestGoodSize = size;
|
||||
+ smallestGoodTop = topGoodRow;
|
||||
+ }
|
||||
+ }
|
||||
+ found = false;
|
||||
+ }
|
||||
+ }
|
||||
+ if (smallestGoodTop < 0) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ *destRow = smallestGoodTop;
|
||||
+ if (destSize) {
|
||||
+ *destSize = smallestGoodSize;
|
||||
+ }
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool VariablePacker::CheckVariablesWithinPackingLimits(int maxVectors, const TVariableInfoList& in_variables)
|
||||
+{
|
||||
+ ASSERT(maxVectors > 0);
|
||||
+ maxRows_ = maxVectors;
|
||||
+ topNonFullRow_ = 0;
|
||||
+ bottomNonFullRow_ = maxRows_ - 1;
|
||||
+ TVariableInfoList variables(in_variables);
|
||||
+
|
||||
+ // As per GLSL 1.017 Appendix A, Section 7 variables are packed in specific
|
||||
+ // order by type, then by size of array, largest first.
|
||||
+ std::sort(variables.begin(), variables.end(), TVariableInfoComparer());
|
||||
+ rows_.clear();
|
||||
+ rows_.resize(maxVectors, 0);
|
||||
+
|
||||
+ // Packs the 4 column variables.
|
||||
+ size_t ii = 0;
|
||||
+ for (; ii < variables.size(); ++ii) {
|
||||
+ const TVariableInfo& variable = variables[ii];
|
||||
+ if (GetNumComponentsPerRow(variable.type) != 4) {
|
||||
+ break;
|
||||
+ }
|
||||
+ topNonFullRow_ += GetNumRows(variable.type) * variable.size;
|
||||
+ }
|
||||
+
|
||||
+ if (topNonFullRow_ > maxRows_) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Packs the 3 column variables.
|
||||
+ int num3ColumnRows = 0;
|
||||
+ for (; ii < variables.size(); ++ii) {
|
||||
+ const TVariableInfo& variable = variables[ii];
|
||||
+ if (GetNumComponentsPerRow(variable.type) != 3) {
|
||||
+ break;
|
||||
+ }
|
||||
+ num3ColumnRows += GetNumRows(variable.type) * variable.size;
|
||||
+ }
|
||||
+
|
||||
+ if (topNonFullRow_ + num3ColumnRows > maxRows_) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ fillColumns(topNonFullRow_, num3ColumnRows, 0, 3);
|
||||
+
|
||||
+ // Packs the 2 column variables.
|
||||
+ int top2ColumnRow = topNonFullRow_ + num3ColumnRows;
|
||||
+ int twoColumnRowsAvailable = maxRows_ - top2ColumnRow;
|
||||
+ int rowsAvailableInColumns01 = twoColumnRowsAvailable;
|
||||
+ int rowsAvailableInColumns23 = twoColumnRowsAvailable;
|
||||
+ for (; ii < variables.size(); ++ii) {
|
||||
+ const TVariableInfo& variable = variables[ii];
|
||||
+ if (GetNumComponentsPerRow(variable.type) != 2) {
|
||||
+ break;
|
||||
+ }
|
||||
+ int numRows = GetNumRows(variable.type) * variable.size;
|
||||
+ if (numRows <= rowsAvailableInColumns01) {
|
||||
+ rowsAvailableInColumns01 -= numRows;
|
||||
+ } else if (numRows <= rowsAvailableInColumns23) {
|
||||
+ rowsAvailableInColumns23 -= numRows;
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ int numRowsUsedInColumns01 =
|
||||
+ twoColumnRowsAvailable - rowsAvailableInColumns01;
|
||||
+ int numRowsUsedInColumns23 =
|
||||
+ twoColumnRowsAvailable - rowsAvailableInColumns23;
|
||||
+ fillColumns(top2ColumnRow, numRowsUsedInColumns01, 0, 2);
|
||||
+ fillColumns(maxRows_ - numRowsUsedInColumns23, numRowsUsedInColumns23,
|
||||
+ 2, 2);
|
||||
+
|
||||
+ // Packs the 1 column variables.
|
||||
+ for (; ii < variables.size(); ++ii) {
|
||||
+ const TVariableInfo& variable = variables[ii];
|
||||
+ ASSERT(1 == GetNumComponentsPerRow(variable.type));
|
||||
+ int numRows = GetNumRows(variable.type) * variable.size;
|
||||
+ int smallestColumn = -1;
|
||||
+ int smallestSize = maxRows_ + 1;
|
||||
+ int topRow = -1;
|
||||
+ for (int column = 0; column < kNumColumns; ++column) {
|
||||
+ int row = 0;
|
||||
+ int size = 0;
|
||||
+ if (searchColumn(column, numRows, &row, &size)) {
|
||||
+ if (size < smallestSize) {
|
||||
+ smallestSize = size;
|
||||
+ smallestColumn = column;
|
||||
+ topRow = row;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (smallestColumn < 0) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ fillColumns(topRow, numRows, smallestColumn, 1);
|
||||
+ }
|
||||
+
|
||||
+ ASSERT(variables.size() == ii);
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
diff --git a/gfx/angle/src/compiler/VariablePacker.h b/gfx/angle/src/compiler/VariablePacker.h
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gfx/angle/src/compiler/VariablePacker.h
|
||||
@@ -0,0 +1,41 @@
|
||||
+//
|
||||
+// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+//
|
||||
+
|
||||
+#ifndef _VARIABLEPACKER_INCLUDED_
|
||||
+#define _VARIABLEPACKER_INCLUDED_
|
||||
+
|
||||
+#include <vector>
|
||||
+#include "compiler/ShHandle.h"
|
||||
+
|
||||
+class VariablePacker {
|
||||
+ public:
|
||||
+ // Returns true if the passed in variables pack in maxVectors following
|
||||
+ // the packing rules from the GLSL 1.017 spec, Appendix A, section 7.
|
||||
+ bool CheckVariablesWithinPackingLimits(
|
||||
+ int maxVectors,
|
||||
+ const TVariableInfoList& in_variables);
|
||||
+
|
||||
+ // Gets how many components in a row a data type takes.
|
||||
+ static int GetNumComponentsPerRow(ShDataType type);
|
||||
+
|
||||
+ // Gets how many rows a data type takes.
|
||||
+ static int GetNumRows(ShDataType type);
|
||||
+
|
||||
+ private:
|
||||
+ static const int kNumColumns = 4;
|
||||
+ static const unsigned kColumnMask = (1 << kNumColumns) - 1;
|
||||
+
|
||||
+ unsigned makeColumnFlags(int column, int numComponentsPerRow);
|
||||
+ void fillColumns(int topRow, int numRows, int column, int numComponentsPerRow);
|
||||
+ bool searchColumn(int column, int numRows, int* destRow, int* destSize);
|
||||
+
|
||||
+ int topNonFullRow_;
|
||||
+ int bottomNonFullRow_;
|
||||
+ int maxRows_;
|
||||
+ std::vector<unsigned> rows_;
|
||||
+};
|
||||
+
|
||||
+#endif // _VARIABLEPACKER_INCLUDED_
|
||||
diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in
|
||||
--- a/gfx/angle/src/libGLESv2/Makefile.in
|
||||
+++ b/gfx/angle/src/libGLESv2/Makefile.in
|
||||
@@ -84,16 +84,17 @@ CPPSRCS = \
|
||||
ForLoopUnroll.cpp \
|
||||
MapLongVariableNames.cpp \
|
||||
spooky.cpp \
|
||||
BuiltInFunctionEmulator.cpp \
|
||||
Input.cpp \
|
||||
Lexer.cpp \
|
||||
Preprocessor.cpp \
|
||||
Token.cpp \
|
||||
+ VariablePacker.cpp \
|
||||
$(NULL)
|
||||
|
||||
# flex/yacc generated files
|
||||
CPPSRCS += \
|
||||
glslang_lex.cpp \
|
||||
glslang_tab.cpp \
|
||||
$(NULL)
|
||||
|
||||
diff --git a/gfx/angle/tests/build_tests.gyp b/gfx/angle/tests/build_tests.gyp
|
||||
--- a/gfx/angle/tests/build_tests.gyp
|
||||
+++ b/gfx/angle/tests/build_tests.gyp
|
||||
@@ -58,16 +58,35 @@
|
||||
'preprocessor_tests/pragma_test.cpp',
|
||||
'preprocessor_tests/PreprocessorTest.cpp',
|
||||
'preprocessor_tests/PreprocessorTest.h',
|
||||
'preprocessor_tests/space_test.cpp',
|
||||
'preprocessor_tests/token_test.cpp',
|
||||
'preprocessor_tests/version_test.cpp',
|
||||
],
|
||||
},
|
||||
+ {
|
||||
+ 'target_name': 'compiler_tests',
|
||||
+ 'type': 'executable',
|
||||
+ 'dependencies': [
|
||||
+ '../src/build_angle.gyp:translator_common',
|
||||
+ 'gtest',
|
||||
+ 'gmock',
|
||||
+ ],
|
||||
+ 'include_dirs': [
|
||||
+ '../include',
|
||||
+ '../src',
|
||||
+ '../third_party/googletest/include',
|
||||
+ '../third_party/googlemock/include',
|
||||
+ ],
|
||||
+ 'sources': [
|
||||
+ '../third_party/googlemock/src/gmock_main.cc',
|
||||
+ 'compiler_tests/VariablePacker_test.cpp',
|
||||
+ ],
|
||||
+ },
|
||||
],
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# tab-width:2
|
||||
# indent-tabs-mode:nil
|
||||
# End:
|
||||
# vim: set expandtab tabstop=2 shiftwidth=2:
|
||||
diff --git a/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp b/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/gfx/angle/tests/compiler_tests/VariablePacker_test.cpp
|
||||
@@ -0,0 +1,85 @@
|
||||
+//
|
||||
+// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+//
|
||||
+#include "compiler/VariablePacker.h"
|
||||
+#include "gtest/gtest.h"
|
||||
+
|
||||
+TEST(VariablePacking, Pack) {
|
||||
+ VariablePacker packer;
|
||||
+ TVariableInfoList vars;
|
||||
+ const int kMaxRows = 16;
|
||||
+ // test no vars.
|
||||
+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
|
||||
+
|
||||
+ ShDataType types[] = {
|
||||
+ SH_FLOAT_MAT4, // 0
|
||||
+ SH_FLOAT_MAT2, // 1
|
||||
+ SH_FLOAT_VEC4, // 2
|
||||
+ SH_INT_VEC4, // 3
|
||||
+ SH_BOOL_VEC4, // 4
|
||||
+ SH_FLOAT_MAT3, // 5
|
||||
+ SH_FLOAT_VEC3, // 6
|
||||
+ SH_INT_VEC3, // 7
|
||||
+ SH_BOOL_VEC3, // 8
|
||||
+ SH_FLOAT_VEC2, // 9
|
||||
+ SH_INT_VEC2, // 10
|
||||
+ SH_BOOL_VEC2, // 11
|
||||
+ SH_FLOAT, // 12
|
||||
+ SH_INT, // 13
|
||||
+ SH_BOOL, // 14
|
||||
+ SH_SAMPLER_2D, // 15
|
||||
+ SH_SAMPLER_CUBE, // 16
|
||||
+ SH_SAMPLER_EXTERNAL_OES, // 17
|
||||
+ SH_SAMPLER_2D_RECT_ARB, // 18
|
||||
+ };
|
||||
+
|
||||
+ for (size_t tt = 0; tt < sizeof(types) / sizeof(types[0]); ++tt) {
|
||||
+ ShDataType type = types[tt];
|
||||
+ int num_rows = VariablePacker::GetNumRows(type);
|
||||
+ int num_components_per_row = VariablePacker::GetNumComponentsPerRow(type);
|
||||
+ // Check 1 of the type.
|
||||
+ vars.clear();
|
||||
+ vars.push_back(TVariableInfo(type, 1));
|
||||
+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
|
||||
+
|
||||
+ // Check exactly the right amount of 1 type as an array.
|
||||
+ int num_vars = kMaxRows / num_rows;
|
||||
+ vars.clear();
|
||||
+ vars.push_back(TVariableInfo(type, num_vars));
|
||||
+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
|
||||
+
|
||||
+ // test too many
|
||||
+ vars.clear();
|
||||
+ vars.push_back(TVariableInfo(type, num_vars + 1));
|
||||
+ EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
|
||||
+
|
||||
+ // Check exactly the right amount of 1 type as individual vars.
|
||||
+ num_vars = kMaxRows / num_rows *
|
||||
+ ((num_components_per_row > 2) ? 1 : (4 / num_components_per_row));
|
||||
+ vars.clear();
|
||||
+ for (int ii = 0; ii < num_vars; ++ii) {
|
||||
+ vars.push_back(TVariableInfo(type, 1));
|
||||
+ }
|
||||
+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
|
||||
+
|
||||
+ // Check 1 too many.
|
||||
+ vars.push_back(TVariableInfo( type, 1));
|
||||
+ EXPECT_FALSE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
|
||||
+ }
|
||||
+
|
||||
+ // Test example from GLSL ES 3.0 spec chapter 11.
|
||||
+ vars.clear();
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT_VEC4, 1));
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT_MAT3, 1));
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT_MAT3, 1));
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 6));
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 4));
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT_VEC2, 1));
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT, 3));
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT, 2));
|
||||
+ vars.push_back(TVariableInfo(SH_FLOAT, 1));
|
||||
+ EXPECT_TRUE(packer.CheckVariablesWithinPackingLimits(kMaxRows, vars));
|
||||
+}
|
||||
+
|
|
@ -1,29 +0,0 @@
|
|||
# HG changeset patch
|
||||
# Parent 11023ab3d23865b71678e9a4b22a45646ec0c0f0
|
||||
diff --git a/gfx/angle/src/compiler/preprocessor/atom.c b/gfx/angle/src/compiler/preprocessor/atom.c
|
||||
--- a/gfx/angle/src/compiler/preprocessor/atom.c
|
||||
+++ b/gfx/angle/src/compiler/preprocessor/atom.c
|
||||
@@ -327,22 +327,17 @@ static int GrowAtomTable(AtomTable *atab
|
||||
newmap = realloc(atable->amap, sizeof(int)*size);
|
||||
newrev = realloc(atable->arev, sizeof(int)*size);
|
||||
} else {
|
||||
newmap = malloc(sizeof(int)*size);
|
||||
newrev = malloc(sizeof(int)*size);
|
||||
atable->size = 0;
|
||||
}
|
||||
if (!newmap || !newrev) {
|
||||
- /* failed to grow -- error */
|
||||
- if (newmap)
|
||||
- atable->amap = newmap;
|
||||
- if (newrev)
|
||||
- atable->arev = newrev;
|
||||
- return -1;
|
||||
+ abort();
|
||||
}
|
||||
memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int));
|
||||
memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int));
|
||||
atable->amap = newmap;
|
||||
atable->arev = newrev;
|
||||
atable->size = size;
|
||||
}
|
||||
return 0;
|
|
@ -1,5 +1,4 @@
|
|||
# HG changeset patch
|
||||
# Parent 8e2ee5b1a34208fd10f501fdee330878e20df599
|
||||
From: Jeff Gilbert <jgilbert@mozilla.com>
|
||||
|
||||
diff --git a/gfx/angle/src/compiler/Diagnostics.cpp b/gfx/angle/src/compiler/Diagnostics.cpp
|
||||
--- a/gfx/angle/src/compiler/Diagnostics.cpp
|
||||
|
@ -14,9 +13,9 @@ diff --git a/gfx/angle/src/compiler/Diagnostics.cpp b/gfx/angle/src/compiler/Dia
|
|||
#include "compiler/Diagnostics.h"
|
||||
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
+#include "compiler/compiler_debug.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/preprocessor/new/SourceLocation.h"
|
||||
#include "compiler/preprocessor/SourceLocation.h"
|
||||
|
||||
TDiagnostics::TDiagnostics(TInfoSink& infoSink) :
|
||||
mInfoSink(infoSink),
|
||||
|
@ -36,7 +35,7 @@ diff --git a/gfx/angle/src/compiler/DirectiveHandler.cpp b/gfx/angle/src/compile
|
|||
#include <sstream>
|
||||
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
+#include "compiler/compiler_debug.h"
|
||||
#include "compiler/Diagnostics.h"
|
||||
|
||||
static TBehavior getBehavior(const std::string& str)
|
||||
|
@ -57,15 +56,15 @@ diff --git a/gfx/angle/src/compiler/OutputGLSLBase.cpp b/gfx/angle/src/compiler/
|
|||
|
||||
#include "compiler/OutputGLSLBase.h"
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
+#include "compiler/compiler_debug.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
TString getTypeName(const TType& type)
|
||||
TString arrayBrackets(const TType& type)
|
||||
{
|
||||
ASSERT(type.isArray());
|
||||
TInfoSinkBase out;
|
||||
if (type.isMatrix())
|
||||
{
|
||||
out << "[" << type.getArraySize() << "]";
|
||||
diff --git a/gfx/angle/src/compiler/OutputHLSL.cpp b/gfx/angle/src/compiler/OutputHLSL.cpp
|
||||
--- a/gfx/angle/src/compiler/OutputHLSL.cpp
|
||||
+++ b/gfx/angle/src/compiler/OutputHLSL.cpp
|
||||
|
@ -79,7 +78,7 @@ diff --git a/gfx/angle/src/compiler/OutputHLSL.cpp b/gfx/angle/src/compiler/Outp
|
|||
|
||||
#include "common/angleutils.h"
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
+#include "compiler/compiler_debug.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/UnfoldShortCircuit.h"
|
||||
#include "compiler/SearchSymbol.h"
|
||||
|
@ -101,20 +100,20 @@ diff --git a/gfx/angle/src/compiler/Types.h b/gfx/angle/src/compiler/Types.h
|
|||
#include "compiler/BaseTypes.h"
|
||||
#include "compiler/Common.h"
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
+#include "compiler/compiler_debug.h"
|
||||
|
||||
class TType;
|
||||
struct TPublicType;
|
||||
|
||||
//
|
||||
// Need to have association of line numbers to types in a list for building structs.
|
||||
//
|
||||
class TType;
|
||||
struct TTypeLine {
|
||||
TType* type;
|
||||
int line;
|
||||
diff --git a/gfx/angle/src/compiler/debug.cpp b/gfx/angle/src/compiler/compilerdebug.cpp
|
||||
diff --git a/gfx/angle/src/compiler/debug.cpp b/gfx/angle/src/compiler/compiler_debug.cpp
|
||||
rename from gfx/angle/src/compiler/debug.cpp
|
||||
rename to gfx/angle/src/compiler/compilerdebug.cpp
|
||||
rename to gfx/angle/src/compiler/compiler_debug.cpp
|
||||
--- a/gfx/angle/src/compiler/debug.cpp
|
||||
+++ b/gfx/angle/src/compiler/compilerdebug.cpp
|
||||
+++ b/gfx/angle/src/compiler/compiler_debug.cpp
|
||||
@@ -1,17 +1,17 @@
|
||||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
|
@ -122,10 +121,11 @@ rename to gfx/angle/src/compiler/compilerdebug.cpp
|
|||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// debug.cpp: Debugging utilities.
|
||||
-// debug.cpp: Debugging utilities.
|
||||
+// compiler_debug.cpp: Debugging utilities.
|
||||
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
+#include "compiler/compiler_debug.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
@ -134,11 +134,11 @@ rename to gfx/angle/src/compiler/compilerdebug.cpp
|
|||
#include "compiler/ParseHelper.h"
|
||||
|
||||
static const int kTraceBufferLen = 1024;
|
||||
diff --git a/gfx/angle/src/compiler/debug.h b/gfx/angle/src/compiler/compilerdebug.h
|
||||
diff --git a/gfx/angle/src/compiler/debug.h b/gfx/angle/src/compiler/compiler_debug.h
|
||||
rename from gfx/angle/src/compiler/debug.h
|
||||
rename to gfx/angle/src/compiler/compilerdebug.h
|
||||
rename to gfx/angle/src/compiler/compiler_debug.h
|
||||
--- a/gfx/angle/src/compiler/debug.h
|
||||
+++ b/gfx/angle/src/compiler/compilerdebug.h
|
||||
+++ b/gfx/angle/src/compiler/compiler_debug.h
|
||||
@@ -1,15 +1,15 @@
|
||||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
|
@ -147,7 +147,7 @@ rename to gfx/angle/src/compiler/compilerdebug.h
|
|||
//
|
||||
|
||||
-// debug.h: Debugging utilities.
|
||||
+// compilerdebug.h: Debugging utilities.
|
||||
+// compiler_debug.h: Debugging utilities.
|
||||
|
||||
#ifndef COMPILER_DEBUG_H_
|
||||
#define COMPILER_DEBUG_H_
|
||||
|
@ -159,88 +159,22 @@ rename to gfx/angle/src/compiler/compilerdebug.h
|
|||
diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h
|
||||
--- a/gfx/angle/src/compiler/osinclude.h
|
||||
+++ b/gfx/angle/src/compiler/osinclude.h
|
||||
@@ -32,17 +32,17 @@
|
||||
@@ -30,17 +30,17 @@
|
||||
#include <windows.h>
|
||||
#elif defined(ANGLE_OS_POSIX)
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#endif // ANGLE_USE_NSPR
|
||||
#endif // ANGLE_OS_WIN
|
||||
|
||||
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
+#include "compiler/compiler_debug.h"
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
#if defined(ANGLE_USE_NSPR)
|
||||
typedef PRUintn OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
||||
#elif defined(ANGLE_OS_WIN)
|
||||
diff --git a/gfx/angle/src/compiler/preprocessor/atom.c b/gfx/angle/src/compiler/preprocessor/atom.c
|
||||
--- a/gfx/angle/src/compiler/preprocessor/atom.c
|
||||
+++ b/gfx/angle/src/compiler/preprocessor/atom.c
|
||||
@@ -46,17 +46,17 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILI
|
||||
// atom.c
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common/angleutils.h"
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
#include "compiler/preprocessor/slglobals.h"
|
||||
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
#undef free
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////// String table: //////////////////////////////////////
|
||||
diff --git a/gfx/angle/src/compiler/preprocessor/tokens.c b/gfx/angle/src/compiler/preprocessor/tokens.c
|
||||
--- a/gfx/angle/src/compiler/preprocessor/tokens.c
|
||||
+++ b/gfx/angle/src/compiler/preprocessor/tokens.c
|
||||
@@ -46,17 +46,17 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILI
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "common/angleutils.h"
|
||||
-#include "compiler/debug.h"
|
||||
+#include "compiler/compilerdebug.h"
|
||||
#include "compiler/preprocessor/slglobals.h"
|
||||
#include "compiler/util.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4054)
|
||||
#pragma warning(disable: 4152)
|
||||
#endif
|
||||
|
||||
diff --git a/gfx/angle/src/compiler/translator_common.vcproj b/gfx/angle/src/compiler/translator_common.vcproj
|
||||
--- a/gfx/angle/src/compiler/translator_common.vcproj
|
||||
+++ b/gfx/angle/src/compiler/translator_common.vcproj
|
||||
@@ -580,17 +580,17 @@
|
||||
RelativePath=".\Common.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ConstantUnion.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
- RelativePath=".\debug.h"
|
||||
+ RelativePath=".\compilerdebug.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DetectRecursion.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Diagnostics.h"
|
||||
#if defined(ANGLE_OS_WIN)
|
||||
typedef DWORD OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES)
|
||||
#elif defined(ANGLE_OS_POSIX)
|
|
@ -0,0 +1,8 @@
|
|||
From: Jeff Gilbert <jgilbert@mozilla.com>
|
||||
|
||||
diff --git a/gfx/angle/src/compiler/preprocessor/Diagnostics.cpp b/gfx/angle/src/compiler/preprocessor/PreprocessorDiagnostics.cpp
|
||||
rename from gfx/angle/src/compiler/preprocessor/Diagnostics.cpp
|
||||
rename to gfx/angle/src/compiler/preprocessor/PreprocessorDiagnostics.cpp
|
||||
diff --git a/gfx/angle/src/compiler/preprocessor/DirectiveHandler.cpp b/gfx/angle/src/compiler/preprocessor/PreprocessorDirectiveHandler.cpp
|
||||
rename from gfx/angle/src/compiler/preprocessor/DirectiveHandler.cpp
|
||||
rename to gfx/angle/src/compiler/preprocessor/PreprocessorDirectiveHandler.cpp
|
|
@ -1,13 +1,19 @@
|
|||
From: Jeff Gilbert <jgilbert@mozilla.com>
|
||||
|
||||
diff --git a/gfx/angle/src/libGLESv2/libGLESv2.def b/gfx/angle/src/libGLESv2/libGLESv2.def
|
||||
index 5f935c3..2324dcb 100644
|
||||
--- a/gfx/angle/src/libGLESv2/libGLESv2.def
|
||||
+++ b/gfx/angle/src/libGLESv2/libGLESv2.def
|
||||
@@ -180,3 +180,8 @@ EXPORTS
|
||||
@@ -175,8 +175,13 @@ EXPORTS
|
||||
|
||||
; EGL dependencies
|
||||
glCreateContext @144 NONAME
|
||||
glDestroyContext @145 NONAME
|
||||
glMakeCurrent @146 NONAME
|
||||
glGetCurrentContext @147 NONAME
|
||||
glGetProcAddress @148 NONAME
|
||||
glBindTexImage @158 NONAME
|
||||
+
|
||||
+ ; GCC has problems with linking to undecored stdcall functions,
|
||||
+ ; so we explicitly add aliases for APIs used by EGL
|
||||
+ ; GCC has problems with linking to undecorated stdcall functions,
|
||||
+ ; so we explicitly add aliases for APIs used by EGL.
|
||||
+ glGetProcAddress@4=glGetProcAddress
|
||||
+ glBindTexImage@4=glBindTexImage
|
|
@ -1,33 +0,0 @@
|
|||
# HG changeset patch
|
||||
# Parent a1fed68f51737972901e0d6fc829d3e044a453bd
|
||||
diff --git a/gfx/angle/src/libGLESv2/libGLESv2.cpp b/gfx/angle/src/libGLESv2/libGLESv2.cpp
|
||||
--- a/gfx/angle/src/libGLESv2/libGLESv2.cpp
|
||||
+++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp
|
||||
@@ -231,27 +231,16 @@ bool validReadFormatType(GLenum format,
|
||||
switch (type)
|
||||
{
|
||||
case GL_UNSIGNED_BYTE:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
- case GL_BGRA_EXT:
|
||||
- switch (type)
|
||||
- {
|
||||
- case GL_UNSIGNED_BYTE:
|
||||
- case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
|
||||
- case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
|
||||
- break;
|
||||
- default:
|
||||
- return false;
|
||||
- }
|
||||
- break;
|
||||
case gl::IMPLEMENTATION_COLOR_READ_FORMAT:
|
||||
switch (type)
|
||||
{
|
||||
case gl::IMPLEMENTATION_COLOR_READ_TYPE:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
# HG changeset patch
|
||||
# Parent 97ded57f965865c06306a8ef82d082064542caff
|
||||
diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp
|
||||
--- a/gfx/angle/src/libGLESv2/Context.cpp
|
||||
+++ b/gfx/angle/src/libGLESv2/Context.cpp
|
||||
@@ -2585,16 +2585,17 @@ void Context::readPixels(GLint x, GLint
|
||||
{
|
||||
if (desc.Format == D3DFMT_A8R8G8B8 &&
|
||||
format == GL_BGRA_EXT &&
|
||||
type == GL_UNSIGNED_BYTE)
|
||||
{
|
||||
// Fast path for EXT_read_format_bgra, given
|
||||
// an RGBA source buffer. Note that buffers with no
|
||||
// alpha go through the slow path below.
|
||||
+ // Note that this is also the combo exposed by IMPLEMENTATION_COLOR_READ_TYPE/FORMAT
|
||||
memcpy(dest + j * outputPitch,
|
||||
source + j * inputPitch,
|
||||
(rect.right - rect.left) * 4);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rect.right - rect.left; i++)
|
||||
{
|
||||
@@ -2732,20 +2733,20 @@ void Context::readPixels(GLint x, GLint
|
||||
((unsigned short)( a + 0.5f) << 15) |
|
||||
((unsigned short)(31 * r + 0.5f) << 10) |
|
||||
((unsigned short)(31 * g + 0.5f) << 5) |
|
||||
((unsigned short)(31 * b + 0.5f) << 0);
|
||||
break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
break;
|
||||
- case GL_RGB: // IMPLEMENTATION_COLOR_READ_FORMAT
|
||||
+ case GL_RGB:
|
||||
switch (type)
|
||||
{
|
||||
- case GL_UNSIGNED_SHORT_5_6_5: // IMPLEMENTATION_COLOR_READ_TYPE
|
||||
+ case GL_UNSIGNED_SHORT_5_6_5:
|
||||
dest16[i + j * outputPitch / sizeof(unsigned short)] =
|
||||
((unsigned short)(31 * b + 0.5f) << 0) |
|
||||
((unsigned short)(63 * g + 0.5f) << 5) |
|
||||
((unsigned short)(31 * r + 0.5f) << 11);
|
||||
break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
break;
|
||||
diff --git a/gfx/angle/src/libGLESv2/Context.h b/gfx/angle/src/libGLESv2/Context.h
|
||||
--- a/gfx/angle/src/libGLESv2/Context.h
|
||||
+++ b/gfx/angle/src/libGLESv2/Context.h
|
||||
@@ -69,18 +69,18 @@ enum
|
||||
MAX_VARYING_VECTORS_SM3 = 10,
|
||||
MAX_TEXTURE_IMAGE_UNITS = 16,
|
||||
MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF = 4, // For devices supporting vertex texture fetch
|
||||
MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF,
|
||||
MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Coord, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers.
|
||||
MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3,
|
||||
MAX_DRAW_BUFFERS = 1,
|
||||
|
||||
- IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB,
|
||||
- IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5
|
||||
+ IMPLEMENTATION_COLOR_READ_FORMAT = GL_BGRA_EXT,
|
||||
+ IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_BYTE
|
||||
};
|
||||
|
||||
enum QueryType
|
||||
{
|
||||
QUERY_ANY_SAMPLES_PASSED,
|
||||
QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE,
|
||||
|
||||
QUERY_TYPE_COUNT
|
|
@ -1,6 +1,27 @@
|
|||
# HG changeset patch
|
||||
# Parent c5e7517cbb1c38ce9821ba3deca88768b4dff066
|
||||
# Parent 6a165b9e45205190517515abec94429715303081
|
||||
|
||||
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
|
||||
--- a/gfx/angle/Makefile.in
|
||||
+++ b/gfx/angle/Makefile.in
|
||||
@@ -73,16 +73,17 @@ CPPSRCS += \
|
||||
intermOut.cpp \
|
||||
IntermTraverse.cpp \
|
||||
MapLongVariableNames.cpp \
|
||||
parseConst.cpp \
|
||||
ParseHelper.cpp \
|
||||
PoolAlloc.cpp \
|
||||
QualifierAlive.cpp \
|
||||
RemoveTree.cpp \
|
||||
+ spooky.cpp \
|
||||
SymbolTable.cpp \
|
||||
util.cpp \
|
||||
ValidateLimitations.cpp \
|
||||
VariableInfo.cpp \
|
||||
VariablePacker.cpp \
|
||||
$(NULL)
|
||||
|
||||
VPATH += $(srcdir)/src/compiler/depgraph
|
||||
diff --git a/gfx/angle/src/compiler/MapLongVariableNames.cpp b/gfx/angle/src/compiler/MapLongVariableNames.cpp
|
||||
--- a/gfx/angle/src/compiler/MapLongVariableNames.cpp
|
||||
+++ b/gfx/angle/src/compiler/MapLongVariableNames.cpp
|
||||
|
@ -699,3 +720,24 @@ new file mode 100644
|
|||
+
|
||||
+
|
||||
+
|
||||
diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in
|
||||
--- a/gfx/angle/src/libGLESv2/Makefile.in
|
||||
+++ b/gfx/angle/src/libGLESv2/Makefile.in
|
||||
@@ -86,16 +86,17 @@ CPPSRCS += \
|
||||
intermOut.cpp \
|
||||
IntermTraverse.cpp \
|
||||
MapLongVariableNames.cpp \
|
||||
parseConst.cpp \
|
||||
ParseHelper.cpp \
|
||||
PoolAlloc.cpp \
|
||||
QualifierAlive.cpp \
|
||||
RemoveTree.cpp \
|
||||
+ spooky.cpp \
|
||||
SymbolTable.cpp \
|
||||
util.cpp \
|
||||
ValidateLimitations.cpp \
|
||||
VariableInfo.cpp \
|
||||
VariablePacker.cpp \
|
||||
$(NULL)
|
||||
|
||||
VPATH += $(srcdir)/../compiler/depgraph
|
|
@ -1,6 +0,0 @@
|
|||
# HG changeset patch
|
||||
# Parent 2cd2556d673d90f79dc29a78a927d2a38b92e14b
|
||||
|
||||
diff --git a/gfx/angle/src/compiler/preprocessor/new/Diagnostics.cpp b/gfx/angle/src/compiler/preprocessor/new/PreprocessorDiagnostics.cpp
|
||||
rename from gfx/angle/src/compiler/preprocessor/new/Diagnostics.cpp
|
||||
rename to gfx/angle/src/compiler/preprocessor/new/PreprocessorDiagnostics.cpp
|
|
@ -1,6 +0,0 @@
|
|||
# HG changeset patch
|
||||
# Parent a98ccd93f2ab811670cb50edca50f6381274a345
|
||||
|
||||
diff --git a/gfx/angle/src/compiler/preprocessor/new/DirectiveHandler.cpp b/gfx/angle/src/compiler/preprocessor/new/PreprocessorDirectiveHandler.cpp
|
||||
rename from gfx/angle/src/compiler/preprocessor/new/DirectiveHandler.cpp
|
||||
rename to gfx/angle/src/compiler/preprocessor/new/PreprocessorDirectiveHandler.cpp
|
|
@ -0,0 +1,383 @@
|
|||
Name
|
||||
|
||||
ANGLE_multiple_render_targets
|
||||
|
||||
Name Strings
|
||||
|
||||
GL_ANGLE_multiple_render_targets
|
||||
|
||||
Contributors
|
||||
|
||||
Contributors to GL_NV_draw_buffers
|
||||
Contributors to GL_NV_fbo_color_attachments
|
||||
Contributors to the OpenGL ES 2.0 specification
|
||||
Contributors to the OpenGLSL ES 1.0.17 specification
|
||||
Contributors to the OpenGL ES 3.0 specification
|
||||
Nicolas Capens, TransGaming Inc.
|
||||
Daniel Koch, TransGaming Inc.
|
||||
Alastair Patrick, Google Inc.
|
||||
Members of the WebGL working group
|
||||
|
||||
Contact
|
||||
|
||||
Daniel Koch <daniel> <at> <transgaming> <dot> <com>
|
||||
|
||||
Status
|
||||
|
||||
Incomplete -- do not implement!
|
||||
|
||||
Version
|
||||
|
||||
Last Modified Data: November 13, 2012
|
||||
Revision: #5
|
||||
|
||||
Number
|
||||
|
||||
TBD
|
||||
|
||||
Dependencies
|
||||
|
||||
OpenGL ES 2.0 is required.
|
||||
|
||||
The extension is written against the OpenGL ES 2.0 specification.
|
||||
|
||||
ANGLE_framebuffer_blit affects the definition of this extension.
|
||||
APPLE_framebuffer_multisample affects the definitin of this extension.
|
||||
|
||||
Overview
|
||||
|
||||
This extension increases the number of available framebuffer object
|
||||
color attachment points, extends OpenGL ES 2.0 to allow multiple output
|
||||
colors, and provides a mechanism for directing those outputs to
|
||||
multiple color buffers.
|
||||
|
||||
This extension is similar to the combination of the GL_NV_draw_buffers
|
||||
and GL_NV_fbo_color_attachments extensions, but imposes certain
|
||||
restrictions informed by the OpenGL ES 3.0 API.
|
||||
|
||||
New Procedures and Functions
|
||||
|
||||
void DrawBuffersANGLE(sizei n, const enum *bufs);
|
||||
|
||||
New Tokens
|
||||
|
||||
Accepted by the <pname> parameter of GetIntegerv:
|
||||
|
||||
MAX_COLOR_ATTACHMENTS_ANGLE 0x8CDF
|
||||
|
||||
Accepted by the <pname> parameters of GetIntegerv and GetFloatv:
|
||||
|
||||
MAX_DRAW_BUFFERS_ANGLE 0x8824
|
||||
DRAW_BUFFER0_ANGLE 0x8825
|
||||
DRAW_BUFFER1_ANGLE 0x8826
|
||||
DRAW_BUFFER2_ANGLE 0x8827
|
||||
DRAW_BUFFER3_ANGLE 0x8828
|
||||
DRAW_BUFFER4_ANGLE 0x8829
|
||||
DRAW_BUFFER5_ANGLE 0x882A
|
||||
DRAW_BUFFER6_ANGLE 0x882B
|
||||
DRAW_BUFFER7_ANGLE 0x882C
|
||||
DRAW_BUFFER8_ANGLE 0x882D
|
||||
DRAW_BUFFER9_ANGLE 0x882E
|
||||
DRAW_BUFFER10_ANGLE 0x882F
|
||||
DRAW_BUFFER11_ANGLE 0x8830
|
||||
DRAW_BUFFER12_ANGLE 0x8831
|
||||
DRAW_BUFFER13_ANGLE 0x8832
|
||||
DRAW_BUFFER14_ANGLE 0x8833
|
||||
DRAW_BUFFER15_ANGLE 0x8834
|
||||
|
||||
Accepted by the <attachment> parameter of FramebufferRenderbuffer,
|
||||
FramebufferTexture2D and GetFramebufferAttachmentParameteriv, and by
|
||||
the <bufs> parameter of DrawBuffersANGLE:
|
||||
|
||||
COLOR_ATTACHMENT0_ANGLE 0x8CE0
|
||||
COLOR_ATTACHMENT1_ANGLE 0x8CE1
|
||||
COLOR_ATTACHMENT2_ANGLE 0x8CE2
|
||||
COLOR_ATTACHMENT3_ANGLE 0x8CE3
|
||||
COLOR_ATTACHMENT4_ANGLE 0x8CE4
|
||||
COLOR_ATTACHMENT5_ANGLE 0x8CE5
|
||||
COLOR_ATTACHMENT6_ANGLE 0x8CE6
|
||||
COLOR_ATTACHMENT7_ANGLE 0x8CE7
|
||||
COLOR_ATTACHMENT8_ANGLE 0x8CE8
|
||||
COLOR_ATTACHMENT9_ANGLE 0x8CE9
|
||||
COLOR_ATTACHMENT10_ANGLE 0x8CEA
|
||||
COLOR_ATTACHMENT11_ANGLE 0x8CEB
|
||||
COLOR_ATTACHMENT12_ANGLE 0x8CEC
|
||||
COLOR_ATTACHMENT13_ANGLE 0x8CED
|
||||
COLOR_ATTACHMENT14_ANGLE 0x8CEE
|
||||
COLOR_ATTACHMENT15_ANGLE 0x8CEF
|
||||
|
||||
The COLOR_ATTACHMENT0_ANGLE constant is equal to the
|
||||
COLOR_ATTACHMENT0 constant.
|
||||
|
||||
Each COLOR_ATTACHMENT<i>_ANGLE adheres to COLOR_ATTACHMENT<i>_ANGLE
|
||||
= COLOR_ATTACHMENT0_ANGLE + <i>.
|
||||
|
||||
Changes to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization)
|
||||
|
||||
Section 3.2, (Multisampling). Replace the second paragraph:
|
||||
|
||||
An additional buffer, called the multisample buffer, is added to the
|
||||
window system-provided framebuffer. Pixel sample values, including
|
||||
color, depth, and stencil values, are stored in this buffer. Samples
|
||||
contain separate color values for each fragment color. When the
|
||||
window system-provided framebuffer includes a multisample buffer, it
|
||||
does not include depth or stencil buffers, even if the multisample
|
||||
buffer does not store depth or stencil values. Color buffers do
|
||||
coexist with the multisample buffer, however.
|
||||
|
||||
Section 3.8.2, (Shader Execution) Replace subsection "Shader
|
||||
Outputs":
|
||||
|
||||
The OpenGL ES Shading Language specification describes the values
|
||||
that may be output by a fragment shader. These are gl_FragColor and
|
||||
gl_FragData[n]. The final fragment color values or the final
|
||||
fragment data values written by a fragment shader are clamped to the
|
||||
range [0, 1] and then converted to fixed-point as described in
|
||||
section 2.1.2 for framebuffer color components.
|
||||
|
||||
Writing to gl_FragColor specifies the fragment color (color number
|
||||
zero) that will be used by subsequent stages of the pipeline.
|
||||
Writing to gl_FragData[n] specifies the value of fragment color
|
||||
number n. Any colors, or color components, associated with a
|
||||
fragment that are not written by the fragment shader are undefined.
|
||||
A fragment shader may not statically assign values to both
|
||||
gl_FragColor and gl_FragData. In this case, a compile or link error
|
||||
will result. A shader statically assigns a value to a variable if,
|
||||
after preprocessing, it contains a statement that would write to the
|
||||
variable, whether or not run-time flow of control will cause that
|
||||
statement to be executed.
|
||||
|
||||
Changes to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment
|
||||
Operations and the Frame Buffer)
|
||||
|
||||
Insert Table 4.3 (and renumber subsequent tables): Arguments to
|
||||
DrawBuffersANGLE when the context is bound to a framebuffer
|
||||
object, and the buffers they indicate. <i> in
|
||||
COLOR_ATTACHMENT<i>_ANGLE may range from zero to the value of
|
||||
MAX_COLOR_ATTACHMENTS_ANGLE minus one.
|
||||
|
||||
Symbolic Constant Meaning
|
||||
----------------- ---------------------
|
||||
NONE No buffer
|
||||
|
||||
COLOR_ATTACHMENT<i>_ANGLE (see caption) Output fragment color to image
|
||||
attached at color attachment
|
||||
point i
|
||||
|
||||
|
||||
Replace Section 4.2.1, "Selecting a Buffer for Writing" with the following:
|
||||
|
||||
"By default, color values are written into the front buffer for
|
||||
single buffered surfaces or into the back buffer for back buffered
|
||||
surfaces as determined when making the context current. To control
|
||||
the color buffer into which each of the fragment color values is
|
||||
written, DrawBuffersANGLE is used.
|
||||
|
||||
The command
|
||||
|
||||
void DrawBuffersANGLE(sizei n, const enum *bufs);
|
||||
|
||||
defines the draw buffers to which all fragment colors are written.
|
||||
<n> specifies the number of buffers in <bufs>. <bufs> is a pointer
|
||||
to an array of symbolic constants specifying the buffer to which
|
||||
each fragment color is written.
|
||||
|
||||
Each buffer listed in <bufs> must be BACK, NONE, or one of the
|
||||
values from table 4.3. Further, acceptable values for the constants
|
||||
in <bufs> depend on whether the GL is using the default framebuffer
|
||||
(i.e., DRAW_FRAMEBUFFER_BINDING is zero), or a framebuffer object
|
||||
(i.e., DRAW_FRAMEBUFFER_BINDING is non-zero). For more information
|
||||
about framebuffer objects, see section 4.4.
|
||||
|
||||
If the GL is bound to the default framebuffer, then <n> must be 1
|
||||
and the constant must be BACK or NONE. When draw buffer zero is
|
||||
BACK, color values are written into the sole buffer for single-
|
||||
buffered contexts, or into the back buffer for double-buffered
|
||||
contexts. If DrawBuffersANGLE is supplied with a constant other than
|
||||
BACK and NONE, the error INVALID_OPERATION is generated.
|
||||
|
||||
If the GL is bound to a draw framebuffer object, then each of the
|
||||
constants must be one of the values listed in table 4.3.
|
||||
|
||||
In both cases, the draw buffers being defined correspond in order to
|
||||
the respective fragment colors. The draw buffer for fragment
|
||||
colors beyond <n> is set to NONE.
|
||||
|
||||
The maximum number of draw buffers is implementation-dependent. The
|
||||
number of draw buffers supported can be queried by calling
|
||||
GetIntegerv with the symbolic constant MAX_DRAW_BUFFERS_ANGLE. An
|
||||
INVALID_VALUE error is generated if <n> is greater than
|
||||
MAX_DRAW_BUFFERS_ANGLE.
|
||||
|
||||
If the GL is bound to a draw framebuffer object, the <i>th buffer listed
|
||||
in <bufs> must be COLOR_ATTACHMENT<i>_ANGLE or NONE. Specifying a
|
||||
buffer out of order, BACK, or COLOR_ATTACHMENT<m>_ANGLE where <m> is
|
||||
greater than or equal to the value of MAX_COLOR_ATTACHMENTS_ANGLE,
|
||||
will generate the error INVALID_OPERATION.
|
||||
|
||||
If a fragment shader writes to "gl_FragColor", DrawBuffersANGLE
|
||||
specifies a set of draw buffers into which the color written to
|
||||
"gl_FragColor" is written. If a fragment shader writes to
|
||||
"gl_FragData", DrawBuffersANGLE specifies a set of draw buffers
|
||||
into which each of the multiple output colors defined by these
|
||||
variables are separately written. If a fragment shader writes to
|
||||
neither "gl_FragColor" nor "gl_FragData" the values of the
|
||||
fragment colors following shader execution are undefined, and may
|
||||
differ for each fragment color.
|
||||
|
||||
Indicating a buffer or buffers using DrawBuffersANGLE causes
|
||||
subsequent pixel color value writes to affect the indicated
|
||||
buffers. If the GL is bound to a draw framebuffer object and a draw
|
||||
buffer selects an attachment that has no image attached, then that
|
||||
fragment color is not written.
|
||||
|
||||
Specifying NONE as the draw buffer for a fragment color will inhibit
|
||||
that fragment color from being written.
|
||||
|
||||
The state required to handle color buffer selection for each
|
||||
framebuffer is an integer for each supported fragment color. For the
|
||||
default framebuffer, in the initial state the draw buffer for
|
||||
fragment color zero is BACK if there is a default framebuffer
|
||||
associated with the context, otherwise NONE. For framebuffer
|
||||
objects, in the initial state the draw buffer for fragment color
|
||||
zero is COLOR_ATTACHMENT0_ANGLE.
|
||||
|
||||
For both the default framebuffer and framebuffer objects, the
|
||||
initial state of draw buffers for fragment colors other than zero is
|
||||
NONE.
|
||||
|
||||
The value of the draw buffer selected for fragment color <i> can be
|
||||
queried by calling GetIntegerv with the symbolic constant
|
||||
DRAW_BUFFER<i>_ANGLE."
|
||||
|
||||
Replace the second paragraph of Section 4.4.1 (Binding and Managing
|
||||
Framebuffer Objects) with the following:
|
||||
|
||||
"The namespace for framebuffer objects is the unsigned integers, with
|
||||
zero reserved by OpenGL ES to refer to the default framebuffer. A
|
||||
framebuffer object is created by binding an unused name to the
|
||||
target FRAMEBUFFER, DRAW_FRAMEBUFFER, or READ_FRAMEBUFFER. The binding
|
||||
is effected by calling
|
||||
|
||||
void BindFramebuffer(enum target, uint framebuffer);
|
||||
|
||||
with <target> set the desired framebuffer target and <framebuffer> set
|
||||
to the unused name. The resulting framebuffer object is a new state
|
||||
vector. There is a number of color attachment points, plus one each
|
||||
for the depth and stencil attachment points. The number of color attachment
|
||||
points is equal to the value of MAX_COLOR_ATTACHMENTS_ANGLE."
|
||||
|
||||
Changes to Chapter 3 of the OpenGL ES Shading Language 1.0.17 Specification (Basics)
|
||||
|
||||
Add a new section:
|
||||
|
||||
3.4.1 GL_ANGLE_multiple_render_targets Extension
|
||||
|
||||
To use the GL_ANGLE_multiple_render_targets extension in a shader it
|
||||
must be enabled using the #extension directive.
|
||||
|
||||
The shading language preprocessor #define
|
||||
GL_ANGLE_multiple_render_targets will be defined to 1, if the
|
||||
GL_ANGLE_multiple_render_targets extension is supported.
|
||||
|
||||
Dependencies on ANGLE_framebuffer_blit and APPLE_framebuffer_multisample:
|
||||
|
||||
If neither ANGLE_framebuffer_blit nor APPLE_framebuffer_multisample are
|
||||
supported, then all references to "draw framebuffers" should be replaced
|
||||
with references to "framebuffers". References to DRAW_FRAMEBUFFER_BINDING
|
||||
should be replaced with references to FRAMEBUFFER_BINDING. References to
|
||||
DRAW_FRAMEBUFFER and READ_FRAMEBUFFER should be removed.
|
||||
|
||||
If ANGLE_framebuffer_blit is supported, DRAW_FRAMEBUFFER_BINDING, DRAW_FRAMEBUFFER
|
||||
and READ_FRAMEBUFFER all refer to corresponding _ANGLE suffixed names
|
||||
(they have the same token values).
|
||||
|
||||
If APPLE_framebuffer_multisample is supported, DRAW_FRAMEBUFFER_BINDING,
|
||||
DRAW_FRAMEBUFFER and READ_FRAMEBUFFER all refer to the corresponding _APPLE
|
||||
suffixed names (they have the same token values).
|
||||
|
||||
Errors
|
||||
|
||||
<TBD>
|
||||
|
||||
New State
|
||||
|
||||
Add Table 6.X Framebuffer (State per framebuffer object):
|
||||
|
||||
State Type Get Command Initial Value Description
|
||||
--------------- ---- ------------ ------------- -----------
|
||||
DRAW_BUFFER<i>_ANGLE Z10* GetIntegerv see 4.2.1 Draw buffer selected
|
||||
for fragment color i
|
||||
|
||||
Add to Table 6.18 (Implementation Dependent Values)
|
||||
|
||||
Get value Type Get Cmnd Minimum Value Description Sec.
|
||||
------------------------ ---- ----------- ------------- ----------- -----
|
||||
MAX_DRAW_BUFFERS_ANGLE Z+ GetIntegerv 1 Maximum number of 4.2.1
|
||||
active draw buffers
|
||||
MAX_COLOR_ATTACHMENTS_ANGLE Z+ GetIntegerv 1 Number of framebuffer 4.4.1
|
||||
color attachment points
|
||||
Issues
|
||||
|
||||
See ARB_draw_buffers for relevant issues.
|
||||
|
||||
1) Differences from NV_draw_buffers + NV_fbo_color_attachments?
|
||||
|
||||
- interactions with blit_framebuffer
|
||||
- MAX limits are global instead of per-fbo (TBD - Issue 2)
|
||||
- no broadcast from gl_FragColor (TBD - Issue 3)
|
||||
- can be used to with default framebuffer to set NONE/BACK (TBD - Issue 4)
|
||||
|
||||
2) Should the MAX_DRAW_BUFFERS_ANGLE and MAX_COLOR_ATTACHMENTS_ANGLE limits
|
||||
be per-framebuffer values or implementation dependent constants?
|
||||
|
||||
DISCUSSION: In ARB_draw_buffers this was per-context (see Issue 2).
|
||||
EXT_framebuffer_object (and subsequently ARB_framebuffer_object, and GL 3.0
|
||||
through GL 4.2) made these queries framebuffer-dependent.
|
||||
However GL in 4.3 and GLES 3.0, these limits were moved from
|
||||
framebuffer-dependent state to implementation-dependent state after
|
||||
much discussion (Bug 7990).
|
||||
|
||||
NV_draw_buffers has MAX_DRAW_BUFFERS listed as per-framebuffer state,
|
||||
but NV_fbo_color_attachments has MAX_COLOR_ATTACHMENTS as an
|
||||
implementation-dependent constant.
|
||||
|
||||
This is relevant because some implementations are not able to support
|
||||
multisampling in conjuction with multiple color attachments. If the
|
||||
query is per-framebuffer, they can report a maximum of one attachment
|
||||
when there are multisampled attachments, but a higher limit when only
|
||||
single-sampled attachments are present.
|
||||
|
||||
3) Should we support broadcast from gl_FragColor to all gl_FragData[x]
|
||||
or should it be synonymous with gl_FragData[0]?
|
||||
|
||||
DISCUSSION: With NV_draw_buffers, writing to gl_FragColor writes to all
|
||||
the enabled draw buffers (ie broadcast). In OpenGL ES 3.0 when using
|
||||
ESSL 1.0, gl_FragColor is equivalent to writing a single output to
|
||||
gl_FragData[0] and multiple outputs are not possible. When using ESSL 3.0,
|
||||
only user-defined out variables may be used.
|
||||
|
||||
If broadcast is supported, some implementations may have to replace
|
||||
writes to gl_FragColor with replicated writes to all possible gl_FragData
|
||||
locations when this extension is enabled.
|
||||
|
||||
4) Should we allow DrawBuffersANGLE to be called when the default FBO is bound?
|
||||
|
||||
DISCUSSION: NV_draw_buffers specifies that DrawBuffersNV errors with
|
||||
INVALID_OPERATION when the default FBO is bound. OpenGL ES 3.0 allows
|
||||
DrawBuffers to toggle between BACK and NONE on the default FBO.
|
||||
|
||||
An implementation that does not natively support disabling the drawbuffer
|
||||
on the default FBO could emulate this by disabling color writes.
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
11/13/2012 dgkoch add revision history
|
||||
add text from updated ES 3.0 spec
|
||||
add issues for discussion
|
||||
10/16/2012 kbr update name string
|
||||
10/16/2012 kbr remove restrition requiring draw buffer 0 to be non-NULL
|
||||
10/12/2012 kbr remove references to GetDoublev and ReadBuffer
|
||||
10/11/2012 kbr initial draft extension
|
||||
|
|
@ -23,6 +23,8 @@
|
|||
#define COMPILER_EXPORT
|
||||
#endif
|
||||
|
||||
#include "khrplatform.h"
|
||||
|
||||
//
|
||||
// This is the platform independent interface between an OGL driver
|
||||
// and the shading language compiler.
|
||||
|
@ -110,7 +112,10 @@ typedef enum {
|
|||
SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
|
||||
SH_ACTIVE_ATTRIBUTES = 0x8B89,
|
||||
SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
|
||||
SH_MAPPED_NAME_MAX_LENGTH = 0x8B8B
|
||||
SH_MAPPED_NAME_MAX_LENGTH = 0x6000,
|
||||
SH_NAME_MAX_LENGTH = 0x6001,
|
||||
SH_HASHED_NAME_MAX_LENGTH = 0x6002,
|
||||
SH_HASHED_NAMES_COUNT = 0x6003
|
||||
} ShShaderInfo;
|
||||
|
||||
// Compile options.
|
||||
|
@ -145,7 +150,7 @@ typedef enum {
|
|||
SH_DEPENDENCY_GRAPH = 0x0400,
|
||||
|
||||
// Enforce the GLSL 1.017 Appendix A section 7 packing restrictions.
|
||||
SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800,
|
||||
SH_ENFORCE_PACKING_RESTRICTIONS = 0x0800
|
||||
} ShCompileOptions;
|
||||
|
||||
//
|
||||
|
@ -160,6 +165,10 @@ COMPILER_EXPORT int ShInitialize();
|
|||
//
|
||||
COMPILER_EXPORT int ShFinalize();
|
||||
|
||||
// The 64 bits hash function. The first parameter is the input string; the
|
||||
// second parameter is the string length.
|
||||
typedef khronos_uint64_t (*ShHashFunction64)(const char*, unsigned int);
|
||||
|
||||
//
|
||||
// Implementation dependent built-in resources (constants and extensions).
|
||||
// The names for these resources has been obtained by stripping gl_/GL_.
|
||||
|
@ -181,6 +190,11 @@ typedef struct
|
|||
int OES_standard_derivatives;
|
||||
int OES_EGL_image_external;
|
||||
int ARB_texture_rectangle;
|
||||
|
||||
// Name Hashing.
|
||||
// Set a 64 bit hash function to enable user-defined name hashing.
|
||||
// Default is NULL.
|
||||
ShHashFunction64 HashFunction;
|
||||
} ShBuiltInResources;
|
||||
|
||||
//
|
||||
|
@ -267,6 +281,11 @@ COMPILER_EXPORT int ShCompile(
|
|||
// termination character.
|
||||
// SH_MAPPED_NAME_MAX_LENGTH: the length of the mapped variable name including
|
||||
// the null termination character.
|
||||
// SH_NAME_MAX_LENGTH: the max length of a user-defined name including the
|
||||
// null termination character.
|
||||
// SH_HASHED_NAME_MAX_LENGTH: the max length of a hashed name including the
|
||||
// null termination character.
|
||||
// SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile.
|
||||
//
|
||||
// params: Requested parameter
|
||||
COMPILER_EXPORT void ShGetInfo(const ShHandle handle,
|
||||
|
@ -347,6 +366,24 @@ COMPILER_EXPORT void ShGetActiveUniform(const ShHandle handle,
|
|||
char* name,
|
||||
char* mappedName);
|
||||
|
||||
// Returns information about a name hashing entry from the latest compile.
|
||||
// Parameters:
|
||||
// handle: Specifies the compiler
|
||||
// index: Specifies the index of the name hashing entry to be queried.
|
||||
// name: Returns a null terminated string containing the user defined name.
|
||||
// It is assumed that name has enough memory to accomodate the name.
|
||||
// The size of the buffer required to store the user defined name can
|
||||
// be obtained by calling ShGetInfo with SH_NAME_MAX_LENGTH.
|
||||
// hashedName: Returns a null terminated string containing the hashed name of
|
||||
// the uniform variable, It is assumed that hashedName has enough
|
||||
// memory to accomodate the name. The size of the buffer required
|
||||
// to store the name can be obtained by calling ShGetInfo with
|
||||
// SH_HASHED_NAME_MAX_LENGTH.
|
||||
COMPILER_EXPORT void ShGetNameHashingEntry(const ShHandle handle,
|
||||
int index,
|
||||
char* name,
|
||||
char* hashedName);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'essl_to_glsl',
|
||||
'type': 'executable',
|
||||
'dependencies': [
|
||||
'../src/build_angle.gyp:translator_glsl',
|
||||
],
|
||||
'include_dirs': [
|
||||
'../include',
|
||||
],
|
||||
'sources': [
|
||||
'translator/translator.cpp',
|
||||
],
|
||||
},
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'essl_to_hlsl',
|
||||
'type': 'executable',
|
||||
'dependencies': [
|
||||
'../src/build_angle.gyp:translator_hlsl',
|
||||
],
|
||||
'include_dirs': [
|
||||
'../include',
|
||||
'../src',
|
||||
],
|
||||
'sources': [
|
||||
'translator/translator.cpp',
|
||||
'../src/common/debug.cpp',
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
|
||||
'AdditionalDependencies': ['d3d9.lib'],
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'target_name': 'es_util',
|
||||
'type': 'static_library',
|
||||
'dependencies': [
|
||||
'../src/build_angle.gyp:libEGL',
|
||||
'../src/build_angle.gyp:libGLESv2',
|
||||
],
|
||||
'include_dirs': [
|
||||
'gles2_book/Common',
|
||||
'../include',
|
||||
],
|
||||
'sources': [
|
||||
'gles2_book/Common/esShader.c',
|
||||
'gles2_book/Common/esShapes.c',
|
||||
'gles2_book/Common/esTransform.c',
|
||||
'gles2_book/Common/esUtil.c',
|
||||
'gles2_book/Common/esUtil.h',
|
||||
'gles2_book/Common/esUtil_win.h',
|
||||
'gles2_book/Common/Win32/esUtil_TGA.c',
|
||||
'gles2_book/Common/Win32/esUtil_win32.c',
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'gles2_book/Common',
|
||||
'../include',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'target_name': 'hello_triangle',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/Hello_Triangle/Hello_Triangle.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'mip_map_2d',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/MipMap2D/MipMap2D.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'multi_texture',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/MultiTexture/MultiTexture.c',
|
||||
],
|
||||
'copies': [
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)',
|
||||
'files': [
|
||||
'gles2_book/MultiTexture/basemap.tga',
|
||||
'gles2_book/MultiTexture/lightmap.tga',
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'particle_system',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/ParticleSystem/ParticleSystem.c',
|
||||
],
|
||||
'copies': [
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)',
|
||||
'files': [
|
||||
'gles2_book/ParticleSystem/smoke.tga',
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'simple_texture_2d',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/Simple_Texture2D/Simple_Texture2D.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'simple_texture_cubemap',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/Simple_TextureCubemap/Simple_TextureCubemap.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'simple_vertex_shader',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/Simple_VertexShader/Simple_VertexShader.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'stencil_test',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/Stencil_Test/Stencil_Test.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'texture_wrap',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/TextureWrap/TextureWrap.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'post_sub_buffer',
|
||||
'type': 'executable',
|
||||
'dependencies': ['es_util'],
|
||||
'sources': [
|
||||
'gles2_book/PostSubBuffer/PostSubBuffer.c',
|
||||
],
|
||||
},
|
||||
],
|
||||
}],
|
||||
],
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# tab-width:2
|
||||
# indent-tabs-mode:nil
|
||||
# End:
|
||||
# vim: set expandtab tabstop=2 shiftwidth=2:
|
|
@ -1,122 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// esUtil_TGA.c
|
||||
//
|
||||
// This file contains the Win32 implementation of a TGA image loader
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
///
|
||||
// Macros
|
||||
//
|
||||
#define INVERTED_BIT (1 << 5)
|
||||
|
||||
///
|
||||
// Types
|
||||
//
|
||||
#pragma pack(push,x1) // Byte alignment (8-bit)
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char IdSize,
|
||||
MapType,
|
||||
ImageType;
|
||||
unsigned short PaletteStart,
|
||||
PaletteSize;
|
||||
unsigned char PaletteEntryDepth;
|
||||
unsigned short X,
|
||||
Y,
|
||||
Width,
|
||||
Height;
|
||||
unsigned char ColorDepth,
|
||||
Descriptor;
|
||||
|
||||
} TGA_HEADER;
|
||||
|
||||
#pragma pack(pop,x1)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Private Functions
|
||||
//
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Public Functions
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
///
|
||||
// WinTGALoad()
|
||||
//
|
||||
int WinTGALoad( const char *fileName, char **buffer, int *width, int *height )
|
||||
{
|
||||
FILE *fp;
|
||||
TGA_HEADER Header;
|
||||
|
||||
if ( fopen_s ( &fp, fileName, "rb" ) != 0 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( fp == NULL )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fread ( &Header, sizeof(TGA_HEADER), 1, fp );
|
||||
|
||||
*width = Header.Width;
|
||||
*height = Header.Height;
|
||||
|
||||
if ( Header.ColorDepth == 24 )
|
||||
{
|
||||
RGBTRIPLE *Buffer24;
|
||||
|
||||
Buffer24= (RGBTRIPLE*)malloc(sizeof(RGBTRIPLE) * (*width) * (*height));
|
||||
|
||||
if(Buffer24)
|
||||
{
|
||||
int i=0;
|
||||
int x,
|
||||
y;
|
||||
|
||||
fread(Buffer24, sizeof(RGBTRIPLE), (*width) * (*height), fp);
|
||||
|
||||
*buffer= (LPSTR) malloc(3 * (*width) * (*height));
|
||||
|
||||
for ( y = 0; y < *height; y++ )
|
||||
for( x = 0; x < *width; x++ )
|
||||
{
|
||||
int Index= y * (*width) + x;
|
||||
|
||||
if(!(Header.Descriptor & INVERTED_BIT))
|
||||
Index= ((*height) - 1 - y) * (*width) + x;
|
||||
|
||||
(*buffer)[(i * 3)]= Buffer24[Index].rgbtRed;
|
||||
(*buffer)[(i * 3) + 1]= Buffer24[Index].rgbtGreen;
|
||||
(*buffer)[(i * 3) + 2]= Buffer24[Index].rgbtBlue;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
free(Buffer24);
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return(FALSE);
|
||||
}
|
|
@ -1,190 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// esUtil_win32.c
|
||||
//
|
||||
// This file contains the Win32 implementation of the windowing functions.
|
||||
|
||||
|
||||
///
|
||||
// Includes
|
||||
//
|
||||
|
||||
#include <windows.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Private Functions
|
||||
//
|
||||
//
|
||||
|
||||
///
|
||||
// ESWindowProc()
|
||||
//
|
||||
// Main window procedure
|
||||
//
|
||||
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
LRESULT lRet = 1;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
|
||||
if ( esContext ) {
|
||||
esContext->width = LOWORD( lParam );
|
||||
esContext->height = HIWORD( lParam );
|
||||
InvalidateRect( esContext->hWnd, NULL, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
|
||||
|
||||
if ( esContext && esContext->drawFunc )
|
||||
esContext->drawFunc ( esContext );
|
||||
|
||||
if ( esContext )
|
||||
ValidateRect( esContext->hWnd, NULL );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_CHAR:
|
||||
{
|
||||
POINT point;
|
||||
ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
|
||||
|
||||
GetCursorPos( &point );
|
||||
|
||||
if ( esContext && esContext->keyFunc )
|
||||
esContext->keyFunc ( esContext, (unsigned char) wParam,
|
||||
(int) point.x, (int) point.y );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
return lRet;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Public Functions
|
||||
//
|
||||
//
|
||||
|
||||
///
|
||||
// WinCreate()
|
||||
//
|
||||
// Create Win32 instance and window
|
||||
//
|
||||
GLboolean WinCreate ( ESContext *esContext, LPCTSTR title )
|
||||
{
|
||||
WNDCLASS wndclass = {0};
|
||||
DWORD wStyle = 0;
|
||||
RECT windowRect;
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
|
||||
wndclass.style = CS_OWNDC;
|
||||
wndclass.lpfnWndProc = (WNDPROC)ESWindowProc;
|
||||
wndclass.hInstance = hInstance;
|
||||
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
wndclass.lpszClassName = TEXT("opengles2.0");
|
||||
|
||||
if (!RegisterClass (&wndclass) )
|
||||
return FALSE;
|
||||
|
||||
wStyle = WS_VISIBLE | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION | WS_SIZEBOX;
|
||||
|
||||
// Adjust the window rectangle so that the client area has
|
||||
// the correct number of pixels
|
||||
windowRect.left = 0;
|
||||
windowRect.top = 0;
|
||||
windowRect.right = esContext->width;
|
||||
windowRect.bottom = esContext->height;
|
||||
|
||||
AdjustWindowRect ( &windowRect, wStyle, FALSE );
|
||||
|
||||
esContext->hWnd = CreateWindow(
|
||||
TEXT("opengles2.0"),
|
||||
title,
|
||||
wStyle,
|
||||
0,
|
||||
0,
|
||||
windowRect.right - windowRect.left,
|
||||
windowRect.bottom - windowRect.top,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
// Set the ESContext* to the GWL_USERDATA so that it is available to the
|
||||
// ESWindowProc
|
||||
SetWindowLongPtr ( esContext->hWnd, GWL_USERDATA, (LONG) (LONG_PTR) esContext );
|
||||
|
||||
if ( esContext->hWnd == NULL )
|
||||
return GL_FALSE;
|
||||
|
||||
ShowWindow ( esContext->hWnd, TRUE );
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// winLoop()
|
||||
//
|
||||
// Start main windows loop
|
||||
//
|
||||
void WinLoop ( ESContext *esContext )
|
||||
{
|
||||
MSG msg = { 0 };
|
||||
int done = 0;
|
||||
DWORD lastTime = GetTickCount();
|
||||
|
||||
while (!done)
|
||||
{
|
||||
int gotMsg = (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0);
|
||||
DWORD curTime = GetTickCount();
|
||||
float deltaTime = (float)( curTime - lastTime ) / 1000.0f;
|
||||
lastTime = curTime;
|
||||
|
||||
if ( gotMsg )
|
||||
{
|
||||
if (msg.message==WM_QUIT)
|
||||
{
|
||||
done=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
SendMessage( esContext->hWnd, WM_PAINT, 0, 0 );
|
||||
|
||||
// Call update function if registered
|
||||
if ( esContext->updateFunc != NULL )
|
||||
esContext->updateFunc ( esContext, deltaTime );
|
||||
}
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// ESShader.c
|
||||
//
|
||||
// Utility functions for loading shaders and creating program objects.
|
||||
//
|
||||
|
||||
///
|
||||
// Includes
|
||||
//
|
||||
#include "esUtil.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Private Functions
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Public Functions
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
///
|
||||
/// \brief Load a shader, check for compile errors, print error messages to output log
|
||||
/// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER)
|
||||
/// \param shaderSrc Shader source string
|
||||
/// \return A new shader object on success, 0 on failure
|
||||
//
|
||||
GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc )
|
||||
{
|
||||
GLuint shader;
|
||||
GLint compiled;
|
||||
|
||||
// Create the shader object
|
||||
shader = glCreateShader ( type );
|
||||
|
||||
if ( shader == 0 )
|
||||
return 0;
|
||||
|
||||
// Load the shader source
|
||||
glShaderSource ( shader, 1, &shaderSrc, NULL );
|
||||
|
||||
// Compile the shader
|
||||
glCompileShader ( shader );
|
||||
|
||||
// Check the compile status
|
||||
glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );
|
||||
|
||||
if ( !compiled )
|
||||
{
|
||||
GLint infoLen = 0;
|
||||
|
||||
glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );
|
||||
|
||||
if ( infoLen > 1 )
|
||||
{
|
||||
char* infoLog = malloc (sizeof(char) * infoLen );
|
||||
|
||||
glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );
|
||||
esLogMessage ( "Error compiling shader:\n%s\n", infoLog );
|
||||
|
||||
free ( infoLog );
|
||||
}
|
||||
|
||||
glDeleteShader ( shader );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return shader;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
///
|
||||
/// \brief Load a vertex and fragment shader, create a program object, link program.
|
||||
// Errors output to log.
|
||||
/// \param vertShaderSrc Vertex shader source code
|
||||
/// \param fragShaderSrc Fragment shader source code
|
||||
/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure
|
||||
//
|
||||
GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc )
|
||||
{
|
||||
GLuint vertexShader;
|
||||
GLuint fragmentShader;
|
||||
GLuint programObject;
|
||||
GLint linked;
|
||||
|
||||
// Load the vertex/fragment shaders
|
||||
vertexShader = esLoadShader ( GL_VERTEX_SHADER, vertShaderSrc );
|
||||
if ( vertexShader == 0 )
|
||||
return 0;
|
||||
|
||||
fragmentShader = esLoadShader ( GL_FRAGMENT_SHADER, fragShaderSrc );
|
||||
if ( fragmentShader == 0 )
|
||||
{
|
||||
glDeleteShader( vertexShader );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create the program object
|
||||
programObject = glCreateProgram ( );
|
||||
|
||||
if ( programObject == 0 )
|
||||
return 0;
|
||||
|
||||
glAttachShader ( programObject, vertexShader );
|
||||
glAttachShader ( programObject, fragmentShader );
|
||||
|
||||
// Link the program
|
||||
glLinkProgram ( programObject );
|
||||
|
||||
// Check the link status
|
||||
glGetProgramiv ( programObject, GL_LINK_STATUS, &linked );
|
||||
|
||||
if ( !linked )
|
||||
{
|
||||
GLint infoLen = 0;
|
||||
|
||||
glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen );
|
||||
|
||||
if ( infoLen > 1 )
|
||||
{
|
||||
char* infoLog = malloc (sizeof(char) * infoLen );
|
||||
|
||||
glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog );
|
||||
esLogMessage ( "Error linking program:\n%s\n", infoLog );
|
||||
|
||||
free ( infoLog );
|
||||
}
|
||||
|
||||
glDeleteProgram ( programObject );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Free up no longer needed shader resources
|
||||
glDeleteShader ( vertexShader );
|
||||
glDeleteShader ( fragmentShader );
|
||||
|
||||
return programObject;
|
||||
}
|
|
@ -1,279 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// ESShapes.c
|
||||
//
|
||||
// Utility functions for generating shapes
|
||||
//
|
||||
|
||||
///
|
||||
// Includes
|
||||
//
|
||||
#include "esUtil.h"
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
///
|
||||
// Defines
|
||||
//
|
||||
#define ES_PI (3.14159265f)
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Private Functions
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Public Functions
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
/// \brief Generates geometry for a sphere. Allocates memory for the vertex data and stores
|
||||
/// the results in the arrays. Generate index list for a TRIANGLE_STRIP
|
||||
/// \param numSlices The number of slices in the sphere
|
||||
/// \param vertices If not NULL, will contain array of float3 positions
|
||||
/// \param normals If not NULL, will contain array of float3 normals
|
||||
/// \param texCoords If not NULL, will contain array of float2 texCoords
|
||||
/// \param indices If not NULL, will contain the array of indices for the triangle strip
|
||||
/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
|
||||
/// if it is not NULL ) as a GL_TRIANGLE_STRIP
|
||||
//
|
||||
int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals,
|
||||
GLfloat **texCoords, GLushort **indices )
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int numParallels = numSlices / 2;
|
||||
int numVertices = ( numParallels + 1 ) * ( numSlices + 1 );
|
||||
int numIndices = numParallels * numSlices * 6;
|
||||
float angleStep = (2.0f * ES_PI) / ((float) numSlices);
|
||||
|
||||
// Allocate memory for buffers
|
||||
if ( vertices != NULL )
|
||||
*vertices = malloc ( sizeof(GLfloat) * 3 * numVertices );
|
||||
|
||||
if ( normals != NULL )
|
||||
*normals = malloc ( sizeof(GLfloat) * 3 * numVertices );
|
||||
|
||||
if ( texCoords != NULL )
|
||||
*texCoords = malloc ( sizeof(GLfloat) * 2 * numVertices );
|
||||
|
||||
if ( indices != NULL )
|
||||
*indices = malloc ( sizeof(GLushort) * numIndices );
|
||||
|
||||
for ( i = 0; i < numParallels + 1; i++ )
|
||||
{
|
||||
for ( j = 0; j < numSlices + 1; j++ )
|
||||
{
|
||||
int vertex = ( i * (numSlices + 1) + j ) * 3;
|
||||
|
||||
if ( vertices )
|
||||
{
|
||||
(*vertices)[vertex + 0] = radius * sinf ( angleStep * (float)i ) *
|
||||
sinf ( angleStep * (float)j );
|
||||
(*vertices)[vertex + 1] = radius * cosf ( angleStep * (float)i );
|
||||
(*vertices)[vertex + 2] = radius * sinf ( angleStep * (float)i ) *
|
||||
cosf ( angleStep * (float)j );
|
||||
}
|
||||
|
||||
if ( normals )
|
||||
{
|
||||
(*normals)[vertex + 0] = (*vertices)[vertex + 0] / radius;
|
||||
(*normals)[vertex + 1] = (*vertices)[vertex + 1] / radius;
|
||||
(*normals)[vertex + 2] = (*vertices)[vertex + 2] / radius;
|
||||
}
|
||||
|
||||
if ( texCoords )
|
||||
{
|
||||
int texIndex = ( i * (numSlices + 1) + j ) * 2;
|
||||
(*texCoords)[texIndex + 0] = (float) j / (float) numSlices;
|
||||
(*texCoords)[texIndex + 1] = ( 1.0f - (float) i ) / (float) (numParallels - 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate the indices
|
||||
if ( indices != NULL )
|
||||
{
|
||||
GLushort *indexBuf = (*indices);
|
||||
for ( i = 0; i < numParallels ; i++ )
|
||||
{
|
||||
for ( j = 0; j < numSlices; j++ )
|
||||
{
|
||||
*indexBuf++ = i * ( numSlices + 1 ) + j;
|
||||
*indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + j;
|
||||
*indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + ( j + 1 );
|
||||
|
||||
*indexBuf++ = i * ( numSlices + 1 ) + j;
|
||||
*indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + ( j + 1 );
|
||||
*indexBuf++ = i * ( numSlices + 1 ) + ( j + 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return numIndices;
|
||||
}
|
||||
|
||||
//
|
||||
/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores
|
||||
/// the results in the arrays. Generate index list for a TRIANGLES
|
||||
/// \param scale The size of the cube, use 1.0 for a unit cube.
|
||||
/// \param vertices If not NULL, will contain array of float3 positions
|
||||
/// \param normals If not NULL, will contain array of float3 normals
|
||||
/// \param texCoords If not NULL, will contain array of float2 texCoords
|
||||
/// \param indices If not NULL, will contain the array of indices for the triangle strip
|
||||
/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
|
||||
/// if it is not NULL ) as a GL_TRIANGLE_STRIP
|
||||
//
|
||||
int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
|
||||
GLfloat **texCoords, GLushort **indices )
|
||||
{
|
||||
int i;
|
||||
int numVertices = 24;
|
||||
int numIndices = 36;
|
||||
|
||||
GLfloat cubeVerts[] =
|
||||
{
|
||||
-0.5f, -0.5f, -0.5f,
|
||||
-0.5f, -0.5f, 0.5f,
|
||||
0.5f, -0.5f, 0.5f,
|
||||
0.5f, -0.5f, -0.5f,
|
||||
-0.5f, 0.5f, -0.5f,
|
||||
-0.5f, 0.5f, 0.5f,
|
||||
0.5f, 0.5f, 0.5f,
|
||||
0.5f, 0.5f, -0.5f,
|
||||
-0.5f, -0.5f, -0.5f,
|
||||
-0.5f, 0.5f, -0.5f,
|
||||
0.5f, 0.5f, -0.5f,
|
||||
0.5f, -0.5f, -0.5f,
|
||||
-0.5f, -0.5f, 0.5f,
|
||||
-0.5f, 0.5f, 0.5f,
|
||||
0.5f, 0.5f, 0.5f,
|
||||
0.5f, -0.5f, 0.5f,
|
||||
-0.5f, -0.5f, -0.5f,
|
||||
-0.5f, -0.5f, 0.5f,
|
||||
-0.5f, 0.5f, 0.5f,
|
||||
-0.5f, 0.5f, -0.5f,
|
||||
0.5f, -0.5f, -0.5f,
|
||||
0.5f, -0.5f, 0.5f,
|
||||
0.5f, 0.5f, 0.5f,
|
||||
0.5f, 0.5f, -0.5f,
|
||||
};
|
||||
|
||||
GLfloat cubeNormals[] =
|
||||
{
|
||||
0.0f, -1.0f, 0.0f,
|
||||
0.0f, -1.0f, 0.0f,
|
||||
0.0f, -1.0f, 0.0f,
|
||||
0.0f, -1.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, -1.0f,
|
||||
0.0f, 0.0f, -1.0f,
|
||||
0.0f, 0.0f, -1.0f,
|
||||
0.0f, 0.0f, -1.0f,
|
||||
0.0f, 0.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f,
|
||||
-1.0f, 0.0f, 0.0f,
|
||||
-1.0f, 0.0f, 0.0f,
|
||||
-1.0f, 0.0f, 0.0f,
|
||||
-1.0f, 0.0f, 0.0f,
|
||||
1.0f, 0.0f, 0.0f,
|
||||
1.0f, 0.0f, 0.0f,
|
||||
1.0f, 0.0f, 0.0f,
|
||||
1.0f, 0.0f, 0.0f,
|
||||
};
|
||||
|
||||
GLfloat cubeTex[] =
|
||||
{
|
||||
0.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f,
|
||||
0.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
};
|
||||
|
||||
// Allocate memory for buffers
|
||||
if ( vertices != NULL )
|
||||
{
|
||||
*vertices = malloc ( sizeof(GLfloat) * 3 * numVertices );
|
||||
memcpy( *vertices, cubeVerts, sizeof( cubeVerts ) );
|
||||
for ( i = 0; i < numVertices; i++ )
|
||||
{
|
||||
(*vertices)[i] *= scale;
|
||||
}
|
||||
}
|
||||
|
||||
if ( normals != NULL )
|
||||
{
|
||||
*normals = malloc ( sizeof(GLfloat) * 3 * numVertices );
|
||||
memcpy( *normals, cubeNormals, sizeof( cubeNormals ) );
|
||||
}
|
||||
|
||||
if ( texCoords != NULL )
|
||||
{
|
||||
*texCoords = malloc ( sizeof(GLfloat) * 2 * numVertices );
|
||||
memcpy( *texCoords, cubeTex, sizeof( cubeTex ) ) ;
|
||||
}
|
||||
|
||||
|
||||
// Generate the indices
|
||||
if ( indices != NULL )
|
||||
{
|
||||
GLushort cubeIndices[] =
|
||||
{
|
||||
0, 2, 1,
|
||||
0, 3, 2,
|
||||
4, 5, 6,
|
||||
4, 6, 7,
|
||||
8, 9, 10,
|
||||
8, 10, 11,
|
||||
12, 15, 14,
|
||||
12, 14, 13,
|
||||
16, 17, 18,
|
||||
16, 18, 19,
|
||||
20, 23, 22,
|
||||
20, 22, 21
|
||||
};
|
||||
|
||||
*indices = malloc ( sizeof(GLushort) * numIndices );
|
||||
memcpy( *indices, cubeIndices, sizeof( cubeIndices ) );
|
||||
}
|
||||
|
||||
return numIndices;
|
||||
}
|
|
@ -1,212 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// ESUtil.c
|
||||
//
|
||||
// A utility library for OpenGL ES. This library provides a
|
||||
// basic common framework for the example applications in the
|
||||
// OpenGL ES 2.0 Programming Guide.
|
||||
//
|
||||
|
||||
///
|
||||
// Includes
|
||||
//
|
||||
#include "esUtil.h"
|
||||
#include <math.h>
|
||||
|
||||
#define PI 3.1415926535897932384626433832795f
|
||||
|
||||
void ESUTIL_API
|
||||
esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz)
|
||||
{
|
||||
result->m[0][0] *= sx;
|
||||
result->m[0][1] *= sx;
|
||||
result->m[0][2] *= sx;
|
||||
result->m[0][3] *= sx;
|
||||
|
||||
result->m[1][0] *= sy;
|
||||
result->m[1][1] *= sy;
|
||||
result->m[1][2] *= sy;
|
||||
result->m[1][3] *= sy;
|
||||
|
||||
result->m[2][0] *= sz;
|
||||
result->m[2][1] *= sz;
|
||||
result->m[2][2] *= sz;
|
||||
result->m[2][3] *= sz;
|
||||
}
|
||||
|
||||
void ESUTIL_API
|
||||
esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz)
|
||||
{
|
||||
result->m[3][0] += (result->m[0][0] * tx + result->m[1][0] * ty + result->m[2][0] * tz);
|
||||
result->m[3][1] += (result->m[0][1] * tx + result->m[1][1] * ty + result->m[2][1] * tz);
|
||||
result->m[3][2] += (result->m[0][2] * tx + result->m[1][2] * ty + result->m[2][2] * tz);
|
||||
result->m[3][3] += (result->m[0][3] * tx + result->m[1][3] * ty + result->m[2][3] * tz);
|
||||
}
|
||||
|
||||
void ESUTIL_API
|
||||
esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
|
||||
{
|
||||
GLfloat sinAngle, cosAngle;
|
||||
GLfloat mag = sqrtf(x * x + y * y + z * z);
|
||||
|
||||
sinAngle = sinf ( angle * PI / 180.0f );
|
||||
cosAngle = cosf ( angle * PI / 180.0f );
|
||||
if ( mag > 0.0f )
|
||||
{
|
||||
GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs;
|
||||
GLfloat oneMinusCos;
|
||||
ESMatrix rotMat;
|
||||
|
||||
x /= mag;
|
||||
y /= mag;
|
||||
z /= mag;
|
||||
|
||||
xx = x * x;
|
||||
yy = y * y;
|
||||
zz = z * z;
|
||||
xy = x * y;
|
||||
yz = y * z;
|
||||
zx = z * x;
|
||||
xs = x * sinAngle;
|
||||
ys = y * sinAngle;
|
||||
zs = z * sinAngle;
|
||||
oneMinusCos = 1.0f - cosAngle;
|
||||
|
||||
rotMat.m[0][0] = (oneMinusCos * xx) + cosAngle;
|
||||
rotMat.m[0][1] = (oneMinusCos * xy) - zs;
|
||||
rotMat.m[0][2] = (oneMinusCos * zx) + ys;
|
||||
rotMat.m[0][3] = 0.0F;
|
||||
|
||||
rotMat.m[1][0] = (oneMinusCos * xy) + zs;
|
||||
rotMat.m[1][1] = (oneMinusCos * yy) + cosAngle;
|
||||
rotMat.m[1][2] = (oneMinusCos * yz) - xs;
|
||||
rotMat.m[1][3] = 0.0F;
|
||||
|
||||
rotMat.m[2][0] = (oneMinusCos * zx) - ys;
|
||||
rotMat.m[2][1] = (oneMinusCos * yz) + xs;
|
||||
rotMat.m[2][2] = (oneMinusCos * zz) + cosAngle;
|
||||
rotMat.m[2][3] = 0.0F;
|
||||
|
||||
rotMat.m[3][0] = 0.0F;
|
||||
rotMat.m[3][1] = 0.0F;
|
||||
rotMat.m[3][2] = 0.0F;
|
||||
rotMat.m[3][3] = 1.0F;
|
||||
|
||||
esMatrixMultiply( result, &rotMat, result );
|
||||
}
|
||||
}
|
||||
|
||||
void ESUTIL_API
|
||||
esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
|
||||
{
|
||||
float deltaX = right - left;
|
||||
float deltaY = top - bottom;
|
||||
float deltaZ = farZ - nearZ;
|
||||
ESMatrix frust;
|
||||
|
||||
if ( (nearZ <= 0.0f) || (farZ <= 0.0f) ||
|
||||
(deltaX <= 0.0f) || (deltaY <= 0.0f) || (deltaZ <= 0.0f) )
|
||||
return;
|
||||
|
||||
frust.m[0][0] = 2.0f * nearZ / deltaX;
|
||||
frust.m[0][1] = frust.m[0][2] = frust.m[0][3] = 0.0f;
|
||||
|
||||
frust.m[1][1] = 2.0f * nearZ / deltaY;
|
||||
frust.m[1][0] = frust.m[1][2] = frust.m[1][3] = 0.0f;
|
||||
|
||||
frust.m[2][0] = (right + left) / deltaX;
|
||||
frust.m[2][1] = (top + bottom) / deltaY;
|
||||
frust.m[2][2] = -(nearZ + farZ) / deltaZ;
|
||||
frust.m[2][3] = -1.0f;
|
||||
|
||||
frust.m[3][2] = -2.0f * nearZ * farZ / deltaZ;
|
||||
frust.m[3][0] = frust.m[3][1] = frust.m[3][3] = 0.0f;
|
||||
|
||||
esMatrixMultiply(result, &frust, result);
|
||||
}
|
||||
|
||||
|
||||
void ESUTIL_API
|
||||
esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ)
|
||||
{
|
||||
GLfloat frustumW, frustumH;
|
||||
|
||||
frustumH = tanf( fovy / 360.0f * PI ) * nearZ;
|
||||
frustumW = frustumH * aspect;
|
||||
|
||||
esFrustum( result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ );
|
||||
}
|
||||
|
||||
void ESUTIL_API
|
||||
esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
|
||||
{
|
||||
float deltaX = right - left;
|
||||
float deltaY = top - bottom;
|
||||
float deltaZ = farZ - nearZ;
|
||||
ESMatrix ortho;
|
||||
|
||||
if ( (deltaX == 0.0f) || (deltaY == 0.0f) || (deltaZ == 0.0f) )
|
||||
return;
|
||||
|
||||
esMatrixLoadIdentity(&ortho);
|
||||
ortho.m[0][0] = 2.0f / deltaX;
|
||||
ortho.m[3][0] = -(right + left) / deltaX;
|
||||
ortho.m[1][1] = 2.0f / deltaY;
|
||||
ortho.m[3][1] = -(top + bottom) / deltaY;
|
||||
ortho.m[2][2] = -2.0f / deltaZ;
|
||||
ortho.m[3][2] = -(nearZ + farZ) / deltaZ;
|
||||
|
||||
esMatrixMultiply(result, &ortho, result);
|
||||
}
|
||||
|
||||
|
||||
void ESUTIL_API
|
||||
esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB)
|
||||
{
|
||||
ESMatrix tmp = { 0.0f };
|
||||
int i;
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
tmp.m[i][0] = (srcA->m[i][0] * srcB->m[0][0]) +
|
||||
(srcA->m[i][1] * srcB->m[1][0]) +
|
||||
(srcA->m[i][2] * srcB->m[2][0]) +
|
||||
(srcA->m[i][3] * srcB->m[3][0]) ;
|
||||
|
||||
tmp.m[i][1] = (srcA->m[i][0] * srcB->m[0][1]) +
|
||||
(srcA->m[i][1] * srcB->m[1][1]) +
|
||||
(srcA->m[i][2] * srcB->m[2][1]) +
|
||||
(srcA->m[i][3] * srcB->m[3][1]) ;
|
||||
|
||||
tmp.m[i][2] = (srcA->m[i][0] * srcB->m[0][2]) +
|
||||
(srcA->m[i][1] * srcB->m[1][2]) +
|
||||
(srcA->m[i][2] * srcB->m[2][2]) +
|
||||
(srcA->m[i][3] * srcB->m[3][2]) ;
|
||||
|
||||
tmp.m[i][3] = (srcA->m[i][0] * srcB->m[0][3]) +
|
||||
(srcA->m[i][1] * srcB->m[1][3]) +
|
||||
(srcA->m[i][2] * srcB->m[2][3]) +
|
||||
(srcA->m[i][3] * srcB->m[3][3]) ;
|
||||
}
|
||||
memcpy(result, &tmp, sizeof(ESMatrix));
|
||||
}
|
||||
|
||||
|
||||
void ESUTIL_API
|
||||
esMatrixLoadIdentity(ESMatrix *result)
|
||||
{
|
||||
memset(result, 0x0, sizeof(ESMatrix));
|
||||
result->m[0][0] = 1.0f;
|
||||
result->m[1][1] = 1.0f;
|
||||
result->m[2][2] = 1.0f;
|
||||
result->m[3][3] = 1.0f;
|
||||
}
|
||||
|
|
@ -1,290 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// ESUtil.c
|
||||
//
|
||||
// A utility library for OpenGL ES. This library provides a
|
||||
// basic common framework for the example applications in the
|
||||
// OpenGL ES 2.0 Programming Guide.
|
||||
//
|
||||
|
||||
///
|
||||
// Includes
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include "esUtil.h"
|
||||
#include "esUtil_win.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4204) // nonstandard extension used : non-constant aggregate initializer
|
||||
#endif
|
||||
|
||||
///
|
||||
// Extensions
|
||||
//
|
||||
|
||||
PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
|
||||
PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
|
||||
|
||||
PFNEGLPOSTSUBBUFFERNVPROC eglPostSubBufferNV;
|
||||
|
||||
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
|
||||
|
||||
PFNGLDELETEFENCESNVPROC glDeleteFencesNV;
|
||||
PFNGLGENFENCESNVPROC glGenFencesNV;
|
||||
PFNGLGETFENCEIVNVPROC glGetFenceivNV;
|
||||
PFNGLISFENCENVPROC glIsFenceNV;
|
||||
PFNGLFINISHFENCENVPROC glFinishFenceNV;
|
||||
PFNGLSETFENCENVPROC glSetFenceNV;
|
||||
PFNGLTESTFENCENVPROC glTestFenceNV;
|
||||
|
||||
///
|
||||
// CreateEGLContext()
|
||||
//
|
||||
// Creates an EGL rendering context and all associated elements
|
||||
//
|
||||
EGLBoolean CreateEGLContext ( EGLNativeWindowType hWnd, EGLDisplay* eglDisplay,
|
||||
EGLContext* eglContext, EGLSurface* eglSurface,
|
||||
EGLint* configAttribList, EGLint* surfaceAttribList)
|
||||
{
|
||||
EGLint numConfigs;
|
||||
EGLint majorVersion;
|
||||
EGLint minorVersion;
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
EGLConfig config;
|
||||
EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
|
||||
|
||||
// Get Display
|
||||
display = eglGetDisplay(GetDC(hWnd));
|
||||
if ( display == EGL_NO_DISPLAY )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Initialize EGL
|
||||
if ( !eglInitialize(display, &majorVersion, &minorVersion) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Bind to extensions
|
||||
eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR");
|
||||
eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR");
|
||||
|
||||
eglPostSubBufferNV = (PFNEGLPOSTSUBBUFFERNVPROC) eglGetProcAddress("eglPostSubBufferNV");
|
||||
|
||||
glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress("glEGLImageTargetTexture2DOES");
|
||||
|
||||
glDeleteFencesNV = (PFNGLDELETEFENCESNVPROC) eglGetProcAddress("glDeleteFencesNV");
|
||||
glGenFencesNV = (PFNGLGENFENCESNVPROC) eglGetProcAddress("glGenFencesNV");
|
||||
glGetFenceivNV = (PFNGLGETFENCEIVNVPROC) eglGetProcAddress("glGetFenceivNV");
|
||||
glIsFenceNV = (PFNGLISFENCENVPROC) eglGetProcAddress("glIsFenceNV");
|
||||
glFinishFenceNV = (PFNGLFINISHFENCENVPROC) eglGetProcAddress("glFinishFenceNV");
|
||||
glSetFenceNV = (PFNGLSETFENCENVPROC) eglGetProcAddress("glSetFenceNV");
|
||||
glTestFenceNV = (PFNGLTESTFENCENVPROC) eglGetProcAddress("glTestFenceNV");
|
||||
|
||||
// Get configs
|
||||
if ( !eglGetConfigs(display, NULL, 0, &numConfigs) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Choose config
|
||||
if ( !eglChooseConfig(display, configAttribList, &config, 1, &numConfigs) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Create a surface
|
||||
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, surfaceAttribList);
|
||||
if ( surface == EGL_NO_SURFACE )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Create a GL context
|
||||
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );
|
||||
if ( context == EGL_NO_CONTEXT )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Make the context current
|
||||
if ( !eglMakeCurrent(display, surface, surface, context) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
*eglDisplay = display;
|
||||
*eglSurface = surface;
|
||||
*eglContext = context;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Public Functions
|
||||
//
|
||||
//
|
||||
|
||||
///
|
||||
// esInitContext()
|
||||
//
|
||||
// Initialize ES utility context. This must be called before calling any other
|
||||
// functions.
|
||||
//
|
||||
void ESUTIL_API esInitContext ( ESContext *esContext )
|
||||
{
|
||||
if ( esContext != NULL )
|
||||
{
|
||||
memset( esContext, 0, sizeof( ESContext) );
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
// esCreateWindow()
|
||||
//
|
||||
// title - name for title bar of window
|
||||
// width - width of window to create
|
||||
// height - height of window to create
|
||||
// flags - bitwise or of window creation flags
|
||||
// ES_WINDOW_ALPHA - specifies that the framebuffer should have alpha
|
||||
// ES_WINDOW_DEPTH - specifies that a depth buffer should be created
|
||||
// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created
|
||||
// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created
|
||||
// ES_WINDOW_POST_SUB_BUFFER_SUPPORTED - specifies that EGL_POST_SUB_BUFFER_NV is supported.
|
||||
//
|
||||
GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, LPCTSTR title, GLint width, GLint height, GLuint flags )
|
||||
{
|
||||
EGLint configAttribList[] =
|
||||
{
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 6,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, (flags & ES_WINDOW_ALPHA) ? 8 : EGL_DONT_CARE,
|
||||
EGL_DEPTH_SIZE, (flags & ES_WINDOW_DEPTH) ? 8 : EGL_DONT_CARE,
|
||||
EGL_STENCIL_SIZE, (flags & ES_WINDOW_STENCIL) ? 8 : EGL_DONT_CARE,
|
||||
EGL_SAMPLE_BUFFERS, (flags & ES_WINDOW_MULTISAMPLE) ? 1 : 0,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLint surfaceAttribList[] =
|
||||
{
|
||||
EGL_POST_SUB_BUFFER_SUPPORTED_NV, flags & (ES_WINDOW_POST_SUB_BUFFER_SUPPORTED) ? EGL_TRUE : EGL_FALSE,
|
||||
EGL_NONE, EGL_NONE
|
||||
};
|
||||
|
||||
if ( esContext == NULL )
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
esContext->width = width;
|
||||
esContext->height = height;
|
||||
|
||||
if ( !WinCreate ( esContext, title) )
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if ( !CreateEGLContext ( esContext->hWnd,
|
||||
&esContext->eglDisplay,
|
||||
&esContext->eglContext,
|
||||
&esContext->eglSurface,
|
||||
configAttribList,
|
||||
surfaceAttribList ) )
|
||||
{
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// esMainLoop()
|
||||
//
|
||||
// Start the main loop for the OpenGL ES application
|
||||
//
|
||||
void ESUTIL_API esMainLoop ( ESContext *esContext )
|
||||
{
|
||||
WinLoop ( esContext );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// esRegisterDrawFunc()
|
||||
//
|
||||
void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) (ESContext* ) )
|
||||
{
|
||||
esContext->drawFunc = drawFunc;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// esRegisterUpdateFunc()
|
||||
//
|
||||
void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) )
|
||||
{
|
||||
esContext->updateFunc = updateFunc;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// esRegisterKeyFunc()
|
||||
//
|
||||
void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext,
|
||||
void (ESCALLBACK *keyFunc) (ESContext*, unsigned char, int, int ) )
|
||||
{
|
||||
esContext->keyFunc = keyFunc;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// esLogMessage()
|
||||
//
|
||||
// Log an error message to the debug output for the platform
|
||||
//
|
||||
void ESUTIL_API esLogMessage ( const char *formatStr, ... )
|
||||
{
|
||||
va_list params;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
va_start ( params, formatStr );
|
||||
vsprintf_s ( buf, sizeof(buf), formatStr, params );
|
||||
|
||||
printf ( "%s", buf );
|
||||
|
||||
va_end ( params );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// esLoadTGA()
|
||||
//
|
||||
// Loads a 24-bit TGA image from a file
|
||||
//
|
||||
char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height )
|
||||
{
|
||||
char *buffer;
|
||||
|
||||
if ( WinTGALoad ( fileName, &buffer, width, height ) )
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -1,297 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
//
|
||||
/// \file ESUtil.h
|
||||
/// \brief A utility library for OpenGL ES. This library provides a
|
||||
/// basic common framework for the example applications in the
|
||||
/// OpenGL ES 2.0 Programming Guide.
|
||||
//
|
||||
#ifndef ESUTIL_H
|
||||
#define ESUTIL_H
|
||||
|
||||
///
|
||||
// Includes
|
||||
//
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
// Macros
|
||||
//
|
||||
#define ESUTIL_API __cdecl
|
||||
#define ESCALLBACK __cdecl
|
||||
|
||||
|
||||
/// esCreateWindow flag - RGB color buffer
|
||||
#define ES_WINDOW_RGB 0
|
||||
/// esCreateWindow flag - ALPHA color buffer
|
||||
#define ES_WINDOW_ALPHA 1
|
||||
/// esCreateWindow flag - depth buffer
|
||||
#define ES_WINDOW_DEPTH 2
|
||||
/// esCreateWindow flag - stencil buffer
|
||||
#define ES_WINDOW_STENCIL 4
|
||||
/// esCreateWindow flag - multi-sample buffer
|
||||
#define ES_WINDOW_MULTISAMPLE 8
|
||||
/// esCreateWindow flag - EGL_POST_SUB_BUFFER_NV supported.
|
||||
#define ES_WINDOW_POST_SUB_BUFFER_SUPPORTED 16
|
||||
|
||||
///
|
||||
// Types
|
||||
//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLfloat m[4][4];
|
||||
} ESMatrix;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/// Put your user data here...
|
||||
void* userData;
|
||||
|
||||
/// Window width
|
||||
GLint width;
|
||||
|
||||
/// Window height
|
||||
GLint height;
|
||||
|
||||
/// Window handle
|
||||
EGLNativeWindowType hWnd;
|
||||
|
||||
/// EGL display
|
||||
EGLDisplay eglDisplay;
|
||||
|
||||
/// EGL context
|
||||
EGLContext eglContext;
|
||||
|
||||
/// EGL surface
|
||||
EGLSurface eglSurface;
|
||||
|
||||
/// Callbacks
|
||||
void (ESCALLBACK *drawFunc) ( void* );
|
||||
void (ESCALLBACK *keyFunc) ( void*, unsigned char, int, int );
|
||||
void (ESCALLBACK *updateFunc) ( void*, float deltaTime );
|
||||
} ESContext;
|
||||
|
||||
|
||||
///
|
||||
// Extensions
|
||||
//
|
||||
|
||||
extern PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
|
||||
extern PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
|
||||
|
||||
extern PFNEGLPOSTSUBBUFFERNVPROC eglPostSubBufferNV;
|
||||
|
||||
extern PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
|
||||
|
||||
extern PFNGLDELETEFENCESNVPROC glDeleteFencesNV;
|
||||
extern PFNGLGENFENCESNVPROC glGenFencesNV;
|
||||
extern PFNGLGETFENCEIVNVPROC glGetFenceivNV;
|
||||
extern PFNGLISFENCENVPROC glIsFenceNV;
|
||||
extern PFNGLFINISHFENCENVPROC glFinishFenceNV;
|
||||
extern PFNGLSETFENCENVPROC glSetFenceNV;
|
||||
extern PFNGLTESTFENCENVPROC glTestFenceNV;
|
||||
|
||||
///
|
||||
// Public Functions
|
||||
//
|
||||
|
||||
//
|
||||
///
|
||||
/// \brief Initialize ES framework context. This must be called before calling any other functions.
|
||||
/// \param esContext Application context
|
||||
//
|
||||
void ESUTIL_API esInitContext ( ESContext *esContext );
|
||||
|
||||
//
|
||||
/// \brief Create a window with the specified parameters
|
||||
/// \param esContext Application context
|
||||
/// \param title Name for title bar of window
|
||||
/// \param width Width in pixels of window to create
|
||||
/// \param height Height in pixels of window to create
|
||||
/// \param flags Bitfield for the window creation flags
|
||||
/// ES_WINDOW_RGB - specifies that the color buffer should have R,G,B channels
|
||||
/// ES_WINDOW_ALPHA - specifies that the color buffer should have alpha
|
||||
/// ES_WINDOW_DEPTH - specifies that a depth buffer should be created
|
||||
/// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created
|
||||
/// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created
|
||||
/// ES_WINDOW_POST_SUB_BUFFER_SUPPORTED - specifies that EGL_POST_SUB_BUFFER_NV is supported.
|
||||
/// \return GL_TRUE if window creation is succesful, GL_FALSE otherwise
|
||||
GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, LPCTSTR title, GLint width, GLint height, GLuint flags );
|
||||
|
||||
//
|
||||
/// \brief Start the main loop for the OpenGL ES application
|
||||
/// \param esContext Application context
|
||||
//
|
||||
void ESUTIL_API esMainLoop ( ESContext *esContext );
|
||||
|
||||
//
|
||||
/// \brief Register a draw callback function to be used to render each frame
|
||||
/// \param esContext Application context
|
||||
/// \param drawFunc Draw callback function that will be used to render the scene
|
||||
//
|
||||
void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) ( ESContext* ) );
|
||||
|
||||
//
|
||||
/// \brief Register an update callback function to be used to update on each time step
|
||||
/// \param esContext Application context
|
||||
/// \param updateFunc Update callback function that will be used to render the scene
|
||||
//
|
||||
void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) );
|
||||
|
||||
//
|
||||
/// \brief Register an keyboard input processing callback function
|
||||
/// \param esContext Application context
|
||||
/// \param keyFunc Key callback function for application processing of keyboard input
|
||||
//
|
||||
void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext,
|
||||
void (ESCALLBACK *drawFunc) ( ESContext*, unsigned char, int, int ) );
|
||||
//
|
||||
/// \brief Log a message to the debug output for the platform
|
||||
/// \param formatStr Format string for error log.
|
||||
//
|
||||
void ESUTIL_API esLogMessage ( const char *formatStr, ... );
|
||||
|
||||
//
|
||||
///
|
||||
/// \brief Load a shader, check for compile errors, print error messages to output log
|
||||
/// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER)
|
||||
/// \param shaderSrc Shader source string
|
||||
/// \return A new shader object on success, 0 on failure
|
||||
//
|
||||
GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc );
|
||||
|
||||
//
|
||||
///
|
||||
/// \brief Load a vertex and fragment shader, create a program object, link program.
|
||||
/// Errors output to log.
|
||||
/// \param vertShaderSrc Vertex shader source code
|
||||
/// \param fragShaderSrc Fragment shader source code
|
||||
/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure
|
||||
//
|
||||
GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc );
|
||||
|
||||
|
||||
//
|
||||
/// \brief Generates geometry for a sphere. Allocates memory for the vertex data and stores
|
||||
/// the results in the arrays. Generate index list for a TRIANGLE_STRIP
|
||||
/// \param numSlices The number of slices in the sphere
|
||||
/// \param vertices If not NULL, will contain array of float3 positions
|
||||
/// \param normals If not NULL, will contain array of float3 normals
|
||||
/// \param texCoords If not NULL, will contain array of float2 texCoords
|
||||
/// \param indices If not NULL, will contain the array of indices for the triangle strip
|
||||
/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
|
||||
/// if it is not NULL ) as a GL_TRIANGLE_STRIP
|
||||
//
|
||||
int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals,
|
||||
GLfloat **texCoords, GLushort **indices );
|
||||
|
||||
//
|
||||
/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores
|
||||
/// the results in the arrays. Generate index list for a TRIANGLES
|
||||
/// \param scale The size of the cube, use 1.0 for a unit cube.
|
||||
/// \param vertices If not NULL, will contain array of float3 positions
|
||||
/// \param normals If not NULL, will contain array of float3 normals
|
||||
/// \param texCoords If not NULL, will contain array of float2 texCoords
|
||||
/// \param indices If not NULL, will contain the array of indices for the triangle strip
|
||||
/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
|
||||
/// if it is not NULL ) as a GL_TRIANGLES
|
||||
//
|
||||
int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
|
||||
GLfloat **texCoords, GLushort **indices );
|
||||
|
||||
//
|
||||
/// \brief Loads a 24-bit TGA image from a file
|
||||
/// \param fileName Name of the file on disk
|
||||
/// \param width Width of loaded image in pixels
|
||||
/// \param height Height of loaded image in pixels
|
||||
/// \return Pointer to loaded image. NULL on failure.
|
||||
//
|
||||
char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height );
|
||||
|
||||
|
||||
//
|
||||
/// \brief multiply matrix specified by result with a scaling matrix and return new matrix in result
|
||||
/// \param result Specifies the input matrix. Scaled matrix is returned in result.
|
||||
/// \param sx, sy, sz Scale factors along the x, y and z axes respectively
|
||||
//
|
||||
void ESUTIL_API esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz);
|
||||
|
||||
//
|
||||
/// \brief multiply matrix specified by result with a translation matrix and return new matrix in result
|
||||
/// \param result Specifies the input matrix. Translated matrix is returned in result.
|
||||
/// \param tx, ty, tz Scale factors along the x, y and z axes respectively
|
||||
//
|
||||
void ESUTIL_API esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz);
|
||||
|
||||
//
|
||||
/// \brief multiply matrix specified by result with a rotation matrix and return new matrix in result
|
||||
/// \param result Specifies the input matrix. Rotated matrix is returned in result.
|
||||
/// \param angle Specifies the angle of rotation, in degrees.
|
||||
/// \param x, y, z Specify the x, y and z coordinates of a vector, respectively
|
||||
//
|
||||
void ESUTIL_API esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
|
||||
|
||||
//
|
||||
// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
|
||||
/// \param result Specifies the input matrix. new matrix is returned in result.
|
||||
/// \param left, right Coordinates for the left and right vertical clipping planes
|
||||
/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes
|
||||
/// \param nearZ, farZ Distances to the near and far depth clipping planes. Both distances must be positive.
|
||||
//
|
||||
void ESUTIL_API esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
|
||||
|
||||
//
|
||||
/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
|
||||
/// \param result Specifies the input matrix. new matrix is returned in result.
|
||||
/// \param fovy Field of view y angle in degrees
|
||||
/// \param aspect Aspect ratio of screen
|
||||
/// \param nearZ Near plane distance
|
||||
/// \param farZ Far plane distance
|
||||
//
|
||||
void ESUTIL_API esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ);
|
||||
|
||||
//
|
||||
/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
|
||||
/// \param result Specifies the input matrix. new matrix is returned in result.
|
||||
/// \param left, right Coordinates for the left and right vertical clipping planes
|
||||
/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes
|
||||
/// \param nearZ, farZ Distances to the near and far depth clipping planes. These values are negative if plane is behind the viewer
|
||||
//
|
||||
void ESUTIL_API esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
|
||||
|
||||
//
|
||||
/// \brief perform the following operation - result matrix = srcA matrix * srcB matrix
|
||||
/// \param result Returns multiplied matrix
|
||||
/// \param srcA, srcB Input matrices to be multiplied
|
||||
//
|
||||
void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB);
|
||||
|
||||
//
|
||||
//// \brief return an indentity matrix
|
||||
//// \param result returns identity matrix
|
||||
//
|
||||
void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ESUTIL_H
|
|
@ -1,190 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="esUtil"
|
||||
ProjectGUID="{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}"
|
||||
RootNamespace="esUtil"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Win32"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Win32\esUtil_TGA.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\esUtil_win.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Win32\esUtil_win32.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Common"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\esShader.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\esShapes.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\esTransform.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\esUtil.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\esUtil.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,65 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// esUtil_win.h
|
||||
//
|
||||
// API-neutral interface for creating windows. Implementation needs to be provided per-platform.
|
||||
|
||||
#ifndef ESUTIL_WIN_H
|
||||
#define ESUTIL_WIN_H
|
||||
|
||||
///
|
||||
// Includes
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
// Macros
|
||||
//
|
||||
|
||||
///
|
||||
// Types
|
||||
//
|
||||
|
||||
///
|
||||
// Public Functions
|
||||
//
|
||||
|
||||
///
|
||||
// WinCreate()
|
||||
//
|
||||
// Create Win32 instance and window
|
||||
//
|
||||
GLboolean WinCreate ( ESContext *esContext, LPCTSTR title );
|
||||
|
||||
///
|
||||
// WinLoop()
|
||||
//
|
||||
// Start main windows loop
|
||||
//
|
||||
void WinLoop ( ESContext *esContext );
|
||||
|
||||
///
|
||||
// WinTGALoad()
|
||||
//
|
||||
// TGA loader win32 implementation
|
||||
//
|
||||
int WinTGALoad ( const char *fileName, char **buffer, int *width, int *height );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ESUTIL_WIN_H
|
|
@ -1,194 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// Hello_Triangle.c
|
||||
//
|
||||
// This is a simple example that draws a single triangle with
|
||||
// a minimal vertex/fragment shader. The purpose of this
|
||||
// example is to demonstrate the basic concepts of
|
||||
// OpenGL ES 2.0 rendering.
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Create a shader object, load the shader source, and
|
||||
// compile the shader.
|
||||
//
|
||||
GLuint LoadShader ( GLenum type, const char *shaderSrc )
|
||||
{
|
||||
GLuint shader;
|
||||
GLint compiled;
|
||||
|
||||
// Create the shader object
|
||||
shader = glCreateShader ( type );
|
||||
|
||||
if ( shader == 0 )
|
||||
return 0;
|
||||
|
||||
// Load the shader source
|
||||
glShaderSource ( shader, 1, &shaderSrc, NULL );
|
||||
|
||||
// Compile the shader
|
||||
glCompileShader ( shader );
|
||||
|
||||
// Check the compile status
|
||||
glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );
|
||||
|
||||
if ( !compiled )
|
||||
{
|
||||
GLint infoLen = 0;
|
||||
|
||||
glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );
|
||||
|
||||
if ( infoLen > 1 )
|
||||
{
|
||||
char* infoLog = malloc (sizeof(char) * infoLen );
|
||||
|
||||
glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );
|
||||
esLogMessage ( "Error compiling shader:\n%s\n", infoLog );
|
||||
|
||||
free ( infoLog );
|
||||
}
|
||||
|
||||
glDeleteShader ( shader );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return shader;
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"attribute vec4 vPosition; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = vPosition; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float;\n"\
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 );\n"
|
||||
"} \n";
|
||||
|
||||
GLuint vertexShader;
|
||||
GLuint fragmentShader;
|
||||
GLuint programObject;
|
||||
GLint linked;
|
||||
|
||||
// Load the vertex/fragment shaders
|
||||
vertexShader = LoadShader ( GL_VERTEX_SHADER, vShaderStr );
|
||||
fragmentShader = LoadShader ( GL_FRAGMENT_SHADER, fShaderStr );
|
||||
|
||||
// Create the program object
|
||||
programObject = glCreateProgram ( );
|
||||
|
||||
if ( programObject == 0 )
|
||||
return 0;
|
||||
|
||||
glAttachShader ( programObject, vertexShader );
|
||||
glAttachShader ( programObject, fragmentShader );
|
||||
|
||||
// Bind vPosition to attribute 0
|
||||
glBindAttribLocation ( programObject, 0, "vPosition" );
|
||||
|
||||
// Link the program
|
||||
glLinkProgram ( programObject );
|
||||
|
||||
// Check the link status
|
||||
glGetProgramiv ( programObject, GL_LINK_STATUS, &linked );
|
||||
|
||||
if ( !linked )
|
||||
{
|
||||
GLint infoLen = 0;
|
||||
|
||||
glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen );
|
||||
|
||||
if ( infoLen > 1 )
|
||||
{
|
||||
char* infoLog = malloc (sizeof(char) * infoLen );
|
||||
|
||||
glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog );
|
||||
esLogMessage ( "Error linking program:\n%s\n", infoLog );
|
||||
|
||||
free ( infoLog );
|
||||
}
|
||||
|
||||
glDeleteProgram ( programObject );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Store the program object
|
||||
userData->programObject = programObject;
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f,
|
||||
-0.5f, -0.5f, 0.0f,
|
||||
0.5f, -0.5f, 0.0f };
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex data
|
||||
glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices );
|
||||
glEnableVertexAttribArray ( 0 );
|
||||
|
||||
glDrawArrays ( GL_TRIANGLES, 0, 3 );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("Hello Triangle"), 320, 240, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="Hello_Triangle"
|
||||
ProjectGUID="{8278251F-6C1F-4D80-8499-FA7B590FAFE6}"
|
||||
RootNamespace="Hello_Triangle"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\Hello_Triangle.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,346 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// MipMap2D.c
|
||||
//
|
||||
// This is a simple example that demonstrates generating a mipmap chain
|
||||
// and rendering with it
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
GLint texCoordLoc;
|
||||
|
||||
// Sampler location
|
||||
GLint samplerLoc;
|
||||
|
||||
// Offset location
|
||||
GLint offsetLoc;
|
||||
|
||||
// Texture handle
|
||||
GLuint textureId;
|
||||
|
||||
} UserData;
|
||||
|
||||
|
||||
///
|
||||
// From an RGB8 source image, generate the next level mipmap
|
||||
//
|
||||
GLboolean GenMipMap2D( GLubyte *src, GLubyte **dst, int srcWidth, int srcHeight, int *dstWidth, int *dstHeight )
|
||||
{
|
||||
int x,
|
||||
y;
|
||||
int texelSize = 3;
|
||||
|
||||
*dstWidth = srcWidth / 2;
|
||||
if ( *dstWidth <= 0 )
|
||||
*dstWidth = 1;
|
||||
|
||||
*dstHeight = srcHeight / 2;
|
||||
if ( *dstHeight <= 0 )
|
||||
*dstHeight = 1;
|
||||
|
||||
*dst = malloc ( sizeof(GLubyte) * texelSize * (*dstWidth) * (*dstHeight) );
|
||||
if ( *dst == NULL )
|
||||
return GL_FALSE;
|
||||
|
||||
for ( y = 0; y < *dstHeight; y++ )
|
||||
{
|
||||
for( x = 0; x < *dstWidth; x++ )
|
||||
{
|
||||
int srcIndex[4];
|
||||
float r = 0.0f,
|
||||
g = 0.0f,
|
||||
b = 0.0f;
|
||||
int sample;
|
||||
|
||||
// Compute the offsets for 2x2 grid of pixels in previous
|
||||
// image to perform box filter
|
||||
srcIndex[0] =
|
||||
(((y * 2) * srcWidth) + (x * 2)) * texelSize;
|
||||
srcIndex[1] =
|
||||
(((y * 2) * srcWidth) + (x * 2 + 1)) * texelSize;
|
||||
srcIndex[2] =
|
||||
((((y * 2) + 1) * srcWidth) + (x * 2)) * texelSize;
|
||||
srcIndex[3] =
|
||||
((((y * 2) + 1) * srcWidth) + (x * 2 + 1)) * texelSize;
|
||||
|
||||
// Sum all pixels
|
||||
for ( sample = 0; sample < 4; sample++ )
|
||||
{
|
||||
r += src[srcIndex[sample]];
|
||||
g += src[srcIndex[sample] + 1];
|
||||
b += src[srcIndex[sample] + 2];
|
||||
}
|
||||
|
||||
// Average results
|
||||
r /= 4.0;
|
||||
g /= 4.0;
|
||||
b /= 4.0;
|
||||
|
||||
// Store resulting pixels
|
||||
(*dst)[ ( y * (*dstWidth) + x ) * texelSize ] = (GLubyte)( r );
|
||||
(*dst)[ ( y * (*dstWidth) + x ) * texelSize + 1] = (GLubyte)( g );
|
||||
(*dst)[ ( y * (*dstWidth) + x ) * texelSize + 2] = (GLubyte)( b );
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Generate an RGB8 checkerboard image
|
||||
//
|
||||
GLubyte* GenCheckImage( int width, int height, int checkSize )
|
||||
{
|
||||
int x,
|
||||
y;
|
||||
GLubyte *pixels = malloc( width * height * 3 );
|
||||
|
||||
if ( pixels == NULL )
|
||||
return NULL;
|
||||
|
||||
for ( y = 0; y < height; y++ )
|
||||
for ( x = 0; x < width; x++ )
|
||||
{
|
||||
GLubyte rColor = 0;
|
||||
GLubyte bColor = 0;
|
||||
|
||||
if ( ( x / checkSize ) % 2 == 0 )
|
||||
{
|
||||
rColor = 255 * ( ( y / checkSize ) % 2 );
|
||||
bColor = 255 * ( 1 - ( ( y / checkSize ) % 2 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
bColor = 255 * ( ( y / checkSize ) % 2 );
|
||||
rColor = 255 * ( 1 - ( ( y / checkSize ) % 2 ) );
|
||||
}
|
||||
|
||||
pixels[(y * height + x) * 3] = rColor;
|
||||
pixels[(y * height + x) * 3 + 1] = 0;
|
||||
pixels[(y * height + x) * 3 + 2] = bColor;
|
||||
}
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
///
|
||||
// Create a mipmapped 2D texture image
|
||||
//
|
||||
GLuint CreateMipMappedTexture2D( )
|
||||
{
|
||||
// Texture object handle
|
||||
GLuint textureId;
|
||||
int width = 256,
|
||||
height = 256;
|
||||
int level;
|
||||
GLubyte *pixels;
|
||||
GLubyte *prevImage;
|
||||
GLubyte *newImage = NULL;
|
||||
|
||||
pixels = GenCheckImage( width, height, 8 );
|
||||
if ( pixels == NULL )
|
||||
return 0;
|
||||
|
||||
// Generate a texture object
|
||||
glGenTextures ( 1, &textureId );
|
||||
|
||||
// Bind the texture object
|
||||
glBindTexture ( GL_TEXTURE_2D, textureId );
|
||||
|
||||
// Load mipmap level 0
|
||||
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, width, height,
|
||||
0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
|
||||
|
||||
level = 1;
|
||||
prevImage = &pixels[0];
|
||||
|
||||
while ( width > 1 && height > 1 )
|
||||
{
|
||||
int newWidth,
|
||||
newHeight;
|
||||
|
||||
// Generate the next mipmap level
|
||||
GenMipMap2D( prevImage, &newImage, width, height,
|
||||
&newWidth, &newHeight );
|
||||
|
||||
// Load the mipmap level
|
||||
glTexImage2D( GL_TEXTURE_2D, level, GL_RGB,
|
||||
newWidth, newHeight, 0, GL_RGB,
|
||||
GL_UNSIGNED_BYTE, newImage );
|
||||
|
||||
// Free the previous image
|
||||
free ( prevImage );
|
||||
|
||||
// Set the previous image for the next iteration
|
||||
prevImage = newImage;
|
||||
level++;
|
||||
|
||||
// Half the width and height
|
||||
width = newWidth;
|
||||
height = newHeight;
|
||||
}
|
||||
|
||||
free ( newImage );
|
||||
|
||||
// Set the filtering mode
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
|
||||
return textureId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"uniform float u_offset; \n"
|
||||
"attribute vec4 a_position; \n"
|
||||
"attribute vec2 a_texCoord; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = a_position; \n"
|
||||
" gl_Position.x += u_offset;\n"
|
||||
" v_texCoord = a_texCoord; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"uniform sampler2D s_texture; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = texture2D( s_texture, v_texCoord );\n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" );
|
||||
|
||||
// Get the sampler location
|
||||
userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" );
|
||||
|
||||
// Get the offset location
|
||||
userData->offsetLoc = glGetUniformLocation( userData->programObject, "u_offset" );
|
||||
|
||||
// Load the texture
|
||||
userData->textureId = CreateMipMappedTexture2D ();
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLfloat vVertices[] = { -0.5f, 0.5f, 0.0f, 1.5f, // Position 0
|
||||
0.0f, 0.0f, // TexCoord 0
|
||||
-0.5f, -0.5f, 0.0f, 0.75f, // Position 1
|
||||
0.0f, 1.0f, // TexCoord 1
|
||||
0.5f, -0.5f, 0.0f, 0.75f, // Position 2
|
||||
1.0f, 1.0f, // TexCoord 2
|
||||
0.5f, 0.5f, 0.0f, 1.5f, // Position 3
|
||||
1.0f, 0.0f // TexCoord 3
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 4, GL_FLOAT,
|
||||
GL_FALSE, 6 * sizeof(GLfloat), vVertices );
|
||||
// Load the texture coordinate
|
||||
glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT,
|
||||
GL_FALSE, 6 * sizeof(GLfloat), &vVertices[4] );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
glEnableVertexAttribArray ( userData->texCoordLoc );
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
glBindTexture ( GL_TEXTURE_2D, userData->textureId );
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i ( userData->samplerLoc, 0 );
|
||||
|
||||
// Draw quad with nearest sampling
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glUniform1f ( userData->offsetLoc, -0.6f );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
// Draw quad with trilinear filtering
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
||||
glUniform1f ( userData->offsetLoc, 0.6f );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Delete texture object
|
||||
glDeleteTextures ( 1, &userData->textureId );
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("MipMap 2D"), 320, 240, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="MipMap2D"
|
||||
ProjectGUID="{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}"
|
||||
RootNamespace="MipMap2D"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\MipMap2D.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,213 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// MultiTexture.c
|
||||
//
|
||||
// This is an example that draws a quad with a basemap and
|
||||
// lightmap to demonstrate multitexturing.
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
GLint texCoordLoc;
|
||||
|
||||
// Sampler locations
|
||||
GLint baseMapLoc;
|
||||
GLint lightMapLoc;
|
||||
|
||||
// Texture handle
|
||||
GLuint baseMapTexId;
|
||||
GLuint lightMapTexId;
|
||||
|
||||
} UserData;
|
||||
|
||||
|
||||
///
|
||||
// Load texture from disk
|
||||
//
|
||||
GLuint LoadTexture ( char *fileName )
|
||||
{
|
||||
int width,
|
||||
height;
|
||||
char *buffer = esLoadTGA ( fileName, &width, &height );
|
||||
GLuint texId;
|
||||
|
||||
if ( buffer == NULL )
|
||||
{
|
||||
esLogMessage ( "Error loading (%s) image.\n", fileName );
|
||||
return 0;
|
||||
}
|
||||
|
||||
glGenTextures ( 1, &texId );
|
||||
glBindTexture ( GL_TEXTURE_2D, texId );
|
||||
|
||||
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
|
||||
free ( buffer );
|
||||
|
||||
return texId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"attribute vec4 a_position; \n"
|
||||
"attribute vec2 a_texCoord; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = a_position; \n"
|
||||
" v_texCoord = a_texCoord; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"uniform sampler2D s_baseMap; \n"
|
||||
"uniform sampler2D s_lightMap; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" vec4 baseColor; \n"
|
||||
" vec4 lightColor; \n"
|
||||
" \n"
|
||||
" baseColor = texture2D( s_baseMap, v_texCoord ); \n"
|
||||
" lightColor = texture2D( s_lightMap, v_texCoord ); \n"
|
||||
" gl_FragColor = baseColor * (lightColor + 0.25); \n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" );
|
||||
|
||||
// Get the sampler location
|
||||
userData->baseMapLoc = glGetUniformLocation ( userData->programObject, "s_baseMap" );
|
||||
userData->lightMapLoc = glGetUniformLocation ( userData->programObject, "s_lightMap" );
|
||||
|
||||
// Load the textures
|
||||
userData->baseMapTexId = LoadTexture ( "basemap.tga" );
|
||||
userData->lightMapTexId = LoadTexture ( "lightmap.tga" );
|
||||
|
||||
if ( userData->baseMapTexId == 0 || userData->lightMapTexId == 0 )
|
||||
return FALSE;
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLfloat vVertices[] = { -0.5f, 0.5f, 0.0f, // Position 0
|
||||
0.0f, 0.0f, // TexCoord 0
|
||||
-0.5f, -0.5f, 0.0f, // Position 1
|
||||
0.0f, 1.0f, // TexCoord 1
|
||||
0.5f, -0.5f, 0.0f, // Position 2
|
||||
1.0f, 1.0f, // TexCoord 2
|
||||
0.5f, 0.5f, 0.0f, // Position 3
|
||||
1.0f, 0.0f // TexCoord 3
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof(GLfloat), vVertices );
|
||||
// Load the texture coordinate
|
||||
glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3] );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
glEnableVertexAttribArray ( userData->texCoordLoc );
|
||||
|
||||
// Bind the base map
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
glBindTexture ( GL_TEXTURE_2D, userData->baseMapTexId );
|
||||
|
||||
// Set the base map sampler to texture unit to 0
|
||||
glUniform1i ( userData->baseMapLoc, 0 );
|
||||
|
||||
// Bind the light map
|
||||
glActiveTexture ( GL_TEXTURE1 );
|
||||
glBindTexture ( GL_TEXTURE_2D, userData->lightMapTexId );
|
||||
|
||||
// Set the light map sampler to texture unit 1
|
||||
glUniform1i ( userData->lightMapLoc, 1 );
|
||||
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Delete texture object
|
||||
glDeleteTextures ( 1, &userData->baseMapTexId );
|
||||
glDeleteTextures ( 1, &userData->lightMapTexId );
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("MultiTexture"), 320, 240, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,185 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="MultiTexture"
|
||||
ProjectGUID="{120CFF94-ED4B-4C5B-9587-9E40889F15F7}"
|
||||
RootNamespace="MultiTexture"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="xcopy /D /Y basemap.tga "$(OutDir)"
xcopy /D /Y lightmap.tga "$(OutDir)"
"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="xcopy /D /Y basemap.tga "$(OutDir)"
xcopy /D /Y lightmap.tga "$(OutDir)"
"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\MultiTexture.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
Двоичные данные
gfx/angle/samples/gles2_book/MultiTexture/basemap.tga
Двоичные данные
gfx/angle/samples/gles2_book/MultiTexture/basemap.tga
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 768 KiB |
Двоичные данные
gfx/angle/samples/gles2_book/MultiTexture/lightmap.tga
Двоичные данные
gfx/angle/samples/gles2_book/MultiTexture/lightmap.tga
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 192 KiB |
|
@ -1,294 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// ParticleSystem.c
|
||||
//
|
||||
// This is an example that demonstrates rendering a particle system
|
||||
// using a vertex shader and point sprites.
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
#define NUM_PARTICLES 1000
|
||||
#define PARTICLE_SIZE 7
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint lifetimeLoc;
|
||||
GLint startPositionLoc;
|
||||
GLint endPositionLoc;
|
||||
|
||||
// Uniform location
|
||||
GLint timeLoc;
|
||||
GLint colorLoc;
|
||||
GLint centerPositionLoc;
|
||||
GLint samplerLoc;
|
||||
|
||||
// Texture handle
|
||||
GLuint textureId;
|
||||
|
||||
// Particle vertex data
|
||||
float particleData[ NUM_PARTICLES * PARTICLE_SIZE ];
|
||||
|
||||
// Current time
|
||||
float time;
|
||||
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Load texture from disk
|
||||
//
|
||||
GLuint LoadTexture ( char *fileName )
|
||||
{
|
||||
int width,
|
||||
height;
|
||||
char *buffer = esLoadTGA ( fileName, &width, &height );
|
||||
GLuint texId;
|
||||
|
||||
if ( buffer == NULL )
|
||||
{
|
||||
esLogMessage ( "Error loading (%s) image.\n", fileName );
|
||||
return 0;
|
||||
}
|
||||
|
||||
glGenTextures ( 1, &texId );
|
||||
glBindTexture ( GL_TEXTURE_2D, texId );
|
||||
|
||||
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
|
||||
free ( buffer );
|
||||
|
||||
return texId;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
int i;
|
||||
|
||||
GLbyte vShaderStr[] =
|
||||
"uniform float u_time; \n"
|
||||
"uniform vec3 u_centerPosition; \n"
|
||||
"attribute float a_lifetime; \n"
|
||||
"attribute vec3 a_startPosition; \n"
|
||||
"attribute vec3 a_endPosition; \n"
|
||||
"varying float v_lifetime; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" if ( u_time <= a_lifetime ) \n"
|
||||
" { \n"
|
||||
" gl_Position.xyz = a_startPosition + \n"
|
||||
" (u_time * a_endPosition); \n"
|
||||
" gl_Position.xyz += u_centerPosition; \n"
|
||||
" gl_Position.w = 1.0; \n"
|
||||
" } \n"
|
||||
" else \n"
|
||||
" gl_Position = vec4( -1000, -1000, 0, 0 ); \n"
|
||||
" v_lifetime = 1.0 - ( u_time / a_lifetime ); \n"
|
||||
" v_lifetime = clamp ( v_lifetime, 0.0, 1.0 ); \n"
|
||||
" gl_PointSize = ( v_lifetime * v_lifetime ) * 40.0; \n"
|
||||
"}";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"uniform vec4 u_color; \n"
|
||||
"varying float v_lifetime; \n"
|
||||
"uniform sampler2D s_texture; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" vec4 texColor; \n"
|
||||
" texColor = texture2D( s_texture, gl_PointCoord ); \n"
|
||||
" gl_FragColor = vec4( u_color ) * texColor; \n"
|
||||
" gl_FragColor.a *= v_lifetime; \n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->lifetimeLoc = glGetAttribLocation ( userData->programObject, "a_lifetime" );
|
||||
userData->startPositionLoc = glGetAttribLocation ( userData->programObject, "a_startPosition" );
|
||||
userData->endPositionLoc = glGetAttribLocation ( userData->programObject, "a_endPosition" );
|
||||
|
||||
// Get the uniform locations
|
||||
userData->timeLoc = glGetUniformLocation ( userData->programObject, "u_time" );
|
||||
userData->centerPositionLoc = glGetUniformLocation ( userData->programObject, "u_centerPosition" );
|
||||
userData->colorLoc = glGetUniformLocation ( userData->programObject, "u_color" );
|
||||
userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" );
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
|
||||
// Fill in particle data array
|
||||
srand ( 0 );
|
||||
for ( i = 0; i < NUM_PARTICLES; i++ )
|
||||
{
|
||||
float *particleData = &userData->particleData[i * PARTICLE_SIZE];
|
||||
|
||||
// Lifetime of particle
|
||||
(*particleData++) = ( (float)(rand() % 10000) / 10000.0f );
|
||||
|
||||
// End position of particle
|
||||
(*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f;
|
||||
(*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f;
|
||||
(*particleData++) = ( (float)(rand() % 10000) / 5000.0f ) - 1.0f;
|
||||
|
||||
// Start position of particle
|
||||
(*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f;
|
||||
(*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f;
|
||||
(*particleData++) = ( (float)(rand() % 10000) / 40000.0f ) - 0.125f;
|
||||
|
||||
}
|
||||
|
||||
// Initialize time to cause reset on first update
|
||||
userData->time = 1.0f;
|
||||
|
||||
userData->textureId = LoadTexture ( "smoke.tga" );
|
||||
if ( userData->textureId <= 0 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Update time-based variables
|
||||
//
|
||||
void Update ( ESContext *esContext, float deltaTime )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
userData->time += deltaTime;
|
||||
|
||||
if ( userData->time >= 1.0f )
|
||||
{
|
||||
float centerPos[3];
|
||||
float color[4];
|
||||
|
||||
userData->time = 0.0f;
|
||||
|
||||
// Pick a new start location and color
|
||||
centerPos[0] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f;
|
||||
centerPos[1] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f;
|
||||
centerPos[2] = ( (float)(rand() % 10000) / 10000.0f ) - 0.5f;
|
||||
|
||||
glUniform3fv ( userData->centerPositionLoc, 1, ¢erPos[0] );
|
||||
|
||||
// Random color
|
||||
color[0] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f;
|
||||
color[1] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f;
|
||||
color[2] = ( (float)(rand() % 10000) / 20000.0f ) + 0.5f;
|
||||
color[3] = 0.5;
|
||||
|
||||
glUniform4fv ( userData->colorLoc, 1, &color[0] );
|
||||
}
|
||||
|
||||
// Load uniform time variable
|
||||
glUniform1f ( userData->timeLoc, userData->time );
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex attributes
|
||||
glVertexAttribPointer ( userData->lifetimeLoc, 1, GL_FLOAT,
|
||||
GL_FALSE, PARTICLE_SIZE * sizeof(GLfloat),
|
||||
userData->particleData );
|
||||
|
||||
glVertexAttribPointer ( userData->endPositionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, PARTICLE_SIZE * sizeof(GLfloat),
|
||||
&userData->particleData[1] );
|
||||
|
||||
glVertexAttribPointer ( userData->startPositionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, PARTICLE_SIZE * sizeof(GLfloat),
|
||||
&userData->particleData[4] );
|
||||
|
||||
|
||||
glEnableVertexAttribArray ( userData->lifetimeLoc );
|
||||
glEnableVertexAttribArray ( userData->endPositionLoc );
|
||||
glEnableVertexAttribArray ( userData->startPositionLoc );
|
||||
// Blend particles
|
||||
glEnable ( GL_BLEND );
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE );
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
glBindTexture ( GL_TEXTURE_2D, userData->textureId );
|
||||
glEnable ( GL_TEXTURE_2D );
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i ( userData->samplerLoc, 0 );
|
||||
|
||||
glDrawArrays( GL_POINTS, 0, NUM_PARTICLES );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Delete texture object
|
||||
glDeleteTextures ( 1, &userData->textureId );
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("ParticleSystem"), 640, 480, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
esRegisterUpdateFunc ( &esContext, Update );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,185 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="ParticleSystem"
|
||||
ProjectGUID="{B9E5BFFC-D843-4E0E-9D3E-23913A613473}"
|
||||
RootNamespace="ParticleSystem"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="xcopy /D /Y smoke.tga "$(outDir)""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="xcopy /D /Y smoke.tga "$(outDir)""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\ParticleSystem.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
Двоичные данные
gfx/angle/samples/gles2_book/ParticleSystem/smoke.tga
Двоичные данные
gfx/angle/samples/gles2_book/ParticleSystem/smoke.tga
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 48 KiB |
|
@ -1,204 +0,0 @@
|
|||
// Based on a sample from:
|
||||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// PostSubBuffer.c
|
||||
//
|
||||
// This is a simple example that draws a rotating cube in perspective
|
||||
// using a vertex shader to transform the object, posting only a subrectangle
|
||||
// to the window surface.
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
#define WINDOW_WIDTH 320
|
||||
#define WINDOW_HEIGHT 240
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
|
||||
// Uniform locations
|
||||
GLint mvpLoc;
|
||||
|
||||
// Vertex daata
|
||||
GLfloat *vertices;
|
||||
GLushort *indices;
|
||||
int numIndices;
|
||||
|
||||
// Rotation angle
|
||||
GLfloat angle;
|
||||
|
||||
// MVP matrix
|
||||
ESMatrix mvpMatrix;
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"uniform mat4 u_mvpMatrix; \n"
|
||||
"attribute vec4 a_position; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = u_mvpMatrix * a_position; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); \n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
|
||||
// Get the uniform locations
|
||||
userData->mvpLoc = glGetUniformLocation( userData->programObject, "u_mvpMatrix" );
|
||||
|
||||
// Generate the vertex data
|
||||
userData->numIndices = esGenCube( 1.0, &userData->vertices,
|
||||
NULL, NULL, &userData->indices );
|
||||
|
||||
// Starting rotation angle for the cube
|
||||
userData->angle = 45.0f;
|
||||
|
||||
// Clear the whole window surface.
|
||||
glClearColor ( 0.0f, 0.0f, 1.0f, 0.0f );
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Update MVP matrix based on time
|
||||
//
|
||||
void Update ( ESContext *esContext, float deltaTime )
|
||||
{
|
||||
UserData *userData = (UserData*) esContext->userData;
|
||||
ESMatrix perspective;
|
||||
ESMatrix modelview;
|
||||
float aspect;
|
||||
|
||||
// Compute a rotation angle based on time to rotate the cube
|
||||
userData->angle += ( deltaTime * 40.0f );
|
||||
if( userData->angle >= 360.0f )
|
||||
userData->angle -= 360.0f;
|
||||
|
||||
// Compute the window aspect ratio
|
||||
aspect = (GLfloat) esContext->width / (GLfloat) esContext->height;
|
||||
|
||||
// Generate a perspective matrix with a 60 degree FOV
|
||||
esMatrixLoadIdentity( &perspective );
|
||||
esPerspective( &perspective, 60.0f, aspect, 1.0f, 20.0f );
|
||||
|
||||
// Generate a model view matrix to rotate/translate the cube
|
||||
esMatrixLoadIdentity( &modelview );
|
||||
|
||||
// Translate away from the viewer
|
||||
esTranslate( &modelview, 0.0, 0.0, -2.0 );
|
||||
|
||||
// Rotate the cube
|
||||
esRotate( &modelview, userData->angle, 1.0, 0.0, 1.0 );
|
||||
|
||||
// Compute the final MVP by multiplying the
|
||||
// modevleiw and perspective matrices together
|
||||
esMatrixMultiply( &userData->mvpMatrix, &modelview, &perspective );
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 3 * sizeof(GLfloat), userData->vertices );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
|
||||
|
||||
// Load the MVP matrix
|
||||
glUniformMatrix4fv( userData->mvpLoc, 1, GL_FALSE, (GLfloat*) &userData->mvpMatrix.m[0][0] );
|
||||
|
||||
// Draw the cube
|
||||
glDrawElements ( GL_TRIANGLES, userData->numIndices, GL_UNSIGNED_SHORT, userData->indices );
|
||||
|
||||
eglPostSubBufferNV ( esContext->eglDisplay, esContext->eglSurface, 60, 60, WINDOW_WIDTH - 120, WINDOW_HEIGHT - 120 );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
if ( userData->vertices != NULL )
|
||||
{
|
||||
free ( userData->vertices );
|
||||
}
|
||||
|
||||
if ( userData->indices != NULL )
|
||||
{
|
||||
free ( userData->indices );
|
||||
}
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("Simple Vertex Shader"), WINDOW_WIDTH, WINDOW_HEIGHT, ES_WINDOW_RGB | ES_WINDOW_POST_SUB_BUFFER_SUPPORTED );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
esRegisterUpdateFunc ( &esContext, Update );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="PostSubBuffer"
|
||||
ProjectGUID="{667CE95F-5DD8-4495-8C18-5CA8A175B12D}"
|
||||
RootNamespace="Simple_VertexShader"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\PostSubBuffer.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,198 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// Simple_Texture2D.c
|
||||
//
|
||||
// This is a simple example that draws a quad with a 2D
|
||||
// texture image. The purpose of this example is to demonstrate
|
||||
// the basics of 2D texturing
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
GLint texCoordLoc;
|
||||
|
||||
// Sampler location
|
||||
GLint samplerLoc;
|
||||
|
||||
// Texture handle
|
||||
GLuint textureId;
|
||||
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Create a simple 2x2 texture image with four different colors
|
||||
//
|
||||
GLuint CreateSimpleTexture2D( )
|
||||
{
|
||||
// Texture object handle
|
||||
GLuint textureId;
|
||||
|
||||
// 2x2 Image, 3 bytes per pixel (R, G, B)
|
||||
GLubyte pixels[4 * 3] =
|
||||
{
|
||||
255, 0, 0, // Red
|
||||
0, 255, 0, // Green
|
||||
0, 0, 255, // Blue
|
||||
255, 255, 0 // Yellow
|
||||
};
|
||||
|
||||
// Use tightly packed data
|
||||
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
|
||||
|
||||
// Generate a texture object
|
||||
glGenTextures ( 1, &textureId );
|
||||
|
||||
// Bind the texture object
|
||||
glBindTexture ( GL_TEXTURE_2D, textureId );
|
||||
|
||||
// Load the texture
|
||||
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
|
||||
|
||||
// Set the filtering mode
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
|
||||
return textureId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"attribute vec4 a_position; \n"
|
||||
"attribute vec2 a_texCoord; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = a_position; \n"
|
||||
" v_texCoord = a_texCoord; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"uniform sampler2D s_texture; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = texture2D( s_texture, v_texCoord );\n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" );
|
||||
|
||||
// Get the sampler location
|
||||
userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" );
|
||||
|
||||
// Load the texture
|
||||
userData->textureId = CreateSimpleTexture2D ();
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLfloat vVertices[] = { -0.5f, 0.5f, 0.0f, // Position 0
|
||||
0.0f, 0.0f, // TexCoord 0
|
||||
-0.5f, -0.5f, 0.0f, // Position 1
|
||||
0.0f, 1.0f, // TexCoord 1
|
||||
0.5f, -0.5f, 0.0f, // Position 2
|
||||
1.0f, 1.0f, // TexCoord 2
|
||||
0.5f, 0.5f, 0.0f, // Position 3
|
||||
1.0f, 0.0f // TexCoord 3
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof(GLfloat), vVertices );
|
||||
// Load the texture coordinate
|
||||
glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3] );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
glEnableVertexAttribArray ( userData->texCoordLoc );
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
glBindTexture ( GL_TEXTURE_2D, userData->textureId );
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i ( userData->samplerLoc, 0 );
|
||||
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Delete texture object
|
||||
glDeleteTextures ( 1, &userData->textureId );
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("Simple Texture 2D"), 320, 240, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="Simple_Texture2D"
|
||||
ProjectGUID="{2E54D748-781B-4DF2-A1DD-B9384A821810}"
|
||||
RootNamespace="Simple_Texture2D"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\Simple_Texture2D.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,229 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// Simple_TextureCubemap.c
|
||||
//
|
||||
// This is a simple example that draws a sphere with a cubemap image applied.
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
GLint normalLoc;
|
||||
|
||||
// Sampler location
|
||||
GLint samplerLoc;
|
||||
|
||||
// Texture handle
|
||||
GLuint textureId;
|
||||
|
||||
// Vertex data
|
||||
int numIndices;
|
||||
GLfloat *vertices;
|
||||
GLfloat *normals;
|
||||
GLushort *indices;
|
||||
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Create a simple cubemap with a 1x1 face with a different
|
||||
// color for each face
|
||||
GLuint CreateSimpleTextureCubemap( )
|
||||
{
|
||||
GLuint textureId;
|
||||
// Six 1x1 RGB faces
|
||||
GLubyte cubePixels[6][3] =
|
||||
{
|
||||
// Face 0 - Red
|
||||
255, 0, 0,
|
||||
// Face 1 - Green,
|
||||
0, 255, 0,
|
||||
// Face 3 - Blue
|
||||
0, 0, 255,
|
||||
// Face 4 - Yellow
|
||||
255, 255, 0,
|
||||
// Face 5 - Purple
|
||||
255, 0, 255,
|
||||
// Face 6 - White
|
||||
255, 255, 255
|
||||
};
|
||||
|
||||
// Generate a texture object
|
||||
glGenTextures ( 1, &textureId );
|
||||
|
||||
// Bind the texture object
|
||||
glBindTexture ( GL_TEXTURE_CUBE_MAP, textureId );
|
||||
|
||||
// Load the cube face - Positive X
|
||||
glTexImage2D ( GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[0] );
|
||||
|
||||
// Load the cube face - Negative X
|
||||
glTexImage2D ( GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[1] );
|
||||
|
||||
// Load the cube face - Positive Y
|
||||
glTexImage2D ( GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[2] );
|
||||
|
||||
// Load the cube face - Negative Y
|
||||
glTexImage2D ( GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[3] );
|
||||
|
||||
// Load the cube face - Positive Z
|
||||
glTexImage2D ( GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[4] );
|
||||
|
||||
// Load the cube face - Negative Z
|
||||
glTexImage2D ( GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, &cubePixels[5] );
|
||||
|
||||
// Set the filtering mode
|
||||
glTexParameteri ( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glTexParameteri ( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
|
||||
return textureId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"attribute vec4 a_position; \n"
|
||||
"attribute vec3 a_normal; \n"
|
||||
"varying vec3 v_normal; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = a_position; \n"
|
||||
" v_normal = a_normal; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"varying vec3 v_normal; \n"
|
||||
"uniform samplerCube s_texture; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = textureCube( s_texture, v_normal );\n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
userData->normalLoc = glGetAttribLocation ( userData->programObject, "a_normal" );
|
||||
|
||||
// Get the sampler locations
|
||||
userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" );
|
||||
|
||||
// Load the texture
|
||||
userData->textureId = CreateSimpleTextureCubemap ();
|
||||
|
||||
// Generate the vertex data
|
||||
userData->numIndices = esGenSphere ( 20, 0.75f, &userData->vertices, &userData->normals,
|
||||
NULL, &userData->indices );
|
||||
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
|
||||
glCullFace ( GL_BACK );
|
||||
glEnable ( GL_CULL_FACE );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 0, userData->vertices );
|
||||
// Load the normal
|
||||
glVertexAttribPointer ( userData->normalLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 0, userData->normals );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
glEnableVertexAttribArray ( userData->normalLoc );
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
glBindTexture ( GL_TEXTURE_CUBE_MAP, userData->textureId );
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i ( userData->samplerLoc, 0 );
|
||||
|
||||
glDrawElements ( GL_TRIANGLES, userData->numIndices,
|
||||
GL_UNSIGNED_SHORT, userData->indices );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Delete texture object
|
||||
glDeleteTextures ( 1, &userData->textureId );
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
|
||||
free ( userData->vertices );
|
||||
free ( userData->normals );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("Simple Texture Cubemap"), 320, 240, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,184 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="Simple_TextureCubemap"
|
||||
ProjectGUID="{5EE56061-643D-406E-B42D-4299D2411056}"
|
||||
RootNamespace="Simple_TextureCubemap"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
UseLibraryDependencyInputs="false"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\Simple_TextureCubemap.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,194 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// Simple_VertexShader.c
|
||||
//
|
||||
// This is a simple example that draws a rotating cube in perspective
|
||||
// using a vertex shader to transform the object
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
|
||||
// Uniform locations
|
||||
GLint mvpLoc;
|
||||
|
||||
// Vertex daata
|
||||
GLfloat *vertices;
|
||||
GLushort *indices;
|
||||
int numIndices;
|
||||
|
||||
// Rotation angle
|
||||
GLfloat angle;
|
||||
|
||||
// MVP matrix
|
||||
ESMatrix mvpMatrix;
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"uniform mat4 u_mvpMatrix; \n"
|
||||
"attribute vec4 a_position; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = u_mvpMatrix * a_position; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); \n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
|
||||
// Get the uniform locations
|
||||
userData->mvpLoc = glGetUniformLocation( userData->programObject, "u_mvpMatrix" );
|
||||
|
||||
// Generate the vertex data
|
||||
userData->numIndices = esGenCube( 1.0, &userData->vertices,
|
||||
NULL, NULL, &userData->indices );
|
||||
|
||||
// Starting rotation angle for the cube
|
||||
userData->angle = 45.0f;
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Update MVP matrix based on time
|
||||
//
|
||||
void Update ( ESContext *esContext, float deltaTime )
|
||||
{
|
||||
UserData *userData = (UserData*) esContext->userData;
|
||||
ESMatrix perspective;
|
||||
ESMatrix modelview;
|
||||
float aspect;
|
||||
|
||||
// Compute a rotation angle based on time to rotate the cube
|
||||
userData->angle += ( deltaTime * 40.0f );
|
||||
if( userData->angle >= 360.0f )
|
||||
userData->angle -= 360.0f;
|
||||
|
||||
// Compute the window aspect ratio
|
||||
aspect = (GLfloat) esContext->width / (GLfloat) esContext->height;
|
||||
|
||||
// Generate a perspective matrix with a 60 degree FOV
|
||||
esMatrixLoadIdentity( &perspective );
|
||||
esPerspective( &perspective, 60.0f, aspect, 1.0f, 20.0f );
|
||||
|
||||
// Generate a model view matrix to rotate/translate the cube
|
||||
esMatrixLoadIdentity( &modelview );
|
||||
|
||||
// Translate away from the viewer
|
||||
esTranslate( &modelview, 0.0, 0.0, -2.0 );
|
||||
|
||||
// Rotate the cube
|
||||
esRotate( &modelview, userData->angle, 1.0, 0.0, 1.0 );
|
||||
|
||||
// Compute the final MVP by multiplying the
|
||||
// modevleiw and perspective matrices together
|
||||
esMatrixMultiply( &userData->mvpMatrix, &modelview, &perspective );
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 3 * sizeof(GLfloat), userData->vertices );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
|
||||
|
||||
// Load the MVP matrix
|
||||
glUniformMatrix4fv( userData->mvpLoc, 1, GL_FALSE, (GLfloat*) &userData->mvpMatrix.m[0][0] );
|
||||
|
||||
// Draw the cube
|
||||
glDrawElements ( GL_TRIANGLES, userData->numIndices, GL_UNSIGNED_SHORT, userData->indices );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
if ( userData->vertices != NULL )
|
||||
{
|
||||
free ( userData->vertices );
|
||||
}
|
||||
|
||||
if ( userData->indices != NULL )
|
||||
{
|
||||
free ( userData->indices );
|
||||
}
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("Simple Vertex Shader"), 320, 240, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
esRegisterUpdateFunc ( &esContext, Update );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="Simple_VertexShader"
|
||||
ProjectGUID="{667CE95F-5DD8-4395-8C18-5CA8A175B12D}"
|
||||
RootNamespace="Simple_VertexShader"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\Simple_VertexShader.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,273 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// Stencil_Test.c
|
||||
//
|
||||
// This example shows various stencil buffer
|
||||
// operations.
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
|
||||
// Uniform locations
|
||||
GLint colorLoc;
|
||||
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"attribute vec4 a_position; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = a_position; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"uniform vec4 u_color; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = u_color; \n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
|
||||
// Get the sampler location
|
||||
userData->colorLoc = glGetUniformLocation ( userData->programObject, "u_color" );
|
||||
|
||||
// Set the clear color
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
|
||||
// Set the stencil clear value
|
||||
glClearStencil ( 0x1 );
|
||||
|
||||
// Set the depth clear value
|
||||
glClearDepthf( 0.75f );
|
||||
|
||||
// Enable the depth and stencil tests
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
glEnable( GL_STENCIL_TEST );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Initialize the stencil buffer values, and then use those
|
||||
// values to control rendering
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
int i;
|
||||
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
GLfloat vVertices[] = {
|
||||
-0.75f, 0.25f, 0.50f, // Quad #0
|
||||
-0.25f, 0.25f, 0.50f,
|
||||
-0.25f, 0.75f, 0.50f,
|
||||
-0.75f, 0.75f, 0.50f,
|
||||
0.25f, 0.25f, 0.90f, // Quad #1
|
||||
0.75f, 0.25f, 0.90f,
|
||||
0.75f, 0.75f, 0.90f,
|
||||
0.25f, 0.75f, 0.90f,
|
||||
-0.75f, -0.75f, 0.50f, // Quad #2
|
||||
-0.25f, -0.75f, 0.50f,
|
||||
-0.25f, -0.25f, 0.50f,
|
||||
-0.75f, -0.25f, 0.50f,
|
||||
0.25f, -0.75f, 0.50f, // Quad #3
|
||||
0.75f, -0.75f, 0.50f,
|
||||
0.75f, -0.25f, 0.50f,
|
||||
0.25f, -0.25f, 0.50f,
|
||||
-1.00f, -1.00f, 0.00f, // Big Quad
|
||||
1.00f, -1.00f, 0.00f,
|
||||
1.00f, 1.00f, 0.00f,
|
||||
-1.00f, 1.00f, 0.00f
|
||||
};
|
||||
|
||||
GLubyte indices[][6] = {
|
||||
{ 0, 1, 2, 0, 2, 3 }, // Quad #0
|
||||
{ 4, 5, 6, 4, 6, 7 }, // Quad #1
|
||||
{ 8, 9, 10, 8, 10, 11 }, // Quad #2
|
||||
{ 12, 13, 14, 12, 14, 15 }, // Quad #3
|
||||
{ 16, 17, 18, 16, 18, 19 } // Big Quad
|
||||
};
|
||||
|
||||
#define NumTests 4
|
||||
GLfloat colors[NumTests][4] = {
|
||||
{ 1.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ 0.0f, 1.0f, 0.0f, 1.0f },
|
||||
{ 0.0f, 0.0f, 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f, 0.0f }
|
||||
};
|
||||
|
||||
GLint numStencilBits;
|
||||
GLuint stencilValues[NumTests] = {
|
||||
0x7, // Result of test 0
|
||||
0x0, // Result of test 1
|
||||
0x2, // Result of test 2
|
||||
0xff // Result of test 3. We need to fill this
|
||||
// value in a run-time
|
||||
};
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color, depth, and stencil buffers. At this
|
||||
// point, the stencil buffer will be 0x1 for all pixels
|
||||
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 0, vVertices );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
|
||||
// Test 0:
|
||||
//
|
||||
// Initialize upper-left region. In this case, the
|
||||
// stencil-buffer values will be replaced because the
|
||||
// stencil test for the rendered pixels will fail the
|
||||
// stencil test, which is
|
||||
//
|
||||
// ref mask stencil mask
|
||||
// ( 0x7 & 0x3 ) < ( 0x1 & 0x7 )
|
||||
//
|
||||
// The value in the stencil buffer for these pixels will
|
||||
// be 0x7.
|
||||
//
|
||||
glStencilFunc( GL_LESS, 0x7, 0x3 );
|
||||
glStencilOp( GL_REPLACE, GL_DECR, GL_DECR );
|
||||
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[0] );
|
||||
|
||||
// Test 1:
|
||||
//
|
||||
// Initialize the upper-right region. Here, we'll decrement
|
||||
// the stencil-buffer values where the stencil test passes
|
||||
// but the depth test fails. The stencil test is
|
||||
//
|
||||
// ref mask stencil mask
|
||||
// ( 0x3 & 0x3 ) > ( 0x1 & 0x3 )
|
||||
//
|
||||
// but where the geometry fails the depth test. The
|
||||
// stencil values for these pixels will be 0x0.
|
||||
//
|
||||
glStencilFunc( GL_GREATER, 0x3, 0x3 );
|
||||
glStencilOp( GL_KEEP, GL_DECR, GL_KEEP );
|
||||
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[1] );
|
||||
|
||||
// Test 2:
|
||||
//
|
||||
// Initialize the lower-left region. Here we'll increment
|
||||
// (with saturation) the stencil value where both the
|
||||
// stencil and depth tests pass. The stencil test for
|
||||
// these pixels will be
|
||||
//
|
||||
// ref mask stencil mask
|
||||
// ( 0x1 & 0x3 ) == ( 0x1 & 0x3 )
|
||||
//
|
||||
// The stencil values for these pixels will be 0x2.
|
||||
//
|
||||
glStencilFunc( GL_EQUAL, 0x1, 0x3 );
|
||||
glStencilOp( GL_KEEP, GL_INCR, GL_INCR );
|
||||
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[2] );
|
||||
|
||||
// Test 3:
|
||||
//
|
||||
// Finally, initialize the lower-right region. We'll invert
|
||||
// the stencil value where the stencil tests fails. The
|
||||
// stencil test for these pixels will be
|
||||
//
|
||||
// ref mask stencil mask
|
||||
// ( 0x2 & 0x1 ) == ( 0x1 & 0x1 )
|
||||
//
|
||||
// The stencil value here will be set to ~((2^s-1) & 0x1),
|
||||
// (with the 0x1 being from the stencil clear value),
|
||||
// where 's' is the number of bits in the stencil buffer
|
||||
//
|
||||
glStencilFunc( GL_EQUAL, 0x2, 0x1 );
|
||||
glStencilOp( GL_INVERT, GL_KEEP, GL_KEEP );
|
||||
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[3] );
|
||||
|
||||
// Since we don't know at compile time how many stecil bits are present,
|
||||
// we'll query, and update the value correct value in the
|
||||
// stencilValues arrays for the fourth tests. We'll use this value
|
||||
// later in rendering.
|
||||
glGetIntegerv( GL_STENCIL_BITS, &numStencilBits );
|
||||
|
||||
stencilValues[3] = ~(((1 << numStencilBits) - 1) & 0x1) & 0xff;
|
||||
|
||||
// Use the stencil buffer for controlling where rendering will
|
||||
// occur. We diable writing to the stencil buffer so we
|
||||
// can test against them without modifying the values we
|
||||
// generated.
|
||||
glStencilMask( 0x0 );
|
||||
|
||||
for ( i = 0; i < NumTests; ++i )
|
||||
{
|
||||
glStencilFunc( GL_EQUAL, stencilValues[i], 0xff );
|
||||
glUniform4fv( userData->colorLoc, 1, colors[i] );
|
||||
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices[4] );
|
||||
}
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("Stencil Test"), 320, 240,
|
||||
ES_WINDOW_RGB | ES_WINDOW_DEPTH | ES_WINDOW_STENCIL );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,177 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="Stencil_Test"
|
||||
ProjectGUID="{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}"
|
||||
RootNamespace="Stencil_Test"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
IgnoreAllDefaultLibraries="false"
|
||||
GenerateDebugInformation="true"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\Stencil_Test.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,254 +0,0 @@
|
|||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// TextureWrap.c
|
||||
//
|
||||
// This is an example that demonstrates the three texture
|
||||
// wrap modes available on 2D textures
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
GLint texCoordLoc;
|
||||
|
||||
// Sampler location
|
||||
GLint samplerLoc;
|
||||
|
||||
// Offset location
|
||||
GLint offsetLoc;
|
||||
|
||||
// Texture handle
|
||||
GLuint textureId;
|
||||
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Generate an RGB8 checkerboard image
|
||||
//
|
||||
GLubyte* GenCheckImage( int width, int height, int checkSize )
|
||||
{
|
||||
int x,
|
||||
y;
|
||||
GLubyte *pixels = malloc( width * height * 3 );
|
||||
|
||||
if ( pixels == NULL )
|
||||
return NULL;
|
||||
|
||||
for ( y = 0; y < height; y++ )
|
||||
for ( x = 0; x < width; x++ )
|
||||
{
|
||||
GLubyte rColor = 0;
|
||||
GLubyte bColor = 0;
|
||||
|
||||
if ( ( x / checkSize ) % 2 == 0 )
|
||||
{
|
||||
rColor = 255 * ( ( y / checkSize ) % 2 );
|
||||
bColor = 255 * ( 1 - ( ( y / checkSize ) % 2 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
bColor = 255 * ( ( y / checkSize ) % 2 );
|
||||
rColor = 255 * ( 1 - ( ( y / checkSize ) % 2 ) );
|
||||
}
|
||||
|
||||
pixels[(y * height + x) * 3] = rColor;
|
||||
pixels[(y * height + x) * 3 + 1] = 0;
|
||||
pixels[(y * height + x) * 3 + 2] = bColor;
|
||||
}
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
///
|
||||
// Create a mipmapped 2D texture image
|
||||
//
|
||||
GLuint CreateTexture2D( )
|
||||
{
|
||||
// Texture object handle
|
||||
GLuint textureId;
|
||||
int width = 256,
|
||||
height = 256;
|
||||
GLubyte *pixels;
|
||||
|
||||
pixels = GenCheckImage( width, height, 64 );
|
||||
if ( pixels == NULL )
|
||||
return 0;
|
||||
|
||||
// Generate a texture object
|
||||
glGenTextures ( 1, &textureId );
|
||||
|
||||
// Bind the texture object
|
||||
glBindTexture ( GL_TEXTURE_2D, textureId );
|
||||
|
||||
// Load mipmap level 0
|
||||
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, width, height,
|
||||
0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
|
||||
|
||||
// Set the filtering mode
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
|
||||
return textureId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"uniform float u_offset; \n"
|
||||
"attribute vec4 a_position; \n"
|
||||
"attribute vec2 a_texCoord; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = a_position; \n"
|
||||
" gl_Position.x += u_offset;\n"
|
||||
" v_texCoord = a_texCoord; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"uniform sampler2D s_texture; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_FragColor = texture2D( s_texture, v_texCoord );\n"
|
||||
"} \n";
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" );
|
||||
|
||||
// Get the sampler location
|
||||
userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" );
|
||||
|
||||
// Get the offset location
|
||||
userData->offsetLoc = glGetUniformLocation( userData->programObject, "u_offset" );
|
||||
|
||||
// Load the texture
|
||||
userData->textureId = CreateTexture2D ();
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
GLfloat vVertices[] = { -0.3f, 0.3f, 0.0f, 1.0f, // Position 0
|
||||
-1.0f, -1.0f, // TexCoord 0
|
||||
-0.3f, -0.3f, 0.0f, 1.0f, // Position 1
|
||||
-1.0f, 2.0f, // TexCoord 1
|
||||
0.3f, -0.3f, 0.0f, 1.0f, // Position 2
|
||||
2.0f, 2.0f, // TexCoord 2
|
||||
0.3f, 0.3f, 0.0f, 1.0f, // Position 3
|
||||
2.0f, -1.0f // TexCoord 3
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 4, GL_FLOAT,
|
||||
GL_FALSE, 6 * sizeof(GLfloat), vVertices );
|
||||
// Load the texture coordinate
|
||||
glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT,
|
||||
GL_FALSE, 6 * sizeof(GLfloat), &vVertices[4] );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
glEnableVertexAttribArray ( userData->texCoordLoc );
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
glBindTexture ( GL_TEXTURE_2D, userData->textureId );
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i ( userData->samplerLoc, 0 );
|
||||
|
||||
// Draw quad with repeat wrap mode
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
||||
glUniform1f ( userData->offsetLoc, -0.7f );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
// Draw quad with clamp to edge wrap mode
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
glUniform1f ( userData->offsetLoc, 0.0f );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
// Draw quad with mirrored repeat
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT );
|
||||
glUniform1f ( userData->offsetLoc, 0.7f );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = esContext->userData;
|
||||
|
||||
// Delete texture object
|
||||
glDeleteTextures ( 1, &userData->textureId );
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("Texture Wrap"), 640, 480, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="TextureWrap"
|
||||
ProjectGUID="{CC1DE9A2-B456-4565-9C21-932253E969B9}"
|
||||
RootNamespace="TextureWrap"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../Common;../../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\TextureWrap.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,210 +0,0 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "esUtil", "gles2_book\Common\esUtil.vcproj", "{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78}
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6} = {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hello_Triangle", "gles2_book\Hello_Triangle\Hello_Triangle.vcproj", "{8278251F-6C1F-4D80-8499-FA7B590FAFE6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MipMap2D", "gles2_book\MipMap2D\MipMap2D.vcproj", "{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MultiTexture", "gles2_book\MultiTexture\MultiTexture.vcproj", "{120CFF94-ED4B-4C5B-9587-9E40889F15F7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ParticleSystem", "gles2_book\ParticleSystem\ParticleSystem.vcproj", "{B9E5BFFC-D843-4E0E-9D3E-23913A613473}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple_Texture2D", "gles2_book\Simple_Texture2D\Simple_Texture2D.vcproj", "{2E54D748-781B-4DF2-A1DD-B9384A821810}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple_TextureCubemap", "gles2_book\Simple_TextureCubemap\Simple_TextureCubemap.vcproj", "{5EE56061-643D-406E-B42D-4299D2411056}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple_VertexShader", "gles2_book\Simple_VertexShader\Simple_VertexShader.vcproj", "{667CE95F-5DD8-4395-8C18-5CA8A175B12D}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Stencil_Test", "gles2_book\Stencil_Test\Stencil_Test.vcproj", "{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextureWrap", "gles2_book\TextureWrap\TextureWrap.vcproj", "{CC1DE9A2-B456-4565-9C21-932253E969B9}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "..\src\libEGL\libEGL.vcproj", "{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "..\src\libGLESv2\libGLESv2.vcproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "..\src\compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "essl_to_hlsl", "translator\essl_to_hlsl.vcproj", "{E12EA115-EBC7-47C2-B651-30A0CE986025}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "..\src\compiler\translator_common.vcproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325} = {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PostSubBuffer", "gles2_book\PostSubBuffer\PostSubBuffer.vcproj", "{667CE95F-5DD8-4495-8C18-5CA8A175B12D}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F} = {47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preprocessor", "..\src\compiler\preprocessor\new\preprocessor.vcproj", "{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Release|Win32.Build.0 = Release|Win32
|
||||
{47C93F52-AB4E-4FF9-8D4F-B38CD60A183F}.Release|x64.ActiveCfg = Release|Win32
|
||||
{8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Release|Win32.Build.0 = Release|Win32
|
||||
{8278251F-6C1F-4D80-8499-FA7B590FAFE6}.Release|x64.ActiveCfg = Release|Win32
|
||||
{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Release|Win32.Build.0 = Release|Win32
|
||||
{4E69AC1F-1C7A-4D58-917C-E764FBEB489A}.Release|x64.ActiveCfg = Release|Win32
|
||||
{120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Release|Win32.Build.0 = Release|Win32
|
||||
{120CFF94-ED4B-4C5B-9587-9E40889F15F7}.Release|x64.ActiveCfg = Release|Win32
|
||||
{B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Release|Win32.Build.0 = Release|Win32
|
||||
{B9E5BFFC-D843-4E0E-9D3E-23913A613473}.Release|x64.ActiveCfg = Release|Win32
|
||||
{2E54D748-781B-4DF2-A1DD-B9384A821810}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2E54D748-781B-4DF2-A1DD-B9384A821810}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2E54D748-781B-4DF2-A1DD-B9384A821810}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{2E54D748-781B-4DF2-A1DD-B9384A821810}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2E54D748-781B-4DF2-A1DD-B9384A821810}.Release|Win32.Build.0 = Release|Win32
|
||||
{2E54D748-781B-4DF2-A1DD-B9384A821810}.Release|x64.ActiveCfg = Release|Win32
|
||||
{5EE56061-643D-406E-B42D-4299D2411056}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5EE56061-643D-406E-B42D-4299D2411056}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5EE56061-643D-406E-B42D-4299D2411056}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{5EE56061-643D-406E-B42D-4299D2411056}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5EE56061-643D-406E-B42D-4299D2411056}.Release|Win32.Build.0 = Release|Win32
|
||||
{5EE56061-643D-406E-B42D-4299D2411056}.Release|x64.ActiveCfg = Release|Win32
|
||||
{667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Release|Win32.Build.0 = Release|Win32
|
||||
{667CE95F-5DD8-4395-8C18-5CA8A175B12D}.Release|x64.ActiveCfg = Release|Win32
|
||||
{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Release|Win32.Build.0 = Release|Win32
|
||||
{EEACE995-26BC-4D56-A8B3-3E7A9AB3EB26}.Release|x64.ActiveCfg = Release|Win32
|
||||
{CC1DE9A2-B456-4565-9C21-932253E969B9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{CC1DE9A2-B456-4565-9C21-932253E969B9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{CC1DE9A2-B456-4565-9C21-932253E969B9}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{CC1DE9A2-B456-4565-9C21-932253E969B9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{CC1DE9A2-B456-4565-9C21-932253E969B9}.Release|Win32.Build.0 = Release|Win32
|
||||
{CC1DE9A2-B456-4565-9C21-932253E969B9}.Release|x64.ActiveCfg = Release|Win32
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.Build.0 = Debug|x64
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.Build.0 = Release|Win32
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.ActiveCfg = Release|x64
|
||||
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.Build.0 = Release|x64
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.Build.0 = Debug|x64
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.ActiveCfg = Release|x64
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.Build.0 = Release|x64
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.Build.0 = Debug|x64
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.ActiveCfg = Release|x64
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.Build.0 = Release|x64
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|Win32.Build.0 = Release|Win32
|
||||
{E12EA115-EBC7-47C2-B651-30A0CE986025}.Release|x64.ActiveCfg = Release|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.Build.0 = Debug|x64
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.Build.0 = Release|Win32
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.ActiveCfg = Release|x64
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.Build.0 = Release|x64
|
||||
{667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Release|Win32.Build.0 = Release|Win32
|
||||
{667CE95F-5DD8-4495-8C18-5CA8A175B12D}.Release|x64.ActiveCfg = Release|Win32
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Debug|x64.Build.0 = Debug|x64
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|Win32.Build.0 = Release|Win32
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|x64.ActiveCfg = Release|x64
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,193 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="essl_to_glsl"
|
||||
ProjectGUID="{EADEBCCD-65ED-45D1-9E06-949A21EBAB9E}"
|
||||
RootNamespace="essl_to_glsl"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\common\debug.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\translator.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,195 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="essl_to_hlsl"
|
||||
ProjectGUID="{E12EA115-EBC7-47C2-B651-30A0CE986025}"
|
||||
RootNamespace="essl_to_hlsl"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include;../../src"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="d3d9.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="../../include;../../src"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="d3d9.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\common\debug.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\translator.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,376 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
//
|
||||
// Return codes from main.
|
||||
//
|
||||
enum TFailCode {
|
||||
ESuccess = 0,
|
||||
EFailUsage,
|
||||
EFailCompile,
|
||||
EFailCompilerCreate,
|
||||
};
|
||||
|
||||
static void usage();
|
||||
static ShShaderType FindShaderType(const char* fileName);
|
||||
static bool CompileFile(char* fileName, ShHandle compiler, int compileOptions);
|
||||
static void LogMsg(const char* msg, const char* name, const int num, const char* logName);
|
||||
static void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongVariableNames);
|
||||
|
||||
// If NUM_SOURCE_STRINGS is set to a value > 1, the input file data is
|
||||
// broken into that many chunks.
|
||||
const unsigned int NUM_SOURCE_STRINGS = 2;
|
||||
typedef std::vector<char*> ShaderSource;
|
||||
static bool ReadShaderSource(const char* fileName, ShaderSource& source);
|
||||
static void FreeShaderSource(ShaderSource& source);
|
||||
|
||||
//
|
||||
// Set up the per compile resources
|
||||
//
|
||||
void GenerateResources(ShBuiltInResources* resources)
|
||||
{
|
||||
ShInitBuiltInResources(resources);
|
||||
|
||||
resources->MaxVertexAttribs = 8;
|
||||
resources->MaxVertexUniformVectors = 128;
|
||||
resources->MaxVaryingVectors = 8;
|
||||
resources->MaxVertexTextureImageUnits = 0;
|
||||
resources->MaxCombinedTextureImageUnits = 8;
|
||||
resources->MaxTextureImageUnits = 8;
|
||||
resources->MaxFragmentUniformVectors = 16;
|
||||
resources->MaxDrawBuffers = 1;
|
||||
|
||||
resources->OES_standard_derivatives = 0;
|
||||
resources->OES_EGL_image_external = 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
TFailCode failCode = ESuccess;
|
||||
|
||||
int compileOptions = 0;
|
||||
int numCompiles = 0;
|
||||
ShHandle vertexCompiler = 0;
|
||||
ShHandle fragmentCompiler = 0;
|
||||
char* buffer = 0;
|
||||
int bufferLen = 0;
|
||||
int numAttribs = 0, numUniforms = 0;
|
||||
ShShaderSpec spec = SH_GLES2_SPEC;
|
||||
ShShaderOutput output = SH_ESSL_OUTPUT;
|
||||
|
||||
ShInitialize();
|
||||
|
||||
ShBuiltInResources resources;
|
||||
GenerateResources(&resources);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
for (; (argc >= 1) && (failCode == ESuccess); argc--, argv++) {
|
||||
if (argv[0][0] == '-') {
|
||||
switch (argv[0][1]) {
|
||||
case 'i': compileOptions |= SH_INTERMEDIATE_TREE; break;
|
||||
case 'm': compileOptions |= SH_MAP_LONG_VARIABLE_NAMES; break;
|
||||
case 'o': compileOptions |= SH_OBJECT_CODE; break;
|
||||
case 'u': compileOptions |= SH_ATTRIBUTES_UNIFORMS; break;
|
||||
case 'l': compileOptions |= SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX; break;
|
||||
case 'e': compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS; break;
|
||||
case 'd': compileOptions |= SH_DEPENDENCY_GRAPH; break;
|
||||
case 't': compileOptions |= SH_TIMING_RESTRICTIONS; break;
|
||||
case 's':
|
||||
if (argv[0][2] == '=') {
|
||||
switch (argv[0][3]) {
|
||||
case 'e': spec = SH_GLES2_SPEC; break;
|
||||
case 'w': spec = SH_WEBGL_SPEC; break;
|
||||
case 'c': spec = SH_CSS_SHADERS_SPEC; break;
|
||||
default: failCode = EFailUsage;
|
||||
}
|
||||
} else {
|
||||
failCode = EFailUsage;
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
if (argv[0][2] == '=') {
|
||||
switch (argv[0][3]) {
|
||||
case 'e': output = SH_ESSL_OUTPUT; break;
|
||||
case 'g': output = SH_GLSL_OUTPUT; break;
|
||||
case 'h': output = SH_HLSL_OUTPUT; break;
|
||||
default: failCode = EFailUsage;
|
||||
}
|
||||
} else {
|
||||
failCode = EFailUsage;
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
if (argv[0][2] == '=') {
|
||||
switch (argv[0][3]) {
|
||||
case 'i': resources.OES_EGL_image_external = 1; break;
|
||||
case 'd': resources.OES_standard_derivatives = 1; break;
|
||||
case 'r': resources.ARB_texture_rectangle = 1; break;
|
||||
default: failCode = EFailUsage;
|
||||
}
|
||||
} else {
|
||||
failCode = EFailUsage;
|
||||
}
|
||||
break;
|
||||
default: failCode = EFailUsage;
|
||||
}
|
||||
} else {
|
||||
ShHandle compiler = 0;
|
||||
switch (FindShaderType(argv[0])) {
|
||||
case SH_VERTEX_SHADER:
|
||||
if (vertexCompiler == 0)
|
||||
vertexCompiler = ShConstructCompiler(
|
||||
SH_VERTEX_SHADER, spec, output, &resources);
|
||||
compiler = vertexCompiler;
|
||||
break;
|
||||
case SH_FRAGMENT_SHADER:
|
||||
if (fragmentCompiler == 0)
|
||||
fragmentCompiler = ShConstructCompiler(
|
||||
SH_FRAGMENT_SHADER, spec, output, &resources);
|
||||
compiler = fragmentCompiler;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (compiler) {
|
||||
bool compiled = CompileFile(argv[0], compiler, compileOptions);
|
||||
|
||||
LogMsg("BEGIN", "COMPILER", numCompiles, "INFO LOG");
|
||||
ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &bufferLen);
|
||||
buffer = (char*) realloc(buffer, bufferLen * sizeof(char));
|
||||
ShGetInfoLog(compiler, buffer);
|
||||
puts(buffer);
|
||||
LogMsg("END", "COMPILER", numCompiles, "INFO LOG");
|
||||
printf("\n\n");
|
||||
|
||||
if (compiled && (compileOptions & SH_OBJECT_CODE)) {
|
||||
LogMsg("BEGIN", "COMPILER", numCompiles, "OBJ CODE");
|
||||
ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &bufferLen);
|
||||
buffer = (char*) realloc(buffer, bufferLen * sizeof(char));
|
||||
ShGetObjectCode(compiler, buffer);
|
||||
puts(buffer);
|
||||
LogMsg("END", "COMPILER", numCompiles, "OBJ CODE");
|
||||
printf("\n\n");
|
||||
}
|
||||
if (compiled && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) {
|
||||
LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE ATTRIBS");
|
||||
PrintActiveVariables(compiler, SH_ACTIVE_ATTRIBUTES, (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) != 0);
|
||||
LogMsg("END", "COMPILER", numCompiles, "ACTIVE ATTRIBS");
|
||||
printf("\n\n");
|
||||
|
||||
LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE UNIFORMS");
|
||||
PrintActiveVariables(compiler, SH_ACTIVE_UNIFORMS, (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) != 0);
|
||||
LogMsg("END", "COMPILER", numCompiles, "ACTIVE UNIFORMS");
|
||||
printf("\n\n");
|
||||
}
|
||||
if (!compiled)
|
||||
failCode = EFailCompile;
|
||||
++numCompiles;
|
||||
} else {
|
||||
failCode = EFailCompilerCreate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((vertexCompiler == 0) && (fragmentCompiler == 0))
|
||||
failCode = EFailUsage;
|
||||
if (failCode == EFailUsage)
|
||||
usage();
|
||||
|
||||
if (vertexCompiler)
|
||||
ShDestruct(vertexCompiler);
|
||||
if (fragmentCompiler)
|
||||
ShDestruct(fragmentCompiler);
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
ShFinalize();
|
||||
|
||||
return failCode;
|
||||
}
|
||||
|
||||
//
|
||||
// print usage to stdout
|
||||
//
|
||||
void usage()
|
||||
{
|
||||
printf("Usage: translate [-i -m -o -u -l -e -b=e -b=g -b=h -x=i -x=d] file1 file2 ...\n"
|
||||
"Where: filename : filename ending in .frag or .vert\n"
|
||||
" -i : print intermediate tree\n"
|
||||
" -m : map long variable names\n"
|
||||
" -o : print translated code\n"
|
||||
" -u : print active attribs and uniforms\n"
|
||||
" -l : unroll for-loops with integer indices\n"
|
||||
" -e : emulate certain built-in functions (workaround for driver bugs)\n"
|
||||
" -t : enforce experimental timing restrictions\n"
|
||||
" -d : print dependency graph used to enforce timing restrictions\n"
|
||||
" -s=e : use GLES2 spec (this is by default)\n"
|
||||
" -s=w : use WebGL spec\n"
|
||||
" -s=c : use CSS Shaders spec\n"
|
||||
" -b=e : output GLSL ES code (this is by default)\n"
|
||||
" -b=g : output GLSL code\n"
|
||||
" -b=h : output HLSL code\n"
|
||||
" -x=i : enable GL_OES_EGL_image_external\n"
|
||||
" -x=d : enable GL_OES_EGL_standard_derivatives\n"
|
||||
" -x=r : enable ARB_texture_rectangle\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Deduce the shader type from the filename. Files must end in one of the
|
||||
// following extensions:
|
||||
//
|
||||
// .frag* = fragment shader
|
||||
// .vert* = vertex shader
|
||||
//
|
||||
ShShaderType FindShaderType(const char* fileName)
|
||||
{
|
||||
assert(fileName);
|
||||
|
||||
const char* ext = strrchr(fileName, '.');
|
||||
|
||||
if (ext && strcmp(ext, ".sl") == 0)
|
||||
for (; ext > fileName && ext[0] != '.'; ext--);
|
||||
|
||||
ext = strrchr(fileName, '.');
|
||||
if (ext) {
|
||||
if (strncmp(ext, ".frag", 4) == 0) return SH_FRAGMENT_SHADER;
|
||||
if (strncmp(ext, ".vert", 4) == 0) return SH_VERTEX_SHADER;
|
||||
}
|
||||
|
||||
return SH_FRAGMENT_SHADER;
|
||||
}
|
||||
|
||||
//
|
||||
// Read a file's data into a string, and compile it using ShCompile
|
||||
//
|
||||
bool CompileFile(char* fileName, ShHandle compiler, int compileOptions)
|
||||
{
|
||||
ShaderSource source;
|
||||
if (!ReadShaderSource(fileName, source))
|
||||
return false;
|
||||
|
||||
int ret = ShCompile(compiler, &source[0], source.size(), compileOptions);
|
||||
|
||||
FreeShaderSource(source);
|
||||
return ret ? true : false;
|
||||
}
|
||||
|
||||
void LogMsg(const char* msg, const char* name, const int num, const char* logName)
|
||||
{
|
||||
printf("#### %s %s %d %s ####\n", msg, name, num, logName);
|
||||
}
|
||||
|
||||
void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongVariableNames)
|
||||
{
|
||||
int nameSize = 0;
|
||||
switch (varType) {
|
||||
case SH_ACTIVE_ATTRIBUTES:
|
||||
ShGetInfo(compiler, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &nameSize);
|
||||
break;
|
||||
case SH_ACTIVE_UNIFORMS:
|
||||
ShGetInfo(compiler, SH_ACTIVE_UNIFORM_MAX_LENGTH, &nameSize);
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
if (nameSize <= 1) return;
|
||||
char* name = new char[nameSize];
|
||||
|
||||
char* mappedName = NULL;
|
||||
if (mapLongVariableNames) {
|
||||
int mappedNameSize = 0;
|
||||
ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameSize);
|
||||
mappedName = new char[mappedNameSize];
|
||||
}
|
||||
|
||||
int activeVars = 0, size = 0;
|
||||
ShDataType type = SH_NONE;
|
||||
const char* typeName = NULL;
|
||||
ShGetInfo(compiler, varType, &activeVars);
|
||||
for (int i = 0; i < activeVars; ++i) {
|
||||
switch (varType) {
|
||||
case SH_ACTIVE_ATTRIBUTES:
|
||||
ShGetActiveAttrib(compiler, i, NULL, &size, &type, name, mappedName);
|
||||
break;
|
||||
case SH_ACTIVE_UNIFORMS:
|
||||
ShGetActiveUniform(compiler, i, NULL, &size, &type, name, mappedName);
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
switch (type) {
|
||||
case SH_FLOAT: typeName = "GL_FLOAT"; break;
|
||||
case SH_FLOAT_VEC2: typeName = "GL_FLOAT_VEC2"; break;
|
||||
case SH_FLOAT_VEC3: typeName = "GL_FLOAT_VEC3"; break;
|
||||
case SH_FLOAT_VEC4: typeName = "GL_FLOAT_VEC4"; break;
|
||||
case SH_INT: typeName = "GL_INT"; break;
|
||||
case SH_INT_VEC2: typeName = "GL_INT_VEC2"; break;
|
||||
case SH_INT_VEC3: typeName = "GL_INT_VEC3"; break;
|
||||
case SH_INT_VEC4: typeName = "GL_INT_VEC4"; break;
|
||||
case SH_BOOL: typeName = "GL_BOOL"; break;
|
||||
case SH_BOOL_VEC2: typeName = "GL_BOOL_VEC2"; break;
|
||||
case SH_BOOL_VEC3: typeName = "GL_BOOL_VEC3"; break;
|
||||
case SH_BOOL_VEC4: typeName = "GL_BOOL_VEC4"; break;
|
||||
case SH_FLOAT_MAT2: typeName = "GL_FLOAT_MAT2"; break;
|
||||
case SH_FLOAT_MAT3: typeName = "GL_FLOAT_MAT3"; break;
|
||||
case SH_FLOAT_MAT4: typeName = "GL_FLOAT_MAT4"; break;
|
||||
case SH_SAMPLER_2D: typeName = "GL_SAMPLER_2D"; break;
|
||||
case SH_SAMPLER_CUBE: typeName = "GL_SAMPLER_CUBE"; break;
|
||||
case SH_SAMPLER_EXTERNAL_OES: typeName = "GL_SAMPLER_EXTERNAL_OES"; break;
|
||||
default: assert(0);
|
||||
}
|
||||
printf("%d: name:%s type:%s size:%d", i, name, typeName, size);
|
||||
if (mapLongVariableNames)
|
||||
printf(" mapped name:%s", mappedName);
|
||||
printf("\n");
|
||||
}
|
||||
delete [] name;
|
||||
if (mappedName)
|
||||
delete [] mappedName;
|
||||
}
|
||||
|
||||
static bool ReadShaderSource(const char* fileName, ShaderSource& source) {
|
||||
FILE* in = fopen(fileName, "rb");
|
||||
if (!in) {
|
||||
printf("Error: unable to open input file: %s\n", fileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Obtain file size.
|
||||
fseek(in, 0, SEEK_END);
|
||||
int count = ftell(in);
|
||||
rewind(in);
|
||||
|
||||
int len = (int)ceil((float)count / (float)NUM_SOURCE_STRINGS);
|
||||
source.reserve(NUM_SOURCE_STRINGS);
|
||||
// Notice the usage of do-while instead of a while loop here.
|
||||
// It is there to handle empty files in which case a single empty
|
||||
// string is added to vector.
|
||||
do {
|
||||
char* data = new char[len + 1];
|
||||
int nread = fread(data, 1, len, in);
|
||||
data[nread] = '\0';
|
||||
source.push_back(data);
|
||||
|
||||
count -= nread;
|
||||
} while (count > 0);
|
||||
|
||||
fclose(in);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void FreeShaderSource(ShaderSource& source) {
|
||||
for (ShaderSource::size_type i = 0; i < source.size(); ++i) {
|
||||
delete [] source[i];
|
||||
}
|
||||
source.clear();
|
||||
}
|
||||
|
|
@ -1,27 +1,15 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual C++ Express 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "libEGL\libEGL.vcproj", "{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78}
|
||||
EndProjectSection
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual C++ Express 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEGL", "libEGL\libEGL.vcxproj", "{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "libGLESv2\libGLESv2.vcproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7} = {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}
|
||||
EndProjectSection
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLESv2", "libGLESv2\libGLESv2.vcxproj", "{B5871A7A-968C-42E3-A33B-981E6F448E78}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "compiler\translator_hlsl.vcproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD} = {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}
|
||||
EndProjectSection
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_hlsl", "compiler\translator_hlsl.vcxproj", "{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "compiler\translator_common.vcproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325} = {FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}
|
||||
EndProjectSection
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translator_common", "compiler\translator_common.vcxproj", "{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preprocessor", "compiler\preprocessor\new\preprocessor.vcproj", "{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "preprocessor", "compiler\preprocessor\preprocessor.vcxproj", "{FBE32DF3-0FB0-4F2F-A424-2C21BD7BC325}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
|
@ -3,332 +3,8 @@
|
|||
# found in the LICENSE file.
|
||||
|
||||
{
|
||||
'variables': {
|
||||
'angle_code': 1,
|
||||
},
|
||||
'target_defaults': {
|
||||
'defines': [
|
||||
'ANGLE_DISABLE_TRACE',
|
||||
'ANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL0',
|
||||
'ANGLE_USE_NEW_PREPROCESSOR=1',
|
||||
],
|
||||
},
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'preprocessor',
|
||||
'type': 'static_library',
|
||||
'include_dirs': [
|
||||
],
|
||||
'sources': [
|
||||
'compiler/preprocessor/new/Diagnostics.cpp',
|
||||
'compiler/preprocessor/new/Diagnostics.h',
|
||||
'compiler/preprocessor/new/DirectiveHandler.cpp',
|
||||
'compiler/preprocessor/new/DirectiveHandler.h',
|
||||
'compiler/preprocessor/new/DirectiveParser.cpp',
|
||||
'compiler/preprocessor/new/DirectiveParser.h',
|
||||
'compiler/preprocessor/new/ExpressionParser.cpp',
|
||||
'compiler/preprocessor/new/ExpressionParser.h',
|
||||
'compiler/preprocessor/new/Input.cpp',
|
||||
'compiler/preprocessor/new/Input.h',
|
||||
'compiler/preprocessor/new/Lexer.cpp',
|
||||
'compiler/preprocessor/new/Lexer.h',
|
||||
'compiler/preprocessor/new/Macro.cpp',
|
||||
'compiler/preprocessor/new/Macro.h',
|
||||
'compiler/preprocessor/new/MacroExpander.cpp',
|
||||
'compiler/preprocessor/new/MacroExpander.h',
|
||||
'compiler/preprocessor/new/numeric_lex.h',
|
||||
'compiler/preprocessor/new/pp_utils.h',
|
||||
'compiler/preprocessor/new/Preprocessor.cpp',
|
||||
'compiler/preprocessor/new/Preprocessor.h',
|
||||
'compiler/preprocessor/new/SourceLocation.h',
|
||||
'compiler/preprocessor/new/Token.cpp',
|
||||
'compiler/preprocessor/new/Token.h',
|
||||
'compiler/preprocessor/new/Tokenizer.cpp',
|
||||
'compiler/preprocessor/new/Tokenizer.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'translator_common',
|
||||
'type': 'static_library',
|
||||
'dependencies': ['preprocessor'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
],
|
||||
'defines': [
|
||||
'COMPILER_IMPLEMENTATION',
|
||||
],
|
||||
'sources': [
|
||||
'compiler/BaseTypes.h',
|
||||
'compiler/BuiltInFunctionEmulator.cpp',
|
||||
'compiler/BuiltInFunctionEmulator.h',
|
||||
'compiler/Common.h',
|
||||
'compiler/Compiler.cpp',
|
||||
'compiler/ConstantUnion.h',
|
||||
'compiler/debug.cpp',
|
||||
'compiler/debug.h',
|
||||
'compiler/DetectRecursion.cpp',
|
||||
'compiler/DetectRecursion.h',
|
||||
'compiler/Diagnostics.h',
|
||||
'compiler/Diagnostics.cpp',
|
||||
'compiler/DirectiveHandler.h',
|
||||
'compiler/DirectiveHandler.cpp',
|
||||
'compiler/ExtensionBehavior.h',
|
||||
'compiler/ForLoopUnroll.cpp',
|
||||
'compiler/ForLoopUnroll.h',
|
||||
'compiler/glslang.h',
|
||||
'compiler/glslang_lex.cpp',
|
||||
'compiler/glslang_tab.cpp',
|
||||
'compiler/glslang_tab.h',
|
||||
'compiler/InfoSink.cpp',
|
||||
'compiler/InfoSink.h',
|
||||
'compiler/Initialize.cpp',
|
||||
'compiler/Initialize.h',
|
||||
'compiler/InitializeDll.cpp',
|
||||
'compiler/InitializeDll.h',
|
||||
'compiler/InitializeGlobals.h',
|
||||
'compiler/InitializeParseContext.cpp',
|
||||
'compiler/InitializeParseContext.h',
|
||||
'compiler/Intermediate.cpp',
|
||||
'compiler/intermediate.h',
|
||||
'compiler/intermOut.cpp',
|
||||
'compiler/IntermTraverse.cpp',
|
||||
'compiler/localintermediate.h',
|
||||
'compiler/MapLongVariableNames.cpp',
|
||||
'compiler/MapLongVariableNames.h',
|
||||
'compiler/MMap.h',
|
||||
'compiler/osinclude.h',
|
||||
'compiler/parseConst.cpp',
|
||||
'compiler/ParseHelper.cpp',
|
||||
'compiler/ParseHelper.h',
|
||||
'compiler/PoolAlloc.cpp',
|
||||
'compiler/PoolAlloc.h',
|
||||
'compiler/QualifierAlive.cpp',
|
||||
'compiler/QualifierAlive.h',
|
||||
'compiler/RemoveTree.cpp',
|
||||
'compiler/RemoveTree.h',
|
||||
'compiler/RenameFunction.h',
|
||||
'compiler/ShHandle.h',
|
||||
'compiler/SymbolTable.cpp',
|
||||
'compiler/SymbolTable.h',
|
||||
'compiler/Types.h',
|
||||
'compiler/util.cpp',
|
||||
'compiler/util.h',
|
||||
'compiler/ValidateLimitations.cpp',
|
||||
'compiler/ValidateLimitations.h',
|
||||
'compiler/VariableInfo.cpp',
|
||||
'compiler/VariableInfo.h',
|
||||
# Old preprocessor
|
||||
'compiler/preprocessor/atom.c',
|
||||
'compiler/preprocessor/atom.h',
|
||||
'compiler/preprocessor/compile.h',
|
||||
'compiler/preprocessor/cpp.c',
|
||||
'compiler/preprocessor/cpp.h',
|
||||
'compiler/preprocessor/cppstruct.c',
|
||||
'compiler/preprocessor/length_limits.h',
|
||||
'compiler/preprocessor/memory.c',
|
||||
'compiler/preprocessor/memory.h',
|
||||
'compiler/preprocessor/parser.h',
|
||||
'compiler/preprocessor/preprocess.h',
|
||||
'compiler/preprocessor/scanner.c',
|
||||
'compiler/preprocessor/scanner.h',
|
||||
'compiler/preprocessor/slglobals.h',
|
||||
'compiler/preprocessor/symbols.c',
|
||||
'compiler/preprocessor/symbols.h',
|
||||
'compiler/preprocessor/tokens.c',
|
||||
'compiler/preprocessor/tokens.h',
|
||||
# Dependency graph
|
||||
'compiler/depgraph/DependencyGraph.cpp',
|
||||
'compiler/depgraph/DependencyGraph.h',
|
||||
'compiler/depgraph/DependencyGraphBuilder.cpp',
|
||||
'compiler/depgraph/DependencyGraphBuilder.h',
|
||||
'compiler/depgraph/DependencyGraphOutput.cpp',
|
||||
'compiler/depgraph/DependencyGraphOutput.h',
|
||||
'compiler/depgraph/DependencyGraphTraverse.cpp',
|
||||
# Timing restrictions
|
||||
'compiler/timing/RestrictFragmentShaderTiming.cpp',
|
||||
'compiler/timing/RestrictFragmentShaderTiming.h',
|
||||
'compiler/timing/RestrictVertexShaderTiming.cpp',
|
||||
'compiler/timing/RestrictVertexShaderTiming.h',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'sources': ['compiler/ossource_win.cpp'],
|
||||
}, { # else: posix
|
||||
'sources': ['compiler/ossource_posix.cpp'],
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'translator_glsl',
|
||||
'type': '<(component)',
|
||||
'dependencies': ['translator_common'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
],
|
||||
'defines': [
|
||||
'COMPILER_IMPLEMENTATION',
|
||||
],
|
||||
'sources': [
|
||||
'compiler/CodeGenGLSL.cpp',
|
||||
'compiler/OutputESSL.cpp',
|
||||
'compiler/OutputESSL.h',
|
||||
'compiler/OutputGLSLBase.cpp',
|
||||
'compiler/OutputGLSLBase.h',
|
||||
'compiler/OutputGLSL.cpp',
|
||||
'compiler/OutputGLSL.h',
|
||||
'compiler/ShaderLang.cpp',
|
||||
'compiler/TranslatorESSL.cpp',
|
||||
'compiler/TranslatorESSL.h',
|
||||
'compiler/TranslatorGLSL.cpp',
|
||||
'compiler/TranslatorGLSL.h',
|
||||
'compiler/VersionGLSL.cpp',
|
||||
'compiler/VersionGLSL.h',
|
||||
],
|
||||
},
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'translator_hlsl',
|
||||
'type': '<(component)',
|
||||
'dependencies': ['translator_common'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
],
|
||||
'defines': [
|
||||
'COMPILER_IMPLEMENTATION',
|
||||
],
|
||||
'sources': [
|
||||
'compiler/ShaderLang.cpp',
|
||||
'compiler/DetectDiscontinuity.cpp',
|
||||
'compiler/DetectDiscontinuity.h',
|
||||
'compiler/CodeGenHLSL.cpp',
|
||||
'compiler/OutputHLSL.cpp',
|
||||
'compiler/OutputHLSL.h',
|
||||
'compiler/TranslatorHLSL.cpp',
|
||||
'compiler/TranslatorHLSL.h',
|
||||
'compiler/UnfoldShortCircuit.cpp',
|
||||
'compiler/UnfoldShortCircuit.h',
|
||||
'compiler/SearchSymbol.cpp',
|
||||
'compiler/SearchSymbol.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'libGLESv2',
|
||||
'type': 'shared_library',
|
||||
'dependencies': ['translator_hlsl'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
'$(DXSDK_DIR)/include',
|
||||
],
|
||||
'sources': [
|
||||
'common/angleutils.h',
|
||||
'common/debug.cpp',
|
||||
'common/debug.h',
|
||||
'common/RefCountObject.cpp',
|
||||
'common/RefCountObject.h',
|
||||
'common/version.h',
|
||||
'libGLESv2/IndexDataManager.cpp',
|
||||
'libGLESv2/IndexDataManager.h',
|
||||
'libGLESv2/vertexconversion.h',
|
||||
'libGLESv2/VertexDataManager.cpp',
|
||||
'libGLESv2/VertexDataManager.h',
|
||||
'libGLESv2/BinaryStream.h',
|
||||
'libGLESv2/Blit.cpp',
|
||||
'libGLESv2/Blit.h',
|
||||
'libGLESv2/Buffer.cpp',
|
||||
'libGLESv2/Buffer.h',
|
||||
'libGLESv2/Context.cpp',
|
||||
'libGLESv2/Context.h',
|
||||
'libGLESv2/Fence.cpp',
|
||||
'libGLESv2/Fence.h',
|
||||
'libGLESv2/Framebuffer.cpp',
|
||||
'libGLESv2/Framebuffer.h',
|
||||
'libGLESv2/HandleAllocator.cpp',
|
||||
'libGLESv2/HandleAllocator.h',
|
||||
'libGLESv2/libGLESv2.cpp',
|
||||
'libGLESv2/libGLESv2.def',
|
||||
'libGLESv2/libGLESv2.rc',
|
||||
'libGLESv2/main.cpp',
|
||||
'libGLESv2/main.h',
|
||||
'libGLESv2/mathutil.h',
|
||||
'libGLESv2/Program.cpp',
|
||||
'libGLESv2/Program.h',
|
||||
'libGLESv2/ProgramBinary.cpp',
|
||||
'libGLESv2/ProgramBinary.h',
|
||||
'libGLESv2/Query.h',
|
||||
'libGLESv2/Query.cpp',
|
||||
'libGLESv2/Renderbuffer.cpp',
|
||||
'libGLESv2/Renderbuffer.h',
|
||||
'libGLESv2/ResourceManager.cpp',
|
||||
'libGLESv2/ResourceManager.h',
|
||||
'libGLESv2/Shader.cpp',
|
||||
'libGLESv2/Shader.h',
|
||||
'libGLESv2/Texture.cpp',
|
||||
'libGLESv2/TextureSSE2.cpp',
|
||||
'libGLESv2/Texture.h',
|
||||
'libGLESv2/utilities.cpp',
|
||||
'libGLESv2/utilities.h',
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
|
||||
'AdditionalDependencies': [
|
||||
'd3d9.lib',
|
||||
'd3dx9.lib',
|
||||
'd3dcompiler.lib',
|
||||
],
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
'target_name': 'libEGL',
|
||||
'type': 'shared_library',
|
||||
'dependencies': ['libGLESv2'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
],
|
||||
'sources': [
|
||||
'common/angleutils.h',
|
||||
'common/debug.cpp',
|
||||
'common/debug.h',
|
||||
'common/RefCountObject.cpp',
|
||||
'common/RefCountObject.h',
|
||||
'common/version.h',
|
||||
'libEGL/Config.cpp',
|
||||
'libEGL/Config.h',
|
||||
'libEGL/Display.cpp',
|
||||
'libEGL/Display.h',
|
||||
'libEGL/libEGL.cpp',
|
||||
'libEGL/libEGL.def',
|
||||
'libEGL/libEGL.rc',
|
||||
'libEGL/main.cpp',
|
||||
'libEGL/main.h',
|
||||
'libEGL/Surface.cpp',
|
||||
'libEGL/Surface.h',
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
|
||||
'AdditionalDependencies': [
|
||||
'd3d9.lib',
|
||||
'dxguid.lib',
|
||||
'dwmapi.lib',
|
||||
],
|
||||
'DelayLoadDLLs': [
|
||||
'dwmapi.dll',
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
}],
|
||||
'includes': [
|
||||
'build_angle.gypi',
|
||||
],
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,328 @@
|
|||
# Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
{
|
||||
'variables': {
|
||||
'angle_code': 1,
|
||||
},
|
||||
'target_defaults': {
|
||||
'defines': [
|
||||
'ANGLE_DISABLE_TRACE',
|
||||
'ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ L"d3dcompiler_46.dll", L"d3dcompiler_43.dll" }',
|
||||
],
|
||||
},
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'preprocessor',
|
||||
'type': 'static_library',
|
||||
'include_dirs': [
|
||||
],
|
||||
'sources': [
|
||||
'compiler/preprocessor/Diagnostics.cpp',
|
||||
'compiler/preprocessor/Diagnostics.h',
|
||||
'compiler/preprocessor/DirectiveHandler.cpp',
|
||||
'compiler/preprocessor/DirectiveHandler.h',
|
||||
'compiler/preprocessor/DirectiveParser.cpp',
|
||||
'compiler/preprocessor/DirectiveParser.h',
|
||||
'compiler/preprocessor/ExpressionParser.cpp',
|
||||
'compiler/preprocessor/ExpressionParser.h',
|
||||
'compiler/preprocessor/Input.cpp',
|
||||
'compiler/preprocessor/Input.h',
|
||||
'compiler/preprocessor/length_limits.h',
|
||||
'compiler/preprocessor/Lexer.cpp',
|
||||
'compiler/preprocessor/Lexer.h',
|
||||
'compiler/preprocessor/Macro.cpp',
|
||||
'compiler/preprocessor/Macro.h',
|
||||
'compiler/preprocessor/MacroExpander.cpp',
|
||||
'compiler/preprocessor/MacroExpander.h',
|
||||
'compiler/preprocessor/numeric_lex.h',
|
||||
'compiler/preprocessor/pp_utils.h',
|
||||
'compiler/preprocessor/Preprocessor.cpp',
|
||||
'compiler/preprocessor/Preprocessor.h',
|
||||
'compiler/preprocessor/SourceLocation.h',
|
||||
'compiler/preprocessor/Token.cpp',
|
||||
'compiler/preprocessor/Token.h',
|
||||
'compiler/preprocessor/Tokenizer.cpp',
|
||||
'compiler/preprocessor/Tokenizer.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'translator_common',
|
||||
'type': 'static_library',
|
||||
'dependencies': ['preprocessor'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
],
|
||||
'defines': [
|
||||
'COMPILER_IMPLEMENTATION',
|
||||
],
|
||||
'sources': [
|
||||
'compiler/BaseTypes.h',
|
||||
'compiler/BuiltInFunctionEmulator.cpp',
|
||||
'compiler/BuiltInFunctionEmulator.h',
|
||||
'compiler/Common.h',
|
||||
'compiler/Compiler.cpp',
|
||||
'compiler/ConstantUnion.h',
|
||||
'compiler/debug.cpp',
|
||||
'compiler/debug.h',
|
||||
'compiler/DetectRecursion.cpp',
|
||||
'compiler/DetectRecursion.h',
|
||||
'compiler/Diagnostics.h',
|
||||
'compiler/Diagnostics.cpp',
|
||||
'compiler/DirectiveHandler.h',
|
||||
'compiler/DirectiveHandler.cpp',
|
||||
'compiler/ExtensionBehavior.h',
|
||||
'compiler/ForLoopUnroll.cpp',
|
||||
'compiler/ForLoopUnroll.h',
|
||||
'compiler/glslang.h',
|
||||
'compiler/glslang_lex.cpp',
|
||||
'compiler/glslang_tab.cpp',
|
||||
'compiler/glslang_tab.h',
|
||||
'compiler/HashNames.h',
|
||||
'compiler/InfoSink.cpp',
|
||||
'compiler/InfoSink.h',
|
||||
'compiler/Initialize.cpp',
|
||||
'compiler/Initialize.h',
|
||||
'compiler/InitializeDll.cpp',
|
||||
'compiler/InitializeDll.h',
|
||||
'compiler/InitializeGlobals.h',
|
||||
'compiler/InitializeParseContext.cpp',
|
||||
'compiler/InitializeParseContext.h',
|
||||
'compiler/Intermediate.cpp',
|
||||
'compiler/intermediate.h',
|
||||
'compiler/intermOut.cpp',
|
||||
'compiler/IntermTraverse.cpp',
|
||||
'compiler/localintermediate.h',
|
||||
'compiler/MapLongVariableNames.cpp',
|
||||
'compiler/MapLongVariableNames.h',
|
||||
'compiler/MMap.h',
|
||||
'compiler/osinclude.h',
|
||||
'compiler/parseConst.cpp',
|
||||
'compiler/ParseHelper.cpp',
|
||||
'compiler/ParseHelper.h',
|
||||
'compiler/PoolAlloc.cpp',
|
||||
'compiler/PoolAlloc.h',
|
||||
'compiler/QualifierAlive.cpp',
|
||||
'compiler/QualifierAlive.h',
|
||||
'compiler/RemoveTree.cpp',
|
||||
'compiler/RemoveTree.h',
|
||||
'compiler/RenameFunction.h',
|
||||
'compiler/ShHandle.h',
|
||||
'compiler/SymbolTable.cpp',
|
||||
'compiler/SymbolTable.h',
|
||||
'compiler/Types.h',
|
||||
'compiler/util.cpp',
|
||||
'compiler/util.h',
|
||||
'compiler/ValidateLimitations.cpp',
|
||||
'compiler/ValidateLimitations.h',
|
||||
'compiler/VariableInfo.cpp',
|
||||
'compiler/VariableInfo.h',
|
||||
'compiler/VariablePacker.cpp',
|
||||
'compiler/VariablePacker.h',
|
||||
# Dependency graph
|
||||
'compiler/depgraph/DependencyGraph.cpp',
|
||||
'compiler/depgraph/DependencyGraph.h',
|
||||
'compiler/depgraph/DependencyGraphBuilder.cpp',
|
||||
'compiler/depgraph/DependencyGraphBuilder.h',
|
||||
'compiler/depgraph/DependencyGraphOutput.cpp',
|
||||
'compiler/depgraph/DependencyGraphOutput.h',
|
||||
'compiler/depgraph/DependencyGraphTraverse.cpp',
|
||||
# Timing restrictions
|
||||
'compiler/timing/RestrictFragmentShaderTiming.cpp',
|
||||
'compiler/timing/RestrictFragmentShaderTiming.h',
|
||||
'compiler/timing/RestrictVertexShaderTiming.cpp',
|
||||
'compiler/timing/RestrictVertexShaderTiming.h',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'sources': ['compiler/ossource_win.cpp'],
|
||||
}, { # else: posix
|
||||
'sources': ['compiler/ossource_posix.cpp'],
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'translator_glsl',
|
||||
'type': '<(component)',
|
||||
'dependencies': ['translator_common'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
],
|
||||
'defines': [
|
||||
'COMPILER_IMPLEMENTATION',
|
||||
],
|
||||
'sources': [
|
||||
'compiler/CodeGenGLSL.cpp',
|
||||
'compiler/OutputESSL.cpp',
|
||||
'compiler/OutputESSL.h',
|
||||
'compiler/OutputGLSLBase.cpp',
|
||||
'compiler/OutputGLSLBase.h',
|
||||
'compiler/OutputGLSL.cpp',
|
||||
'compiler/OutputGLSL.h',
|
||||
'compiler/ShaderLang.cpp',
|
||||
'compiler/TranslatorESSL.cpp',
|
||||
'compiler/TranslatorESSL.h',
|
||||
'compiler/TranslatorGLSL.cpp',
|
||||
'compiler/TranslatorGLSL.h',
|
||||
'compiler/VersionGLSL.cpp',
|
||||
'compiler/VersionGLSL.h',
|
||||
],
|
||||
},
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'translator_hlsl',
|
||||
'type': '<(component)',
|
||||
'dependencies': ['translator_common'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
],
|
||||
'defines': [
|
||||
'COMPILER_IMPLEMENTATION',
|
||||
],
|
||||
'sources': [
|
||||
'compiler/ShaderLang.cpp',
|
||||
'compiler/DetectDiscontinuity.cpp',
|
||||
'compiler/DetectDiscontinuity.h',
|
||||
'compiler/CodeGenHLSL.cpp',
|
||||
'compiler/OutputHLSL.cpp',
|
||||
'compiler/OutputHLSL.h',
|
||||
'compiler/TranslatorHLSL.cpp',
|
||||
'compiler/TranslatorHLSL.h',
|
||||
'compiler/UnfoldShortCircuit.cpp',
|
||||
'compiler/UnfoldShortCircuit.h',
|
||||
'compiler/SearchSymbol.cpp',
|
||||
'compiler/SearchSymbol.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'libGLESv2',
|
||||
'type': 'shared_library',
|
||||
'dependencies': ['translator_hlsl'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
'$(DXSDK_DIR)/include',
|
||||
],
|
||||
'sources': [
|
||||
'common/angleutils.h',
|
||||
'common/debug.cpp',
|
||||
'common/debug.h',
|
||||
'common/RefCountObject.cpp',
|
||||
'common/RefCountObject.h',
|
||||
'common/version.h',
|
||||
'libGLESv2/IndexDataManager.cpp',
|
||||
'libGLESv2/IndexDataManager.h',
|
||||
'libGLESv2/vertexconversion.h',
|
||||
'libGLESv2/VertexDataManager.cpp',
|
||||
'libGLESv2/VertexDataManager.h',
|
||||
'libGLESv2/BinaryStream.h',
|
||||
'libGLESv2/Blit.cpp',
|
||||
'libGLESv2/Blit.h',
|
||||
'libGLESv2/Buffer.cpp',
|
||||
'libGLESv2/Buffer.h',
|
||||
'libGLESv2/Context.cpp',
|
||||
'libGLESv2/Context.h',
|
||||
'libGLESv2/D3DConstantTable.cpp',
|
||||
'libGLESv2/D3DConstantTable.h',
|
||||
'libGLESv2/Fence.cpp',
|
||||
'libGLESv2/Fence.h',
|
||||
'libGLESv2/Float16ToFloat32.cpp',
|
||||
'libGLESv2/Framebuffer.cpp',
|
||||
'libGLESv2/Framebuffer.h',
|
||||
'libGLESv2/HandleAllocator.cpp',
|
||||
'libGLESv2/HandleAllocator.h',
|
||||
'libGLESv2/libGLESv2.cpp',
|
||||
'libGLESv2/libGLESv2.def',
|
||||
'libGLESv2/libGLESv2.rc',
|
||||
'libGLESv2/main.cpp',
|
||||
'libGLESv2/main.h',
|
||||
'libGLESv2/mathutil.h',
|
||||
'libGLESv2/Program.cpp',
|
||||
'libGLESv2/Program.h',
|
||||
'libGLESv2/ProgramBinary.cpp',
|
||||
'libGLESv2/ProgramBinary.h',
|
||||
'libGLESv2/Query.h',
|
||||
'libGLESv2/Query.cpp',
|
||||
'libGLESv2/Renderbuffer.cpp',
|
||||
'libGLESv2/Renderbuffer.h',
|
||||
'libGLESv2/ResourceManager.cpp',
|
||||
'libGLESv2/ResourceManager.h',
|
||||
'libGLESv2/Shader.cpp',
|
||||
'libGLESv2/Shader.h',
|
||||
'libGLESv2/Texture.cpp',
|
||||
'libGLESv2/TextureSSE2.cpp',
|
||||
'libGLESv2/Texture.h',
|
||||
'libGLESv2/utilities.cpp',
|
||||
'libGLESv2/utilities.h',
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
|
||||
'AdditionalDependencies': [
|
||||
'd3d9.lib',
|
||||
],
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
'target_name': 'libEGL',
|
||||
'type': 'shared_library',
|
||||
'dependencies': ['libGLESv2'],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../include',
|
||||
'$(DXSDK_DIR)/include',
|
||||
],
|
||||
'sources': [
|
||||
'common/angleutils.h',
|
||||
'common/debug.cpp',
|
||||
'common/debug.h',
|
||||
'common/RefCountObject.cpp',
|
||||
'common/RefCountObject.h',
|
||||
'common/version.h',
|
||||
'libEGL/Config.cpp',
|
||||
'libEGL/Config.h',
|
||||
'libEGL/Display.cpp',
|
||||
'libEGL/Display.h',
|
||||
'libEGL/libEGL.cpp',
|
||||
'libEGL/libEGL.def',
|
||||
'libEGL/libEGL.rc',
|
||||
'libEGL/main.cpp',
|
||||
'libEGL/main.h',
|
||||
'libEGL/Surface.cpp',
|
||||
'libEGL/Surface.h',
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
|
||||
'AdditionalDependencies': [
|
||||
'd3d9.lib',
|
||||
'dxguid.lib',
|
||||
'dwmapi.lib',
|
||||
],
|
||||
'DelayLoadDLLs': [
|
||||
'dwmapi.dll',
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
}],
|
||||
],
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# tab-width:2
|
||||
# indent-tabs-mode:nil
|
||||
# End:
|
||||
# vim: set expandtab tabstop=2 shiftwidth=2:
|
||||
# Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
|
@ -84,6 +84,12 @@ bool perfActive()
|
|||
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
|
||||
{
|
||||
#if !defined(ANGLE_DISABLE_PERF)
|
||||
#if defined(ANGLE_DISABLE_TRACE)
|
||||
if (!perfActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
va_list vararg;
|
||||
va_start(vararg, format);
|
||||
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#define MAJOR_VERSION 1
|
||||
#define MINOR_VERSION 0
|
||||
#define BUILD_VERSION 0
|
||||
#define BUILD_REVISION 1267
|
||||
#define BUILD_REVISION 1560
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
||||
|
|
|
@ -124,6 +124,8 @@ bool TCompiler::Init(const ShBuiltInResources& resources)
|
|||
return false;
|
||||
InitExtensionBehavior(resources, extensionBehavior);
|
||||
|
||||
hashFunction = resources.HashFunction;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -193,7 +195,8 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
|||
// Call mapLongVariableNames() before collectAttribsUniforms() so in
|
||||
// collectAttribsUniforms() we already have the mapped symbol names and
|
||||
// we could composite mapped and original variable names.
|
||||
if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES))
|
||||
// Also, if we hash all the names, then no need to do this for long names.
|
||||
if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL)
|
||||
mapLongVariableNames(root);
|
||||
|
||||
if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) {
|
||||
|
@ -242,6 +245,8 @@ void TCompiler::clearResults()
|
|||
uniforms.clear();
|
||||
|
||||
builtInFunctionEmulator.Cleanup();
|
||||
|
||||
nameMap.clear();
|
||||
}
|
||||
|
||||
bool TCompiler::detectRecursion(TIntermNode* root)
|
||||
|
@ -317,7 +322,7 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
|
|||
|
||||
void TCompiler::collectAttribsUniforms(TIntermNode* root)
|
||||
{
|
||||
CollectAttribsUniforms collect(attribs, uniforms);
|
||||
CollectAttribsUniforms collect(attribs, uniforms, hashFunction);
|
||||
root->traverse(&collect);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include "compiler/Diagnostics.h"
|
||||
|
||||
#include "compiler/compilerdebug.h"
|
||||
#include "compiler/compiler_debug.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/preprocessor/new/SourceLocation.h"
|
||||
#include "compiler/preprocessor/SourceLocation.h"
|
||||
|
||||
TDiagnostics::TDiagnostics(TInfoSink& infoSink) :
|
||||
mInfoSink(infoSink),
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef COMPILER_DIAGNOSTICS_H_
|
||||
#define COMPILER_DIAGNOSTICS_H_
|
||||
|
||||
#include "compiler/preprocessor/new/Diagnostics.h"
|
||||
#include "compiler/preprocessor/Diagnostics.h"
|
||||
|
||||
class TInfoSink;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#include "compiler/compilerdebug.h"
|
||||
#include "compiler/compiler_debug.h"
|
||||
#include "compiler/Diagnostics.h"
|
||||
|
||||
static TBehavior getBehavior(const std::string& str)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "compiler/ExtensionBehavior.h"
|
||||
#include "compiler/Pragma.h"
|
||||
#include "compiler/preprocessor/new/DirectiveHandler.h"
|
||||
#include "compiler/preprocessor/DirectiveHandler.h"
|
||||
|
||||
class TDiagnostics;
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_HASH_NAMES_H_
|
||||
#define COMPILER_HASH_NAMES_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#define HASHED_NAME_PREFIX "webgl_"
|
||||
|
||||
typedef std::map<TPersistString, TPersistString> NameMap;
|
||||
|
||||
#endif // COMPILER_HASH_NAMES_H_
|
|
@ -12,6 +12,7 @@
|
|||
#include <limits.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "compiler/HashNames.h"
|
||||
#include "compiler/localintermediate.h"
|
||||
#include "compiler/QualifierAlive.h"
|
||||
#include "compiler/RemoveTree.h"
|
||||
|
@ -1445,3 +1446,14 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||
return addConstantUnion(leftUnionArray, TType(promoteTo, t.getPrecision(), t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine());
|
||||
}
|
||||
|
||||
// static
|
||||
TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction)
|
||||
{
|
||||
if (hashFunction == NULL || name.empty())
|
||||
return name;
|
||||
khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length());
|
||||
TStringStream stream;
|
||||
stream << HASHED_NAME_PREFIX << std::hex << number;
|
||||
TString hashedName = stream.str();
|
||||
return hashedName;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
|
||||
#include "compiler/OutputESSL.h"
|
||||
|
||||
TOutputESSL::TOutputESSL(TInfoSinkBase& objSink)
|
||||
: TOutputGLSLBase(objSink)
|
||||
TOutputESSL::TOutputESSL(TInfoSinkBase& objSink,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable)
|
||||
: TOutputGLSLBase(objSink, hashFunction, nameMap, symbolTable)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
class TOutputESSL : public TOutputGLSLBase
|
||||
{
|
||||
public:
|
||||
TOutputESSL(TInfoSinkBase& objSink);
|
||||
TOutputESSL(TInfoSinkBase& objSink,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable);
|
||||
|
||||
protected:
|
||||
virtual bool writeVariablePrecision(TPrecision precision);
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
|
||||
#include "compiler/OutputGLSL.h"
|
||||
|
||||
TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink)
|
||||
: TOutputGLSLBase(objSink)
|
||||
TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable)
|
||||
: TOutputGLSLBase(objSink, hashFunction, nameMap, symbolTable)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
class TOutputGLSL : public TOutputGLSLBase
|
||||
{
|
||||
public:
|
||||
TOutputGLSL(TInfoSinkBase& objSink);
|
||||
TOutputGLSL(TInfoSinkBase& objSink,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable);
|
||||
|
||||
protected:
|
||||
virtual bool writeVariablePrecision(TPrecision);
|
||||
|
|
|
@ -5,39 +5,10 @@
|
|||
//
|
||||
|
||||
#include "compiler/OutputGLSLBase.h"
|
||||
#include "compiler/compilerdebug.h"
|
||||
#include "compiler/compiler_debug.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
TString getTypeName(const TType& type)
|
||||
{
|
||||
TInfoSinkBase out;
|
||||
if (type.isMatrix())
|
||||
{
|
||||
out << "mat";
|
||||
out << type.getNominalSize();
|
||||
}
|
||||
else if (type.isVector())
|
||||
{
|
||||
switch (type.getBasicType())
|
||||
{
|
||||
case EbtFloat: out << "vec"; break;
|
||||
case EbtInt: out << "ivec"; break;
|
||||
case EbtBool: out << "bvec"; break;
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
out << type.getNominalSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type.getBasicType() == EbtStruct)
|
||||
out << type.getTypeName();
|
||||
else
|
||||
out << type.getBasicString();
|
||||
}
|
||||
return TString(out.c_str());
|
||||
}
|
||||
|
||||
TString arrayBrackets(const TType& type)
|
||||
{
|
||||
ASSERT(type.isArray());
|
||||
|
@ -66,10 +37,16 @@ bool isSingleStatement(TIntermNode* node) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase& objSink)
|
||||
TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase& objSink,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable)
|
||||
: TIntermTraverser(true, true, true),
|
||||
mObjSink(objSink),
|
||||
mDeclaringVariables(false)
|
||||
mDeclaringVariables(false),
|
||||
mHashFunction(hashFunction),
|
||||
mNameMap(nameMap),
|
||||
mSymbolTable(symbolTable)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -101,7 +78,7 @@ void TOutputGLSLBase::writeVariableType(const TType& type)
|
|||
if ((type.getBasicType() == EbtStruct) &&
|
||||
(mDeclaredStructs.find(type.getTypeName()) == mDeclaredStructs.end()))
|
||||
{
|
||||
out << "struct " << type.getTypeName() << "{\n";
|
||||
out << "struct " << hashName(type.getTypeName()) << "{\n";
|
||||
const TTypeList* structure = type.getStruct();
|
||||
ASSERT(structure != NULL);
|
||||
for (size_t i = 0; i < structure->size(); ++i)
|
||||
|
@ -110,7 +87,7 @@ void TOutputGLSLBase::writeVariableType(const TType& type)
|
|||
ASSERT(fieldType != NULL);
|
||||
if (writeVariablePrecision(fieldType->getPrecision()))
|
||||
out << " ";
|
||||
out << getTypeName(*fieldType) << " " << fieldType->getFieldName();
|
||||
out << getTypeName(*fieldType) << " " << hashName(fieldType->getFieldName());
|
||||
if (fieldType->isArray())
|
||||
out << arrayBrackets(*fieldType);
|
||||
out << ";\n";
|
||||
|
@ -140,7 +117,7 @@ void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence& args)
|
|||
|
||||
const TString& name = arg->getSymbol();
|
||||
if (!name.empty())
|
||||
out << " " << name;
|
||||
out << " " << hashName(name);
|
||||
if (type.isArray())
|
||||
out << arrayBrackets(type);
|
||||
|
||||
|
@ -157,7 +134,7 @@ const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
|
|||
|
||||
if (type.getBasicType() == EbtStruct)
|
||||
{
|
||||
out << type.getTypeName() << "(";
|
||||
out << hashName(type.getTypeName()) << "(";
|
||||
const TTypeList* structure = type.getStruct();
|
||||
ASSERT(structure != NULL);
|
||||
for (size_t i = 0; i < structure->size(); ++i)
|
||||
|
@ -196,7 +173,7 @@ void TOutputGLSLBase::visitSymbol(TIntermSymbol* node)
|
|||
if (mLoopUnroll.NeedsToReplaceSymbolWithValue(node))
|
||||
out << mLoopUnroll.GetLoopIndexValue(node);
|
||||
else
|
||||
out << node->getSymbol();
|
||||
out << hashVariableName(node->getSymbol());
|
||||
|
||||
if (mDeclaringVariables && node->getType().isArray())
|
||||
out << arrayBrackets(node->getType());
|
||||
|
@ -243,7 +220,7 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
|
|||
{
|
||||
out << ".";
|
||||
// TODO(alokp): ASSERT
|
||||
out << node->getType().getFieldName();
|
||||
out << hashName(node->getType().getFieldName());
|
||||
visitChildren = false;
|
||||
}
|
||||
break;
|
||||
|
@ -467,7 +444,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
|||
// Function declaration.
|
||||
ASSERT(visit == PreVisit);
|
||||
writeVariableType(node->getType());
|
||||
out << " " << node->getName();
|
||||
out << " " << hashName(node->getName());
|
||||
|
||||
out << "(";
|
||||
writeFunctionParameters(node->getSequence());
|
||||
|
@ -480,7 +457,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
|||
// Function definition.
|
||||
ASSERT(visit == PreVisit);
|
||||
writeVariableType(node->getType());
|
||||
out << " " << TFunction::unmangleName(node->getName());
|
||||
out << " " << hashFunctionName(node->getName());
|
||||
|
||||
incrementDepth();
|
||||
// Function definition node contains one or two children nodes
|
||||
|
@ -510,8 +487,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
|||
// Function call.
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
TString functionName = TFunction::unmangleName(node->getName());
|
||||
out << functionName << "(";
|
||||
out << hashFunctionName(node->getName()) << "(";
|
||||
}
|
||||
else if (visit == InVisit)
|
||||
{
|
||||
|
@ -572,7 +548,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
|||
{
|
||||
const TType& type = node->getType();
|
||||
ASSERT(type.getBasicType() == EbtStruct);
|
||||
out << type.getTypeName() << "(";
|
||||
out << hashName(type.getTypeName()) << "(";
|
||||
}
|
||||
else if (visit == InVisit)
|
||||
{
|
||||
|
@ -718,3 +694,59 @@ void TOutputGLSLBase::visitCodeBlock(TIntermNode* node) {
|
|||
out << "{\n}\n"; // Empty code block.
|
||||
}
|
||||
}
|
||||
|
||||
TString TOutputGLSLBase::getTypeName(const TType& type)
|
||||
{
|
||||
TInfoSinkBase out;
|
||||
if (type.isMatrix())
|
||||
{
|
||||
out << "mat";
|
||||
out << type.getNominalSize();
|
||||
}
|
||||
else if (type.isVector())
|
||||
{
|
||||
switch (type.getBasicType())
|
||||
{
|
||||
case EbtFloat: out << "vec"; break;
|
||||
case EbtInt: out << "ivec"; break;
|
||||
case EbtBool: out << "bvec"; break;
|
||||
default: UNREACHABLE(); break;
|
||||
}
|
||||
out << type.getNominalSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type.getBasicType() == EbtStruct)
|
||||
out << hashName(type.getTypeName());
|
||||
else
|
||||
out << type.getBasicString();
|
||||
}
|
||||
return TString(out.c_str());
|
||||
}
|
||||
|
||||
TString TOutputGLSLBase::hashName(const TString& name)
|
||||
{
|
||||
if (mHashFunction == NULL || name.empty())
|
||||
return name;
|
||||
NameMap::const_iterator it = mNameMap.find(name.c_str());
|
||||
if (it != mNameMap.end())
|
||||
return it->second.c_str();
|
||||
TString hashedName = TIntermTraverser::hash(name, mHashFunction);
|
||||
mNameMap[name.c_str()] = hashedName.c_str();
|
||||
return hashedName;
|
||||
}
|
||||
|
||||
TString TOutputGLSLBase::hashVariableName(const TString& name)
|
||||
{
|
||||
if (mSymbolTable.findBuiltIn(name) != NULL)
|
||||
return name;
|
||||
return hashName(name);
|
||||
}
|
||||
|
||||
TString TOutputGLSLBase::hashFunctionName(const TString& mangled_name)
|
||||
{
|
||||
TString name = TFunction::unmangleName(mangled_name);
|
||||
if (mSymbolTable.findBuiltIn(mangled_name) != NULL || name == "main")
|
||||
return name;
|
||||
return hashName(name);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
class TOutputGLSLBase : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
TOutputGLSLBase(TInfoSinkBase& objSink);
|
||||
TOutputGLSLBase(TInfoSinkBase& objSink,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable);
|
||||
|
||||
protected:
|
||||
TInfoSinkBase& objSink() { return mObjSink; }
|
||||
|
@ -25,6 +28,7 @@ protected:
|
|||
virtual bool writeVariablePrecision(TPrecision precision) = 0;
|
||||
void writeFunctionParameters(const TIntermSequence& args);
|
||||
const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion);
|
||||
TString getTypeName(const TType& type);
|
||||
|
||||
virtual void visitSymbol(TIntermSymbol* node);
|
||||
virtual void visitConstantUnion(TIntermConstantUnion* node);
|
||||
|
@ -37,6 +41,15 @@ protected:
|
|||
|
||||
void visitCodeBlock(TIntermNode* node);
|
||||
|
||||
|
||||
// Return the original name if hash function pointer is NULL;
|
||||
// otherwise return the hashed name.
|
||||
TString hashName(const TString& name);
|
||||
// Same as hashName(), but without hashing built-in variables.
|
||||
TString hashVariableName(const TString& name);
|
||||
// Same as hashName(), but without hashing built-in functions.
|
||||
TString hashFunctionName(const TString& mangled_name);
|
||||
|
||||
private:
|
||||
TInfoSinkBase& mObjSink;
|
||||
bool mDeclaringVariables;
|
||||
|
@ -48,6 +61,12 @@ private:
|
|||
DeclaredStructs mDeclaredStructs;
|
||||
|
||||
ForLoopUnroll mLoopUnroll;
|
||||
|
||||
// name hashing.
|
||||
ShHashFunction64 mHashFunction;
|
||||
NameMap& mNameMap;
|
||||
|
||||
TSymbolTable& mSymbolTable;
|
||||
};
|
||||
|
||||
#endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "compiler/OutputHLSL.h"
|
||||
|
||||
#include "common/angleutils.h"
|
||||
#include "compiler/compilerdebug.h"
|
||||
#include "compiler/compiler_debug.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/UnfoldShortCircuit.h"
|
||||
#include "compiler/SearchSymbol.h"
|
||||
|
@ -1340,7 +1340,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
|
|||
case EOpPrototype:
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
out << typeString(node->getType()) << " " << decorate(node->getName()) << "(";
|
||||
out << typeString(node->getType()) << " " << decorate(node->getName()) << (mOutputLod0Function ? "Lod0(" : "(");
|
||||
|
||||
TIntermSequence &arguments = node->getSequence();
|
||||
|
||||
|
@ -1362,6 +1362,14 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
|
|||
|
||||
out << ");\n";
|
||||
|
||||
// Also prototype the Lod0 variant if needed
|
||||
if (mContainsLoopDiscontinuity && !mOutputLod0Function)
|
||||
{
|
||||
mOutputLod0Function = true;
|
||||
node->traverse(this);
|
||||
mOutputLod0Function = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "compiler/glslang.h"
|
||||
#include "compiler/preprocessor/new/SourceLocation.h"
|
||||
#include "compiler/preprocessor/SourceLocation.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -846,14 +846,26 @@ bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size,
|
|||
//
|
||||
// Returns true if there was an error.
|
||||
//
|
||||
bool TParseContext::nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type)
|
||||
bool TParseContext::nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type, bool array)
|
||||
{
|
||||
//
|
||||
// Make the qualifier make sense.
|
||||
//
|
||||
if (type.qualifier == EvqConst) {
|
||||
if (type.qualifier == EvqConst)
|
||||
{
|
||||
// Make the qualifier make sense.
|
||||
type.qualifier = EvqTemporary;
|
||||
error(line, "variables with qualifier 'const' must be initialized", identifier.c_str());
|
||||
|
||||
if (array)
|
||||
{
|
||||
error(line, "arrays may not be declared constant since they cannot be initialized", identifier.c_str());
|
||||
}
|
||||
else if (type.isStructureContainingArrays())
|
||||
{
|
||||
error(line, "structures containing arrays may not be declared constant since they cannot be initialized", identifier.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
error(line, "variables with qualifier 'const' must be initialized", identifier.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
@ -9,7 +9,7 @@
|
|||
#include "compiler/Diagnostics.h"
|
||||
#include "compiler/DirectiveHandler.h"
|
||||
#include "compiler/localintermediate.h"
|
||||
#include "compiler/preprocessor/new/Preprocessor.h"
|
||||
#include "compiler/preprocessor/Preprocessor.h"
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/SymbolTable.h"
|
||||
|
||||
|
@ -97,7 +97,7 @@ struct TParseContext {
|
|||
bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);
|
||||
bool structQualifierErrorCheck(int line, const TPublicType& pType);
|
||||
bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);
|
||||
bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type);
|
||||
bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type, bool array);
|
||||
bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable);
|
||||
bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
|
||||
bool extensionErrorCheck(int line, const TString&);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "compiler/BuiltInFunctionEmulator.h"
|
||||
#include "compiler/ExtensionBehavior.h"
|
||||
#include "compiler/HashNames.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/SymbolTable.h"
|
||||
#include "compiler/VariableInfo.h"
|
||||
|
@ -68,6 +69,10 @@ public:
|
|||
const TVariableInfoList& getUniforms() const { return uniforms; }
|
||||
int getMappedNameMaxLength() const;
|
||||
|
||||
ShHashFunction64 getHashFunction() const { return hashFunction; }
|
||||
NameMap& getNameMap() { return nameMap; }
|
||||
TSymbolTable& getSymbolTable() { return symbolTable; }
|
||||
|
||||
protected:
|
||||
ShShaderType getShaderType() const { return shaderType; }
|
||||
ShShaderSpec getShaderSpec() const { return shaderSpec; }
|
||||
|
@ -124,6 +129,10 @@ private:
|
|||
|
||||
// Cached copy of the ref-counted singleton.
|
||||
LongNameMap* longNameMap;
|
||||
|
||||
// name hashing.
|
||||
ShHashFunction64 hashFunction;
|
||||
NameMap nameMap;
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
@ -125,6 +125,9 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
|
|||
resources->OES_standard_derivatives = 0;
|
||||
resources->OES_EGL_image_external = 0;
|
||||
resources->ARB_texture_rectangle = 0;
|
||||
|
||||
// Disable name hashing by default.
|
||||
resources->HashFunction = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -224,6 +227,22 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params)
|
|||
// handle array and struct dereferences.
|
||||
*params = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
break;
|
||||
case SH_NAME_MAX_LENGTH:
|
||||
*params = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
break;
|
||||
case SH_HASHED_NAME_MAX_LENGTH:
|
||||
if (compiler->getHashFunction() == NULL) {
|
||||
*params = 0;
|
||||
} else {
|
||||
// 64 bits hashing output requires 16 bytes for hex
|
||||
// representation.
|
||||
const char HashedNamePrefix[] = HASHED_NAME_PREFIX;
|
||||
*params = 16 + sizeof(HashedNamePrefix);
|
||||
}
|
||||
break;
|
||||
case SH_HASHED_NAMES_COUNT:
|
||||
*params = compiler->getNameMap().size();
|
||||
break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
@ -283,3 +302,46 @@ void ShGetActiveUniform(const ShHandle handle,
|
|||
getVariableInfo(SH_ACTIVE_UNIFORMS,
|
||||
handle, index, length, size, type, name, mappedName);
|
||||
}
|
||||
|
||||
void ShGetNameHashingEntry(const ShHandle handle,
|
||||
int index,
|
||||
char* name,
|
||||
char* hashedName)
|
||||
{
|
||||
if (!handle || !name || !hashedName || index < 0)
|
||||
return;
|
||||
|
||||
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
|
||||
TCompiler* compiler = base->getAsCompiler();
|
||||
if (!compiler) return;
|
||||
|
||||
const NameMap& nameMap = compiler->getNameMap();
|
||||
if (index >= static_cast<int>(nameMap.size()))
|
||||
return;
|
||||
|
||||
NameMap::const_iterator it = nameMap.begin();
|
||||
for (int i = 0; i < index; ++i)
|
||||
++it;
|
||||
|
||||
size_t len = it->first.length() + 1;
|
||||
int max_len = 0;
|
||||
ShGetInfo(handle, SH_NAME_MAX_LENGTH, &max_len);
|
||||
if (static_cast<int>(len) > max_len) {
|
||||
ASSERT(false);
|
||||
len = max_len;
|
||||
}
|
||||
strncpy(name, it->first.c_str(), len);
|
||||
// To be on the safe side in case the source is longer than expected.
|
||||
name[len] = '\0';
|
||||
|
||||
len = it->second.length() + 1;
|
||||
max_len = 0;
|
||||
ShGetInfo(handle, SH_HASHED_NAME_MAX_LENGTH, &max_len);
|
||||
if (static_cast<int>(len) > max_len) {
|
||||
ASSERT(false);
|
||||
len = max_len;
|
||||
}
|
||||
strncpy(hashedName, it->second.c_str(), len);
|
||||
// To be on the safe side in case the source is longer than expected.
|
||||
hashedName[len] = '\0';
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
@ -20,9 +20,16 @@
|
|||
|
||||
#include "common/angleutils.h"
|
||||
|
||||
//
|
||||
// TType helper function needs a place to live.
|
||||
//
|
||||
TType::TType(const TPublicType &p) :
|
||||
type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize),
|
||||
maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0)
|
||||
{
|
||||
if (p.userDef) {
|
||||
structure = p.userDef->getStruct();
|
||||
typeName = NewPoolTString(p.userDef->getTypeName().c_str());
|
||||
computeDeepestStructNesting();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Recursively generate mangled names.
|
||||
|
@ -92,6 +99,25 @@ void TType::computeDeepestStructNesting()
|
|||
deepestStructNesting = 1 + maxNesting;
|
||||
}
|
||||
|
||||
bool TType::isStructureContainingArrays() const
|
||||
{
|
||||
if (!structure)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (TTypeList::const_iterator member = structure->begin(); member != structure->end(); member++)
|
||||
{
|
||||
if (member->type->isArray() ||
|
||||
member->type->isStructureContainingArrays())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Dump functions.
|
||||
//
|
||||
|
|
|
@ -23,7 +23,7 @@ void TranslatorESSL::translate(TIntermNode* root) {
|
|||
sink, getShaderType() == SH_FRAGMENT_SHADER);
|
||||
|
||||
// Write translated shader.
|
||||
TOutputESSL outputESSL(sink);
|
||||
TOutputESSL outputESSL(sink, getHashFunction(), getNameMap(), getSymbolTable());
|
||||
root->traverse(&outputESSL);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,6 @@ void TranslatorGLSL::translate(TIntermNode* root) {
|
|||
sink, false);
|
||||
|
||||
// Write translated shader.
|
||||
TOutputGLSL outputGLSL(sink);
|
||||
TOutputGLSL outputGLSL(sink, getHashFunction(), getNameMap(), getSymbolTable());
|
||||
root->traverse(&outputGLSL);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
@ -9,12 +9,14 @@
|
|||
|
||||
#include "compiler/BaseTypes.h"
|
||||
#include "compiler/Common.h"
|
||||
#include "compiler/compilerdebug.h"
|
||||
#include "compiler/compiler_debug.h"
|
||||
|
||||
class TType;
|
||||
struct TPublicType;
|
||||
|
||||
//
|
||||
// Need to have association of line numbers to types in a list for building structs.
|
||||
//
|
||||
class TType;
|
||||
struct TTypeLine {
|
||||
TType* type;
|
||||
int line;
|
||||
|
@ -27,59 +29,14 @@ inline TTypeList* NewPoolTTypeList()
|
|||
return new(memory) TTypeList;
|
||||
}
|
||||
|
||||
//
|
||||
// This is a workaround for a problem with the yacc stack, It can't have
|
||||
// types that it thinks have non-trivial constructors. It should
|
||||
// just be used while recognizing the grammar, not anything else. Pointers
|
||||
// could be used, but also trying to avoid lots of memory management overhead.
|
||||
//
|
||||
// Not as bad as it looks, there is no actual assumption that the fields
|
||||
// match up or are name the same or anything like that.
|
||||
//
|
||||
class TPublicType {
|
||||
public:
|
||||
TBasicType type;
|
||||
TQualifier qualifier;
|
||||
TPrecision precision;
|
||||
int size; // size of vector or matrix, not size of array
|
||||
bool matrix;
|
||||
bool array;
|
||||
int arraySize;
|
||||
TType* userDef;
|
||||
int line;
|
||||
|
||||
void setBasic(TBasicType bt, TQualifier q, int ln = 0)
|
||||
{
|
||||
type = bt;
|
||||
qualifier = q;
|
||||
precision = EbpUndefined;
|
||||
size = 1;
|
||||
matrix = false;
|
||||
array = false;
|
||||
arraySize = 0;
|
||||
userDef = 0;
|
||||
line = ln;
|
||||
}
|
||||
|
||||
void setAggregate(int s, bool m = false)
|
||||
{
|
||||
size = s;
|
||||
matrix = m;
|
||||
}
|
||||
|
||||
void setArray(bool a, int s = 0)
|
||||
{
|
||||
array = a;
|
||||
arraySize = s;
|
||||
}
|
||||
};
|
||||
|
||||
typedef TMap<TTypeList*, TTypeList*> TStructureMap;
|
||||
typedef TMap<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
|
||||
|
||||
//
|
||||
// Base class for things that have a type.
|
||||
//
|
||||
class TType {
|
||||
class TType
|
||||
{
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||
TType() {}
|
||||
|
@ -88,16 +45,7 @@ public:
|
|||
maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0)
|
||||
{
|
||||
}
|
||||
explicit TType(const TPublicType &p) :
|
||||
type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize),
|
||||
maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0)
|
||||
{
|
||||
if (p.userDef) {
|
||||
structure = p.userDef->getStruct();
|
||||
typeName = NewPoolTString(p.userDef->getTypeName().c_str());
|
||||
computeDeepestStructNesting();
|
||||
}
|
||||
}
|
||||
explicit TType(const TPublicType &p);
|
||||
TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) :
|
||||
type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
|
||||
maxArraySize(0), arrayInformationType(0), structure(userDef), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0)
|
||||
|
@ -284,6 +232,8 @@ public:
|
|||
// deepest field (nesting2.field1.position).
|
||||
int getDeepestStructNesting() const { return deepestStructNesting; }
|
||||
|
||||
bool isStructureContainingArrays() const;
|
||||
|
||||
protected:
|
||||
void buildMangledName(TString&);
|
||||
int getStructSize() const;
|
||||
|
@ -308,4 +258,61 @@ protected:
|
|||
TString *typeName; // for structure field type name
|
||||
};
|
||||
|
||||
//
|
||||
// This is a workaround for a problem with the yacc stack, It can't have
|
||||
// types that it thinks have non-trivial constructors. It should
|
||||
// just be used while recognizing the grammar, not anything else. Pointers
|
||||
// could be used, but also trying to avoid lots of memory management overhead.
|
||||
//
|
||||
// Not as bad as it looks, there is no actual assumption that the fields
|
||||
// match up or are name the same or anything like that.
|
||||
//
|
||||
struct TPublicType
|
||||
{
|
||||
TBasicType type;
|
||||
TQualifier qualifier;
|
||||
TPrecision precision;
|
||||
int size; // size of vector or matrix, not size of array
|
||||
bool matrix;
|
||||
bool array;
|
||||
int arraySize;
|
||||
TType* userDef;
|
||||
int line;
|
||||
|
||||
void setBasic(TBasicType bt, TQualifier q, int ln = 0)
|
||||
{
|
||||
type = bt;
|
||||
qualifier = q;
|
||||
precision = EbpUndefined;
|
||||
size = 1;
|
||||
matrix = false;
|
||||
array = false;
|
||||
arraySize = 0;
|
||||
userDef = 0;
|
||||
line = ln;
|
||||
}
|
||||
|
||||
void setAggregate(int s, bool m = false)
|
||||
{
|
||||
size = s;
|
||||
matrix = m;
|
||||
}
|
||||
|
||||
void setArray(bool a, int s = 0)
|
||||
{
|
||||
array = a;
|
||||
arraySize = s;
|
||||
}
|
||||
|
||||
bool isStructureContainingArrays() const
|
||||
{
|
||||
if (!userDef)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return userDef->isStructureContainingArrays();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _TYPES_INCLUDED_
|
||||
|
|
|
@ -95,9 +95,9 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node)
|
|||
mTemporaryIndex = i + 1;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnfoldShortCircuit::visitSelection(Visit visit, TIntermSelection *node)
|
||||
|
|
|
@ -77,23 +77,25 @@ static void getBuiltInVariableInfo(const TType& type,
|
|||
static void getUserDefinedVariableInfo(const TType& type,
|
||||
const TString& name,
|
||||
const TString& mappedName,
|
||||
TVariableInfoList& infoList);
|
||||
TVariableInfoList& infoList,
|
||||
ShHashFunction64 hashFunction);
|
||||
|
||||
// Returns info for an attribute or uniform.
|
||||
static void getVariableInfo(const TType& type,
|
||||
const TString& name,
|
||||
const TString& mappedName,
|
||||
TVariableInfoList& infoList)
|
||||
TVariableInfoList& infoList,
|
||||
ShHashFunction64 hashFunction)
|
||||
{
|
||||
if (type.getBasicType() == EbtStruct) {
|
||||
if (type.isArray()) {
|
||||
for (int i = 0; i < type.getArraySize(); ++i) {
|
||||
TString lname = name + arrayBrackets(i);
|
||||
TString lmappedName = mappedName + arrayBrackets(i);
|
||||
getUserDefinedVariableInfo(type, lname, lmappedName, infoList);
|
||||
getUserDefinedVariableInfo(type, lname, lmappedName, infoList, hashFunction);
|
||||
}
|
||||
} else {
|
||||
getUserDefinedVariableInfo(type, name, mappedName, infoList);
|
||||
getUserDefinedVariableInfo(type, name, mappedName, infoList, hashFunction);
|
||||
}
|
||||
} else {
|
||||
getBuiltInVariableInfo(type, name, mappedName, infoList);
|
||||
|
@ -124,7 +126,8 @@ void getBuiltInVariableInfo(const TType& type,
|
|||
void getUserDefinedVariableInfo(const TType& type,
|
||||
const TString& name,
|
||||
const TString& mappedName,
|
||||
TVariableInfoList& infoList)
|
||||
TVariableInfoList& infoList,
|
||||
ShHashFunction64 hashFunction)
|
||||
{
|
||||
ASSERT(type.getBasicType() == EbtStruct);
|
||||
|
||||
|
@ -133,8 +136,9 @@ void getUserDefinedVariableInfo(const TType& type,
|
|||
const TType* fieldType = (*structure)[i].type;
|
||||
getVariableInfo(*fieldType,
|
||||
name + "." + fieldType->getFieldName(),
|
||||
mappedName + "." + fieldType->getFieldName(),
|
||||
infoList);
|
||||
mappedName + "." + TIntermTraverser::hash(fieldType->getFieldName(), hashFunction),
|
||||
infoList,
|
||||
hashFunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,9 +153,11 @@ TVariableInfo::TVariableInfo(ShDataType type, int size)
|
|||
}
|
||||
|
||||
CollectAttribsUniforms::CollectAttribsUniforms(TVariableInfoList& attribs,
|
||||
TVariableInfoList& uniforms)
|
||||
TVariableInfoList& uniforms,
|
||||
ShHashFunction64 hashFunction)
|
||||
: mAttribs(attribs),
|
||||
mUniforms(uniforms)
|
||||
mUniforms(uniforms),
|
||||
mHashFunction(hashFunction)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -206,10 +212,16 @@ bool CollectAttribsUniforms::visitAggregate(Visit, TIntermAggregate* node)
|
|||
// cannot be initialized in a shader, we must have only
|
||||
// TIntermSymbol nodes in the sequence.
|
||||
ASSERT(variable != NULL);
|
||||
TString processedSymbol;
|
||||
if (mHashFunction == NULL)
|
||||
processedSymbol = variable->getSymbol();
|
||||
else
|
||||
processedSymbol = TIntermTraverser::hash(variable->getOriginalSymbol(), mHashFunction);
|
||||
getVariableInfo(variable->getType(),
|
||||
variable->getOriginalSymbol(),
|
||||
variable->getSymbol(),
|
||||
infoList);
|
||||
processedSymbol,
|
||||
infoList,
|
||||
mHashFunction);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -27,7 +27,8 @@ typedef std::vector<TVariableInfo> TVariableInfoList;
|
|||
class CollectAttribsUniforms : public TIntermTraverser {
|
||||
public:
|
||||
CollectAttribsUniforms(TVariableInfoList& attribs,
|
||||
TVariableInfoList& uniforms);
|
||||
TVariableInfoList& uniforms,
|
||||
ShHashFunction64 hashFunction);
|
||||
|
||||
virtual void visitSymbol(TIntermSymbol*);
|
||||
virtual void visitConstantUnion(TIntermConstantUnion*);
|
||||
|
@ -41,6 +42,8 @@ public:
|
|||
private:
|
||||
TVariableInfoList& mAttribs;
|
||||
TVariableInfoList& mUniforms;
|
||||
|
||||
ShHashFunction64 mHashFunction;
|
||||
};
|
||||
|
||||
#endif // COMPILER_VARIABLE_INFO_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
@ -9,17 +9,22 @@
|
|||
static const int GLSL_VERSION_110 = 110;
|
||||
static const int GLSL_VERSION_120 = 120;
|
||||
|
||||
// We need to scan for three things:
|
||||
// We need to scan for the following:
|
||||
// 1. "invariant" keyword: This can occur in both - vertex and fragment shaders
|
||||
// but only at the global scope.
|
||||
// 2. "gl_PointCoord" built-in variable: This can only occur in fragment shader
|
||||
// but inside any scope.
|
||||
// 3. Call to a matrix constructor with another matrix as argument.
|
||||
// (These constructors were reserved in GLSL version 1.10.)
|
||||
//
|
||||
// If it weren't for (3) then we would only need to scan the global
|
||||
// scope of the vertex shader. However, we need to scan the entire
|
||||
// shader in both cases.
|
||||
// 4. Arrays as "out" function parameters.
|
||||
// GLSL spec section 6.1.1: "When calling a function, expressions that do
|
||||
// not evaluate to l-values cannot be passed to parameters declared as
|
||||
// out or inout."
|
||||
// GLSL 1.1 section 5.8: "Other binary or unary expressions,
|
||||
// non-dereferenced arrays, function names, swizzles with repeated fields,
|
||||
// and constants cannot be l-values."
|
||||
// GLSL 1.2 relaxed the restriction on arrays, section 5.8: "Variables that
|
||||
// are built-in types, entire structures or arrays... are all l-values."
|
||||
//
|
||||
// TODO(alokp): The following two cases of invariant decalaration get lost
|
||||
// during parsing - they do not get carried over to the intermediate tree.
|
||||
|
@ -79,6 +84,26 @@ bool TVersionGLSL::visitAggregate(Visit, TIntermAggregate* node)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case EOpParameters: {
|
||||
const TIntermSequence& params = node->getSequence();
|
||||
for (TIntermSequence::const_iterator iter = params.begin();
|
||||
iter != params.end(); ++iter)
|
||||
{
|
||||
const TIntermTyped* param = (*iter)->getAsTyped();
|
||||
if (param->isArray())
|
||||
{
|
||||
TQualifier qualifier = param->getQualifier();
|
||||
if ((qualifier == EvqOut) || (qualifier == EvqInOut))
|
||||
{
|
||||
updateVersion(GLSL_VERSION_120);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fully processed. No need to visit children.
|
||||
visitChildren = false;
|
||||
break;
|
||||
}
|
||||
case EOpConstructMat2:
|
||||
case EOpConstructMat3:
|
||||
case EOpConstructMat4: {
|
||||
|
|
|
@ -22,14 +22,18 @@
|
|||
// - c++ style name hiding rules.
|
||||
// - built-in variable gl_PointCoord for fragment shaders.
|
||||
// - matrix constructors taking matrix as argument.
|
||||
// - array as "out" function parameters
|
||||
//
|
||||
class TVersionGLSL : public TIntermTraverser {
|
||||
public:
|
||||
TVersionGLSL(ShShaderType type);
|
||||
|
||||
// Returns 120 if "invariant" keyword, "gl_PointCoord", or
|
||||
// matrix/matrix constructors are used in the shader. Else 110 is
|
||||
// returned.
|
||||
// Returns 120 if the following is used the shader:
|
||||
// - "invariant",
|
||||
// - "gl_PointCoord",
|
||||
// - matrix/matrix constructors
|
||||
// - array "out" parameters
|
||||
// Else 110 is returned.
|
||||
int getVersion() { return mVersion; }
|
||||
|
||||
virtual void visitSymbol(TIntermSymbol*);
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// debug.cpp: Debugging utilities.
|
||||
// compiler_debug.cpp: Debugging utilities.
|
||||
|
||||
#include "compiler/compilerdebug.h"
|
||||
#include "compiler/compiler_debug.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
|
@ -4,7 +4,7 @@
|
|||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// compilerdebug.h: Debugging utilities.
|
||||
// compiler_debug.h: Debugging utilities.
|
||||
|
||||
#ifndef COMPILER_DEBUG_H_
|
||||
#define COMPILER_DEBUG_H_
|
|
@ -38,7 +38,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
|
|||
%{
|
||||
#include "compiler/glslang.h"
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/preprocessor/new/Token.h"
|
||||
#include "compiler/preprocessor/Token.h"
|
||||
#include "compiler/util.h"
|
||||
#include "glslang_tab.h"
|
||||
|
||||
|
@ -272,146 +272,13 @@ O [0-7]
|
|||
|
||||
%%
|
||||
|
||||
// Old preprocessor interface.
|
||||
extern "C" {
|
||||
#include "compiler/preprocessor/preprocess.h"
|
||||
|
||||
extern int InitPreprocessor();
|
||||
extern int FinalizePreprocessor();
|
||||
extern void PredefineIntMacro(const char *name, int value);
|
||||
|
||||
#define SETUP_CONTEXT(pp) \
|
||||
TParseContext* context = (TParseContext*) pp->pC; \
|
||||
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
|
||||
|
||||
// Preprocessor callbacks.
|
||||
void CPPDebugLogMsg(const char *msg)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->trace(msg);
|
||||
}
|
||||
|
||||
void CPPWarningToInfoLog(const char *msg)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->warning(yylineno, msg, "");
|
||||
}
|
||||
|
||||
void CPPShInfoLogMsg(const char *msg)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->error(yylineno, msg, "");
|
||||
context->recover();
|
||||
}
|
||||
|
||||
void CPPErrorToInfoLog(const char *msg)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->error(yylineno, msg, "");
|
||||
context->recover();
|
||||
}
|
||||
|
||||
void SetLineNumber(int line)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int string = 0;
|
||||
DecodeSourceLoc(yylineno, &string, NULL);
|
||||
yylineno = EncodeSourceLoc(string, line);
|
||||
}
|
||||
|
||||
void SetStringNumber(int string)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int line = 0;
|
||||
DecodeSourceLoc(yylineno, NULL, &line);
|
||||
yylineno = EncodeSourceLoc(string, line);
|
||||
}
|
||||
|
||||
int GetStringNumber()
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int string = 0;
|
||||
DecodeSourceLoc(yylineno, &string, NULL);
|
||||
return string;
|
||||
}
|
||||
|
||||
int GetLineNumber()
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int line = 0;
|
||||
DecodeSourceLoc(yylineno, NULL, &line);
|
||||
return line;
|
||||
}
|
||||
|
||||
void IncLineNumber()
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int string = 0, line = 0;
|
||||
DecodeSourceLoc(yylineno, &string, &line);
|
||||
yylineno = EncodeSourceLoc(string, ++line);
|
||||
}
|
||||
|
||||
void DecLineNumber()
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int string = 0, line = 0;
|
||||
DecodeSourceLoc(yylineno, &string, &line);
|
||||
yylineno = EncodeSourceLoc(string, --line);
|
||||
}
|
||||
|
||||
void HandlePragma(const char **tokens, int numTokens)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
|
||||
if (numTokens != 4) return;
|
||||
if (strcmp(tokens[1], "(") != 0) return;
|
||||
if (strcmp(tokens[3], ")") != 0) return;
|
||||
|
||||
context->handlePragmaDirective(yylineno, tokens[0], tokens[2]);
|
||||
}
|
||||
|
||||
void StoreStr(const char *string)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
TString strSrc;
|
||||
strSrc = TString(string);
|
||||
|
||||
context->HashErrMsg = context->HashErrMsg + " " + strSrc;
|
||||
}
|
||||
|
||||
const char* GetStrfromTStr(void)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
cpp->ErrMsg = context->HashErrMsg.c_str();
|
||||
return cpp->ErrMsg;
|
||||
}
|
||||
|
||||
void ResetTString(void)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->HashErrMsg = "";
|
||||
}
|
||||
|
||||
void updateExtensionBehavior(const char* extName, const char* behavior)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->handleExtensionDirective(yylineno, extName, behavior);
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
int string_input(char* buf, int max_size, yyscan_t yyscanner) {
|
||||
int len = 0;
|
||||
|
||||
#if ANGLE_USE_NEW_PREPROCESSOR
|
||||
pp::Token token;
|
||||
yyget_extra(yyscanner)->preprocessor.lex(&token);
|
||||
len = token.type == pp::Token::LAST ? 0 : token.text.size();
|
||||
int len = token.type == pp::Token::LAST ? 0 : token.text.size();
|
||||
if ((len > 0) && (len < max_size))
|
||||
memcpy(buf, token.text.c_str(), len);
|
||||
yyset_lineno(EncodeSourceLoc(token.location.file, token.location.line), yyscanner);
|
||||
#else
|
||||
len = yylex_CPP(buf, max_size);
|
||||
#endif // ANGLE_USE_NEW_PREPROCESSOR
|
||||
|
||||
if (len >= max_size)
|
||||
YY_FATAL_ERROR("Input buffer overflow");
|
||||
|
@ -471,9 +338,6 @@ int glslang_finalize(TParseContext* context) {
|
|||
context->scanner = NULL;
|
||||
yylex_destroy(scanner);
|
||||
|
||||
#if !ANGLE_USE_NEW_PREPROCESSOR
|
||||
FinalizePreprocessor();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -484,27 +348,14 @@ int glslang_scan(int count, const char* const string[], const int length[],
|
|||
context->AfterEOF = false;
|
||||
|
||||
// Initialize preprocessor.
|
||||
#if ANGLE_USE_NEW_PREPROCESSOR
|
||||
if (!context->preprocessor.init(count, string, length))
|
||||
return 1;
|
||||
#else
|
||||
if (InitPreprocessor())
|
||||
return 1;
|
||||
cpp->pC = context;
|
||||
cpp->pastFirstStatement = 0;
|
||||
if (InitScannerInput(cpp, count, string, length))
|
||||
return 1;
|
||||
#endif // ANGLE_USE_NEW_PREPROCESSOR
|
||||
|
||||
// Define extension macros.
|
||||
const TExtensionBehavior& extBehavior = context->extensionBehavior();
|
||||
for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
|
||||
iter != extBehavior.end(); ++iter) {
|
||||
#if ANGLE_USE_NEW_PREPROCESSOR
|
||||
context->preprocessor.predefineMacro(iter->first.c_str(), 1);
|
||||
#else
|
||||
PredefineIntMacro(iter->first.c_str(), 1);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1200,7 +1200,7 @@ init_declarator_list
|
|||
if (context->structQualifierErrorCheck($3.line, $$.type))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck($3.line, *$3.string, $$.type))
|
||||
if (context->nonInitConstErrorCheck($3.line, *$3.string, $$.type, false))
|
||||
context->recover();
|
||||
|
||||
TVariable* variable = 0;
|
||||
|
@ -1213,7 +1213,7 @@ init_declarator_list
|
|||
if (context->structQualifierErrorCheck($3.line, $1.type))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
|
||||
if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type, true))
|
||||
context->recover();
|
||||
|
||||
$$ = $1;
|
||||
|
@ -1231,7 +1231,7 @@ init_declarator_list
|
|||
if (context->structQualifierErrorCheck($3.line, $1.type))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
|
||||
if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type, true))
|
||||
context->recover();
|
||||
|
||||
$$ = $1;
|
||||
|
@ -1285,7 +1285,7 @@ single_declaration
|
|||
if (context->structQualifierErrorCheck($2.line, $$.type))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck($2.line, *$2.string, $$.type))
|
||||
if (context->nonInitConstErrorCheck($2.line, *$2.string, $$.type, false))
|
||||
context->recover();
|
||||
|
||||
$$.type = $1;
|
||||
|
@ -1316,7 +1316,7 @@ single_declaration
|
|||
if (context->structQualifierErrorCheck($2.line, $1))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck($2.line, *$2.string, $1))
|
||||
if (context->nonInitConstErrorCheck($2.line, *$2.string, $1, true))
|
||||
context->recover();
|
||||
|
||||
$$.type = $1;
|
||||
|
|
|
@ -807,7 +807,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
|
|||
|
||||
#include "compiler/glslang.h"
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/preprocessor/new/Token.h"
|
||||
#include "compiler/preprocessor/Token.h"
|
||||
#include "compiler/util.h"
|
||||
#include "glslang_tab.h"
|
||||
|
||||
|
@ -2948,146 +2948,13 @@ void yyfree (void * ptr , yyscan_t yyscanner)
|
|||
|
||||
#define YYTABLES_NAME "yytables"
|
||||
|
||||
// Old preprocessor interface.
|
||||
extern "C" {
|
||||
#include "compiler/preprocessor/preprocess.h"
|
||||
|
||||
extern int InitPreprocessor();
|
||||
extern int FinalizePreprocessor();
|
||||
extern void PredefineIntMacro(const char *name, int value);
|
||||
|
||||
#define SETUP_CONTEXT(pp) \
|
||||
TParseContext* context = (TParseContext*) pp->pC; \
|
||||
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
|
||||
|
||||
// Preprocessor callbacks.
|
||||
void CPPDebugLogMsg(const char *msg)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->trace(msg);
|
||||
}
|
||||
|
||||
void CPPWarningToInfoLog(const char *msg)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->warning(yylineno, msg, "");
|
||||
}
|
||||
|
||||
void CPPShInfoLogMsg(const char *msg)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->error(yylineno, msg, "");
|
||||
context->recover();
|
||||
}
|
||||
|
||||
void CPPErrorToInfoLog(const char *msg)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->error(yylineno, msg, "");
|
||||
context->recover();
|
||||
}
|
||||
|
||||
void SetLineNumber(int line)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int string = 0;
|
||||
DecodeSourceLoc(yylineno, &string, NULL);
|
||||
yylineno = EncodeSourceLoc(string, line);
|
||||
}
|
||||
|
||||
void SetStringNumber(int string)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int line = 0;
|
||||
DecodeSourceLoc(yylineno, NULL, &line);
|
||||
yylineno = EncodeSourceLoc(string, line);
|
||||
}
|
||||
|
||||
int GetStringNumber()
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int string = 0;
|
||||
DecodeSourceLoc(yylineno, &string, NULL);
|
||||
return string;
|
||||
}
|
||||
|
||||
int GetLineNumber()
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int line = 0;
|
||||
DecodeSourceLoc(yylineno, NULL, &line);
|
||||
return line;
|
||||
}
|
||||
|
||||
void IncLineNumber()
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int string = 0, line = 0;
|
||||
DecodeSourceLoc(yylineno, &string, &line);
|
||||
yylineno = EncodeSourceLoc(string, ++line);
|
||||
}
|
||||
|
||||
void DecLineNumber()
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
int string = 0, line = 0;
|
||||
DecodeSourceLoc(yylineno, &string, &line);
|
||||
yylineno = EncodeSourceLoc(string, --line);
|
||||
}
|
||||
|
||||
void HandlePragma(const char **tokens, int numTokens)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
|
||||
if (numTokens != 4) return;
|
||||
if (strcmp(tokens[1], "(") != 0) return;
|
||||
if (strcmp(tokens[3], ")") != 0) return;
|
||||
|
||||
context->handlePragmaDirective(yylineno, tokens[0], tokens[2]);
|
||||
}
|
||||
|
||||
void StoreStr(const char *string)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
TString strSrc;
|
||||
strSrc = TString(string);
|
||||
|
||||
context->HashErrMsg = context->HashErrMsg + " " + strSrc;
|
||||
}
|
||||
|
||||
const char* GetStrfromTStr(void)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
cpp->ErrMsg = context->HashErrMsg.c_str();
|
||||
return cpp->ErrMsg;
|
||||
}
|
||||
|
||||
void ResetTString(void)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->HashErrMsg = "";
|
||||
}
|
||||
|
||||
void updateExtensionBehavior(const char* extName, const char* behavior)
|
||||
{
|
||||
SETUP_CONTEXT(cpp);
|
||||
context->handleExtensionDirective(yylineno, extName, behavior);
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
int string_input(char* buf, int max_size, yyscan_t yyscanner) {
|
||||
int len = 0;
|
||||
|
||||
#if ANGLE_USE_NEW_PREPROCESSOR
|
||||
pp::Token token;
|
||||
yyget_extra(yyscanner)->preprocessor.lex(&token);
|
||||
len = token.type == pp::Token::LAST ? 0 : token.text.size();
|
||||
int len = token.type == pp::Token::LAST ? 0 : token.text.size();
|
||||
if ((len > 0) && (len < max_size))
|
||||
memcpy(buf, token.text.c_str(), len);
|
||||
yyset_lineno(EncodeSourceLoc(token.location.file, token.location.line),yyscanner);
|
||||
#else
|
||||
len = yylex_CPP(buf, max_size);
|
||||
#endif // ANGLE_USE_NEW_PREPROCESSOR
|
||||
|
||||
if (len >= max_size)
|
||||
YY_FATAL_ERROR("Input buffer overflow");
|
||||
|
@ -3147,9 +3014,6 @@ int glslang_finalize(TParseContext* context) {
|
|||
context->scanner = NULL;
|
||||
yylex_destroy(scanner);
|
||||
|
||||
#if !ANGLE_USE_NEW_PREPROCESSOR
|
||||
FinalizePreprocessor();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3160,27 +3024,14 @@ int glslang_scan(int count, const char* const string[], const int length[],
|
|||
context->AfterEOF = false;
|
||||
|
||||
// Initialize preprocessor.
|
||||
#if ANGLE_USE_NEW_PREPROCESSOR
|
||||
if (!context->preprocessor.init(count, string, length))
|
||||
return 1;
|
||||
#else
|
||||
if (InitPreprocessor())
|
||||
return 1;
|
||||
cpp->pC = context;
|
||||
cpp->pastFirstStatement = 0;
|
||||
if (InitScannerInput(cpp, count, string, length))
|
||||
return 1;
|
||||
#endif // ANGLE_USE_NEW_PREPROCESSOR
|
||||
|
||||
// Define extension macros.
|
||||
const TExtensionBehavior& extBehavior = context->extensionBehavior();
|
||||
for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
|
||||
iter != extBehavior.end(); ++iter) {
|
||||
#if ANGLE_USE_NEW_PREPROCESSOR
|
||||
context->preprocessor.predefineMacro(iter->first.c_str(), 1);
|
||||
#else
|
||||
PredefineIntMacro(iter->first.c_str(), 1);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3333,7 +3333,7 @@ yyreduce:
|
|||
if (context->structQualifierErrorCheck((yyvsp[(3) - (3)].lex).line, (yyval.interm).type))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(3) - (3)].lex).line, *(yyvsp[(3) - (3)].lex).string, (yyval.interm).type))
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(3) - (3)].lex).line, *(yyvsp[(3) - (3)].lex).string, (yyval.interm).type, false))
|
||||
context->recover();
|
||||
|
||||
TVariable* variable = 0;
|
||||
|
@ -3350,7 +3350,7 @@ yyreduce:
|
|||
if (context->structQualifierErrorCheck((yyvsp[(3) - (5)].lex).line, (yyvsp[(1) - (5)].interm).type))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(3) - (5)].lex).line, *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type))
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(3) - (5)].lex).line, *(yyvsp[(3) - (5)].lex).string, (yyvsp[(1) - (5)].interm).type, true))
|
||||
context->recover();
|
||||
|
||||
(yyval.interm) = (yyvsp[(1) - (5)].interm);
|
||||
|
@ -3372,7 +3372,7 @@ yyreduce:
|
|||
if (context->structQualifierErrorCheck((yyvsp[(3) - (6)].lex).line, (yyvsp[(1) - (6)].interm).type))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(3) - (6)].lex).line, *(yyvsp[(3) - (6)].lex).string, (yyvsp[(1) - (6)].interm).type))
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(3) - (6)].lex).line, *(yyvsp[(3) - (6)].lex).string, (yyvsp[(1) - (6)].interm).type, true))
|
||||
context->recover();
|
||||
|
||||
(yyval.interm) = (yyvsp[(1) - (6)].interm);
|
||||
|
@ -3435,7 +3435,7 @@ yyreduce:
|
|||
if (context->structQualifierErrorCheck((yyvsp[(2) - (2)].lex).line, (yyval.interm).type))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(2) - (2)].lex).line, *(yyvsp[(2) - (2)].lex).string, (yyval.interm).type))
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(2) - (2)].lex).line, *(yyvsp[(2) - (2)].lex).string, (yyval.interm).type, false))
|
||||
context->recover();
|
||||
|
||||
(yyval.interm).type = (yyvsp[(1) - (2)].interm.type);
|
||||
|
@ -3474,7 +3474,7 @@ yyreduce:
|
|||
if (context->structQualifierErrorCheck((yyvsp[(2) - (5)].lex).line, (yyvsp[(1) - (5)].interm.type)))
|
||||
context->recover();
|
||||
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(2) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string, (yyvsp[(1) - (5)].interm.type)))
|
||||
if (context->nonInitConstErrorCheck((yyvsp[(2) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string, (yyvsp[(1) - (5)].interm.type), true))
|
||||
context->recover();
|
||||
|
||||
(yyval.interm).type = (yyvsp[(1) - (5)].interm.type);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#ifndef __INTERMEDIATE_H
|
||||
#define __INTERMEDIATE_H
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/Common.h"
|
||||
#include "compiler/Types.h"
|
||||
#include "compiler/ConstantUnion.h"
|
||||
|
@ -545,6 +547,10 @@ public:
|
|||
void incrementDepth() {depth++;}
|
||||
void decrementDepth() {depth--;}
|
||||
|
||||
// Return the original name if hash function pointer is NULL;
|
||||
// otherwise return the hashed name.
|
||||
static TString hash(const TString& name, ShHashFunction64 hashFunction);
|
||||
|
||||
const bool preVisit;
|
||||
const bool inVisit;
|
||||
const bool postVisit;
|
||||
|
|
|
@ -24,9 +24,7 @@
|
|||
#error Unsupported platform.
|
||||
#endif
|
||||
|
||||
#if defined(ANGLE_USE_NSPR)
|
||||
#include "prthread.h"
|
||||
#elif defined(ANGLE_OS_WIN)
|
||||
#if defined(ANGLE_OS_WIN)
|
||||
#define STRICT
|
||||
#define VC_EXTRALEAN 1
|
||||
#include <windows.h>
|
||||
|
@ -34,24 +32,21 @@
|
|||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#endif // ANGLE_USE_NSPR
|
||||
#endif // ANGLE_OS_WIN
|
||||
|
||||
|
||||
#include "compiler/compilerdebug.h"
|
||||
#include "compiler/compiler_debug.h"
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
#if defined(ANGLE_USE_NSPR)
|
||||
typedef unsigned OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
||||
#elif defined(ANGLE_OS_WIN)
|
||||
#if defined(ANGLE_OS_WIN)
|
||||
typedef DWORD OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES)
|
||||
#elif defined(ANGLE_OS_POSIX)
|
||||
typedef unsigned int OS_TLSIndex;
|
||||
#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
||||
#endif // ANGLE_USE_NSPR
|
||||
#endif // ANGLE_OS_WIN
|
||||
|
||||
OS_TLSIndex OS_AllocTLSIndex();
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
||||
|
@ -60,9 +55,7 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
|||
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||
{
|
||||
ASSERT(nIndex != OS_INVALID_TLS_INDEX);
|
||||
#if defined(ANGLE_USE_NSPR)
|
||||
return PR_GetThreadPrivate(nIndex);
|
||||
#elif defined(ANGLE_OS_WIN)
|
||||
#if defined(ANGLE_OS_WIN)
|
||||
return TlsGetValue(nIndex);
|
||||
#elif defined(ANGLE_OS_POSIX)
|
||||
return pthread_getspecific(nIndex);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
//
|
||||
// This file contains the nspr specific functions
|
||||
//
|
||||
#include "compiler/osinclude.h"
|
||||
|
||||
//
|
||||
// Thread Local Storage Operations
|
||||
//
|
||||
OS_TLSIndex OS_AllocTLSIndex()
|
||||
{
|
||||
unsigned index;
|
||||
PRStatus status = PR_NewThreadPrivateIndex(&index, NULL);
|
||||
|
||||
if (status) {
|
||||
assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
|
||||
return OS_INVALID_TLS_INDEX;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
|
||||
{
|
||||
if (nIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
||||
return false;
|
||||
}
|
||||
|
||||
return PR_SetThreadPrivate(nIndex, lpvValue) == 0;
|
||||
}
|
||||
|
||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
||||
{
|
||||
// Can't delete TLS keys with nspr
|
||||
return true;
|
||||
}
|
||||
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче