Panda3D
iPhoneGraphicsWindow.h
1 // Filename: iPhoneGraphicsWindow.h
2 // Created by: drose (08Apr09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef IPHONEGRAPHICSWINDOW_H
16 #define IPHONEGRAPHICSWINDOW_H
17 
18 #include "pandabase.h"
19 #include "graphicsWindow.h"
20 #include "buttonHandle.h"
21 #include "glesgsg.h"
22 #import "eaglView.h"
23 
24 #import <UIKit/UIKit.h>
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : IPhoneGraphicsWindow
28 // Description : An interface to the osx/ system for managing GL
29 // windows under X.
30 ////////////////////////////////////////////////////////////////////
32 public:
34  const string &name,
35  const FrameBufferProperties &fb_prop,
36  const WindowProperties &win_prop,
37  int flags,
39  GraphicsOutput *host);
40  virtual ~IPhoneGraphicsWindow();
41 
42  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
43  virtual void end_frame(FrameMode mode, Thread *current_thread);
44  virtual void begin_flip();
45  virtual void end_flip();
46  virtual void process_events();
47 
48  virtual void set_properties_now(WindowProperties &properties);
49  virtual void clear_pipe();
50 
51  void rotate_window();
52  void touches_began(NSSet *touches, UIEvent *event);
53  void touches_moved(NSSet *touches, UIEvent *event);
54  void touches_ended(NSSet *touches, UIEvent *event);
55  void touches_cancelled(NSSet *touches, UIEvent *event);
56 
57  CGPoint get_average_location(NSSet *touches);
58 
59 
60 protected:
61  virtual void close_window();
62  virtual bool open_window();
63 
64 private:
65  void set_pointer_in_window(int x, int y);
66  void set_pointer_out_of_window();
67  void handle_button_delta(int num_touches);
68 
69 private:
70  EAGLView *_gl_view;
71  int _last_buttons;
72 
73 public:
74  static TypeHandle get_class_type() {
75  return _type_handle;
76  }
77  static void init_type() {
78  GraphicsWindow::init_type();
79  register_type(_type_handle, "IPhoneGraphicsWindow",
80  GraphicsWindow::get_class_type());
81  }
82  virtual TypeHandle get_type() const {
83  return get_class_type();
84  }
85  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
86 
87 private:
88  static TypeHandle _type_handle;
89 };
90 
91 #include "iPhoneGraphicsWindow.I"
92 
93 #endif
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame...
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows...
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
This is a base class for the various different classes that represent the result of a frame of render...
An interface to the osx/ system for managing GL windows under X.
A thread; that is, a lightweight process.
Definition: thread.h:51
Encapsulates all the communication with a particular instance of a given rendering backend...
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
virtual void clear_pipe()
Sets the window&#39;s _pipe pointer to NULL; this is generally called only as a precursor to deleting the...
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...