Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

12.03.2010, 12:08

wxWidgets + DirectX - Initialisierung ändert wxControl

Ich lasse einen Frame erstellen, in dem ein wxControl initialisiert wird. In diesem Control lasse ich dann D3D9 initialisieren. Rendern usw. klappt, allerdings verkleinert sich das wxControl nach der Initialisierung.

Vorher:

(Link)


Nacher:

(Link)


Header:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Frame : public wxFrame
{
public:
    Frame (wxWindow *parent = NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
    ~Frame (void);

private:
    DECLARE_EVENT_TABLE()
    void OnClose (wxCloseEvent &event);
};

class Control: public wxControl
{
public:
    DECLARE_DYNAMIC_CLASS(Control);
    Control(wxWindow *parent = NULL, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
    ~Control(void);

private:
    DECLARE_EVENT_TABLE()
    void OnClose (wxCloseEvent &event);
    void OnIdle(wxIdleEvent&);
    void OnPaint(wxPaintEvent&);
    void OnEraseBackground(wxEraseEvent&);

private:
    Device* device;
    bool d3dInitialized;
};


cpp:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
IMPLEMENT_DYNAMIC_CLASS(Control, wxControl);

BEGIN_EVENT_TABLE(Frame, wxFrame)
    EVT_CLOSE (Frame::OnClose)
END_EVENT_TABLE()

BEGIN_EVENT_TABLE(Control, wxControl)
    EVT_CLOSE (Control::OnClose)
    EVT_PAINT(Control::OnPaint)
    EVT_ERASE_BACKGROUND(Control::OnEraseBackground)
    EVT_IDLE(Control::OnIdle)
END_EVENT_TABLE()

Frame::Frame (wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, -1,  wxT("Test"), pos, size)
{
    Control* window = new Control(this, wxID_ANY, wxDefaultPosition, size, wxSUNKEN_BORDER);
}

Frame::~Frame (void)
{
}

void Frame::OnClose(wxCloseEvent &event)
{
    Destroy();
}

Control::Control(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
                : wxControl(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE), d3dInitialized(false), device(NULL)
{
}

Control::~Control(void)
{
}

void Control::OnClose(wxCloseEvent &event)
{
    Destroy();
}

void Control::OnIdle(wxIdleEvent&)
{
    Refresh();
}

void Control::OnPaint(wxPaintEvent& event)
{
    wxPaintDC dc(this);

    if (!d3dInitialized)
    {
        d3dInitialized = true;
        device = new D3D9Renderer (800, 600, 32, true, (HWND)GetHandle());
        device->setClearColor (0.9f, 0.5f, 0.1f);
    }

    /*device->startRendering (true, true, false);
    device->stopRendering ();*/
}

void Control::OnEraseBackground(wxEraseEvent&)
{
}

2

12.03.2010, 17:54

War klar, sobald ich poste, finde ich den Fehler, sieht so aus, als müsste ich D3D innerhalb der Control Klasse initialisieren. -.-'