1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 -----------------------------------------------------------------------------
26 */
27 
28 #include "OgreShaderCGProgramProcessor.h"
29 #include "OgreShaderProgramSet.h"
30 #include "OgreShaderProgram.h"
31 
32 namespace Ogre {
33 namespace RTShader {
34 
35 String CGProgramProcessor::TargetLanguage = "cg";
36 
37 //-----------------------------------------------------------------------------
CGProgramProcessor()38 CGProgramProcessor::CGProgramProcessor()
39 {
40 
41 }
42 
43 //-----------------------------------------------------------------------------
~CGProgramProcessor()44 CGProgramProcessor::~CGProgramProcessor()
45 {
46 
47 }
48 
49 //-----------------------------------------------------------------------------
preCreateGpuPrograms(ProgramSet * programSet)50 bool CGProgramProcessor::preCreateGpuPrograms( ProgramSet* programSet )
51 {
52 	Program* vsProgram = programSet->getCpuVertexProgram();
53 	Program* psProgram = programSet->getCpuFragmentProgram();
54 	Function* vsMain   = vsProgram->getEntryPointFunction();
55 	Function* fsMain   = psProgram->getEntryPointFunction();
56 	bool success;
57 
58 	// Compact vertex shader outputs.
59 	success = ProgramProcessor::compactVsOutputs(vsMain, fsMain);
60 	if (success == false)
61 		return false;
62 
63 	return true;
64 }
65 
66 //-----------------------------------------------------------------------------
postCreateGpuPrograms(ProgramSet * programSet)67 bool CGProgramProcessor::postCreateGpuPrograms( ProgramSet* programSet )
68 {
69 	// Bind vertex shader auto parameters.
70 	bindAutoParameters(programSet->getCpuVertexProgram(), programSet->getGpuVertexProgram());
71 
72 	// Bind fragment shader auto parameters.
73 	bindAutoParameters(programSet->getCpuFragmentProgram(), programSet->getGpuFragmentProgram());
74 
75 	return true;
76 }
77 }
78 }
79