blender.org
code.blender.org
User:Jwilkins/VFX/Aspects
for
User:Jwilkins/VFX/Aspects
User page
No discussion
Links
View source
History
From BlenderWiki
Jump to:
navigation
,
search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on
wiki.blender.org
.
You can view and copy the source of this page:
= Aspects = Header File: <tt>GPU_aspect.h</tt> An ''aspect'' is a collection of shaders and other features grouped together to do a particular kind of drawing in ''Blender''. At a low level ''aspects'' can be thought of as a module that handles compiling and choosing between ''OpenGL'' shaders. For example, there is an aspect that manages shaders for drawing fonts, another for drawing solid 3D meshes, and another for drawing wire frame objects. The term ''aspect'' is taken from ''aspect-oriented programming'' (''AOP''). The idea is that each way of drawing in ''Blender'' is a different facet of the more general task of drawing. In the language of ''AOP'', which shader to use at a given time is a "cross cutting concern" of ''Blender'' and each kind of drawing (or aspect of drawing) should be controlled through a different module and choosing which module to use should be centralized. Why do we need a special term here? Because words like ''renderer'', ''shader'', and ''context'' are already taken and choosing one of those would overload an already overburdened term. The current interface may seem over-engineered, but this is because the interface is designed to allow for additional features, such as multi-pass drawing and the ability to select between polymorphic implementations of each aspect at runtime (including implementations created in ''Python''). For this reason the interface should be considered experimental, as it could be either simplified or embellished as this feature evolves. == Objects == <source lang="c"> void GPU_gen_aspects (size_t count, uint32_t* aspects); void GPU_delete_aspects(size_t count, const uint32_t* aspects); </source> Aspects are indexed by a <tt>uint32_t</tt>. Creating and destroying those indexes is done using <tt>GPU_gen_aspects</tt> and <tt>GPU_delete_aspects</tt>. These functions operate similarly to ''OpenGL'' <tt>Gen</tt> and <tt>Delete</tt> functions. == Implementations == <source lang="c"> typedef struct GPUaspectimpl { bool (*render_begin )(const void* object, void* param); bool (*render_end )(const void* object, void* param); bool (*render_commit)(const void* object); bool (*select_begin )(const void* object, void* param); bool (*select_end )(const void* object, void* param); bool (*select_commit)(const void* object); void (*enable )(const void* object, uint32_t options); void (*disable )(const void* object, uint32_t options); void* object; } GPUaspectimpl; void GPU_aspect_impl(uint32_t aspect, GPUaspectimpl* aspectImpl); </source> Aspects are implemented by a table of functions held in a <tt>GPUaspectimpl</tt> structure. The implementation of an aspect is set by <tt>GPU_aspect_impl</tt>. The aspect module does not own the pointer to this table, so it will not be freed when <tt>GPU_delete_aspect</tt> is called. It is up to the allocator of the <tt>GPUaspectimpl</tt> to free it if it was allocated dynamically, but not before <tt>GPU_delete_aspect</tt> is called or <tt>GPU_aspect_impl</tt> is called with a different pointer. Setting the implementation pointer to <tt>NULL</tt> will return the implementation to its original state (which is a dummy implementation). Creating a new implementation requires understanding what each of these functions is supposed to do, however the aspect module is still in development, so the functions and their purpose are subject to change. The ''object'' field is meant so that different aspect implementations may use the same functions but have a separate workspace (like a <tt>this</tt> pointer in ''C++''). == Switching == <source lang="c"> bool GPU_aspect_begin(uint32_t aspect, const void* object); bool GPU_aspect_end(void); </source> Currently the ''param'' parameter is always ''NULL''. The ''param'' parameter is intended to provide a local context for an aspect so that it can behave different depending on where it is called. Header File: <tt>GPU_blender_aspect.h</tt> <source lang="c"> GPU_ASPECT_BASIC GPU_ASPECT_CODEGEN GPU_ASPECT_FONT GPU_ASPECT_PIXELS GPU_ASPECT_RASTER GPU_ASPECT_SPRITE </source> These are built-in aspects for ''Blender'' that can be in the ''aspect'' field of <tt>GPU_aspect_begin</tt>, <tt>GPU_aspect_enable</tt>, and <tt>GPU_aspect_disable</tt>. == Options == <source lang="c"> void GPU_aspect_enable (uint32_t aspect, uint32_t options); void GPU_aspect_disable(uint32_t aspect, uint32_t options); </source> These functions set and reset flags in the context of each ''aspect''. For example, in <tt>GPU_ASPECT_BASIC</tt> the <tt>GPU_BASIC_LIGHTING</tt> flag enables or disables whether lighting computations are done. == Commit == <source lang="c"> void GPU_commit_aspect(void); </source> Before drawing anything the <tt>GPU_commit_aspect</tt> function must be called so that all state needed by the current ''aspect'' can be "committed" to the ''OpenGL'' driver.
Return to
User:Jwilkins/VFX/Aspects
.
User:Jwilkins
Unversioned
Main Page
Blender Development
Blender 2.6
User Manual
Tutorials
Books
Scripts
2.72 Python API
(external link)
Blender Development
Blender 2.5
2.59 Python API
(external link)
Blender Development
Blender 2.4
User Manual
Tutorials
Books
Scripts
2.49 Python API
(external link)
Blender Development