OpenTTD Source  1.11.0-beta2
cocoa_ogl.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef VIDEO_COCOA_OGL_H
11 #define VIDEO_COCOA_OGL_H
12 
13 #include "cocoa_v.h"
14 
15 @class OTTD_OpenGLView;
16 
18  CGLContextObj gl_context;
19 
20  uint8 *anim_buffer;
21 
22  const char *AllocateContext(bool allow_software);
23 
24 public:
25  VideoDriver_CocoaOpenGL() : gl_context(nullptr), anim_buffer(nullptr) {}
26 
27  const char *Start(const StringList &param) override;
28  void Stop() override;
29 
30  bool HasEfficient8Bpp() const override { return true; }
31 
32  bool UseSystemCursor() override { return true; }
33 
34  void ClearSystemSprites() override;
35 
36  bool HasAnimBuffer() override { return true; }
37  uint8 *GetAnimBuffer() override { return this->anim_buffer; }
38 
40  const char *GetName() const override { return "cocoa-opengl"; }
41 
42  void AllocateBackingStore(bool force = false) override;
43 
44 protected:
45  void Paint() override;
46 
47  void *GetVideoPointer() override;
48  void ReleaseVideoPointer() override;
49 
50  NSView* AllocateDrawView() override;
51 };
52 
54 public:
55  FVideoDriver_CocoaOpenGL() : DriverFactoryBase(Driver::DT_VIDEO, 9, "cocoa-opengl", "Cocoa OpenGL Video Driver") {}
56  Driver *CreateInstance() const override { return new VideoDriver_CocoaOpenGL(); }
57 };
58 
59 #endif /* VIDEO_COCOA_OGL_H */
DriverFactoryBase::DriverFactoryBase
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description)
Construct a new DriverFactory.
Definition: driver.cpp:206
VideoDriver_CocoaOpenGL::Paint
void Paint() override
Paint the window.
cocoa_v.h
VideoDriver_CocoaOpenGL::HasEfficient8Bpp
bool HasEfficient8Bpp() const override
Has this video driver an efficient code path for palette animated 8-bpp sprites?
Definition: cocoa_ogl.h:30
VideoDriver_CocoaOpenGL::UseSystemCursor
bool UseSystemCursor() override
Get whether the mouse cursor is drawn by the video driver.
Definition: cocoa_ogl.h:32
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:58
VideoDriver_CocoaOpenGL::GetVideoPointer
void * GetVideoPointer() override
Get a pointer to the video buffer.
VideoDriver_CocoaOpenGL::HasAnimBuffer
bool HasAnimBuffer() override
Does this video driver support a separate animation buffer in addition to the colour buffer?
Definition: cocoa_ogl.h:36
FVideoDriver_CocoaOpenGL
Definition: cocoa_ogl.h:53
VideoDriver_Cocoa
Definition: cocoa_v.h:23
FVideoDriver_CocoaOpenGL::CreateInstance
Driver * CreateInstance() const override
Create an instance of this driver-class.
Definition: cocoa_ogl.h:56
VideoDriver_CocoaOpenGL::anim_buffer
uint8 * anim_buffer
Animation buffer from OpenGL back-end.
Definition: cocoa_ogl.h:20
VideoDriver_CocoaOpenGL::Start
const char * Start(const StringList &param) override
Start this driver.
Driver::DT_VIDEO
@ DT_VIDEO
A video driver.
Definition: driver.h:44
VideoDriver_CocoaOpenGL
Definition: cocoa_ogl.h:17
VideoDriver_CocoaOpenGL::ClearSystemSprites
void ClearSystemSprites() override
Clear all cached sprites.
Driver
A driver for communicating with the user.
Definition: driver.h:23
VideoDriver_CocoaOpenGL::GetName
const char * GetName() const override
Return driver name.
Definition: cocoa_ogl.h:40
VideoDriver_CocoaOpenGL::ReleaseVideoPointer
void ReleaseVideoPointer() override
Hand video buffer back to the drawing backend.
VideoDriver_CocoaOpenGL::GetAnimBuffer
uint8 * GetAnimBuffer() override
Get a pointer to the animation buffer of the video back-end.
Definition: cocoa_ogl.h:37
VideoDriver_CocoaOpenGL::Stop
void Stop() override
Stop this driver.
DriverFactoryBase
Base for all driver factories.
Definition: driver.h:59