Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

robwxgl.h

00001 /*
00002  * robwxgl.h
00003  * 
00004  * Copyright (c) 2000-2004 by Florian Fischer (florianfischer@gmx.de)
00005  * and Martin Trautmann (martintrautmann@gmx.de) 
00006  * 
00007  * This file may be distributed and/or modified under the terms of the 
00008  * GNU General Public License version 2 as published by the Free Software 
00009  * Foundation. 
00010  * 
00011  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013  * 
00014  */
00015 
00016 // OpenGL board visualization
00017 
00018 #ifdef __RT_OPENGL__ // You need to enable this to compile OpenGL related stuff
00019 
00020 #ifndef __RT_WXGL_H__
00021 #define __RT_WXGL_H__
00022 
00023 #include "robwxvis.h"
00024 #define NOMINMAX // Windows headers need this, otherwise they will #define min to something!
00025 #include <wx/wx.h>
00026 #include <wx/glcanvas.h>
00027 
00028 class GLFieldPanel : public wxGLCanvas, public FieldDisplay 
00029 {
00030 public:
00031         GLFieldPanel(wxWindow* parent, RobVisFrame* vframe, wxWindowID id);
00032         ~GLFieldPanel();
00033         void EnterSim(const SimInfo& info);
00034         // set status & draw field
00035         void StepSim(const lrt::Vector<BotInfo>& status);
00036         void ExitSim();
00037         // repaint field
00038         void Update(bool force = false); 
00039         bool Show(bool doShow); 
00040         void HandleProgramColourChange();
00041         wxWindow* GetAsWindow(); 
00042 
00043         void SetUseHQ(bool hq) { useHQ = hq; }
00044         bool GetUseHQ() { return useHQ; }
00045 
00046         DECLARE_EVENT_TABLE()
00047 private:
00048         void OnPaint(wxPaintEvent& event);
00049         void OnSize(wxSizeEvent& event);
00050         void OnEraseBackground(wxEraseEvent& event);
00051         void OnKeyDown(wxKeyEvent& event);
00052 
00053         void OnLeftDown(wxMouseEvent& event);
00054         void OnRightDown(wxMouseEvent& event);
00055         void OnLeftUp(wxMouseEvent& event);
00056         void OnRightUp(wxMouseEvent& event);
00057         void OnMouseMotion(wxMouseEvent& event);
00058         void OnMouseWheel(wxMouseEvent& event);
00059         void OnEnterWindow(wxMouseEvent& event);
00060         void OnLeaveWindow(wxMouseEvent& event);
00061 
00062         void InitGL();
00063         void GenLists();
00064         void LoadTextures();
00065         void DrawField(int x, int z, const BotInfo& info);
00066         void MakeGLColour(const wxColour& wc, float factor, float* dest);
00067         int LoadTexture(const wxBitmap& bmp);
00068         void UpdateBigFieldIfNeeded();
00069 
00070         bool glInitDone;
00071         bool useHQ; // high quality setting enabled?
00072         float posDist, angUp, angSide; // camera position
00073         int listBot, listBotHQ, listHead;
00074         void* quadric; // the GLU quadric object
00075 
00076         unsigned int texField, texIset[3];
00077         int listBigField; int lbfX, lbfY;
00078 
00079         SimInfo simInfo;
00080         lrt::Vector<BotInfo> status; 
00081 
00082         wxPoint dragPoint;
00083         bool isClickEvent; // for LeftUp(): if isClickEvent, the user didn't drag while the button was down
00084 
00085         // for click point computation
00086         double fieldModelMatrix[16], projMatrix[16];
00087         int viewport[4];
00088 };
00089 
00090 
00091 #endif // include file
00092 #endif // __RT_OPENGL__ enabled

This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer