45 mAutomaticResourceInit(true),
46 mCullingEnabled(true),
48 mShaderAnimationEnabled(true),
49 mNearFarClippingPlanesOptimized(false)
51 VL_DEBUG_SET_OBJECT_NAME()
63 super::operator=(other);
101 InOutContract(
Rendering* rendering): mRendering(rendering)
108 mOpenGLContext = mRendering->
renderers()[0]->framebuffer()->openglContext();
111 mOpenGLContext->makeCurrent();
144 vl::Log::error(
"Rendering::render(): no Renderer specified for this Rendering!\n");
151 vl::Log::error(
"Rendering::render(): no RendererTarget specified for Renderer #0!\n");
156 if (!
renderers()[0]->framebuffer()->openglContext())
158 vl::Log::error(
"Rendering::render(): invalid Framebuffer for Renderer #0, OpenGLContext is NULL!\n");
169 if (!
camera()->viewport())
179 if (
camera()->boundTransform())
194 camera()->modelingMatrix().getZ());
225 Sphere world_bounding_sphere;
249 for(
size_t i=0; i<
renderers().size(); ++i)
255 vl::Log::error(
Say(
"Rendering::render(): no RendererTarget specified for Renderer #%n!\n") << i );
262 vl::Log::error(
Say(
"Rendering::render(): invalid Framebuffer for Renderer #%n, OpenGLContext is NULL!\n") << i );
277 if (actor_list ==
NULL)
280 if (actor_list->
empty())
290 std::set<Shader*> shader_set;
294 for(
size_t iactor=0; iactor < actor_list->
size(); iactor++)
296 Actor* actor = actor_list->
at(iactor);
317 effect = eom_it->second.get();
329 int geometry_lod = 0;
336 const int pass_count = effect->
lod(effect_lod)->size();
337 for(
int ipass=0; ipass<pass_count; ++ipass)
341 Shader* shader = effect->
lod(effect_lod)->at(ipass);
349 if ( prev_pass !=
NULL )
378 shader_set.insert(shader);
392 for(
size_t i=0; i<count; ++i )
Associates a Renderable object to an Effect and Transform.
ref< RenderQueueSorter > mRenderQueueSorter
const Renderable * lod(int lod_index) const
Returns the Renderable object representing the LOD level specifed by lod_index.
void setLastUpdateTime(real time)
Used internally.
unsigned int handle() const
OpenGL texture handle as returned by glGenTextures().
void resetContextStates(EResetContextStates start_or_finish)
Resets the OpenGL states necessary to begin and finish a rendering. - For internal use only...
const Transform * transform() const
The root of the Transform tree updated at every rendering frame.
int evaluateLOD(Camera *camera)
bool mAutomaticResourceInit
RenderStateSet * gocRenderStateSet()
size_t renderStatesCount() const
The Renderer class executes the actual rendering on the given RenderQueue.
A simple String formatting class.
The Plane class defines a plane using a normal and an origin.
void sort(RenderQueueSorter *sorter, Camera *camera)
std::vector< Plane > & planes()
ShaderAnimator * shaderAnimator()
Returns the ShaderAnimator used to update/animate a Shader (see vl::ShaderAnimator documentation)...
bool linked() const
Returns true if the program has been succesfully linked.
void dispatchOnRenderingStarted()
Calls the RenderEventCallback::onRenderingStarted() method of all the active callback objects...
const SetupParams * setupParams() const
See SetupParams.
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
RenderQueueSorter * renderQueueSorter()
The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting i...
ref< ActorCollection > mActorQueue
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
virtual void render()
Executes the rendering.
bool createTexture()
Creates a texture using the parameters specified by the last prepareTexture*() called.
const Camera * camera() const
The Camera that defines the point of view and viewport to be used when rendering the scene...
const Sphere & boundingSphere() const
Returns the bounding sphere (not guaranteed to be up to date) that contains this Actor.
bool isEnabled() const
Whether the ShaderAnimator is enabled or not.
bool nearFarClippingPlanesOptimized() const
Returns whether near/far planes optimization is enabled.
bool automaticResourceInit() const
Whether OpenGL resources such as textures and GLSL programs should be automatically initialized befor...
Internally used by the rendering engine.
unsigned int enableMask() const
The enable mask of an Actor is usually used to defines whether the actor should be rendered or not de...
const T * at(size_t i) const
Visualization Library main namespace.
int evaluateLOD(Actor *actor, Camera *camera)
If a LODEvaluator is installed computes the effect LOD to be used otherwise returns 0...
The TextureImageUnit class associates a Texture object to an OpenGL texture unit. ...
Rendering & operator=(const Rendering &other)
Assignment operator.
const Frustum & frustum() const
The view frustum of the camera used to perform frustum culling.
Implements the default RenderQueueSorter.
bool linkProgram(bool force_relink=false)
Links the GLSLProgram calling glLinkProgram(handle()) only if the program needs to be linked...
Texture * texture()
The texture sampler by a texture unit.
void computeFrustumPlanes()
Computes the Camera's frustum planes in world space.
void computeNearFarOptimizedProjMatrix(const Sphere &scene_bounding_sphere)
The near and far clipping planes are adjusted to fit the provided scene_bounding_sphere.
unsigned int enableMask() const
The enable mask of the Rendering, used to define wheter the rendering is enabled or not...
Collection< Renderer > mRenderers
real frameClock() const
The update time of the current rendering frame.
ActorCollection * actorQueue()
virtual void updateShader(Shader *shader, Camera *camera, real cur_time)=0
Reimplement this function to update/animate a Shader.
std::map< unsigned int, ref< Effect > > mEffectOverrideMask
void setModelingMatrix(const mat4 &mat)
Sets the Camera's modelingMatrix() (inverse of the view matrix).
bool shaderAnimationEnabled() const
Whether Shader::shaderAnimator()->updateShader() should be called or not.
int renderRank() const
Returns the rendering rank of an Effect.
Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects...
The Sphere class defines a sphere using a center and a radius using vl::real precision.
The Rendering class collects all the information to perform the rendering of a scene.
unsigned int enableMask() const
The enable mask of an Actor's Effect defines whether the actor should be rendered or not depending on...
bool cullingEnabled() const
Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the re...
ref< RenderQueue > mRenderQueue
RenderToken * newToken(bool multipass)
Defines the sequence of Shader objects used to render an Actor.
The RenderQueue class collects a list of RenderToken objects to be sorted and rendered.
Effect * effect()
Returns the Effect bound to an Actor.
Defined as a simple subclass of Collection<Actor>, see Collection for more information.
void dispatchOnRenderingFinished()
Calls the RenderEventCallback::onRenderingFinished() method of all the active callback objects...
ref< Collection< SceneManager > > mSceneManagers
It's basically an std::vector for Objects that is itself an Object so it can be reference counted and...
void computeBounds()
Computes the bounding box and bounding sphere of an Actor if boundsDirty().
ref< Transform > mTransform
ERenderState type() const
The ref<> class is used to reference-count an Object.
bool mShaderAnimationEnabled
void fillRenderQueue(ActorCollection *actor_list)
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
const GLSLProgram * glslProgram() const
Returns the GLSLProgram associated to a Shader (if any)
bool evaluateLOD() const
Whether the Level-Of-Detail should be evaluated or not.
bool mNearFarClippingPlanesOptimized
const RenderStateSlot * renderStates() const
RenderQueue * renderQueue()
real lastUpdateTime() const
Last time this Actor was animated/updated using a shaderAnimator().
const RenderToken * mNextPass
const Collection< Renderer > & renderers() const
The list of Renderers used to perform the rendering.
Collection< SceneManager > * sceneManagers()
Returns the list of SceneManager[s] containing the Actor[s] to be rendered.
bool isEnabled(unsigned int mask)
const ref< ShaderPasses > & lod(int lod_level) const
Returns the ShaderPasses representing the specified LOD level.