[shaderz] r27 committed - * Brought back support for shader parsing from the old code

0 views
Skip to first unread message

sha...@googlecode.com

unread,
Sep 5, 2010, 7:16:26 PM9/5/10
to shade...@googlegroups.com
Revision: 27
Author: vijay.michaeljoseph
Date: Sun Sep 5 16:15:41 2010
Log: * Brought back support for shader parsing from the old code
http://code.google.com/p/shaderz/source/detail?r=27

Added:
/trunk/include/shshaderinfo.h
/trunk/src/shshaderinfo.cpp
Modified:
/trunk/include/qt/qtmainwindow.h
/trunk/shaderz.xcodeproj/project.pbxproj
/trunk/shaderz.xcodeproj/vijayjoseph.mode1v3
/trunk/shaderz.xcodeproj/vijayjoseph.pbxuser
/trunk/src/qt/qtmainwindow.cpp

=======================================
--- /dev/null
+++ /trunk/include/shshaderinfo.h Sun Sep 5 16:15:41 2010
@@ -0,0 +1,106 @@
+#ifndef SHSHADERINFO_H
+#define SHSHADERINFO_H
+
+#include "shdefs.h"
+#include <CG/cg.h>
+#include <CG/cggl.h>
+#include <vector>
+#include <string>
+
+namespace Shaderz
+{
+ typedef enum
+ {
+ SH_PARAMETERCLASS_UNKNOWN = 0,
+ SH_PARAMETERCLASS_SCALAR,
+ SH_PARAMETERCLASS_VECTOR,
+ SH_PARAMETERCLASS_MATRIX,
+ SH_PARAMETERCLASS_STRUCT,
+ SH_PARAMETERCLASS_ARRAY,
+ SH_PARAMETERCLASS_SAMPLER,
+ SH_PARAMETERCLASS_OBJECT,
+
+ SH_PARAMETERCLASS_MAX
+ } shParameterClass;
+
+ typedef enum
+ {
+ SH_PARAMETERTYPE_UNKNOWN = 0,
+ SH_PARAMETERTYPE_HALF,
+ SH_PARAMETERTYPE_INT,
+ SH_PARAMETERTYPE_FLOAT,
+ SH_PARAMETERTYPE_BOOL,
+ SH_PARAMETERTYPE_SAMPLER1D,
+ SH_PARAMETERTYPE_SAMPLER2D,
+ SH_PARAMETERTYPE_SAMPLER3D,
+ SH_PARAMETERTYPE_SAMPLERRECT,
+ SH_PARAMETERTYPE_SAMPLERCUBE,
+
+ SH_PARAMETERTYPE_MAX
+ } shParameterType;
+
+ /**
+ * Base class for shader program information.
+ */
+ class shShaderInfo
+ {
+ public:
+ struct shShaderParameter
+ {
+ std::string name; // name of the parameter as it exists
in the shader
+ shParameterClass paramClass; // the class this
parameter belongs to
+ shParameterType paramType; // the type this
parameter belongs to
+ int rows; // the number of
rows (default=1 for all, >1 for matrix/vectors)
+ int columns; // the number of
columns for this parameter
+ std::vector<shShaderParameter> memberList; // the members
(iff this is a struct)
+ };
+
+ public:
+ shShaderInfo();
+ shShaderInfo(const std::string sShaderFile);
+ virtual ~shShaderInfo(){}
+
+ void setFile(const std::string sShaderFile);
+ virtual bool parseShader(void);
+ virtual int getParameterNum() const { return m_parameterList.size(); }
+ virtual const shShaderParameter* getParameter(int paramIndex) const {
return paramIndex < m_parameterList.size() ? &m_parameterList[paramIndex] :
0; }
+ virtual const std::vector<shShaderParameter>& getParameters()
const { return m_parameterList; }
+ virtual void dumpParameterInfo(std::vector<shShaderParameter>*
pInParameterList = 0, int indentLevel=0);
+
+ protected:
+ virtual void initShaderInfo();
+
+ protected:
+ std::string m_sShaderFile;
+ std::vector<shShaderParameter> m_parameterList;
+ };
+
+ /**
+ * ShaderInfo implementation for shaders writen in CG
+ */
+ class shShaderInfoCG : public shShaderInfo
+ {
+ public:
+ shShaderInfoCG();
+ shShaderInfoCG(std::string sShaderFile);
+ virtual ~shShaderInfoCG(){}
+ virtual bool parseShader(void);
+
+ protected:
+ virtual void initShaderInfo();
+ virtual void collectParameterInfo( CGparameter currentParam,
std::vector<shShaderParameter>& paramRoot );
+ virtual bool getParameterInfo( const CGparameter& currentParam,
shShaderParameter& paramInfo ) const;
+ virtual shParameterClass translateCGParamClass( const
CGparameterclass& cgParamClass ) const;
+ virtual shParameterType translateCGParamType( const CGtype&
cgParamType ) const;
+ virtual bool getParamSizeInfo( const CGparameter& cgParam, int&
columns, int& rows ) const;
+
+ protected:
+ CGprogram m_ShaderHandle;
+ CGcontext m_Context;
+ CGprofile m_VertexProfile;
+
+ private:
+ typedef shShaderInfo ParentClass;
+ };
+}
+#endif // SHSHADERINFO_H
=======================================
--- /dev/null
+++ /trunk/src/shshaderinfo.cpp Sun Sep 5 16:15:41 2010
@@ -0,0 +1,200 @@
+#include "shshaderinfo.h"
+#include "shlogger.h"
+
+using namespace Shaderz;
+
+shShaderInfo::shShaderInfo()
+{
+}
+
+shShaderInfo::shShaderInfo(const std::string sShaderFile)
+{
+ setFile(sShaderFile);
+}
+
+void shShaderInfo::setFile(const std::string sShaderFile)
+{
+ m_sShaderFile = sShaderFile;
+}
+
+bool shShaderInfo::parseShader(void)
+{
+ return false;
+}
+
+void shShaderInfo::initShaderInfo()
+{
+ // nothing to be done here
+}
+
+void shShaderInfo::dumpParameterInfo(std::vector<shShaderParameter>*
pInParameterList, int indentLevel)
+{
+ unsigned int index;
+ std::vector<shShaderParameter> parameterRoot = pInParameterList ?
*pInParameterList : m_parameterList;
+ for( index=0; index < parameterRoot.size(); ++index )
+ {
+ for( int indentIndex=0; indentIndex<indentLevel; ++indentIndex )
LOG<<"\t";
+ LOG<<parameterRoot[index].name<<" ";
+ LOG<<"Class="<<parameterRoot[index].paramClass<<" ";
+ LOG<<"Type="<<parameterRoot[index].paramType<<" ";
+ LOG<<"Size="<<parameterRoot[index].columns<<"
x "<<parameterRoot[index].rows;
+ if( SH_PARAMETERCLASS_STRUCT == parameterRoot[index].paramClass )
+ {
+ LOG<<"\n";
+ dumpParameterInfo( &parameterRoot[index].memberList,
indentLevel+1 );
+ }
+ LOG<<"\n";
+ }
+}
+
+
+//////
+// shShaderInfoCG
+/////
+shShaderInfoCG::shShaderInfoCG()
+ : ParentClass()
+{
+ initShaderInfo();
+}
+
+shShaderInfoCG::shShaderInfoCG(std::string sShaderFile)
+ : ParentClass(sShaderFile)
+{
+ initShaderInfo();
+ parseShader();
+}
+
+bool shShaderInfoCG::parseShader(void)
+{
+ ParentClass::parseShader();
+
+ LOG<<"Parsing shader: "<<m_sShaderFile<<"\nContext="<<m_Context<<"\n";
+ m_ShaderHandle = cgCreateProgramFromFile( m_Context, CG_SOURCE,
m_sShaderFile.c_str(), m_VertexProfile, "main", 0 );
+ if( m_ShaderHandle == 0 )
+ {
+ LOG<<"Failed to create program handle.\n";
+ CGerror err = cgGetError();
+ LOG<<"CgErr = "<<cgGetErrorString(err)<<"\n";
+ return false;
+ }
+ // search for Global and Program parameters
+ CGenum query[] = { CG_GLOBAL, CG_PROGRAM };
+ for( unsigned int i=0; i<sizeof(query)/sizeof(query[0]); ++i )
+ {
+ CGparameter pParam = cgGetFirstParameter( m_ShaderHandle,
query[i] );
+ collectParameterInfo( pParam, m_parameterList );
+ }
+
+ return true;
+}
+
+void shShaderInfoCG::collectParameterInfo( CGparameter currentParam,
std::vector<shShaderParameter>& paramRoot )
+{
+ while(currentParam)
+ {
+ struct shShaderParameter paramInfo;
+ getParameterInfo( currentParam, paramInfo );
+ if( SH_PARAMETERCLASS_STRUCT == paramInfo.paramClass )
+ {
+ CGparameter structParam =
cgGetFirstStructParameter(currentParam);
+ collectParameterInfo(structParam, paramInfo.memberList);
+ }
+ paramRoot.push_back(paramInfo);
+ currentParam = cgGetNextParameter( currentParam );
+ }
+}
+
+shParameterClass shShaderInfoCG::translateCGParamClass( const
CGparameterclass& cgParamClass ) const
+{
+ switch(cgParamClass)
+ {
+ case CG_PARAMETERCLASS_SCALAR: return SH_PARAMETERCLASS_SCALAR;
+ case CG_PARAMETERCLASS_VECTOR: return SH_PARAMETERCLASS_VECTOR;
+ case CG_PARAMETERCLASS_MATRIX: return SH_PARAMETERCLASS_MATRIX;
+ case CG_PARAMETERCLASS_STRUCT: return SH_PARAMETERCLASS_STRUCT;
+ case CG_PARAMETERCLASS_ARRAY: return SH_PARAMETERCLASS_ARRAY;
+ case CG_PARAMETERCLASS_SAMPLER: return SH_PARAMETERCLASS_SAMPLER;
+ case CG_PARAMETERCLASS_OBJECT: return SH_PARAMETERCLASS_OBJECT;
+ case CG_PARAMETERCLASS_UNKNOWN:
+ case CG_PARAMETERCLASS_MAX:
+ default: return SH_PARAMETERCLASS_UNKNOWN;
+ }
+
+ return SH_PARAMETERCLASS_UNKNOWN;
+}
+
+shParameterType shShaderInfoCG::translateCGParamType( const CGtype&
cgParamType ) const
+{
+ switch(cgParamType)
+ {
+ case CG_HALF: return SH_PARAMETERTYPE_HALF;
+ case CG_INT: return SH_PARAMETERTYPE_INT;
+ case CG_FLOAT: return SH_PARAMETERTYPE_FLOAT;
+ case CG_BOOL: return SH_PARAMETERTYPE_BOOL;
+ case CG_SAMPLER1D: return SH_PARAMETERTYPE_SAMPLER1D;
+ case CG_SAMPLER2D: return SH_PARAMETERTYPE_SAMPLER2D;
+ case CG_SAMPLER3D: return SH_PARAMETERTYPE_SAMPLER3D;
+ case CG_SAMPLERRECT: return SH_PARAMETERTYPE_SAMPLERRECT;
+ case CG_SAMPLERCUBE: return SH_PARAMETERTYPE_SAMPLERCUBE;
+ default: return SH_PARAMETERTYPE_UNKNOWN;
+ }
+
+ return SH_PARAMETERTYPE_UNKNOWN;
+}
+
+bool shShaderInfoCG::getParamSizeInfo( const CGparameter& cgParam, int&
columns, int& rows ) const
+{
+ // create the initial mapping for type and size of parameters
+ struct cgParamTypeSizeMapping
+ {
+ CGtype _type;
+ int _col;
+ int _rows;
+ };
+
+#define CG_DATATYPE_MACRO(name, compiler_name, enum_name, base_name,
ncols, nrows, pc) \
+ {enum_name, ncols, nrows},
+
+ cgParamTypeSizeMapping map[] = {
+#include <CG/cg_datatypes.h>
+ };
+#undef CG_DATATYPE_MACRO
+
+ CGtype paramType = cgGetParameterType(cgParam);
+ unsigned int mapIndex;
+ for( mapIndex=0; mapIndex < sizeof(map)/sizeof(map[0]); ++mapIndex )
+ {
+ if( paramType == map[mapIndex]._type )
+ {
+ columns = map[mapIndex]._col;
+ rows = map[mapIndex]._rows;
+ break;
+ }
+ }
+
+ return true;
+}
+
+void shShaderInfoCG::initShaderInfo()
+{
+ m_Context = cgCreateContext();
+ if( m_Context == 0 )
+ {
+ LOG<<"Failed to create context.\n";
+ }
+
+ m_VertexProfile = cgGLGetLatestProfile( CG_GL_VERTEX );
+ if( m_VertexProfile == CG_PROFILE_UNKNOWN )
+ {
+ LOG<<"Failed to get profile.\n";
+ }
+}
+
+bool shShaderInfoCG::getParameterInfo( const CGparameter& currentParam,
shShaderParameter& paramInfo ) const
+{
+ paramInfo.name = cgGetParameterName(currentParam);
+ paramInfo.paramClass = translateCGParamClass(
cgGetParameterClass(currentParam) );
+ paramInfo.paramType =
translateCGParamType(cgGetParameterBaseType(currentParam));
+ getParamSizeInfo( currentParam, paramInfo.columns, paramInfo.rows );
+ return true;
+}
=======================================
--- /trunk/include/qt/qtmainwindow.h Sun Sep 5 01:15:27 2010
+++ /trunk/include/qt/qtmainwindow.h Sun Sep 5 16:15:41 2010
@@ -24,8 +24,10 @@

