I have a Lazarus Form with a Castle2DControl on it. I can draw an image to this and also move it. However, when it moves it does not erase the last one so I get an image trail?
I tried using: Castle2DControl.Erasebackground(Form1.Canvas.Handle);
but no joy?
How to I erase so I do not get the trail?
I am drawing the image in the controls onRender event and changing the position in the onUpdate event as per instructions on the web site > getting started.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The screen is not automatically cleared at the beginning under Castle2DControl, under the assumption that in some use-cases you want to see things underneath. You need to clear it yourself, various ways:
Call "RenderContext.Clear([cbColor], Black)" at the very beginning of OnRender. RenderContext is defined in CastleGLUtils unit, Black constant is from CastleColors, or you can construct any color by Vector4(...).
Make the 2D scene manager not transparent: Castle2DControl.SceneManager.Transparent := false.
Place TCastleSimpleBackground at the back, like Window.Controls.InsertBack(TCastleSimpleBackground.Create(Application)).
Place TCastleRectangleControl at the back, like this:
R := TCastleRectangleControl.Create(Application);
R.FullSize := true;
R.Color := Black;
Window.Controls.InsertBack(R);
Note: do not use "EraseBackground(Form1.Canvas.Handle)". You cannot clear OpenGL context with EraseBackground.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I decided to fix it, that is: make the 2D scene manager non-transparent by default, so things would work out-of-the-box as expected. This makes 2D scene manager consistent with default (3D and 2D) scene manager in TCastleSceneManager, which is more intuitve, we had questions about it before already.
So, now TCastle2DControl is by default not transparent.
Internally, we have a new class TCastle2DSceneManager that is exactly like T2DSceneManager, but has Transparent = false by default (just like ancestor TCastleSceneManager). The class T2DSceneManager remains for compatibility with Transparent = true, but marked as deprecated. And TCastle2DControl uses new TCastle2DSceneManager.
You can of course go back to previous situation by setting Transparent:=true, e.g. Castle2DControl.SceneManager.Transparent := true. Note that you can also control the color of background, e.g. Castle2DControl.SceneManager.BackgroundColor := Yellow;.
View and moderate all "General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Old Forum"
Hi All
Thx in advance!
I have a Lazarus Form with a Castle2DControl on it. I can draw an image to this and also move it. However, when it moves it does not erase the last one so I get an image trail?
I tried using: Castle2DControl.Erasebackground(Form1.Canvas.Handle);
but no joy?
How to I erase so I do not get the trail?
I am drawing the image in the controls onRender event and changing the position in the onUpdate event as per instructions on the web site > getting started.
The simplest way to clear the screen is
You may also specify the custom color to clear the screen, just use
for orange color (also replace CastleColors with CastleVectors in your "uses" section)
Hi!
The screen is not automatically cleared at the beginning under Castle2DControl, under the assumption that in some use-cases you want to see things underneath. You need to clear it yourself, various ways:
Call "
RenderContext.Clear([cbColor], Black)
" at the very beginning of OnRender. RenderContext is defined in CastleGLUtils unit, Black constant is from CastleColors, or you can construct any color by Vector4(...).Make the 2D scene manager not transparent:
Castle2DControl.SceneManager.Transparent := false
.Place TCastleSimpleBackground at the back, like
Window.Controls.InsertBack(TCastleSimpleBackground.Create(Application))
.Place TCastleRectangleControl at the back, like this:
Note: do not use "
EraseBackground(Form1.Canvas.Handle)
". You cannot clear OpenGL context with EraseBackground.View and moderate all "General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Old Forum"
Thank you all very very much.
As an addendum to this thread:
I decided to fix it, that is: make the 2D scene manager non-transparent by default, so things would work out-of-the-box as expected. This makes 2D scene manager consistent with default (3D and 2D) scene manager in TCastleSceneManager, which is more intuitve, we had questions about it before already.
So, now TCastle2DControl is by default not transparent.
Internally, we have a new class TCastle2DSceneManager that is exactly like T2DSceneManager, but has Transparent = false by default (just like ancestor TCastleSceneManager). The class T2DSceneManager remains for compatibility with Transparent = true, but marked as deprecated. And TCastle2DControl uses new TCastle2DSceneManager.
You can of course go back to previous situation by setting Transparent:=true, e.g.
Castle2DControl.SceneManager.Transparent := true
. Note that you can also control the color of background, e.g.Castle2DControl.SceneManager.BackgroundColor := Yellow;
.You can test it using CGE from GitHub, https://github.com/castle-engine/castle-engine/ .