UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
mac_gl_common.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAC_GL_PROFILE_3_2   1
 
#define MAC_GL_PROFILE_LEGACY   0
 

Typedefs

typedef int mac_opengl_version_t
 

Functions

int get_mac_kernel_version_major (void)
 
void mac_gl_free (void *)
 
void * mac_gl_init (mac_opengl_version_t)
 
void mac_gl_make_current (void *)
 

Detailed Description

Macro Definition Documentation

◆ MAC_GL_PROFILE_3_2

#define MAC_GL_PROFILE_3_2   1

Definition at line 39 of file mac_gl_common.h.

Referenced by init_gl_context(), and mac_gl_init().

◆ MAC_GL_PROFILE_LEGACY

#define MAC_GL_PROFILE_LEGACY   0

Definition at line 38 of file mac_gl_common.h.

Referenced by init_gl_context(), and mac_gl_init().

Typedef Documentation

◆ mac_opengl_version_t

typedef int mac_opengl_version_t

Definition at line 40 of file mac_gl_common.h.

Function Documentation

◆ get_mac_kernel_version_major()

int get_mac_kernel_version_major ( void )

Definition at line 62 of file mac_gl_common.m.

63{
64 int mib[2];
65 size_t len;
66 char *kernelVersion;
67
68 // Get the kernel's version as a string called "kernelVersion":
69 mib[0] = CTL_KERN;
70 mib[1] = KERN_OSRELEASE;
71 sysctl(mib, 2, NULL, &len, NULL, 0);
72 kernelVersion = malloc(len * sizeof(char));
73 sysctl(mib, 2, kernelVersion, &len, NULL, 0);
74
75 return atoi(kernelVersion);
76}
int void size_t * len

References len.

Referenced by init_gl_context(), and mac_gl_init().

◆ mac_gl_free()

void mac_gl_free ( void * state)

Definition at line 157 of file mac_gl_common.m.

158{
159 struct state_mac_gl *s = (struct state_mac_gl *) state;
160
161 [ s->view release ];
162 [ s->autoreleasePool release ];
163 free(s);
164}
void ** state
UltraGridOpenGLView * view
NSAutoreleasePool * autoreleasePool

References state.

Referenced by destroy_gl_context().

◆ mac_gl_init()

void * mac_gl_init ( mac_opengl_version_t ogl_version)

Definition at line 96 of file mac_gl_common.m.

97{
98 struct state_mac_gl *s;
99 NSOpenGLPixelFormatAttribute attrs[3];
100 int mac_version_major;
101
102 mac_version_major = get_mac_kernel_version_major();
103
104 if(ogl_version == MAC_GL_PROFILE_3_2) { /* Lion or later */
105#ifdef __MAC_10_7
106 if(mac_version_major < 11) {
107 fprintf(stderr, "[Mac OpenGL] Unable to activate OpenGL 3.2 for pre-Lion Macs.\n");
108 return NULL;
109 }
110 attrs[0] = kCGLPFAOpenGLProfile;
111 attrs[1] = kCGLOGLPVersion_3_2_Core; // kCGLOGLPVersion_Legacy;
112 attrs[2] = 0;
113#else
114 fprintf(stderr, "[Mac OpenGL] OpenGL 3.2 support was not compiled in! Did you compile with an older Mac?\n");
115 return NULL;
116#endif
117 } else if(ogl_version == MAC_GL_PROFILE_LEGACY) {
118#ifdef __MAC_10_7
119 if(mac_version_major >= 11) {
120 attrs[0] = kCGLPFAOpenGLProfile;
121 attrs[1] = kCGLOGLPVersion_Legacy; // kCGLOGLPVersion_Legacy;
122 attrs[2] = 0;
123 }
124#else
125 attrs[0] = 0;
126#endif
127 }
128
129 s = (struct state_mac_gl *) malloc(sizeof(struct state_mac_gl));
130 s->magic = MAC_GL_MAGIC;
131
132 NSApplicationLoad();
133
134 NSApp = [NSApplication sharedApplication];
135
136 s->autoreleasePool = [[NSAutoreleasePool alloc] init];
137
138 if(mac_version_major >= 11) {
139 s->pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: attrs];
140 } else {
141 s->pixFmt = [NSOpenGLView defaultPixelFormat];
142 }
143
144 if(!s->pixFmt) {
145 fprintf(stderr, "[Mac OpenGL] Failed to acquire pixel format.\n");
146 return NULL;
147 }
148
149 s->view = [[UltraGridOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat: s->pixFmt];
150
151 [ s->view display];
152 [ s->view initialize: s];
153
154 return s;
155}
static af_result_code init(struct module *parent, const char *cfg, void **state)
#define MAC_GL_PROFILE_LEGACY
#define MAC_GL_PROFILE_3_2
int get_mac_kernel_version_major()
#define MAC_GL_MAGIC
static bool initialize(struct vidcap_screen_osx_state *s)
Definition screen_osx.c:108
This struct represents initialized video display state.
NSOpenGLPixelFormat * pixFmt
uint32_t magic

References state_mac_gl::autoreleasePool, get_mac_kernel_version_major(), MAC_GL_MAGIC, MAC_GL_PROFILE_3_2, MAC_GL_PROFILE_LEGACY, state_mac_gl::magic, state_mac_gl::pixFmt, and state_mac_gl::view.

Referenced by init_gl_context().

Here is the call graph for this function:

◆ mac_gl_make_current()

void mac_gl_make_current ( void * state)

Definition at line 166 of file mac_gl_common.m.

167{
168 struct state_mac_gl *s = (struct state_mac_gl *) state;
169
170 if(state) {
171 [s->view->context makeCurrentContext];
172 } else {
173 [NSOpenGLContext clearCurrentContext];
174 }
175}
NSOpenGLContext * context

References state.

Referenced by gl_context_make_current().