48 VL_DEBUG_SET_OBJECT_NAME()
61 GLSLProgState(): mCamera(
NULL), mTransform(
NULL), mGLSLProgUniformSet(
NULL), mShaderUniformSet(
NULL), mActorUniformSet(
NULL) {}
63 bool operator<(
const GLSLProgState& other)
const 65 if ( mCamera != other.mCamera )
66 return mCamera < other.mCamera;
68 if ( mTransform != other.mTransform )
69 return mTransform < other.mTransform;
71 if ( mGLSLProgUniformSet != other.mGLSLProgUniformSet )
72 return mGLSLProgUniformSet < other.mGLSLProgUniformSet;
74 if ( mShaderUniformSet != other.mShaderUniformSet )
75 return mShaderUniformSet < other.mShaderUniformSet;
77 return mActorUniformSet < other.mActorUniformSet;
92 std::map<const GLSLProgram*, GLSLProgState> glslprogram_map;
112 for(
int itok=0; itok < render_queue->
size(); ++itok)
130 if (cur_scissor != scissor)
132 cur_scissor = scissor;
140 VL_CHECK(glIsEnabled(GL_SCISSOR_TEST))
146 for(
int ipass=0; tok !=
NULL; tok = tok->
mNextPass, ++ipass )
162 shader = eom_it->second.get();
186 if (glGetError() != GL_NO_ERROR)
188 Log::error(
"An unsupported OpenGL glEnable/glDisable capability has been enabled!\n");
219 cur_glsl_prog_uniform_set = cur_glsl_program->
getUniformSet();
228 bool update_cm =
false;
229 bool update_tr =
false;
230 bool update_pu =
false;
231 bool update_su =
false;
232 bool update_au =
false;
233 GLSLProgState* glsl_state =
NULL;
236 std::map<const GLSLProgram*, GLSLProgState>::iterator glsl_state_it = glslprogram_map.find(cur_glsl_program);
238 if ( glsl_state_it == glslprogram_map.end() )
245 glsl_state = &glslprogram_map[cur_glsl_program];
248 update_pu = cur_glsl_prog_uniform_set !=
NULL;
249 update_su = cur_shader_uniform_set !=
NULL;
250 update_au = cur_actor_uniform_set !=
NULL;
258 glsl_state = &glsl_state_it->second;
260 update_cm = glsl_state->mCamera != camera;
261 update_tr = glsl_state->mTransform != cur_transform;
262 update_pu = glsl_state->mGLSLProgUniformSet != cur_glsl_prog_uniform_set && cur_glsl_prog_uniform_set !=
NULL;
263 update_su = glsl_state->mShaderUniformSet != cur_shader_uniform_set && cur_shader_uniform_set !=
NULL;
264 update_au = glsl_state->mActorUniformSet != cur_actor_uniform_set && cur_actor_uniform_set !=
NULL;
268 glsl_state->mCamera = camera;
269 glsl_state->mTransform = cur_transform;
270 glsl_state->mGLSLProgUniformSet = cur_glsl_prog_uniform_set;
271 glsl_state->mShaderUniformSet = cur_shader_uniform_set;
272 glsl_state->mActorUniformSet = cur_actor_uniform_set;
278 if (update_cm || update_tr) {
296 VL_CHECK( cur_glsl_prog_uniform_set && cur_glsl_prog_uniform_set->
uniforms().size() );
306 VL_CHECK( cur_shader_uniform_set && cur_shader_uniform_set->
uniforms().size() );
316 VL_CHECK( cur_actor_uniform_set && cur_actor_uniform_set->
uniforms().size() );
353 VL_glClientActiveTexture( GL_TEXTURE0 );
VL_CHECK_OGL();
382 std::vector<RenderStateSlot> mOriginalDefaultRS;
384 InOutContract(
Renderer* renderer,
Camera* camera): mRenderer(renderer)
424 for(
size_t i=0; i<mOriginalDefaultRS.size(); ++i)
436 } contract(
this, camera);
438 return renderRaw( render_queue, camera, frame_clock );
Associates a Renderable object to an Effect and Transform.
unsigned long mRenderTick
Callback class to update the state of the projection, view, transform and normal matrices of a GLSLPr...
const ProjViewTransfCallback * projViewTransfCallback() const
Transform * transform()
Returns the Transform bound tho an Actor.
The Renderer class executes the actual rendering on the given RenderQueue.
A simple String formatting class.
void applyEnables(const EnableSet *cur)
Applies an EnableSet to an OpenGLContext - Typically for internal use only.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
ref< ProjViewTransfCallback > mProjViewTransfCallback
vl::ref< EnableSet > mDummyEnables
EnableSet * getEnableSet()
bool linked() const
Returns true if the program has been succesfully linked.
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
OpenGLContext * openglContext()
The OpenGLContext bound to a render target.
const FramebufferObject * framebuffer() const
The Framebuffer on which the rendering is performed.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. ...
bool validateProgram() const
Returns true if the validation of this GLSL program is succesful, see also http://www.opengl.org/sdk/docs/man/xhtml/glValidateProgram.xml for more information.
std::map< unsigned int, ref< Shader > > mShaderOverrideMask
void setDefaultRenderState(const RenderStateSlot &rs_slot)
Defines the default render state slot to be used by the opengl context.
const UniformSet * getUniformSet() const
Returns the installed UniformSet.
bool applyUniformSet(const UniformSet *uniforms=NULL) const
Applies a set of uniforms to the currently bound GLSL program.
const GLSLProgram * glslProgram() const
Returns the GLSLProgram associated to a RenderStateSet (if any)
Internally used by the rendering engine.
void dispatchOnRendererFinished()
Dispatches the onRendererFinished() event to the registered RenderEventCallback objects.
unsigned int enableMask() const
The enable mask of an Actor is usually used to defines whether the actor should be rendered or not de...
Viewport * viewport()
The viewport bound to a camera.
Visualization Library main namespace.
static void bug(const String &message)
Use this function to provide information about programming errors: wrong parameter initialization...
const Scissor * scissor() const
Returns the Scissor used when rendering an Actor.
std::vector< RenderStateSlot > & overriddenDefaultRenderStates()
Render states that will be used as default by the opengl context by this renderer.
const RenderQueue * renderRaw(const RenderQueue *in_render_queue, Camera *camera, real frame_clock)
Used by render() to loop through the render queue.
UniformSet * getUniformSet()
Returns a GLSLProgram's static UniformSet. Static uniforms are those uniforms whose value is constant...
vl::ref< RenderStateSet > mDummyStateSet
void activate(EFramebufferBind target=FBB_FRAMEBUFFER)
Activates the FramebufferObject by calling bindFramebuffer() and bindDrawBuffers() ...
void dispatchOnActorRenderStarted(real frame_clock, const Camera *camera, Renderable *renderable, const Shader *shader, int pass)
Calls all the onActorRenderStarted() of all the ActorEventCallback installed on this Actor...
String infoLog() const
Returns the info log of this GLSL program using the OpenGL function glGetProgramInfoLog(), see also http://www.opengl.org/sdk/docs/man/xhtml/glGetProgramInfoLog.xml for more information.
void applyRenderStates(const RenderStateSet *cur, const Camera *camera)
Applies a RenderStateSet to an OpenGLContext - Typically for internal use only.
bool isEnabled(unsigned int mask)
Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects...
void render(const Actor *actor, const Shader *shader, const Camera *camera, OpenGLContext *gl_context)
Renders the Renderable and if necessary compiles the display list and updates the BufferObjects...
A set of RenderState objects managed by a Shader.
const Scissor * scissor() const
Returns the Scissor to be used when rendering an Actor.
The RenderQueue class collects a list of RenderToken objects to be sorted and rendered.
virtual const RenderQueue * render(const RenderQueue *in_render_queue, Camera *camera, real frame_clock)
Takes as input the render queue to render and returns a possibly filtered render queue for further pr...
void bindVAS(const IVertexAttribSet *vas, bool use_vbo, bool force)
Activates the specified vertex attribute set - For internal use only.
bool isCleanState(bool verbose)
Checks whether the OpenGL state is clean or not.
const std::string & objectName() const
The name of the object, by default set to the object's class name.
virtual void updateMatrices(bool cam_changed, bool transf_changed, const GLSLProgram *glsl_program, const Camera *camera, const Transform *transform)
Update matrices of the current GLSLProgram, if glsl_program == NULL then fixed function pipeline is a...
UniformSet * getUniformSet()
Returns the UniformSet installed.
RenderStateSet * getRenderStateSet()
const RenderToken * at(int i) const
bool Has_Fixed_Function_Pipeline
OpenGL: true if !Is_OpenGL_Forward_Compatible && !Is_OpenGL_Core_Profile OpenGL ES 1: always true Ope...
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
The Scissor class wraps the OpenGL function glScissor(), see http://www.opengl.org/sdk/docs/man/xhtml...
unsigned int handle() const
The handle of the GLSL program as returned by glCreateProgram()
const GLSLProgram * glslProgram() const
Returns the GLSLProgram associated to a Shader (if any)
void enable(const Viewport *viewport) const
Enables the scissor test on the area specified by scissorRect() clipped against the given Viewport...
const RenderToken * mNextPass
unsigned int enableMask() const
Enable mask used to enable/disable the rendering of matching Actors.
EClearFlags clearFlags() const
The clear flags used to clear the viewport.
static bool areUniformsColliding(const UniformSet *u1, const UniformSet *u2)
Returns true if the two UniformSet contain at least one Uniform variable with the same name...
void dispatchOnRendererStarted()
Dispatches the onRendererStarted() event to the registered RenderEventCallback objects.
const RenderStateSlot & defaultRenderState(ERenderState rs)
Returns the default render state slot used by VL when a specific render state type is left undefined...
VLCORE_EXPORT GlobalSettings * globalSettings()
Returns VisulizationLibrary's global settings.
A set of enables managed by Shader.
void setClearFlags(EClearFlags clear_flags)
Usually you want to use rather RendererAbstract::setClearFlags()