-
Notifications
You must be signed in to change notification settings - Fork 219
Renderer Interface
Rendering is done through an interface called spades::client::IRenderer
. This abstracts the actual rendering APIs.
- Setup a struct
SceneDefinition
and give it toBeginScene
- Add objects to the scene by renderer commands (this must be done for every frame since the renderer doesn't remember them over a frame):
- Models
- Dynamic Light
- Sprites
- Debug Line
- Call
EndScene
to tell the renderer that we have nothing to add to the scene anymore - Draw 2D images
- Call
FrameDone
. - Call
Flip
. The renderer will transfer the rendered image to the screen.
Initializes all subsystems of the renderer.
Destroys every objects needed by the renderer and releases memory used by them.
Returns an image object with the specified file name. Loaded images are cached during the lifetime of the renderer (that is, the renderer keeps a reference to the image).
Returns a model object with the specified file name. Loaded models are cached during the lifetime of the renderer (that is, the renderer keeps a reference to the model).
Creates a temporary image object from the given bitmap.
Creates a temporary model object from the given voxel bitmap.
Tells the renderer to render the given game map instead of the currently set one.
Specifies the fog color.
Tells the renderer to get ready for the 3D renderer commands.
Tells the renderer that there are no more 3D renderers commands for the current frame.
Adds a point light or spotlight to the scene. This should not be called outside of BeginScene ... EndScene.
Adds a model to the scene. This should not be called outside of BeginScene ... EndScene.
Adds a 3D line segment to the scene. (Actually this should be used for debugging)
This should not be called outside of BeginScene ... EndScene.
Adds a sprite particle. This should not be called outside of BeginScene ... EndScene.
Adds a long sprite. This is mainly used for long bright objects without an exact shape, such as bullet tracers. This should not be called outside of BeginScene ... EndScene.
Specifies the color used by AddSprite
, AddLongSprite
, and DrawImage
.
-
DrawImage
treats this color value as "non-alpha premultiplied." So when A = 0, the renderer image becomes completely invisible. -
AddSprite
andAddLongSprite
treat this color value as "alpha premultiplied." Therefore when A = 0, additive blending occurs.
Draws an image in the screen coordinate system. This should not be called between BeginScene and EndScene.
Draws a 2D view of the current game map in the specified rectangle. This should not be called between BeginScene and EndScene.
Tells the renderer that there are no more things to render in the current frame. This should not be called between BeginScene and EndScene.
Displays the rendered image to the screen. This should not be called between BeginScene and EndScene.
Returns the current renderer image as a bitmap. Note that usually this operation is extremely slow.
This should not be called between BeginScene and EndScene.
GLRenderer
is an OpenGL 2.0/3.0 implementation of IRenderer
and supports all required function. GLRenderer
is currently the only implementation of IRenderer
.
-
BeginScene
just initializes the rendering -
EndScene
renders the scene in multiple passes:- Preparation
- Shadow Maps Generation
- Ocean Reflection Pass
- Sun-light Pass
- Dynamic Light Pass
- Post-process
-
FrameDone
flushes 2D rendering command buffer. -
Flip
callsSwap
of the OpenGL device.
SWRenderer
is a multi-threaded software implementation (similar to VOXLAP) of IRenderer
and supports the following fundamental features.
- Map
- Models
- 2D Images
- Sprites
Fast mode (r_swUndersampling
) can be used to boost the performance up by reducing the ray tracing density (effectively lowering the screen resolution).
- Intel Core i5 1.7GHz (Dual Core, HTT enabled, Clang 3.3?, OS X)
- 30FPS @ 1280x720
- 55FPS @ 800x600
- Intel Core 2 Duo 1.4GHz (Dual Core, Microsoft Visual C++ 2013, Windows 8)
- 20FPS @ 800x600
- AMD E-450 (Dual Core, Microsoft Visual C++ 2013, Windows 7)
- 15FPS @ 800x600
Obsolete feature: This was removed in 0.2.0.
When cg_smp
is set to 1, multi-threaded rendering architecture is enabled. Client
issues commands to AsyncRenderer
, and AsyncRenderer
sends the commands to IRenderer
in a separate thread.
This architecture is similar to cg_smp
of id Software's Quake 3.
Note that SMP renderer is unstable, difficult to trace errors, and there is some lag because of thread scheduling. Logging facility might not work expectedly.
This wiki is in the middle of an update process to match the latest changes of OpenSpades 0.1.2
It may contain outdated, incorrect or incomplete information.
Please contact the repository owner (@yvt) via email or ask a question in the issue tracker if there is any obscure information you are looking for that can't be found in neither the source code nor in this wiki.