arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

PShaderTxt.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     7-15-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 
00019 // PShaderTxt.h
00020 ///  editable text for a shader
00021 /// must be created in conjunction with a "gl" window, needs context
00022 /// to load programs
00023 
00024 #ifndef __PROGRAMMABLE_SHADER_TXT_DOT_H
00025 #define __PROGRAMMABLE_SHADER_TXT_DOT_H
00026 
00027 #include "../errs/ErrTxtWin.h"
00028 #include <qfiledialog.h> 
00029 #include <qwidget.h>
00030 #include <stateGlift.h>
00031 #include <qmultilineedit.h>
00032 #include <qgl.h>
00033 #include <string>
00034 
00035 class PShaderTxt : public QWidget {
00036    Q_OBJECT
00037 public:
00038    PShaderTxt(const QGLContext *ctx, QWidget *parent, const char *name=0, WFlags wf=0);
00039    PShaderTxt(const QGLContext *ctx, glift::ProgShaderSP s, QWidget *parent, const char *name=0, WFlags wf=0);
00040    virtual ~PShaderTxt();
00041 
00042    enum SUPPORTED_SHADERS {
00043       NOT_LOADED,
00044       UNKNOWN,
00045       ARB_FP,
00046       ARB_VP,
00047       SHADER_LAST
00048    };
00049    int getShaderType() const { return _stype; }
00050 
00051    QString getFileName();
00052 
00053 signals:
00054    void initAFP(glift::FragProgARBSP fp);
00055    void initAVP(glift::VertexProgARBSP vp);
00056 
00057 public slots:
00058    void loadShader();
00059    void loadShader(glift::ProgShaderSP shader);
00060    void loadShaderFromFile(const QString &fname);
00061    void loadShaderFromText(const QString &text);
00062    void saveShader(const QString &lastPath);
00063    void saveShaderAs(const QString &lastPath);
00064    void closeShader(const QString &lastPath);
00065 
00066 protected:
00067 
00068     void conf();
00069     /// false for success, true for failure
00070     bool castShader();
00071     /// highlight the error text
00072     int getErrorPos(std::string s);
00073    
00074 
00075     QMultiLineEdit *_mle;
00076 
00077     /// this should always exist
00078     glift::ProgShaderSP    _shader;
00079     /// these depend on the shader loaded
00080     glift::FragProgARBSP   _fpshader;
00081     glift::VertexProgARBSP _vpshader;
00082 
00083     const QGLContext *_ctx;
00084     
00085     ErrTxtWin  *_errw;
00086 
00087     int _stype;
00088 };
00089 
00090 
00091 #endif
00092 

Send questions, comments, and bug reports to:
jmk