Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to toggle and update renderstates?


Lavos
 Share

Recommended Posts

Okay I did my code like so:

```

Public WIREMODE As Boolean

```

```

Public Function Init_Render_States()

WIREMODE = Not WIREMODE

'Setup render states

With Nemo

.Set_EngineCullMode D3DCULL_NONE

.Set_EngineRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA

.Set_EngineRenderState D3DRS_LIGHTING, True

.Set_EngineRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA

.Set_EngineRenderState D3DRS_ALPHABLENDENABLE, False

If WIREMODE Then

.Set_EngineRenderState D3DRS_FILLMODE, D3DFILL_WIREFRAME

Else

.Set_EngineRenderState D3DRS_FILLMODE, D3DFILL_SOLID

End If

.Set_EngineRenderState D3DRS_ZENABLE, False

.Set_EngineRenderState D3DRS_ZWRITEENABLE, False

.Set_EngineRenderState D3DRS_POINTSPRITE_ENABLE, 1

.Set_EngineRenderState D3DRS_POINTSCALE_ENABLE, 0

.Set_EngineAlphaBlendingOp D3DBLENDOP_ADD

.Set_EngineSpecularEnable False

End With

End Function

```

Under frmMapEditor i have this:

```

Private Sub chkWireMode_Click()

If chkWireMode.value Then

WIREMODE = True

Else

WIREMODE = False

End If

End Sub

```

With the check box on the form, i wanted to toggle renderstates using the chkbox, but it doesn't seem to update, I thought maybe adding:

```

If WIREMODE Then

.Set_EngineRenderState D3DRS_FILLMODE, D3DFILL_WIREFRAME

Else

.Set_EngineRenderState D3DRS_FILLMODE, D3DFILL_SOLID

End If

```

into the gameloop might work, but it froze and crashed the compiler. Any ideas on how to get around this?
Link to comment
Share on other sites

Remove 'WIREMODE = Not WIREMODE' from your '[background=rgb(248, 248, 248)]Init_Render_States[/background][background=rgb(248, 248, 248)]' [/background]function. Then once the check box is checked, set WIREMODE is true and just reload Init_Render_States.

```

Private Sub chkWireMode_Click()

WIREMODE = chkWireMode.Value

Call Init_Render_States

End Sub

```
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...