Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing shapes with wxWidgets

I want to learn how to draw shapes with wxWidgets. Where do I start? In case there are multiple ways, I prefer ease of use over cross-platform compatibility. I'm a Windows user.

like image 685
Pieter Avatar asked Nov 21 '25 18:11

Pieter


2 Answers

This is done by creating a wxPanel, connecting to the paint event, and using the DC provided in that paint event to draw various things.

The DC has a number of drawing related functions. This will probably be using Windows GDI or something similar, which means performance probably won't be fantastic, but it should work for simple purposes. You can find a tutorial with sample code on the Wiki. Look for the documentation for the wxDC class to see a list of drawing functions you can use.

If you need something with more performance, look into the wxGLCanvas which renders a hardware accelerated OpenGL canvas.

like image 113
cecilkorik Avatar answered Nov 23 '25 07:11

cecilkorik


I recommend looking at the old OGL library (included in contrib of wx 2.8, but not in the later versions of wx) or wxArt2D. This is simpler than doing it manually, although you can, of course, still do it, after all both of these libraries are implemented in wxWidgets.

like image 38
VZ. Avatar answered Nov 23 '25 07:11

VZ.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!