Code Search for Developers
 
 
  

program-glsl.h from NeoEngineNG at Krugle


Show program-glsl.h syntax highlighted

/***************************************************************************
              program-glsl.h  -  GLSL vertex/fragment programs
                             -------------------
    begin       : Mon Jan 5 2004
    copyright   : (C) 2004 by Reality Rift Studios
    email       : mattias@realityrift.com
 
  	last modify date	: Mon Sep 20 2004
	last modify			: GLSL manager
	l.m. copyright   	: (C) 2004 by Arcadia Design s.r.l.
    email       		: Dario Deledda (penguindark@hotmail.com)

 ***************************************************************************

 The contents of this file are subject to the Mozilla Public License Version
 1.1 (the "License"); you may not use this file except in compliance with
 the License. You may obtain a copy of the License at 
 http://www.mozilla.org/MPL/

 Software distributed under the License is distributed on an "AS IS" basis,
 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 for the specific language governing rights and limitations under the
 License.

 The Original Code is the NeoEngine, NeoDevOpenGL, shader-arb.h

 The Initial Developer of the Original Code is Mattias Jansson.
 Portions created by Mattias Jansson are Copyright (C) 2004
 Reality Rift Studios. All Rights Reserved.
 
 Contributors: Dario Deledda (penguindark@hotmail.com)

 ***************************************************************************/

#ifndef __NEOGLSHADER_PROGRAMGLSL_H
#define __NEOGLSHADER_PROGRAMGLSL_H


#include "device.h"
#include "shader.h"
#include <neoengine/base.h>
#include <neoengine/pointer.h>
#include <neoengine/loadableentity.h>
#include <neoengine/file.h>
#include <vector>

using namespace std;
namespace NeoOGL
{

struct GLSLattrib{
	/*! Parameter type */
	GLuint	m_eType;
	/*! Attrib shader alias */
	string	m_strName;
	/*! Attrib index in the vertex buffer */
	GLuint	m_uiIndex;
};

/**
  * \brief GLSL program neoengine implementation
  * \author Dario Deledda (penguindark@hotmail.com)
  */
class ProgramGLSL:public Shader
{
	protected:


		/*! Native shader object */
		unsigned int									m_uiShader;

		/*! Shader type enum (vertexshader or fragmentshader) */
		GLenum											m_eType;

		/*! string for vx/fg shader loading */
		string											m_strSource;

		/*! vector of GLSL shader's  vertexbuffer attributes */
		vector<GLSLattrib>								m_AttribVec;
		
		/*! All attrib parameters */
		std::vector< GLSLattrib >						m_vAttrib;

		/*! delete all space form the string */
		void deleteSpace(std::string &inString);

		/*! match the uniform strings */
		bool match_uniform(const std::string& inString);

		/*! match the attrib strings */
		bool match_attrib(const string& inString);

		/*! Overload LoadNode no compile inside */
		bool LoadNode( unsigned int uiFlags );

	public:
		
		/*!vertex and fragment shaders handle */
		vector<GLhandleARB>								m_vhVS,m_vhFS,m_vhGS;

		/*! Geometry shader input type */
		GLenum											m_eGeometryInpType;
		/*! Geometry shader output type */
		GLenum											m_eGeometryOutType;
		/*! Geometry shader output vertex max number */
		GLint											m_iGeometryOutVertex;

		/*!GLSL program handle */
		GLhandleARB										m_hProgram;

		/*!bind all the GLSL uniform variables */
		bool BindParamGLSL(const std::string& inString);

		/*!load all GLSL source file */
		bool LoadSource( string fileName );

		/**
		* \param pkDevice                             Render device
		* \param eType                                Shader type
		* \param rstrName							  Shader name
		* \param pkShaderPool						  Ptr to shader pool
		* \param pkFileManager                        Filemananger, null if default
		*/
		                                              ProgramGLSL( Device *pkDevice, SHADERTYPE eType, const std::string &rstrName, NeoEngine::ShaderPool *pkShaderPool, NeoEngine::FileManager *pkFileManager = 0);

