1 /*
2   Copyright 2012-2019 David Robillard <http://drobilla.net>
3 
4   Permission to use, copy, modify, and/or distribute this software for any
5   purpose with or without fee is hereby granted, provided that the above
6   copyright notice and this permission notice appear in all copies.
7 
8   THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16 
17 /**
18    @file pugl_internal_types.h Private platform-independent type definitions.
19 */
20 
21 #ifndef PUGL_INTERNAL_TYPES_H
22 #define PUGL_INTERNAL_TYPES_H
23 
24 #include <stdbool.h>
25 #include <stdint.h>
26 
27 #include "pugl.h"
28 
29 /** Platform-specific internals. */
30 typedef struct PuglInternalsImpl PuglInternals;
31 
32 typedef struct {
33 	int  context_version_major;
34 	int  context_version_minor;
35 	int  red_bits;
36 	int  green_bits;
37 	int  blue_bits;
38 	int  alpha_bits;
39 	int  depth_bits;
40 	int  stencil_bits;
41 	int  samples;
42 	bool use_compat_profile;
43 	bool double_buffer;
44 	bool resizable;
45 } PuglHints;
46 
47 /** Cross-platform view definition. */
48 struct PuglViewImpl {
49 	PuglHandle       handle;
50 	PuglEventFunc    eventFunc;
51 
52 	PuglInternals* impl;
53 
54 	char*            windowClass;
55 	PuglNativeWindow parent;
56 	PuglContextType  ctx_type;
57 	uintptr_t        transient_parent;
58 
59 	PuglHints hints;
60 	int       width;
61 	int       height;
62 	int       min_width;
63 	int       min_height;
64 	int       min_aspect_x;
65 	int       min_aspect_y;
66 	int       max_aspect_x;
67 	int       max_aspect_y;
68 	bool      ignoreKeyRepeat;
69 	bool      redisplay;
70 	bool      visible;
71 };
72 
73 /** Opaque surface used by draw context. */
74 typedef void PuglSurface;
75 
76 /** Drawing context interface. */
77 typedef struct {
78 	/** Get visual information from display and setup view as necessary. */
79 	int (*configure)(PuglView*);
80 
81 	/** Create surface and drawing context. */
82 	int (*create)(PuglView*);
83 
84 	/** Destroy surface and drawing context. */
85 	int (*destroy)(PuglView*);
86 
87 	/** Enter drawing context. */
88 	int (*enter)(PuglView*);
89 
90 	/** Leave drawing context, explicitly flushing if parameter is true. */
91 	int (*leave)(PuglView*, bool);
92 
93 	/** Resize drawing context to the given width and height. */
94 	int (*resize)(PuglView*, int, int);
95 
96 	/** Return the puglGetContext() handle for the application, if any. */
97 	void* (*getHandle)(PuglView*);
98 } PuglDrawContext;
99 
100 #endif // PUGL_INTERNAL_TYPES_H
101