47 VL_DEBUG_SET_OBJECT_NAME()
60 GLSLProgState(): mCamera(
NULL), mTransform(
NULL), mGLSLProgUniformSet(
NULL), mShaderUniformSet(
NULL), mActorUniformSet(
NULL) {}
62 bool operator<(
const GLSLProgState& other)
const 64 if ( mCamera != other.mCamera )
65 return mCamera < other.mCamera;
67 if ( mTransform != other.mTransform )
68 return mTransform < other.mTransform;
70 if ( mGLSLProgUniformSet != other.mGLSLProgUniformSet )
71 return mGLSLProgUniformSet < other.mGLSLProgUniformSet;
73 if ( mShaderUniformSet != other.mShaderUniformSet )
74 return mShaderUniformSet < other.mShaderUniformSet;
76 return mActorUniformSet < other.mActorUniformSet;
91 std::map<const GLSLProgram*, GLSLProgState> glslprogram_map;
111 for(
int itok=0; itok < render_queue->
size(); ++itok)
129 if (cur_scissor != scissor)
131 cur_scissor = scissor;
139 VL_CHECK(glIsEnabled(GL_SCISSOR_TEST))
145 for(
int ipass=0; tok !=
NULL; tok = tok->
mNextPass, ++ipass )
161 shader = eom_it->second.get();
185 if (glGetError() != GL_NO_ERROR)
187 Log::error(
"An unsupported OpenGL glEnable/glDisable capability has been enabled!\n");
218 cur_glsl_prog_uniform_set = cur_glsl_program->
getUniformSet();
227 bool update_cm =
false;
228 bool update_tr =
false;
229 bool update_pu =
false;
230 bool update_su =
false;
231 bool update_au =
false;
232 GLSLProgState* glsl_state =
NULL;
235 std::map<const GLSLProgram*, GLSLProgState>::iterator glsl_state_it = glslprogram_map.find(cur_glsl_program);
237 if ( glsl_state_it == glslprogram_map.end() )
244 glsl_state = &glslprogram_map[cur_glsl_program];
247 update_pu = cur_glsl_prog_uniform_set !=
NULL;
248 update_su = cur_shader_uniform_set !=
NULL;
249 update_au = cur_actor_uniform_set !=
NULL;
257 glsl_state = &glsl_state_it->second;
259 update_cm = glsl_state->mCamera != camera;
260 update_tr = glsl_state->mTransform != cur_transform;
261 update_pu = glsl_state->mGLSLProgUniformSet != cur_glsl_prog_uniform_set && cur_glsl_prog_uniform_set !=
NULL;
262 update_su = glsl_state->mShaderUniformSet != cur_shader_uniform_set && cur_shader_uniform_set !=
NULL;
263 update_au = glsl_state->mActorUniformSet != cur_actor_uniform_set && cur_actor_uniform_set !=
NULL;
267 glsl_state->mCamera = camera;
268 glsl_state->mTransform = cur_transform;
269 glsl_state->mGLSLProgUniformSet = cur_glsl_prog_uniform_set;
270 glsl_state->mShaderUniformSet = cur_shader_uniform_set;
271 glsl_state->mActorUniformSet = cur_actor_uniform_set;
277 if (update_cm || update_tr) {
295 VL_CHECK( cur_glsl_prog_uniform_set && cur_glsl_prog_uniform_set->
uniforms().size() );
305 VL_CHECK( cur_shader_uniform_set && cur_shader_uniform_set->
uniforms().size() );
315 VL_CHECK( cur_actor_uniform_set && cur_actor_uniform_set->
uniforms().size() );
352 VL_glClientActiveTexture( GL_TEXTURE0 );
VL_CHECK_OGL();
379 std::vector<RenderStateSlot> mOriginalDefaultRS;
381 InOutContract(
Renderer* renderer,
Camera* camera): mRenderer(renderer)
421 for(
size_t i=0; i<mOriginalDefaultRS.size(); ++i)
433 } contract(
this, camera);
435 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.
const Framebuffer * framebuffer() const
The Framebuffer on which the rendering is performed.
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...
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 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.
void activate(EFramebufferBind target=FBB_FRAMEBUFFER)
Activates the Framebuffer by calling bindFramebuffer() and bindDrawBuffers()
The RenderQueue class collects a list of RenderToken objects to be sorted and rendered.
OpenGLContext * openglContext()
The OpenGLContext bound to a render target.
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()