		/**
		* Destruct this instance of the OpenGL vertex shader instance
		*/
		virtual                                      ~ProgramGLSL();

		/**
		* Bild the shader
		* \param pstrSourceV                                 Pointer to source vertex shader string
		* \param pstrSourceF                                 Pointer to source fragment shader string
		* \param pstrSourceG                                 Pointer to source geometry shader string
		* \return                                            True if succesful, false otherwise.
		*/
		virtual bool                                 Build( const std::string *pstrSourceV = 0, 
															const std::string *pstrSourceF = 0,
															const std::string *pstrSourceG = 0);

		/**
		* Compile the pipeline shader, performing OpenGL and target specific operations
		* \param pstrSource                           Source string, null if use already loaded source
		* \return                                     True if compiled, or false
		*/
		virtual bool                                  Compile( const std::string *pstrSource = 0 );

		/**
		* Compile a Fragment shader, performing OpenGL and target specific operations
		* \param pstrSource                           Source string, null if use already loaded source
		* \return                                     True if compiled, or false
		*/
		virtual bool                                  CompileFrag( const std::string *pstrSource = 0 );

		/**
		* Compile a Vertex shader, performing OpenGL and target specific operations
		* \param pstrSource                           Source string, null if use already loaded source
		* \return                                     True if compiled, or false
		*/
		virtual bool                                  CompileVert( const std::string *pstrSource = 0 );
		
		/**
		* Compile a Geometry shader, performing OpenGL and target specific operations
		* \param pstrSource                           Source string, null if use already loaded source
		* \return                                     True if compiled, or false
		*/
		virtual bool								  CompileGeometry( const std::string *pstrSource = 0 );

		/** 
		* Set the Geometry shader input type 
		* \param inType								  Source enum that specify the input type
		* \return                                     Always True 
		*/
		virtual	bool								  SetGeometryInputType( const unsigned int inType )
															{ m_eGeometryInpType=inType; return true; } 
		
		/** 
		* Set the Geometry shader output type 
		* \param inType								  Source enum that specify the output type
		* \return                                     Always True 
		*/
		virtual	bool								  SetGeometryOutputType( const unsigned int inType )
															{ m_eGeometryOutType=inType; return true; } 

		/** 
		* Set the Geometry shader max number of vertex in output 
		* \param inType								  number of output vertex
		* \return                                     Always True 
		*/
		virtual	bool								  SetGeometryVertexOutNum( const unsigned int inNum ) 
															{ m_iGeometryOutVertex=inNum; return true; } 

		/**
		* Link the shader with the program, performing OpenGL and target specific operations
		* \return                                     True if linked, or false
		*/
		virtual bool                                  Link(void);

		/**
		* Clear the shader program, performing OpenGL and target specific operations
		* \return                                     True if cleared, or false
		*/
		virtual bool                                  Clear(void);

		/**
		* Bind this pipeline shader and parameters, performing OpenGL and target specific operations
		* \param pkPrimitive                          Primitive currently processing
		* \return                                     True if bound, or false if error
		*/
		virtual bool                                  Bind( NeoEngine::RenderPrimitive *pkPrimitive );

		/**
		* Disable shader
		* \return                                     True if successful, false if error
		*/
		virtual bool                                  Unbind();

		/**
		* Bind light parameters
		* \param pkPrimitive                          Primitive currently processing
		* \return                                     True if bound, or false if error
		*/
		virtual bool                                  BindLightParams( NeoEngine::RenderPrimitive *pkPrimitive );

