Panda3D
Loading...
Searching...
No Matches
osxGraphicsWindow.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file osxGraphicsWindow.h
10 */
11
12#ifndef OSXGRAPHICSWINDOW_H
13#define OSXGRAPHICSWINDOW_H
14
15#include "pandabase.h"
16#include "graphicsWindow.h"
17#include "buttonHandle.h"
18
19#include <Carbon/Carbon.h>
20
21#define __glext_h_
22#include <OpenGL/gl.h>
23#include <AGL/agl.h>
24
25#define HACK_SCREEN_HASH_CONTEXT true
26OSStatus report_agl_error(const std::string &comment);
27
28/**
29 * An interface to the osx/ system for managing GL windows under X.
30 */
32public:
34 const std::string &name,
35 const FrameBufferProperties &fb_prop,
36 const WindowProperties &win_prop,
37 int flags,
39 GraphicsOutput *host);
40 virtual ~osxGraphicsWindow();
41
42 virtual bool move_pointer(int device, int x, int y);
43
44 virtual bool begin_frame(FrameMode mode, Thread *current_thread);
45 virtual void end_frame(FrameMode mode, Thread *current_thread);
46 virtual void begin_flip();
47 virtual void end_flip();
48 virtual void process_events();
49
50 virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
51 int x_size, int y_size);
52
53 virtual void mouse_mode_absolute();
54 virtual void mouse_mode_relative();
55
56 virtual void set_properties_now(WindowProperties &properties);
57
58private:
59 void release_system_resources(bool destructing);
60 inline void send_key_event(ButtonHandle key, bool down);
61
62protected:
63 virtual void close_window();
64 virtual bool open_window();
65
66private:
67 bool os_open_window(WindowProperties &properties);
68
69 // a singleton .. for the events to find the right pipe to push the event
70 // into
71
72public: // do not call direct ..
73 OSStatus handle_key_input(EventHandlerCallRef myHandler, EventRef event,
74 Boolean keyDown);
75 OSStatus handle_text_input(EventHandlerCallRef myHandler, EventRef event);
76 OSStatus handle_window_mouse_events(EventHandlerCallRef myHandler, EventRef event);
77 ButtonHandle osx_translate_key(UInt32 key, EventRef event);
78 static osxGraphicsWindow *get_current_osx_window(WindowRef hint);
79
80 void handle_modifier_delta(UInt32 new_modifiers);
81 void handle_button_delta(UInt32 new_buttons);
82 void do_resize();
83
84 OSStatus event_handler(EventHandlerCallRef myHandler, EventRef event);
85
86 virtual void user_close_request();
87 void system_close_window();
88 void system_set_window_foreground(bool foreground);
89 void system_point_to_local_point(Point &global_point);
90 void local_point_to_system_point(Point &local_point);
91 AGLContext get_gsg_context();
92 AGLContext get_context();
93 OSStatus build_gl(bool full_screen);
94 bool set_icon_filename(const Filename &icon_filename);
95
96 void set_pointer_in_window(int x, int y);
97 void set_pointer_out_of_window();
98
99private:
100 UInt32 _last_key_modifiers;
101 UInt32 _last_buttons;
102 WindowRef _osx_window;
103 bool _is_fullscreen;
104
105 CGImageRef _pending_icon;
106 CGImageRef _current_icon;
107
108 int _ID;
109 static osxGraphicsWindow *full_screen_window;
110
111#ifdef HACK_SCREEN_HASH_CONTEXT
112 AGLContext _holder_aglcontext;
113#endif
114 CFDictionaryRef _originalMode;
115
116 // True if _properties.get_cursor_hidden() is true.
117 bool _cursor_hidden;
118
119 // True if the cursor is actually hidden right now via system calls.
120 bool _display_hide_cursor;
121
122 SInt32 _wheel_hdelta;
123 SInt32 _wheel_vdelta;
124
125public:
126 static TypeHandle get_class_type() {
127 return _type_handle;
128 }
129 static void init_type() {
130 GraphicsWindow::init_type();
131 register_type(_type_handle, "osxGraphicsWindow",
132 GraphicsWindow::get_class_type());
133 }
134 virtual TypeHandle get_type() const {
135 return get_class_type();
136 }
137 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
138
139private:
140 static TypeHandle _type_handle;
141};
142
143#include "osxGraphicsWindow.I"
144
145#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
This class is the main interface to controlling the render process.
This is a base class for the various different classes that represent the result of a frame of render...
An object to create GraphicsOutputs that share a particular 3-D API.
Encapsulates all the communication with a particular instance of a given rendering backend.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
A thread; that is, a lightweight process.
Definition thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An interface to the osx/ system for managing GL windows under X.
virtual void mouse_mode_relative()
detaches mouse.
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 bool move_pointer(int device, int x, int y)
Forces the pointer to the indicated position within the window, if possible.
virtual void mouse_mode_absolute()
reattaches mouse to location
virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin, int x_size, int y_size)
Called from the window thread in response to a request from within the code (via request_properties()...
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 void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...