public slots:
void OnClickedBrowse();
+ void OnClickedShaderInfo();

protected:
+ QLayout* mShaderLayout;

private:
typedef QDialog ParentClass;
=======================================
--- /trunk/shaderz.xcodeproj/project.pbxproj Sun Sep 5 01:15:27 2010
+++ /trunk/shaderz.xcodeproj/project.pbxproj Sun Sep 5 16:15:41 2010
@@ -7,6 +7,9 @@
objects = {

/* Begin PBXFileReference section */
+ 497754BC1234571000F4DCE4 /* osgnvcg1.cg */ = {isa = PBXFileReference;
fileEncoding = 4; lastKnownFileType = text; name = osgnvcg1.cg; path =
data/osgnvcg1.cg; sourceTree = "<group>"; };
+ 49C717A81233984000171C0E /* shshaderinfo.h */ = {isa = PBXFileReference;
fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
shshaderinfo.h; sourceTree = "<group>"; };
+ 49C717A91233986000171C0E /* shshaderinfo.cpp */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp;
path = shshaderinfo.cpp; sourceTree = "<group>"; };
49C7DC811232ACD900E24C8D /* CMakeLists.txt */ = {isa = PBXFileReference;
fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt;
sourceTree = "<group>"; };
49C7DC881232AFB600E24C8D /* osgadapterwidget.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = osgadapterwidget.h; sourceTree = "<group>"; };
49C7DC891232AFB600E24C8D /* qtmainwindow.h */ = {isa = PBXFileReference;
fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
qtmainwindow.h; sourceTree = "<group>"; };
@@ -22,10 +25,19 @@
/* End PBXFileReference section */

