shader_definition.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef RVE_RENDER_SERVER_SHADER_DEFINITION_H
00031 #define RVE_RENDER_SERVER_SHADER_DEFINITION_H
00032 
00033 #include <string>
00034 #include <vector>
00035 
00036 #include <ros/types.h>
00037 
00038 namespace rve_render_server
00039 {
00040 
00041 struct ShaderParameter
00042 {
00043   ShaderParameter()
00044   {}
00045 
00046   ShaderParameter(const std::string& type, const std::string& name, const std::string& semantic)
00047   : type(type)
00048   , name(name)
00049   , semantic(semantic)
00050   {}
00051 
00052   std::string type;
00053   std::string name;
00054   std::string semantic;
00055 };
00056 typedef std::vector<ShaderParameter> V_ShaderParameter;
00057 
00058 struct ShaderUniform
00059 {
00060   ShaderUniform()
00061   {}
00062 
00063   ShaderUniform(const std::string& type, const std::string& name, uint32_t auto_constant_type, uint32_t extra)
00064   : type(type)
00065   , name(name)
00066   , auto_constant_type(auto_constant_type)
00067   , extra(extra)
00068   {}
00069 
00070   std::string type;
00071   std::string name;
00072   uint32_t auto_constant_type;
00073   uint32_t extra;
00074 };
00075 typedef std::vector<ShaderUniform> V_ShaderUniform;
00076 
00077 struct ShaderSampler
00078 {
00079   ShaderSampler()
00080   {}
00081 
00082   ShaderSampler(const std::string& name, uint32_t reg)
00083   : name(name)
00084   , reg(reg)
00085   {
00086   }
00087 
00088   std::string name;
00089   uint32_t reg;
00090 };
00091 typedef std::vector<ShaderSampler> V_ShaderSampler;
00092 
00093 typedef std::vector<std::string> V_string;
00094 
00095 struct ShaderDefinition
00096 {
00097   std::string geom_input;
00098   std::string geom_output;
00099 
00100   V_string includes;
00101   V_ShaderParameter inputs;
00102   V_ShaderParameter outputs;
00103   V_ShaderUniform uniforms;
00104   V_ShaderSampler samplers;
00105 
00106   std::string body;
00107 
00108   void include(const std::string& inc)
00109   {
00110     includes.push_back(inc);
00111   }
00112 
00113   void input(const std::string& type, const std::string& name, const std::string& semantic)
00114   {
00115     inputs.push_back(ShaderParameter(type, name, semantic));
00116   }
00117 
00118   void output(const std::string& type, const std::string& name, const std::string& semantic)
00119   {
00120     outputs.push_back(ShaderParameter(type, name, semantic));
00121   }
00122 
00123   void uniform(const std::string& type, const std::string& name, uint32_t auto_constant_type, uint32_t extra = 0)
00124   {
00125     uniforms.push_back(ShaderUniform(type, name, auto_constant_type, extra));
00126   }
00127 
00128   void sampler(const std::string& name, uint32_t reg)
00129   {
00130     samplers.push_back(ShaderSampler(name, reg));
00131   }
00132 
00133 };
00134 
00135 }
00136 
00137 #endif // RVE_RENDER_SERVER_SHADER_DEFINITION_H
00138 


rve_render_server
Author(s): Josh Faust
autogenerated on Wed Dec 11 2013 14:31:15