# TCastleWindow missing?

**URL:** <https://forum.castle-engine.io/t/tcastlewindow-missing/105>\
**Category:** Uncategorized\
**Created:** [December 1, 2019, 11:59am UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105 "2019-12-01T11:59:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 11:59am UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/1 "2019-12-01T11:59:49Z")

</div>

I’m not sure if it’s supposed to be a component like TCastleControl but I can’t see it anywhere in my lazarus, if I try to autocomplete window:= then TCastleWindow doesn’t even show up

---

<div class="post-metadata">

**Author:** ![eugeneloza](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/eugeneloza/32/12_2.png) [@eugeneloza](https://forum.castle-engine.io/u/eugeneloza)\
**Post date:** [December 1, 2019, 12:24pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/2 "2019-12-01T12:24:28Z")

</div>

Hi, @gregest and welcome to the forum! 🙂

There are two ways you can create a game in Castle Game Engine:

1. You can use Lazarus LCL, and add `TCastleControl`, among any other Lazarus controls, to the form. This is a bit easier, as Lazarus will automatically add all dependencies to `Uses` section and will configure the project options for you.

2. (I really advice going this way) Use an universal `TCastleWindowBase` to create game environment. With `TCastleWindowBase` you can ensure portability of your game much easier (like compilation for Android).

In order to have `TCastleWindow`-related classes available for hints in Lazarus (and use the second approach) you have to “File \> New \> Simple Program”. Then “Package \> Open Package File (\*.lpk)”. Navigate to Castle Game Engine folder and add castle\_base.lpk and castle\_window.lpk to your project (“Use \> Add to project” for both).

Now in your `Uses` section include `CastleWindow` and you are ready to go.

This is the very minimal example how to create a `TCastleWindowBase` this way:

```auto
program Project1;

uses CastleWindow;

var
  Window: TCastleWindowBase;

begin
  Window := TCastleWindowBase.Create(Application);
  Window.OpenAndRun;
end.

```

However, this is a “minimal” example. In order to use the newly created window efficiently, check the documentation [https://castle-engine.io/manual\_window.php](https://castle-engine.io/manual_window.php) and/or examples with your Castle Game Engine.

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 12:48pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/3 "2019-12-01T12:48:32Z")

</div>

oh, so it needs to be in a seperate code, not inside the main bigger code or maybe I’m misunderstanding

---

<div class="post-metadata">

**Author:** ![eugeneloza](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/eugeneloza/32/12_2.png) [@eugeneloza](https://forum.castle-engine.io/u/eugeneloza)\
**Post date:** [December 1, 2019, 1:18pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/4 "2019-12-01T13:18:40Z")

</div>

> [@gregest](#):
>
> not inside the main bigger code

In order to work with Castle Window you have to initialize it properly (at the beginning of your code) and add something to it (like images, 3D objects, effects, etc.). That would require reorganization of your code a bit. You’ll need to make a proper initialization like you can see e.g. in examples/portable\_game\_skeleton/my\_fantastic\_game\_standalone.lpi - Everything else should work out-of-the box, unless your code did something very complex that goes beyond what is “easy to port” to CGE.

If you already have a “main bigger code” done in Lazarus LCL, then indeed you’re much easier to work with `TCastleControl` which will simply add itself to the other objects on your `Form` and you can use it right away from your ready app. In fact that was the way I my first Castle Game Engine-made game worked (Project Helena) - it uses a “ready” Form developed for many years, 10k lines code base; and using Castle Game Engine `TCastleControl` for drawing and `SoundEngine` for music/sound.

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 2:21pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/5 "2019-12-01T14:21:42Z")

</div>

okay I think I understand, I mainly asked because the manual mostly uses Tcastlewindow rather than castlecontrol so I thought I was missing something, thank you for the help

---

<div class="post-metadata">

**Author:** ![eugeneloza](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/eugeneloza/32/12_2.png) [@eugeneloza](https://forum.castle-engine.io/u/eugeneloza)\
**Post date:** [December 1, 2019, 2:28pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/6 "2019-12-01T14:28:07Z")

</div>

Yeah. Note that `TCastleControl` is working almost exactly like `TCastleWindow`. I.e. when in examples a `Window` is used, you can simple write `CastleControl1` instead and it’ll work most of the time (unless you’re doing something too complex).

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 2:41pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/7 "2019-12-01T14:41:21Z")

</div>

oh that’s very helpful to know, thank you for the help, I will still need to create the simple program portion for the other things, correct?

---

<div class="post-metadata">

**Author:** ![eugeneloza](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/eugeneloza/32/12_2.png) [@eugeneloza](https://forum.castle-engine.io/u/eugeneloza)\
**Post date:** [December 1, 2019, 2:46pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/8 "2019-12-01T14:46:37Z")

</div>

> [@gregest](#):
>
> I will still need to create the simple program portion for the other things, correct?

No. If you’re adding a `TCastleControl` to your already-working Lazarus project (not a “simple program” but an “Application”), nothing more is needed - Lazarus will make everything for you. Of course, you’ll still need to add and use events, like `OnRender` (to draw something on `TCastleControl`) or `OnPress` (to receive keyboard/mouse events) or `OnUpdate` (to do something every frame) - but that’ll be “Extending your code” to use Castle Game Engine.

You’ll need to start with a “simple program” only if you want to use `TCastleWindow`, e.g. if you’re planning to port your game/project to Android or want additional features, like a full-screen mode. UPD: note that even if you start with `TCastleControl`, you can “translate” your code from `TCastleControl` into using `TCastleWindowBase` - however, that’ll require some reworking of how the application is initialized and manages GUI elements.

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 3:06pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/9 "2019-12-01T15:06:19Z")

</div>

perfect, that’s all of the questions I had and I guess I will be staying with TCastleControl at the beginning since it just seems simpler to use, thank you for the help

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 3:27pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/10 "2019-12-01T15:27:36Z")

</div>

turns out I don’t actually understand because I just can’t figure out what to replace the variables with that the examples use because even when I put them as global variables like MyLabel: TCastleLabel it just says identifier not found so I have no idea how to recreate it using TCastleControl, so I just don’t see what is the “conversion” between TCastleControl and CastleWindow

---

<div class="post-metadata">

**Author:** ![eugeneloza](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/eugeneloza/32/12_2.png) [@eugeneloza](https://forum.castle-engine.io/u/eugeneloza)\
**Post date:** [December 1, 2019, 3:39pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/11 "2019-12-01T15:39:34Z")

</div>

> [@gregest](#):
>
> even when I put them as global variables like MyLabel: TCastleLabel it just says identifier not found

To use `TCastleLabel` you have either to add it from Lazarus “Castle” tab (in CGE 6.4; I think it was removed in CGE 6.5) or manually add `CastleControls` to your Uses section. There are a lot of different “controls” you can insert into your `TCastleControl`, most of which are found in `CastleControls` unit. Note that you can see which unit the class belongs to in API reference: [Castle Game Engine: Class Hierarchy](https://castle-engine.io/apidoc/html/ClassHierarchy.html) — it’s very efficient, once you learn to use it. E.g. if you find `TCastleLabel` there you’ll get to a thorough description page [Castle Game Engine: CastleControls: Class TCastleLabel](https://castle-engine.io/apidoc/html/CastleControls.TCastleLabel.html) which also mentions: “Unit CastleControls” - i.e. it’s the unit you need to have in your `Uses` section to use this element.

If you’re working with CGE examples or other projects created with Castle Game Engine - you can simply ctrl+click the definition of some control or other class (`TCastleLabel` in example above) and Lazarus will automatically take you to the definition of the class in the unit it is defined.

E.g. if you want to draw a `TDrawableImage` (`TGlImage` in CGE 6.4) then you’ll need to add `Uses ... CastleGlImages;`. And if you want a `TCastleSceneManager` then you’ll need `Uses ... CastleSceneManager;`. Etc.

> [@gregest](#):
>
> I just don’t see what is the “conversion” between TCastleControl and CastleWindow

It doesn’t have anything to do with the problem above. E.g. you need to `Window.Controls.Add(SomeCastleLabel);` or `CastleControl.Controls.Add(SomeCastleLabel);` - they’ll work the same way. In both ways you need to have `TCastleLabel` available in “namespace” - and that needs `Uses ... CastleControls;`.

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 3:53pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/12 "2019-12-01T15:53:55Z")

</div>

right, I forgot about the components, my bad

thank you for the help again and I’m sorry for asking stupid questions

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [December 1, 2019, 5:39pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/13 "2019-12-01T17:39:32Z")

</div>

1. The difference between `TCastleControl` and `TCastleWindow` is that `TCastleControl` is a component on a normal, Lazarus form. In contrast: `TCastleWindow` is a complete window, unrelated to normal Lazarus GUI.

2. An example how to add CGE UI controls (like `TCastleLabel`) to `TCastleControl` is inside the engine `examples/lazarus/model_3d_with_2d_controls/`, [https://github.com/castle-engine/castle-engine/tree/master/examples/lazarus/model\_3d\_with\_2d\_controls/](https://github.com/castle-engine/castle-engine/tree/master/examples/lazarus/model_3d_with_2d_controls/) . See mainf.pas unit implementation, [https://github.com/castle-engine/castle-engine/blob/master/examples/lazarus/model\_3d\_with\_2d\_controls/mainf.pas#L62](https://github.com/castle-engine/castle-engine/blob/master/examples/lazarus/model_3d_with_2d_controls/mainf.pas#L62) .

3. To complicate matters a bit, note that there are also `TCastleControlBase` and `TCastleWindowBase`. They are similar to their counterparts (without the `Base` suffix), but they do not have a default `SceneManager` instance inside. For new games, I would advise using `TCastleControlBase` / `TCastleWindowBase` (instead of `TCastleControl` / `TCastleWindow`), although our examples are not yet updated to show the new way.

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 5:58pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/14 "2019-12-01T17:58:49Z")

</div>

I tried using the CGE editor but for some reason it keeps telling me “cannot find “zip” program on $PATH” even though I’m pretty sure I already added WinRAR to my path variable so I’m not sure why it’s still not recognizing it

---

<div class="post-metadata">

**Author:** ![eugeneloza](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/eugeneloza/32/12_2.png) [@eugeneloza](https://forum.castle-engine.io/u/eugeneloza)\
**Post date:** [December 1, 2019, 6:03pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/15 "2019-12-01T18:03:33Z")

</div>

> [@gregest](#):
>
> “cannot find “zip” program on $PATH”

I think you miss zlib1.dll (and maybe other required DLLs) in the $PATH or in the game “root” folder. You can find it in tools/build-tool/data/external\_libraries/ and select the corresponding 32 or 64 bit libraries directory (corresponding to whether you use 32 or 64 bit Lazarus+FPC). It doesn’t have any relation to WinRAR or any other standalone archiver.

See [Documentation | Castle Game Engine](https://castle-engine.io/documentation.php#section_libraries) for more details.

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 6:34pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/16 "2019-12-01T18:34:07Z")

</div>

oh I thought I didn’t need those DLLs since it even mentions that “If you use our or build tool, the DLL files will be automatically copied alongside your EXE file, so you don’t have to do anything.” even after putting all the DLLs in the folder where the exe is, it still says the same thing about zip

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [December 1, 2019, 7:03pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/17 "2019-12-01T19:03:56Z")

</div>

Indeed you should not need to deal with DLLs if you just run a ready precompiled CGE from [https://github.com/castle-engine/castle-engine/releases/tag/snapshot](https://github.com/castle-engine/castle-engine/releases/tag/snapshot) . The editor comes packaged with necessary DLLs, and compiling applications from the editor will automatically copy the DLLs alongside your EXE.

As for the “zip” error - when exactly do you see it?

Compiling and running CGE applications should not make any error about “zip”.

It’s possible to see this error, if you try “package” option (from the editor or the build tool). You need to install a “zip” program to make it work, since the default package format on Windows is zip. You can get “zip” e.g. by installing Cygwin. Zip is _not_ related to WinRAR at all.

In any case, you should not need “zip” if you don’t need to execute “package”.

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 7:18pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/18 "2019-12-01T19:18:13Z")

</div>

I was trying to run the “package” which is when it told me that “zip” is missing so I assumed it was something with .zip file extension, but if I don’t need the package function which I’m not sure what it’s for, I assume releasing the app, then I won’t bother with it for now

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [December 1, 2019, 7:21pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/19 "2019-12-01T19:21:53Z")

</div>

The “package” function packages the application exe + data into a zip file (on Windows). See [https://github.com/castle-engine/castle-engine/wiki/Build-Tool](https://github.com/castle-engine/castle-engine/wiki/Build-Tool) , section “package” [https://github.com/castle-engine/castle-engine/wiki/Build-Tool#package](https://github.com/castle-engine/castle-engine/wiki/Build-Tool#package) for details. It uses command-line “zip” for that purpose, so indeed it will make an error if you don’t have it.

Indeed you don’t need to use “package” for now 🙂 The important thing is that using “compile” and “run” works.

You can later release CGE applications in any way you like, you can also package them yourself into any format (rar, zip). The “package” function is helpful… but it’s definitely not necessary to use it 🙂

---

<div class="post-metadata">

**Author:** ![gregest](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/g/e9c0ed/32.png) [@gregest](https://forum.castle-engine.io/u/gregest)\
**Post date:** [December 1, 2019, 7:54pm UTC](https://forum.castle-engine.io/t/tcastlewindow-missing/105/20 "2019-12-01T19:54:52Z")

</div>

Ah I see, I thought I needed so I wanted to get it working because I like it when all the things work

[Next page](https://forum.castle-engine.io/t/tcastlewindow-missing/105.md?page=2)