/* Begin PBXGroup section */
+ 497754BD1234571600F4DCE4 /* data */ = {
+ isa = PBXGroup;
+ children = (
+ 497754BC1234571000F4DCE4 /* osgnvcg1.cg */,
+ );
+ name = data;
+ sourceTree = "<group>";
+ };
49C7DC641232ABF100E24C8D = {
isa = PBXGroup;
children = (
49C7DC811232ACD900E24C8D /* CMakeLists.txt */,
+ 497754BD1234571600F4DCE4 /* data */,
49C7DC861232AFB600E24C8D /* include */,
49C7DC8C1232AFB600E24C8D /* src */,
49C7DCE51232DB5D00E24C8D /* ReadMe.txt */,
@@ -37,6 +49,7 @@
children = (
49C7DC871232AFB600E24C8D /* qt */,
49C7DC8B1232AFB600E24C8D /* shlogger.h */,
+ 49C717A81233984000171C0E /* shshaderinfo.h */,
49C7DCA81232C9EF00E24C8D /* shdefs.h */,
);
path = include;
@@ -57,6 +70,7 @@
children = (
49C7DC8D1232AFB600E24C8D /* qt */,
49C7DC911232AFB600E24C8D /* shmain.cpp */,
+ 49C717A91233986000171C0E /* shshaderinfo.cpp */,
49C7DC921232AFB600E24C8D /* shlogger.cpp */,
);
path = src;
=======================================
--- /trunk/shaderz.xcodeproj/vijayjoseph.mode1v3 Sun Sep 5 01:15:27 2010
+++ /trunk/shaderz.xcodeproj/vijayjoseph.mode1v3 Sun Sep 5 16:15:41 2010
@@ -197,7 +197,208 @@
<key>Notifications</key>
<array/>
<key>OpenEditors</key>
- <array/>
+ <array>
+ <dict>
+ <key>Content</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754C11234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>osgnvcg1.cg</string>
+ <key>PBXSplitModuleInNavigatorKey</key>
+ <dict>
+ <key>Split0</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754C21234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>osgnvcg1.cg</string>
+ <key>_historyCapacity</key>
+ <integer>0</integer>
+ <key>bookmark</key>
+ <string>497754C31234572800F4DCE4</string>
+ <key>history</key>
+ <array>
+ <string>497754BE1234572000F4DCE4</string>
+ </array>
+ </dict>
+ <key>SplitCount</key>
+ <string>1</string>
+ </dict>
+ <key>StatusBarVisibility</key>
+ <true/>
+ </dict>
+ <key>Geometry</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 20}, {802, 677}}</string>
+ <key>PBXModuleWindowStatusBarHidden2</key>
+ <false/>
+ <key>RubberWindowFrame</key>
+ <string>15 55 802 718 0 0 1280 778 </string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Content</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754C41234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>shshaderinfo.h</string>
+ <key>PBXSplitModuleInNavigatorKey</key>
+ <dict>
+ <key>Split0</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754C51234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>shshaderinfo.h</string>
+ <key>_historyCapacity</key>
+ <integer>0</integer>
+ <key>bookmark</key>
+ <string>497754C71234572800F4DCE4</string>
+ <key>history</key>
+ <array>
+ <string>497754C61234572800F4DCE4</string>
+ </array>
+ </dict>
+ <key>SplitCount</key>
+ <string>1</string>
+ </dict>
+ <key>StatusBarVisibility</key>
+ <true/>
+ </dict>
+ <key>Geometry</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 20}, {802, 677}}</string>
+ <key>PBXModuleWindowStatusBarHidden2</key>
+ <false/>
+ <key>RubberWindowFrame</key>
+ <string>15 55 802 718 0 0 1280 778 </string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Content</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754C81234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>qtmainwindow.cpp</string>
+ <key>PBXSplitModuleInNavigatorKey</key>
+ <dict>
+ <key>Split0</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754C91234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>qtmainwindow.cpp</string>
+ <key>_historyCapacity</key>
+ <integer>0</integer>
+ <key>bookmark</key>
+ <string>497754CB1234572800F4DCE4</string>
+ <key>history</key>
+ <array>
+ <string>497754CA1234572800F4DCE4</string>
+ </array>
+ </dict>
+ <key>SplitCount</key>
+ <string>1</string>
+ </dict>
+ <key>StatusBarVisibility</key>
+ <true/>
+ </dict>
+ <key>Geometry</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 20}, {802, 677}}</string>
+ <key>PBXModuleWindowStatusBarHidden2</key>
+ <false/>
+ <key>RubberWindowFrame</key>
+ <string>15 55 802 718 0 0 1280 778 </string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Content</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754CC1234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>shshaderinfo.cpp</string>
+ <key>PBXSplitModuleInNavigatorKey</key>
+ <dict>
+ <key>Split0</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754CD1234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>shshaderinfo.cpp</string>
+ <key>_historyCapacity</key>
+ <integer>0</integer>
+ <key>bookmark</key>
+ <string>497754CE1234572800F4DCE4</string>
+ <key>history</key>
+ <array>
+ <string>497754B112344C6600F4DCE4</string>
+ </array>
+ </dict>
+ <key>SplitCount</key>
+ <string>1</string>
+ </dict>
+ <key>StatusBarVisibility</key>
+ <true/>
+ </dict>
+ <key>Geometry</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 20}, {802, 677}}</string>
+ <key>PBXModuleWindowStatusBarHidden2</key>
+ <false/>
+ <key>RubberWindowFrame</key>
+ <string>15 55 802 718 0 0 1280 778 </string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Content</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754CF1234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>qtmainwindow.h</string>
+ <key>PBXSplitModuleInNavigatorKey</key>
+ <dict>
+ <key>Split0</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>497754D01234572800F4DCE4</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>qtmainwindow.h</string>
+ <key>_historyCapacity</key>
+ <integer>0</integer>
+ <key>bookmark</key>
+ <string>497754D11234572800F4DCE4</string>
+ <key>history</key>
+ <array>
+ <string>497754AD12344A3D00F4DCE4</string>
+ </array>
+ </dict>
+ <key>SplitCount</key>
+ <string>1</string>
+ </dict>
+ <key>StatusBarVisibility</key>
+ <true/>
+ </dict>
+ <key>Geometry</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 20}, {802, 677}}</string>
+ <key>PBXModuleWindowStatusBarHidden2</key>
+ <false/>
+ <key>RubberWindowFrame</key>
+ <string>15 55 802 718 0 0 1280 778 </string>
+ </dict>
+ </dict>
+ </array>
<key>PerspectiveWidths</key>
<array>
<integer>-1</integer>
@@ -269,18 +470,14 @@
<key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key>
<array>
<string>49C7DC641232ABF100E24C8D</string>
- <string>49C7DC861232AFB600E24C8D</string>
- <string>49C7DC871232AFB600E24C8D</string>
- <string>49C7DC8C1232AFB600E24C8D</string>
- <string>49C7DC8D1232AFB600E24C8D</string>
+ <string>497754BD1234571600F4DCE4</string>
<string>1C37FABC05509CD000000102</string>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
- <integer>12</integer>
- <integer>10</integer>
- <integer>9</integer>
+ <integer>3</integer>
+ <integer>2</integer>
<integer>0</integer>
</array>
</array>
@@ -385,9 +582,9 @@
</array>
<key>TableOfContents</key>
<array>
- <string>49C7DC6E1232ABF600E24C8D</string>
+ <string>497754BF1234572800F4DCE4</string>
<string>1CE0B1FE06471DED0097A5F4</string>
- <string>49C7DC6F1232ABF600E24C8D</string>
+ <string>497754C01234572800F4DCE4</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
@@ -521,7 +718,12 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
+ <string>497754CF1234572800F4DCE4</string>
+ <string>497754CC1234572800F4DCE4</string>
+ <string>497754C81234572800F4DCE4</string>
+ <string>497754C41234572800F4DCE4</string>
<string>/Users/vijayjoseph/projects/shaderz/shaderz.xcodeproj</string>
+ <string>497754C11234572800F4DCE4</string>
</array>
<key>WindowString</key>
<string>797 328 690 397 0 0 1280 778 </string>
=======================================
--- /trunk/shaderz.xcodeproj/vijayjoseph.pbxuser Sun Sep 5 01:15:27 2010
+++ /trunk/shaderz.xcodeproj/vijayjoseph.pbxuser Sun Sep 5 16:15:41 2010
@@ -1,5 +1,111 @@
// !$*UTF8*$!
{
+ 497754AD12344A3D00F4DCE4 /* PBXBookmark */ = {
+ isa = PBXBookmark;
+ fRef = 49C7DC891232AFB600E24C8D /* qtmainwindow.h */;
+ };
+ 497754B112344C6600F4DCE4 /* PBXBookmark */ = {
+ isa = PBXBookmark;
+ fRef = 49C717A91233986000171C0E /* shshaderinfo.cpp */;
+ };
+ 497754BC1234571000F4DCE4 /* osgnvcg1.cg */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {743, 1056}}";
+ sepNavSelRange = "{0, 0}";
+ sepNavVisRange = "{63, 1008}";
+ sepNavWindowFrame = "{{15, -1}, {802, 774}}";
+ };
+ };
+ 497754BE1234572000F4DCE4 /* PBXBookmark */ = {
+ isa = PBXBookmark;
+ fRef = 497754BC1234571000F4DCE4 /* osgnvcg1.cg */;
+ };
+ 497754C31234572800F4DCE4 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 497754BC1234571000F4DCE4 /* osgnvcg1.cg */;
+ name = "osgnvcg1.cg: 1";
+ rLen = 0;
+ rLoc = 0;
+ rType = 0;
+ vrLen = 1008;
+ vrLoc = 63;
+ };
+ 497754C61234572800F4DCE4 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 49C717A81233984000171C0E /* shshaderinfo.h */;
+ name = "shshaderinfo.h: 66";
+ rLen = 0;
+ rLoc = 2108;
+ rType = 0;
+ vrLen = 1727;
+ vrLoc = 1001;
+ };
+ 497754C71234572800F4DCE4 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 49C717A81233984000171C0E /* shshaderinfo.h */;
+ name = "shshaderinfo.h: 66";
+ rLen = 0;
+ rLoc = 2137;
+ rType = 0;
+ vrLen = 1718;
+ vrLoc = 1001;
+ };
+ 497754CA1234572800F4DCE4 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 49C7DC8F1232AFB600E24C8D /* qtmainwindow.cpp */;
+ name = "qtmainwindow.cpp: 98";
+ rLen = 0;
+ rLoc = 2535;
+ rType = 0;
+ vrLen = 873;
+ vrLoc = 1647;
+ };
+ 497754CB1234572800F4DCE4 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 49C7DC8F1232AFB600E24C8D /* qtmainwindow.cpp */;
+ name = "qtmainwindow.cpp: 98";
+ rLen = 0;
+ rLoc = 2528;
+ rType = 0;
+ vrLen = 810;
+ vrLoc = 1052;
+ };
+ 497754CE1234572800F4DCE4 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 49C717A91233986000171C0E /* shshaderinfo.cpp */;
+ name = "shshaderinfo.cpp: 30";
+ rLen = 17;
+ rLoc = 445;
+ rType = 0;
+ vrLen = 1187;
+ vrLoc = 74;
+ };
+ 497754D11234572800F4DCE4 /* PBXTextBookmark */ = {
+ isa = PBXTextBookmark;
+ fRef = 49C7DC891232AFB600E24C8D /* qtmainwindow.h */;
+ name = "qtmainwindow.h: 30";
+ rLen = 13;
+ rLoc = 461;
+ rType = 0;
+ vrLen = 530;
+ vrLoc = 0;
+ };
+ 49C717A81233984000171C0E /* shshaderinfo.h */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {1121, 1808}}";
+ sepNavSelRange = "{77, 2}";
+ sepNavVisRange = "{0, 942}";
+ sepNavWindowFrame = "{{15, -1}, {802, 774}}";
+ };
+ };
+ 49C717A91233986000171C0E /* shshaderinfo.cpp */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {876, 3200}}";
+ sepNavSelRange = "{0, 26}";
+ sepNavVisRange = "{0, 1136}";
+ sepNavWindowFrame = "{{15, -1}, {802, 774}}";
+ };
+ };
49C7DC661232ABF100E24C8D /* Project object */ = {
activeArchitecture = i386;
activeBuildConfigurationName = Debug;
@@ -16,7 +122,7 @@
20,
243,
20,
- 48.16259765625,
+ 48,
43,
43,
20,
@@ -31,8 +137,20 @@
PBXFileDataSource_Target_ColumnID,
);
};
- PBXPerProjectTemplateStateSaveDate = 305310706;
- PBXWorkspaceStateSaveDate = 305310706;
+ PBXPerProjectTemplateStateSaveDate = 305416604;
+ PBXWorkspaceStateSaveDate = 305416604;
+ };
+ perUserProjectItems = {
+ 497754AD12344A3D00F4DCE4 /* PBXBookmark */ = 497754AD12344A3D00F4DCE4
/* PBXBookmark */;
+ 497754B112344C6600F4DCE4 /* PBXBookmark */ = 497754B112344C6600F4DCE4
/* PBXBookmark */;
+ 497754BE1234572000F4DCE4 /* PBXBookmark */ = 497754BE1234572000F4DCE4
/* PBXBookmark */;
+ 497754C31234572800F4DCE4 /* PBXTextBookmark */ =
497754C31234572800F4DCE4 /* PBXTextBookmark */;
+ 497754C61234572800F4DCE4 /* PBXTextBookmark */ =
497754C61234572800F4DCE4 /* PBXTextBookmark */;
+ 497754C71234572800F4DCE4 /* PBXTextBookmark */ =
497754C71234572800F4DCE4 /* PBXTextBookmark */;
+ 497754CA1234572800F4DCE4 /* PBXTextBookmark */ =
497754CA1234572800F4DCE4 /* PBXTextBookmark */;
+ 497754CB1234572800F4DCE4 /* PBXTextBookmark */ =
497754CB1234572800F4DCE4 /* PBXTextBookmark */;
+ 497754CE1234572800F4DCE4 /* PBXTextBookmark */ =
497754CE1234572800F4DCE4 /* PBXTextBookmark */;
+ 497754D11234572800F4DCE4 /* PBXTextBookmark */ =
497754D11234572800F4DCE4 /* PBXTextBookmark */;
};
sourceControlManager = 49C7DC6A1232ABF100E24C8D /* Source Control */;
userBuildSettings = {
@@ -51,9 +169,9 @@
};
49C7DC811232ACD900E24C8D /* CMakeLists.txt */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {988, 1840}}";
- sepNavSelRange = "{2901, 40}";
- sepNavVisRange = "{3080, 851}";
+ sepNavIntBoundsRect = "{{0, 0}, {988, 1856}}";
+ sepNavSelRange = "{2624, 0}";
+ sepNavVisRange = "{1184, 2086}";
sepNavWindowFrame = "{{15, -1}, {802, 774}}";
};
};
@@ -68,8 +186,8 @@
49C7DC891232AFB600E24C8D /* qtmainwindow.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {743, 646}}";
- sepNavSelRange = "{386, 15}";
- sepNavVisRange = "{0, 474}";
+ sepNavSelRange = "{461, 13}";
+ sepNavVisRange = "{0, 530}";
sepNavWindowFrame = "{{15, -1}, {802, 774}}";
};
};
@@ -99,9 +217,9 @@
};
49C7DC8F1232AFB600E24C8D /* qtmainwindow.cpp */ = {
uiCtxt = {
- sepNavIntBoundsRect = "{{0, 0}, {743, 912}}";
- sepNavSelRange = "{687, 0}";
- sepNavVisRange = "{161, 911}";
+ sepNavIntBoundsRect = "{{0, 0}, {750, 1616}}";
+ sepNavSelRange = "{2528, 0}";
+ sepNavVisRange = "{1052, 810}";
sepNavWindowFrame = "{{15, -1}, {802, 774}}";
};
};
=======================================
--- /trunk/src/qt/qtmainwindow.cpp Sun Sep 5 01:15:27 2010
+++ /trunk/src/qt/qtmainwindow.cpp Sun Sep 5 16:15:41 2010
@@ -5,8 +5,11 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
+#include <QLabel>
+#include <QGroupBox>
#include "qt/qtshaderzviewwidget.h"
#include "shlogger.h"
+#include "shshaderinfo.h"

