Garry's Mod Wiki

render.Spin

void render.Spin()

Description

Swaps the frame buffers/cycles the frame. In other words, this updates the screen.

If you take a really long time during a single frame render, it is a good idea to use this and let the user know that the game isn't stuck.

Example

Code from Super DOF; Push the current progress of rendering onto the screen and display a percentage of completion near the bottom right.

-- Restore RT render.SetRenderTarget( OldRT ) -- Render our result buffer to the screen matFSB:SetFloat( "$alpha", 1 ) matFSB:SetTexture( "$basetexture", texFSB ) render.SetMaterial( matFSB ) render.DrawScreenQuad() cam.Start2D() local add = ( i / ( math.pi*2 ) ) * ( 1 / passes ) local percent = string.format( "%.1f", ( mul - ( 1 / passes ) + add ) * 100 ) draw.DrawText( percent .. "%", "GModWorldtip", view.w - 100, view.h - 100, Color( 0, 0, 0, 255 ), TEXT_ALIGN_CENTER ) draw.DrawText( percent .. "%", "GModWorldtip", view.w - 101, view.h - 101, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER ) cam.End2D() render.Spin()
Output:

Page Links


Special Pages


Wikis

?

Render Time: 40ms

Session 0
DB GetPage 5
Generate Html 1
SaveChanges 12
Render Body 0
Render Sidebar 20