我如何在wxWidgets中绘制?

How can i draw in wxWidgets?

所以我目前正在编写一个贪吃蛇游戏,我需要绘制指示蛇头的第一个像素(位于软件的中间)。但我似乎找不到任何在屏幕上绘图的功能。我试过使用 DrawRectang 和 DrawPixel。

有什么帮助吗?

wxWidgets 可以通过自己的绘图 API.

自定义绘制 widget/window(或其中的一小部分无效)

这通常用于自定义按钮或其他控件、图形等。您可以处理 EVT_PAINTwxPaintEvent) where you can create a DC ("Device Context"). As well as on creation or size changes, you can force a redraw with wxWindow::Refresh or wxWindow::RefreshRect(对于一小部分)。您可以使用计时器来处理。

请注意,性能和功能相当有限。您可以使用 OpenGL 或 Direct3D ,或 wxWidgets 的各种高级库,本机平台 window 句柄可通过 wxWindow::GetHandle.

获得