isosurf.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: isosurf.h
  3. // Purpose: wxGLCanvas demo program
  4. // Author: Brian Paul (original gltk version), Wolfram Gloger
  5. // Modified by: Julian Smart
  6. // Created: 04/01/98
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_ISOSURF_H_
  11. #define _WX_ISOSURF_H_
  12. // we need OpenGL headers for GLfloat/GLint types used below
  13. #if defined(__WXMAC__) || defined(__WXCOCOA__)
  14. # ifdef __DARWIN__
  15. # include <OpenGL/gl.h>
  16. # include <OpenGL/glu.h>
  17. # else
  18. # include <gl.h>
  19. # include <glu.h>
  20. # endif
  21. #else
  22. # include <GL/gl.h>
  23. # include <GL/glu.h>
  24. #endif
  25. // the maximum number of vertex in the loaded .dat file
  26. #define MAXVERTS 10000
  27. // Define a new application type
  28. class MyApp : public wxApp
  29. {
  30. public:
  31. virtual bool OnInit();
  32. virtual void OnInitCmdLine(wxCmdLineParser& parser);
  33. virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
  34. };
  35. // The OpenGL-enabled canvas
  36. class TestGLCanvas : public wxGLCanvas
  37. {
  38. public:
  39. TestGLCanvas(wxWindow *parent,
  40. wxWindowID id = wxID_ANY,
  41. int *gl_attrib = NULL);
  42. virtual ~TestGLCanvas();
  43. void OnPaint(wxPaintEvent& event);
  44. void OnSize(wxSizeEvent& event);
  45. void OnChar(wxKeyEvent& event);
  46. void OnMouseEvent(wxMouseEvent& event);
  47. void LoadSurface(const wxString& filename);
  48. void InitMaterials();
  49. void InitGL();
  50. private:
  51. wxGLContext* m_glRC;
  52. GLfloat m_verts[MAXVERTS][3];
  53. GLfloat m_norms[MAXVERTS][3];
  54. GLint m_numverts;
  55. GLfloat m_xrot;
  56. GLfloat m_yrot;
  57. wxDECLARE_NO_COPY_CLASS(TestGLCanvas);
  58. wxDECLARE_EVENT_TABLE();
  59. };
  60. // The frame containing the GL canvas
  61. class MyFrame : public wxFrame
  62. {
  63. public:
  64. MyFrame(wxFrame *frame,
  65. const wxString& title,
  66. const wxPoint& pos = wxDefaultPosition,
  67. const wxSize& size = wxDefaultSize,
  68. long style = wxDEFAULT_FRAME_STYLE);
  69. virtual ~MyFrame();
  70. TestGLCanvas *m_canvas;
  71. private :
  72. void OnExit(wxCommandEvent& event);
  73. wxDECLARE_EVENT_TABLE();
  74. };
  75. #endif // _WX_ISOSURF_H_