		/**
		* \param inMatrix							  The matrix to use for th etexture matrix calculus
		* \return									  True if all ok, or false if error
		*/
		virtual bool								  SetTextureModeMatrix(NeoEngine::Matrix &inMatrix);
};

#ifdef WIN32
#	ifdef _MSC_VER
#		pragma warning( disable : 4786 )
#		if ( _MSC_VER >= 1300 )
		   typedef NeoEngine::Pointer< ProgramGLSL > ProgramGLSLPtr;                                         
    	   EXPIMP_TEMPLATE template class NEOENGINE_API NeoEngine::Pointer< ProgramGLSL >;                   
    	   EXPIMP_TEMPLATE template class NEOENGINE_API std::allocator< NeoEngine::Pointer< ProgramGLSL > >; 
    	   EXPIMP_TEMPLATE template class NEOENGINE_API std::vector< NeoEngine::Pointer< ProgramGLSL > >;    
#		elif defined(_MSC_VER)
    	   typedef NeoEngine::Pointer< ProgramGLSL > ProgramGLSLPtr;                                         
    	   EXPIMP_TEMPLATE template class NEOENGINE_API NeoEngine::Pointer< ProgramGLSL >;                   
    	   EXPIMP_TEMPLATE template class NEOENGINE_API std::vector< NeoEngine::Pointer< ProgramGLSL > >     
#		endif
#	else if defined __MINGW32__
		typedef NeoEngine::Pointer< ProgramGLSL > ProgramGLSLPtr;
#	endif
#else
	typedef NeoEngine::Pointer< ProgramGLSL > ProgramGLSLPtr;
#endif

};

#endif




See more files for this project here

NeoEngineNG

NeoenEngine NG (Next Generation) is the evolution of neoengine one,it\'s a different development from NeoEngine2, it\'s a direct inherits from NeoEngine one.\n

Project homepage: http://sourceforge.net/projects/neoengineng
Programming language(s): C,C++
License: other

  glew/
    bin/
      glew32.dll
      glewinfo.exe
      visualinfo.exe
    doc/
      advanced.html
      basic.html
      credits.html
      glew.css
      glew.html
      glew.png
      glx.txt
      glxew.html
      gpl.txt
      index.html
      install.html
      log.html
      new.png
      ogl_sm.jpg
      sgi.txt
      wglew.html
    include/
      GL/
    lib/
      glew32.lib
      glew32s.lib
  Makefile.am
  SConscript
  base.h
  begin.cpp
  buffermanager.cpp
  buffermanager.h
  bufferregion.cpp
  bufferregion.h
  callback.cpp
  clear.cpp
  close.cpp
  config.cpp
  device.cpp
  device.h
  end.cpp
  execute.cpp
  extensions.cpp
  extensions.h
  flip.cpp
  framebuffertarget.cpp
  framebuffertarget.h
  glext.h
  glue.cpp
  glxext.h
  initialize.cpp
  input.cpp
  light.cpp
  link.h
  mouse.cpp
  neodevopengl-static.dev
  neodevopengl.cbp
  neodevopengl.depend
  neodevopengl.dev
  neodevopengl.dsp
  neodevopengl.layout
  neodevopengl.vcproj
  op.h
  open.cpp
  pixelbuffer.cpp
  pixelbuffer.h
  pixelbuffertarget.cpp
  pixelbuffertarget.h
  polygonbuffer.cpp
  polygonstripbuffer.cpp
  program-glsl.cpp
  program-glsl.h
  projection.cpp
  query.cpp
  render.cpp
  renderqueue.cpp
  renderqueue.h
  rendertarget.cpp
  rendertarget.h
  resize.cpp
  shader.cpp
  shader.h
  shadowmap.cpp
  shadowmap.h
  shutdown.cpp
  statistics.cpp
  statistics.h
  stencilbuffer.cpp
  texture.cpp
  texture.h
  textureunit.cpp
  textureunit.h
  vertexbuffer-glsl.cpp
  vertexbuffer-glsl.h
  vertexbuffer.cpp
  vertexbuffer.h
  vertexbuffermanager-glsl.cpp
  vertexbuffermanager-glsl.h
  vertexbuffermanager-nobs.cpp
  vertexbuffermanager-nobs.h
  vertexbuffermanager.cpp
  vertexbuffermanager.h
  viewport.cpp
  wglext.h
  zbufferstate.cpp
  zbufferstate.h