qtMainWindow::qtMainWindow()
: ParentClass(0)
@@ -17,11 +20,37 @@
// put the browse button and viewport in a horizontal line
QHBoxLayout* hLayout = new QHBoxLayout;
{
- // create the browse button
- QPushButton* browseButton = new QPushButton("Browse");
-
- connect( browseButton, SIGNAL(clicked()), this, SLOT(OnClickedBrowse())
);
- hLayout->addWidget(browseButton);
+ // buttons vertical sublayout
+ QVBoxLayout* vLayout = new QVBoxLayout;
+ {
+ // create the browse button
+ QPushButton* browseButton = new QPushButton("Browse");
+ connect( browseButton, SIGNAL(clicked()), this, SLOT(OnClickedBrowse())
);
+ vLayout->addWidget(browseButton);
+
+ // add the shader load button
+ vLayout->addWidget( new QLabel("shaderPath") );
+ QPushButton* shaderInfoBtn = new QPushButton("ShaderInfo");
+ connect( shaderInfoBtn, SIGNAL(clicked()), this,
SLOT(OnClickedShaderInfo()) );
+ vLayout->addWidget(shaderInfoBtn);
+
+ // add the shader info area
+ QGroupBox* shaderInfo = new QGroupBox("Shader Info", this);
+ {
+ QBoxLayout* infoLayout = new QVBoxLayout;
+ if( shaderInfo->layout() )
+ {
+ shaderInfo->layout()->addItem(infoLayout);
+ }
+ else
+ {
+ shaderInfo->setLayout(infoLayout);
+ }
+ mShaderLayout = infoLayout;
+ }
+ vLayout->addWidget(shaderInfo);
+ }
+ hLayout->addItem(vLayout);

// add some spacing
hLayout->addSpacing(10);
@@ -53,3 +82,20 @@
{
LOG<<"Clicked browse button. Put your code changes here.\n";
}
+
+void qtMainWindow::OnClickedShaderInfo()
+{
+ LOG<<"Clicked shader info button.\n";
+ shShaderInfo* shaderInfo = new
shShaderInfoCG("/Users/vijayjoseph/projects/shaderz/data/osgnvcg1.cg");
+ shaderInfo->dumpParameterInfo();
+
+ int paramIndex;
+ for( paramIndex=0; mShaderLayout && paramIndex <
shaderInfo->getParameterNum(); ++paramIndex )
+ {
+ const shShaderInfo::shShaderParameter* shaderParam =
shaderInfo->getParameter(paramIndex);
+ if( shaderParam )
+ {
+ mShaderLayout->addWidget(new QLabel(QString(shaderParam->name.c_str()),
this));
+ }
+ }
+}

Reply all
Reply to author
Forward
0 new messages