aboutsummaryrefslogtreecommitdiff
path: root/miniLibX/mlx_opengl.m
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-11-15 15:18:38 +0100
committerCharles <sircharlesaze@gmail.com>2019-11-15 15:18:38 +0100
commita4fd7a681376899526cfe38c0449f90feb0f582e (patch)
tree1cf4a074b36903a025652a6ef1ae55e280b6418c /miniLibX/mlx_opengl.m
parent9e1f4605408821b74c9e74216fbf995d29a3921c (diff)
downloadcub3d-a4fd7a681376899526cfe38c0449f90feb0f582e.tar.gz
cub3d-a4fd7a681376899526cfe38c0449f90feb0f582e.tar.bz2
cub3d-a4fd7a681376899526cfe38c0449f90feb0f582e.zip
Added miniLibX man pages
Diffstat (limited to 'miniLibX/mlx_opengl.m')
-rw-r--r--miniLibX/mlx_opengl.m57
1 files changed, 57 insertions, 0 deletions
diff --git a/miniLibX/mlx_opengl.m b/miniLibX/mlx_opengl.m
new file mode 100644
index 0000000..554d79b
--- /dev/null
+++ b/miniLibX/mlx_opengl.m
@@ -0,0 +1,57 @@
+// mlx_opengl.m
+
+#import <Cocoa/Cocoa.h>
+#import <OpenGL/gl3.h>
+#import <AppKit/NSOpenGLView.h>
+
+#include <stdio.h>
+
+#include "mlx_int.h"
+#include "mlx_new_window.h"
+
+
+
+
+
+NSOpenGLPixelFormatAttribute pfa_attrs_opengl[] =
+ {
+ NSOpenGLPFADepthSize, 32,
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,
+ 0
+ };
+
+
+
+void *mlx_new_opengl_window(mlx_ptr_t *mlx_ptr, int size_x, int size_y, char *title)
+{
+ mlx_win_list_t *newwin;
+ NSString *str;
+
+ if ((newwin = malloc(sizeof(*newwin))) == NULL)
+ return ((void *)0);
+ newwin->img_list = NULL;
+ newwin->next = mlx_ptr->win_list;
+ newwin->nb_flush = 0;
+ newwin->pixmgt = 0;
+ mlx_ptr->win_list = newwin;
+
+ NSRect windowRect = NSMakeRect(100, 100, size_x, size_y);
+ str = [NSString stringWithCString:title encoding:NSASCIIStringEncoding];
+ newwin->winid = [[MlxWin alloc] initWithRect:windowRect andTitle:str pfaAttrs:pfa_attrs_opengl];
+
+ return ((void *)newwin);
+}
+
+
+int mlx_opengl_swap_buffers(mlx_win_list_t *win_ptr)
+{
+ [(id)(win_ptr->winid) flushGLContext];
+ return (0);
+}
+
+int mlx_opengl_window_set_context(mlx_win_list_t *win_ptr)
+{
+ [(id)(win_ptr->winid) selectGLContext];
+ return (0);
+}