windows port initial commit: simple window with GL 4.3 context
This commit is contained in:
parent
7f62938f84
commit
2421871c3e
|
@ -1,3 +1,9 @@
|
|||
.DS_Store
|
||||
bin/*
|
||||
*.metallib
|
||||
*.metallib
|
||||
|
||||
*.pdb
|
||||
*.exe
|
||||
*.ilk
|
||||
*.vs
|
||||
*.obj
|
|
@ -0,0 +1,3 @@
|
|||
set INCLUDES=/I ..\..\src /I ..\..\src\util /I ..\..\src\platform /I ../../ext
|
||||
|
||||
cl main.c %INCLUDES% /Zi /Zc:preprocessor /std:c11 /link user32.lib opengl32.lib gdi32.lib /out:test.exe
|
|
@ -0,0 +1,80 @@
|
|||
/************************************************************//**
|
||||
*
|
||||
* @file: main.cpp
|
||||
* @author: Martin Fouilleul
|
||||
* @date: 30/07/2022
|
||||
* @revision:
|
||||
*
|
||||
*****************************************************************/
|
||||
#include<stdlib.h>
|
||||
#include<string.h>
|
||||
|
||||
#include"win32_app.c"
|
||||
#include"debug_log.c"
|
||||
#include"memory.c"
|
||||
#include"strings.c"
|
||||
|
||||
|
||||
#include"ringbuffer.c"
|
||||
#include"win32_base_allocator.c"
|
||||
#include"utf8.c"
|
||||
|
||||
#define MG_IMPLEMENTS_BACKEND_GL
|
||||
#include"graphics.c"
|
||||
#include"win32_gl_surface.c"
|
||||
|
||||
//#define LOG_SUBSYSTEM "Main"
|
||||
|
||||
int main()
|
||||
{
|
||||
LogLevel(LOG_LEVEL_DEBUG);
|
||||
|
||||
mp_init();
|
||||
|
||||
mp_rect rect = {.x = 100, .y = 100, .w = 800, .h = 600};
|
||||
mp_window window = mp_window_create(rect, "test", 0);
|
||||
//TODO: create surface
|
||||
mg_surface surface = mg_surface_create_for_window(window, MG_BACKEND_GL);
|
||||
|
||||
mp_window_bring_to_front_and_focus(window);
|
||||
|
||||
while(!mp_should_quit())
|
||||
{
|
||||
mp_pump_events(0);
|
||||
mp_event event = {0};
|
||||
while(mp_next_event(&event))
|
||||
{
|
||||
switch(event.type)
|
||||
{
|
||||
case MP_EVENT_KEYBOARD_CHAR:
|
||||
{
|
||||
printf("entered char %s\n", event.character.sequence);
|
||||
} break;
|
||||
|
||||
case MP_EVENT_WINDOW_CLOSE:
|
||||
{
|
||||
mp_do_quit();
|
||||
} break;
|
||||
|
||||
case MP_EVENT_WINDOW_RESIZE:
|
||||
{
|
||||
} break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mg_surface_prepare(surface);
|
||||
|
||||
//DO stuff
|
||||
glClearColor(1, 0, 1, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
mg_surface_present(surface);
|
||||
}
|
||||
|
||||
mp_terminate();
|
||||
|
||||
return(0);
|
||||
}
|
|
@ -0,0 +1,845 @@
|
|||
#ifndef __wgl_wglext_h_
|
||||
#define __wgl_wglext_h_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright 2013-2020 The Khronos Group Inc.
|
||||
** SPDX-License-Identifier: MIT
|
||||
**
|
||||
** This header is generated from the Khronos OpenGL / OpenGL ES XML
|
||||
** API Registry. The current version of the Registry, generator scripts
|
||||
** used to make the header, and the header can be found at
|
||||
** https://github.com/KhronosGroup/OpenGL-Registry
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#define WGL_WGLEXT_VERSION 20220530
|
||||
|
||||
/* Generated C header for:
|
||||
* API: wgl
|
||||
* Versions considered: .*
|
||||
* Versions emitted: _nomatch_^
|
||||
* Default extensions included: wgl
|
||||
* Additional extensions included: _nomatch_^
|
||||
* Extensions removed: _nomatch_^
|
||||
*/
|
||||
|
||||
#ifndef WGL_ARB_buffer_region
|
||||
#define WGL_ARB_buffer_region 1
|
||||
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
|
||||
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
|
||||
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
|
||||
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
|
||||
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
|
||||
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
|
||||
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
|
||||
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
|
||||
VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
|
||||
BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
|
||||
BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
|
||||
#endif
|
||||
#endif /* WGL_ARB_buffer_region */
|
||||
|
||||
#ifndef WGL_ARB_context_flush_control
|
||||
#define WGL_ARB_context_flush_control 1
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#endif /* WGL_ARB_context_flush_control */
|
||||
|
||||
#ifndef WGL_ARB_create_context
|
||||
#define WGL_ARB_create_context 1
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
|
||||
#endif
|
||||
#endif /* WGL_ARB_create_context */
|
||||
|
||||
#ifndef WGL_ARB_create_context_no_error
|
||||
#define WGL_ARB_create_context_no_error 1
|
||||
#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3
|
||||
#endif /* WGL_ARB_create_context_no_error */
|
||||
|
||||
#ifndef WGL_ARB_create_context_profile
|
||||
#define WGL_ARB_create_context_profile 1
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||
#endif /* WGL_ARB_create_context_profile */
|
||||
|
||||
#ifndef WGL_ARB_create_context_robustness
|
||||
#define WGL_ARB_create_context_robustness 1
|
||||
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#endif /* WGL_ARB_create_context_robustness */
|
||||
|
||||
#ifndef WGL_ARB_extensions_string
|
||||
#define WGL_ARB_extensions_string 1
|
||||
typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
const char *WINAPI wglGetExtensionsStringARB (HDC hdc);
|
||||
#endif
|
||||
#endif /* WGL_ARB_extensions_string */
|
||||
|
||||
#ifndef WGL_ARB_framebuffer_sRGB
|
||||
#define WGL_ARB_framebuffer_sRGB 1
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
|
||||
#endif /* WGL_ARB_framebuffer_sRGB */
|
||||
|
||||
#ifndef WGL_ARB_make_current_read
|
||||
#define WGL_ARB_make_current_read 1
|
||||
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
|
||||
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
HDC WINAPI wglGetCurrentReadDCARB (void);
|
||||
#endif
|
||||
#endif /* WGL_ARB_make_current_read */
|
||||
|
||||
#ifndef WGL_ARB_multisample
|
||||
#define WGL_ARB_multisample 1
|
||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
#endif /* WGL_ARB_multisample */
|
||||
|
||||
#ifndef WGL_ARB_pbuffer
|
||||
#define WGL_ARB_pbuffer 1
|
||||
DECLARE_HANDLE(HPBUFFERARB);
|
||||
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
|
||||
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
|
||||
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
|
||||
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
|
||||
#define WGL_PBUFFER_LARGEST_ARB 0x2033
|
||||
#define WGL_PBUFFER_WIDTH_ARB 0x2034
|
||||
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
|
||||
#define WGL_PBUFFER_LOST_ARB 0x2036
|
||||
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
|
||||
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
|
||||
int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
|
||||
BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
|
||||
BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
|
||||
#endif
|
||||
#endif /* WGL_ARB_pbuffer */
|
||||
|
||||
#ifndef WGL_ARB_pixel_format
|
||||
#define WGL_ARB_pixel_format 1
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
||||
#define WGL_ACCELERATION_ARB 0x2003
|
||||
#define WGL_NEED_PALETTE_ARB 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
||||
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
||||
#define WGL_SWAP_METHOD_ARB 0x2007
|
||||
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
||||
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
||||
#define WGL_TRANSPARENT_ARB 0x200A
|
||||
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
||||
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
||||
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
||||
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
||||
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
||||
#define WGL_SHARE_DEPTH_ARB 0x200C
|
||||
#define WGL_SHARE_STENCIL_ARB 0x200D
|
||||
#define WGL_SHARE_ACCUM_ARB 0x200E
|
||||
#define WGL_SUPPORT_GDI_ARB 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||
#define WGL_STEREO_ARB 0x2012
|
||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||
#define WGL_COLOR_BITS_ARB 0x2014
|
||||
#define WGL_RED_BITS_ARB 0x2015
|
||||
#define WGL_RED_SHIFT_ARB 0x2016
|
||||
#define WGL_GREEN_BITS_ARB 0x2017
|
||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||
#define WGL_BLUE_BITS_ARB 0x2019
|
||||
#define WGL_BLUE_SHIFT_ARB 0x201A
|
||||
#define WGL_ALPHA_BITS_ARB 0x201B
|
||||
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
||||
#define WGL_ACCUM_BITS_ARB 0x201D
|
||||
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
||||
#define WGL_SWAP_COPY_ARB 0x2029
|
||||
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
||||
#define WGL_TYPE_RGBA_ARB 0x202B
|
||||
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
|
||||
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
||||
BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
|
||||
BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#endif
|
||||
#endif /* WGL_ARB_pixel_format */
|
||||
|
||||
#ifndef WGL_ARB_pixel_format_float
|
||||
#define WGL_ARB_pixel_format_float 1
|
||||
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
|
||||
#endif /* WGL_ARB_pixel_format_float */
|
||||
|
||||
#ifndef WGL_ARB_render_texture
|
||||
#define WGL_ARB_render_texture 1
|
||||
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
|
||||
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
|
||||
#define WGL_TEXTURE_FORMAT_ARB 0x2072
|
||||
#define WGL_TEXTURE_TARGET_ARB 0x2073
|
||||
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
|
||||
#define WGL_TEXTURE_RGB_ARB 0x2075
|
||||
#define WGL_TEXTURE_RGBA_ARB 0x2076
|
||||
#define WGL_NO_TEXTURE_ARB 0x2077
|
||||
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
|
||||
#define WGL_TEXTURE_1D_ARB 0x2079
|
||||
#define WGL_TEXTURE_2D_ARB 0x207A
|
||||
#define WGL_MIPMAP_LEVEL_ARB 0x207B
|
||||
#define WGL_CUBE_MAP_FACE_ARB 0x207C
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
|
||||
#define WGL_FRONT_LEFT_ARB 0x2083
|
||||
#define WGL_FRONT_RIGHT_ARB 0x2084
|
||||
#define WGL_BACK_LEFT_ARB 0x2085
|
||||
#define WGL_BACK_RIGHT_ARB 0x2086
|
||||
#define WGL_AUX0_ARB 0x2087
|
||||
#define WGL_AUX1_ARB 0x2088
|
||||
#define WGL_AUX2_ARB 0x2089
|
||||
#define WGL_AUX3_ARB 0x208A
|
||||
#define WGL_AUX4_ARB 0x208B
|
||||
#define WGL_AUX5_ARB 0x208C
|
||||
#define WGL_AUX6_ARB 0x208D
|
||||
#define WGL_AUX7_ARB 0x208E
|
||||
#define WGL_AUX8_ARB 0x208F
|
||||
#define WGL_AUX9_ARB 0x2090
|
||||
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
|
||||
#endif
|
||||
#endif /* WGL_ARB_render_texture */
|
||||
|
||||
#ifndef WGL_ARB_robustness_application_isolation
|
||||
#define WGL_ARB_robustness_application_isolation 1
|
||||
#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008
|
||||
#endif /* WGL_ARB_robustness_application_isolation */
|
||||
|
||||
#ifndef WGL_ARB_robustness_share_group_isolation
|
||||
#define WGL_ARB_robustness_share_group_isolation 1
|
||||
#endif /* WGL_ARB_robustness_share_group_isolation */
|
||||
|
||||
#ifndef WGL_3DFX_multisample
|
||||
#define WGL_3DFX_multisample 1
|
||||
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
|
||||
#define WGL_SAMPLES_3DFX 0x2061
|
||||
#endif /* WGL_3DFX_multisample */
|
||||
|
||||
#ifndef WGL_3DL_stereo_control
|
||||
#define WGL_3DL_stereo_control 1
|
||||
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
|
||||
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
|
||||
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
|
||||
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
|
||||
typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
|
||||
#endif
|
||||
#endif /* WGL_3DL_stereo_control */
|
||||
|
||||
#ifndef WGL_AMD_gpu_association
|
||||
#define WGL_AMD_gpu_association 1
|
||||
#define WGL_GPU_VENDOR_AMD 0x1F00
|
||||
#define WGL_GPU_RENDERER_STRING_AMD 0x1F01
|
||||
#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
|
||||
#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
|
||||
#define WGL_GPU_RAM_AMD 0x21A3
|
||||
#define WGL_GPU_CLOCK_AMD 0x21A4
|
||||
#define WGL_GPU_NUM_PIPES_AMD 0x21A5
|
||||
#define WGL_GPU_NUM_SIMD_AMD 0x21A6
|
||||
#define WGL_GPU_NUM_RB_AMD 0x21A7
|
||||
#define WGL_GPU_NUM_SPI_AMD 0x21A8
|
||||
typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
|
||||
typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void *data);
|
||||
typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
|
||||
typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
|
||||
typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
|
||||
typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
|
||||
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
|
||||
INT WINAPI wglGetGPUInfoAMD (UINT id, INT property, GLenum dataType, UINT size, void *data);
|
||||
UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
|
||||
HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
|
||||
HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
|
||||
BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
|
||||
BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
|
||||
HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
|
||||
VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#endif
|
||||
#endif /* WGL_AMD_gpu_association */
|
||||
|
||||
#ifndef WGL_ATI_pixel_format_float
|
||||
#define WGL_ATI_pixel_format_float 1
|
||||
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
|
||||
#endif /* WGL_ATI_pixel_format_float */
|
||||
|
||||
#ifndef WGL_ATI_render_texture_rectangle
|
||||
#define WGL_ATI_render_texture_rectangle 1
|
||||
#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5
|
||||
#endif /* WGL_ATI_render_texture_rectangle */
|
||||
|
||||
#ifndef WGL_EXT_colorspace
|
||||
#define WGL_EXT_colorspace 1
|
||||
#define WGL_COLORSPACE_EXT 0x309D
|
||||
#define WGL_COLORSPACE_SRGB_EXT 0x3089
|
||||
#define WGL_COLORSPACE_LINEAR_EXT 0x308A
|
||||
#endif /* WGL_EXT_colorspace */
|
||||
|
||||
#ifndef WGL_EXT_create_context_es2_profile
|
||||
#define WGL_EXT_create_context_es2_profile 1
|
||||
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||
#endif /* WGL_EXT_create_context_es2_profile */
|
||||
|
||||
#ifndef WGL_EXT_create_context_es_profile
|
||||
#define WGL_EXT_create_context_es_profile 1
|
||||
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
|
||||
#endif /* WGL_EXT_create_context_es_profile */
|
||||
|
||||
#ifndef WGL_EXT_depth_float
|
||||
#define WGL_EXT_depth_float 1
|
||||
#define WGL_DEPTH_FLOAT_EXT 0x2040
|
||||
#endif /* WGL_EXT_depth_float */
|
||||
|
||||
#ifndef WGL_EXT_display_color_table
|
||||
#define WGL_EXT_display_color_table 1
|
||||
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
|
||||
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
|
||||
GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
|
||||
GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
|
||||
VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
|
||||
#endif
|
||||
#endif /* WGL_EXT_display_color_table */
|
||||
|
||||
#ifndef WGL_EXT_extensions_string
|
||||
#define WGL_EXT_extensions_string 1
|
||||
typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
const char *WINAPI wglGetExtensionsStringEXT (void);
|
||||
#endif
|
||||
#endif /* WGL_EXT_extensions_string */
|
||||
|
||||
#ifndef WGL_EXT_framebuffer_sRGB
|
||||
#define WGL_EXT_framebuffer_sRGB 1
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
|
||||
#endif /* WGL_EXT_framebuffer_sRGB */
|
||||
|
||||
#ifndef WGL_EXT_make_current_read
|
||||
#define WGL_EXT_make_current_read 1
|
||||
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
|
||||
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
HDC WINAPI wglGetCurrentReadDCEXT (void);
|
||||
#endif
|
||||
#endif /* WGL_EXT_make_current_read */
|
||||
|
||||
#ifndef WGL_EXT_multisample
|
||||
#define WGL_EXT_multisample 1
|
||||
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
|
||||
#define WGL_SAMPLES_EXT 0x2042
|
||||
#endif /* WGL_EXT_multisample */
|
||||
|
||||
#ifndef WGL_EXT_pbuffer
|
||||
#define WGL_EXT_pbuffer 1
|
||||
DECLARE_HANDLE(HPBUFFEREXT);
|
||||
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
|
||||
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
|
||||
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
|
||||
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
|
||||
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
|
||||
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
|
||||
#define WGL_PBUFFER_LARGEST_EXT 0x2033
|
||||
#define WGL_PBUFFER_WIDTH_EXT 0x2034
|
||||
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
|
||||
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
|
||||
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
|
||||
int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
|
||||
BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
|
||||
BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
|
||||
#endif
|
||||
#endif /* WGL_EXT_pbuffer */
|
||||
|
||||
#ifndef WGL_EXT_pixel_format
|
||||
#define WGL_EXT_pixel_format 1
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
|
||||
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
|
||||
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
|
||||
#define WGL_ACCELERATION_EXT 0x2003
|
||||
#define WGL_NEED_PALETTE_EXT 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
|
||||
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
|
||||
#define WGL_SWAP_METHOD_EXT 0x2007
|
||||
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
|
||||
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
|
||||
#define WGL_TRANSPARENT_EXT 0x200A
|
||||
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
|
||||
#define WGL_SHARE_DEPTH_EXT 0x200C
|
||||
#define WGL_SHARE_STENCIL_EXT 0x200D
|
||||
#define WGL_SHARE_ACCUM_EXT 0x200E
|
||||
#define WGL_SUPPORT_GDI_EXT 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_EXT 0x2010
|
||||
#define WGL_DOUBLE_BUFFER_EXT 0x2011
|
||||
#define WGL_STEREO_EXT 0x2012
|
||||
#define WGL_PIXEL_TYPE_EXT 0x2013
|
||||
#define WGL_COLOR_BITS_EXT 0x2014
|
||||
#define WGL_RED_BITS_EXT 0x2015
|
||||
#define WGL_RED_SHIFT_EXT 0x2016
|
||||
#define WGL_GREEN_BITS_EXT 0x2017
|
||||
#define WGL_GREEN_SHIFT_EXT 0x2018
|
||||
#define WGL_BLUE_BITS_EXT 0x2019
|
||||
#define WGL_BLUE_SHIFT_EXT 0x201A
|
||||
#define WGL_ALPHA_BITS_EXT 0x201B
|
||||
#define WGL_ALPHA_SHIFT_EXT 0x201C
|
||||
#define WGL_ACCUM_BITS_EXT 0x201D
|
||||
#define WGL_ACCUM_RED_BITS_EXT 0x201E
|
||||
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
|
||||
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
|
||||
#define WGL_DEPTH_BITS_EXT 0x2022
|
||||
#define WGL_STENCIL_BITS_EXT 0x2023
|
||||
#define WGL_AUX_BUFFERS_EXT 0x2024
|
||||
#define WGL_NO_ACCELERATION_EXT 0x2025
|
||||
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
|
||||
#define WGL_FULL_ACCELERATION_EXT 0x2027
|
||||
#define WGL_SWAP_EXCHANGE_EXT 0x2028
|
||||
#define WGL_SWAP_COPY_EXT 0x2029
|
||||
#define WGL_SWAP_UNDEFINED_EXT 0x202A
|
||||
#define WGL_TYPE_RGBA_EXT 0x202B
|
||||
#define WGL_TYPE_COLORINDEX_EXT 0x202C
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
|
||||
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
|
||||
BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
|
||||
BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#endif
|
||||
#endif /* WGL_EXT_pixel_format */
|
||||
|
||||
#ifndef WGL_EXT_pixel_format_packed_float
|
||||
#define WGL_EXT_pixel_format_packed_float 1
|
||||
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
|
||||
#endif /* WGL_EXT_pixel_format_packed_float */
|
||||
|
||||
#ifndef WGL_EXT_swap_control
|
||||
#define WGL_EXT_swap_control 1
|
||||
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
|
||||
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglSwapIntervalEXT (int interval);
|
||||
int WINAPI wglGetSwapIntervalEXT (void);
|
||||
#endif
|
||||
#endif /* WGL_EXT_swap_control */
|
||||
|
||||
#ifndef WGL_EXT_swap_control_tear
|
||||
#define WGL_EXT_swap_control_tear 1
|
||||
#endif /* WGL_EXT_swap_control_tear */
|
||||
|
||||
#ifndef WGL_I3D_digital_video_control
|
||||
#define WGL_I3D_digital_video_control 1
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
|
||||
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
|
||||
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
|
||||
BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
|
||||
#endif
|
||||
#endif /* WGL_I3D_digital_video_control */
|
||||
|
||||
#ifndef WGL_I3D_gamma
|
||||
#define WGL_I3D_gamma 1
|
||||
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
|
||||
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
|
||||
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
|
||||
BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
|
||||
BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
|
||||
BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
|
||||
#endif
|
||||
#endif /* WGL_I3D_gamma */
|
||||
|
||||
#ifndef WGL_I3D_genlock
|
||||
#define WGL_I3D_genlock 1
|
||||
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
|
||||
#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045
|
||||
#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046
|
||||
#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047
|
||||
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
|
||||
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
|
||||
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
|
||||
BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
|
||||
BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
|
||||
BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
|
||||
BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
|
||||
BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
|
||||
BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
|
||||
BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
|
||||
BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
|
||||
BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
|
||||
BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
|
||||
BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
|
||||
#endif
|
||||
#endif /* WGL_I3D_genlock */
|
||||
|
||||
#ifndef WGL_I3D_image_buffer
|
||||
#define WGL_I3D_image_buffer 1
|
||||
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
|
||||
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
|
||||
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
|
||||
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
|
||||
BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
|
||||
BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
|
||||
BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
|
||||
#endif
|
||||
#endif /* WGL_I3D_image_buffer */
|
||||
|
||||
#ifndef WGL_I3D_swap_frame_lock
|
||||
#define WGL_I3D_swap_frame_lock 1
|
||||
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglEnableFrameLockI3D (void);
|
||||
BOOL WINAPI wglDisableFrameLockI3D (void);
|
||||
BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
|
||||
BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
|
||||
#endif
|
||||
#endif /* WGL_I3D_swap_frame_lock */
|
||||
|
||||
#ifndef WGL_I3D_swap_frame_usage
|
||||
#define WGL_I3D_swap_frame_usage 1
|
||||
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
|
||||
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
|
||||
BOOL WINAPI wglBeginFrameTrackingI3D (void);
|
||||
BOOL WINAPI wglEndFrameTrackingI3D (void);
|
||||
BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
|
||||
#endif
|
||||
#endif /* WGL_I3D_swap_frame_usage */
|
||||
|
||||
#ifndef WGL_NV_DX_interop
|
||||
#define WGL_NV_DX_interop 1
|
||||
#define WGL_ACCESS_READ_ONLY_NV 0x00000000
|
||||
#define WGL_ACCESS_READ_WRITE_NV 0x00000001
|
||||
#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002
|
||||
typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
|
||||
typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
|
||||
typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
|
||||
typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
|
||||
typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
|
||||
typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
|
||||
HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
|
||||
BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
|
||||
HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
|
||||
BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
|
||||
BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
|
||||
BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
#endif
|
||||
#endif /* WGL_NV_DX_interop */
|
||||
|
||||
#ifndef WGL_NV_DX_interop2
|
||||
#define WGL_NV_DX_interop2 1
|
||||
#endif /* WGL_NV_DX_interop2 */
|
||||
|
||||
#ifndef WGL_NV_copy_image
|
||||
#define WGL_NV_copy_image 1
|
||||
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#endif
|
||||
#endif /* WGL_NV_copy_image */
|
||||
|
||||
#ifndef WGL_NV_delay_before_swap
|
||||
#define WGL_NV_delay_before_swap 1
|
||||
typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds);
|
||||
#endif
|
||||
#endif /* WGL_NV_delay_before_swap */
|
||||
|
||||
#ifndef WGL_NV_float_buffer
|
||||
#define WGL_NV_float_buffer 1
|
||||
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
|
||||
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
|
||||
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
|
||||
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
|
||||
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
|
||||
#endif /* WGL_NV_float_buffer */
|
||||
|
||||
#ifndef WGL_NV_gpu_affinity
|
||||
#define WGL_NV_gpu_affinity 1
|
||||
DECLARE_HANDLE(HGPUNV);
|
||||
struct _GPU_DEVICE {
|
||||
DWORD cb;
|
||||
CHAR DeviceName[32];
|
||||
CHAR DeviceString[128];
|
||||
DWORD Flags;
|
||||
RECT rcVirtualScreen;
|
||||
};
|
||||
typedef struct _GPU_DEVICE *PGPU_DEVICE;
|
||||
#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
|
||||
#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
|
||||
typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
|
||||
typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
|
||||
BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
|
||||
HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
|
||||
BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
|
||||
BOOL WINAPI wglDeleteDCNV (HDC hdc);
|
||||
#endif
|
||||
#endif /* WGL_NV_gpu_affinity */
|
||||
|
||||
#ifndef WGL_NV_multigpu_context
|
||||
#define WGL_NV_multigpu_context 1
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_NV 0x20AA
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_SINGLE_NV 0x20AB
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_AFR_NV 0x20AC
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTICAST_NV 0x20AD
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTI_DISPLAY_MULTICAST_NV 0x20AE
|
||||
#endif /* WGL_NV_multigpu_context */
|
||||
|
||||
#ifndef WGL_NV_multisample_coverage
|
||||
#define WGL_NV_multisample_coverage 1
|
||||
#define WGL_COVERAGE_SAMPLES_NV 0x2042
|
||||
#define WGL_COLOR_SAMPLES_NV 0x20B9
|
||||
#endif /* WGL_NV_multisample_coverage */
|
||||
|
||||
#ifndef WGL_NV_present_video
|
||||
#define WGL_NV_present_video 1
|
||||
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
|
||||
#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
|
||||
typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
int WINAPI wglEnumerateVideoDevicesNV (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList);
|
||||
BOOL WINAPI wglBindVideoDeviceNV (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
|
||||
BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
|
||||
#endif
|
||||
#endif /* WGL_NV_present_video */
|
||||
|
||||
#ifndef WGL_NV_render_depth_texture
|
||||
#define WGL_NV_render_depth_texture 1
|
||||
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
|
||||
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
|
||||
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
|
||||
#define WGL_DEPTH_COMPONENT_NV 0x20A7
|
||||
#endif /* WGL_NV_render_depth_texture */
|
||||
|
||||
#ifndef WGL_NV_render_texture_rectangle
|
||||
#define WGL_NV_render_texture_rectangle 1
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
|
||||
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
|
||||
#endif /* WGL_NV_render_texture_rectangle */
|
||||
|
||||
#ifndef WGL_NV_swap_group
|
||||
#define WGL_NV_swap_group 1
|
||||
typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
|
||||
typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
|
||||
BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
|
||||
BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
|
||||
BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
|
||||
BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
|
||||
BOOL WINAPI wglResetFrameCountNV (HDC hDC);
|
||||
#endif
|
||||
#endif /* WGL_NV_swap_group */
|
||||
|
||||
#ifndef WGL_NV_vertex_array_range
|
||||
#define WGL_NV_vertex_array_range 1
|
||||
typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
|
||||
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
|
||||
void WINAPI wglFreeMemoryNV (void *pointer);
|
||||
#endif
|
||||
#endif /* WGL_NV_vertex_array_range */
|
||||
|
||||
#ifndef WGL_NV_video_capture
|
||||
#define WGL_NV_video_capture 1
|
||||
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
|
||||
#define WGL_UNIQUE_ID_NV 0x20CE
|
||||
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
|
||||
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
|
||||
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
|
||||
UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
|
||||
BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
|
||||
BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
#endif
|
||||
#endif /* WGL_NV_video_capture */
|
||||
|
||||
#ifndef WGL_NV_video_output
|
||||
#define WGL_NV_video_output 1
|
||||
DECLARE_HANDLE(HPVIDEODEV);
|
||||
#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0
|
||||
#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1
|
||||
#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
|
||||
#define WGL_VIDEO_OUT_COLOR_NV 0x20C3
|
||||
#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4
|
||||
#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5
|
||||
#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
|
||||
#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
|
||||
#define WGL_VIDEO_OUT_FRAME 0x20C8
|
||||
#define WGL_VIDEO_OUT_FIELD_1 0x20C9
|
||||
#define WGL_VIDEO_OUT_FIELD_2 0x20CA
|
||||
#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
|
||||
#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
|
||||
typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
|
||||
typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
|
||||
BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
|
||||
BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
|
||||
BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||
#endif
|
||||
#endif /* WGL_NV_video_output */
|
||||
|
||||
#ifndef WGL_OML_sync_control
|
||||
#define WGL_OML_sync_control 1
|
||||
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
|
||||
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
|
||||
INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
#endif
|
||||
#endif /* WGL_OML_sync_control */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -6,6 +6,8 @@
|
|||
* @revision:
|
||||
*
|
||||
*****************************************************************/
|
||||
|
||||
#define _USE_MATH_DEFINES //NOTE: necessary for MSVC
|
||||
#include<math.h>
|
||||
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
|
@ -121,8 +123,11 @@ typedef struct mg_glyph_info
|
|||
|
||||
} mg_glyph_info;
|
||||
|
||||
const u32 MG_STREAM_MAX_COUNT = 128;
|
||||
const u32 MG_IMAGE_MAX_COUNT = 128;
|
||||
enum
|
||||
{
|
||||
MG_STREAM_MAX_COUNT = 128,
|
||||
MG_IMAGE_MAX_COUNT = 128
|
||||
};
|
||||
|
||||
typedef struct mg_stream_data
|
||||
{
|
||||
|
@ -147,10 +152,13 @@ typedef struct mg_image_data
|
|||
|
||||
} mg_image_data;
|
||||
|
||||
const u32 MG_MATRIX_STACK_MAX_DEPTH = 64;
|
||||
const u32 MG_CLIP_STACK_MAX_DEPTH = 64;
|
||||
const u32 MG_MAX_PATH_ELEMENT_COUNT = 2<<20;
|
||||
const u32 MG_MAX_PRIMITIVE_COUNT = 8<<10;
|
||||
enum
|
||||
{
|
||||
MG_MATRIX_STACK_MAX_DEPTH = 64,
|
||||
MG_CLIP_STACK_MAX_DEPTH = 64,
|
||||
MG_MAX_PATH_ELEMENT_COUNT = 2<<20,
|
||||
MG_MAX_PRIMITIVE_COUNT = 8<<10
|
||||
};
|
||||
|
||||
typedef struct mg_canvas_data
|
||||
{
|
||||
|
@ -219,9 +227,12 @@ typedef struct mg_font_info
|
|||
// internal handle system
|
||||
//---------------------------------------------------------------
|
||||
|
||||
const u32 MG_MAX_RESOURCE_SLOTS = 256,
|
||||
MG_MAX_CONTEXTS = 256,
|
||||
MG_FONT_MAX_COUNT = 256;
|
||||
enum
|
||||
{
|
||||
MG_MAX_RESOURCE_SLOTS = 128,
|
||||
MG_MAX_CONTEXTS = 32,
|
||||
MG_FONT_MAX_COUNT = 128
|
||||
};
|
||||
|
||||
typedef struct mg_resource_slot
|
||||
{
|
||||
|
@ -531,6 +542,11 @@ mg_image_data* mg_image_ptr_from_handle(mg_canvas_data* context, mg_image handle
|
|||
mg_surface_server mg_gles_surface_create_server(mg_surface_info* surface);
|
||||
#endif //MG_IMPLEMENTS_BACKEND_GLES
|
||||
|
||||
#ifdef MG_IMPLEMENTS_BACKEND_GL
|
||||
mg_surface mg_gl_surface_create_for_window(mp_window window);
|
||||
//TODO for view
|
||||
#endif
|
||||
|
||||
void mg_init();
|
||||
|
||||
mg_surface mg_surface_create_for_window(mp_window window, mg_backend_id backend)
|
||||
|
@ -547,6 +563,11 @@ mg_surface mg_surface_create_for_window(mp_window window, mg_backend_id backend)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MG_IMPLEMENTS_BACKEND_GL
|
||||
case MG_BACKEND_GL:
|
||||
surface = mg_gl_surface_create_for_window(window);
|
||||
break;
|
||||
#endif
|
||||
//...
|
||||
|
||||
default:
|
||||
|
@ -675,7 +696,7 @@ void mg_surface_set_hidden(mg_surface surface, bool hidden)
|
|||
vec2 mg_surface_size(mg_surface surface)
|
||||
{
|
||||
DEBUG_ASSERT(__mgInfo.init);
|
||||
vec2 res = {};
|
||||
vec2 res = {0};
|
||||
mg_surface_info* surfaceInfo = mg_surface_ptr_from_handle(surface);
|
||||
if(surfaceInfo)
|
||||
{
|
||||
|
@ -688,12 +709,14 @@ vec2 mg_surface_size(mg_surface surface)
|
|||
// graphics surface server
|
||||
//---------------------------------------------------------------
|
||||
|
||||
/*
|
||||
mg_surface_server mg_gles_surface_server_create_native(void* p);
|
||||
|
||||
mg_surface_server mg_surface_server_create_native(void* p)
|
||||
{
|
||||
return(mg_gles_surface_server_create_native(p));
|
||||
}
|
||||
*/
|
||||
|
||||
mg_surface_server mg_surface_server_create(mg_surface surface)
|
||||
{
|
||||
|
@ -704,10 +727,11 @@ mg_surface_server mg_surface_server_create(mg_surface surface)
|
|||
{
|
||||
switch(surfaceInfo->backend)
|
||||
{
|
||||
#ifdef MG_IMPLEMENTS_BACKEND_GLES
|
||||
case MG_BACKEND_GLES:
|
||||
server = mg_gles_surface_create_server(surfaceInfo);
|
||||
break;
|
||||
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -743,6 +767,7 @@ mg_surface_server_id mg_surface_server_get_id(mg_surface_server server)
|
|||
//---------------------------------------------------------------
|
||||
|
||||
//TODO: move elsewhere, guard with OS ifdef
|
||||
#ifdef __APPLE__
|
||||
mg_surface_client mg_osx_surface_client_create(mg_surface_server_id id);
|
||||
|
||||
mg_surface_client mg_surface_client_create(mg_surface_server_id id)
|
||||
|
@ -753,6 +778,8 @@ mg_surface_client mg_surface_client_create(mg_surface_server_id id)
|
|||
return(client);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void mg_surface_client_destroy(mg_surface_client handle)
|
||||
{
|
||||
mg_resource_slot* slot = mg_resource_slot_from_handle(&__mgInfo.clients, handle.h);
|
||||
|
@ -2639,8 +2666,10 @@ mg_canvas_painter* mg_canvas_painter_create_for_surface(mg_surface surfaceHandle
|
|||
|
||||
switch(surface->backend)
|
||||
{
|
||||
#ifdef MG_IMPLEMENTS_BACKED_METAL
|
||||
case MG_BACKEND_METAL:
|
||||
return(mg_metal_painter_create_for_surface((mg_metal_surface*)surface, viewPort));
|
||||
#endif
|
||||
|
||||
default:
|
||||
return(0);
|
||||
|
@ -3380,7 +3409,7 @@ str32 mg_font_get_glyph_indices(mg_font font, str32 codePoints, str32 backing)
|
|||
mg_font_info* fontInfo = mg_get_font_info(font);
|
||||
if(!fontInfo)
|
||||
{
|
||||
return((str32){});
|
||||
return((str32){0});
|
||||
}
|
||||
return(mg_font_get_glyph_indices_from_font_info(fontInfo, codePoints, backing));
|
||||
}
|
||||
|
@ -3413,7 +3442,7 @@ mg_font_extents mg_font_get_extents(mg_font font)
|
|||
mg_font_info* fontInfo = mg_get_font_info(font);
|
||||
if(!fontInfo)
|
||||
{
|
||||
return((mg_font_extents){});
|
||||
return((mg_font_extents){0});
|
||||
}
|
||||
return(fontInfo->extents);
|
||||
}
|
||||
|
@ -3423,7 +3452,7 @@ mg_font_extents mg_font_get_scaled_extents(mg_font font, f32 emSize)
|
|||
mg_font_info* fontInfo = mg_get_font_info(font);
|
||||
if(!fontInfo)
|
||||
{
|
||||
return((mg_font_extents){});
|
||||
return((mg_font_extents){0});
|
||||
}
|
||||
f32 scale = emSize/fontInfo->unitsPerEm;
|
||||
mg_font_extents extents = fontInfo->extents;
|
||||
|
@ -3494,13 +3523,13 @@ mp_rect mg_text_bounding_box_utf32(mg_font font, f32 fontSize, str32 codePoints)
|
|||
{
|
||||
if(!codePoints.len || !codePoints.ptr)
|
||||
{
|
||||
return((mp_rect){});
|
||||
return((mp_rect){0});
|
||||
}
|
||||
|
||||
mg_font_info* fontInfo = mg_get_font_info(font);
|
||||
if(!fontInfo)
|
||||
{
|
||||
return((mp_rect){});
|
||||
return((mp_rect){0});
|
||||
}
|
||||
|
||||
mem_arena* scratch = mem_scratch();
|
||||
|
@ -3580,7 +3609,7 @@ mp_rect mg_text_bounding_box(mg_font font, f32 fontSize, str8 text)
|
|||
{
|
||||
if(!text.len || !text.ptr)
|
||||
{
|
||||
return((mp_rect){});
|
||||
return((mp_rect){0});
|
||||
}
|
||||
|
||||
mem_arena* scratch = mem_scratch();
|
||||
|
@ -4027,12 +4056,12 @@ mp_rect mg_glyph_outlines(mg_canvas handle, str32 glyphIndices)
|
|||
mg_canvas_data* context = mg_canvas_ptr_from_handle(handle);
|
||||
if(!context)
|
||||
{
|
||||
return((mp_rect){});
|
||||
return((mp_rect){0});
|
||||
}
|
||||
mg_font_info* fontInfo = mg_get_font_info(context->attributes.font);
|
||||
if(!fontInfo)
|
||||
{
|
||||
return((mp_rect){});
|
||||
return((mp_rect){0});
|
||||
}
|
||||
return(mg_glyph_outlines_from_font_info(context, fontInfo, glyphIndices));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/************************************************************//**
|
||||
/************************************************************//**
|
||||
*
|
||||
* @file: graphics.h
|
||||
* @author: Martin Fouilleul
|
||||
|
@ -23,6 +23,7 @@ typedef struct mg_surface { u64 h; } mg_surface;
|
|||
|
||||
typedef enum { MG_BACKEND_DUMMY,
|
||||
MG_BACKEND_METAL,
|
||||
MG_BACKEND_GL,
|
||||
MG_BACKEND_GLES,
|
||||
//...
|
||||
} mg_backend_id;
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
*
|
||||
*****************************************************************/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include"win32_app.c"
|
||||
|
||||
#else
|
||||
|
||||
#include"osx_app.m"
|
||||
#include"metal_surface.m"
|
||||
#include"metal_painter.m"
|
||||
|
@ -17,3 +23,5 @@
|
|||
#pragma clang diagnostic pop
|
||||
|
||||
#include"osx_surface_client.m"
|
||||
|
||||
#endif
|
||||
|
|
244
src/mp_app.h
244
src/mp_app.h
|
@ -67,131 +67,125 @@ typedef enum { MP_KEY_NO_ACTION,
|
|||
MP_KEY_RELEASE,
|
||||
MP_KEY_REPEAT } mp_key_action;
|
||||
|
||||
typedef i32 mp_key_code;
|
||||
|
||||
static const mp_key_code MP_KEY_UNKNOWN = -1,
|
||||
MP_KEY_SPACE = 32,
|
||||
MP_KEY_APOSTROPHE = 39, // '
|
||||
MP_KEY_COMMA = 44, // ,
|
||||
MP_KEY_MINUS = 45, // -
|
||||
MP_KEY_PERIOD = 46, // .
|
||||
MP_KEY_SLASH = 47, // /
|
||||
MP_KEY_0 = 48,
|
||||
MP_KEY_1 = 49,
|
||||
MP_KEY_2 = 50,
|
||||
MP_KEY_3 = 51,
|
||||
MP_KEY_4 = 52,
|
||||
MP_KEY_5 = 53,
|
||||
MP_KEY_6 = 54,
|
||||
MP_KEY_7 = 55,
|
||||
MP_KEY_8 = 56,
|
||||
MP_KEY_9 = 57,
|
||||
MP_KEY_SEMICOLON = 59, // ;
|
||||
MP_KEY_EQUAL = 61, // =
|
||||
MP_KEY_A = 65,
|
||||
MP_KEY_B = 66,
|
||||
MP_KEY_C = 67,
|
||||
MP_KEY_D = 68,
|
||||
MP_KEY_E = 69,
|
||||
MP_KEY_F = 70,
|
||||
MP_KEY_G = 71,
|
||||
MP_KEY_H = 72,
|
||||
MP_KEY_I = 73,
|
||||
MP_KEY_J = 74,
|
||||
MP_KEY_K = 75,
|
||||
MP_KEY_L = 76,
|
||||
MP_KEY_M = 77,
|
||||
MP_KEY_N = 78,
|
||||
MP_KEY_O = 79,
|
||||
MP_KEY_P = 80,
|
||||
MP_KEY_Q = 81,
|
||||
MP_KEY_R = 82,
|
||||
MP_KEY_S = 83,
|
||||
MP_KEY_T = 84,
|
||||
MP_KEY_U = 85,
|
||||
MP_KEY_V = 86,
|
||||
MP_KEY_W = 87,
|
||||
MP_KEY_X = 88,
|
||||
MP_KEY_Y = 89,
|
||||
MP_KEY_Z = 90,
|
||||
MP_KEY_LEFT_BRACKET = 91, // [
|
||||
MP_KEY_BACKSLASH = 92, // \ */
|
||||
MP_KEY_RIGHT_BRACKET = 93, // ]
|
||||
MP_KEY_GRAVE_ACCENT = 96, // `
|
||||
MP_KEY_WORLD_1 = 161, // non-US #1
|
||||
MP_KEY_WORLD_2 = 162, // non-US #2
|
||||
MP_KEY_ESCAPE = 256,
|
||||
MP_KEY_ENTER = 257,
|
||||
MP_KEY_TAB = 258,
|
||||
MP_KEY_BACKSPACE = 259,
|
||||
MP_KEY_INSERT = 260,
|
||||
MP_KEY_DELETE = 261,
|
||||
MP_KEY_RIGHT = 262,
|
||||
MP_KEY_LEFT = 263,
|
||||
MP_KEY_DOWN = 264,
|
||||
MP_KEY_UP = 265,
|
||||
MP_KEY_PAGE_UP = 266,
|
||||
MP_KEY_PAGE_DOWN = 267,
|
||||
MP_KEY_HOME = 268,
|
||||
MP_KEY_END = 269,
|
||||
MP_KEY_CAPS_LOCK = 280,
|
||||
MP_KEY_SCROLL_LOCK = 281,
|
||||
MP_KEY_NUM_LOCK = 282,
|
||||
MP_KEY_PRINT_SCREEN = 283,
|
||||
MP_KEY_PAUSE = 284,
|
||||
MP_KEY_F1 = 290,
|
||||
MP_KEY_F2 = 291,
|
||||
MP_KEY_F3 = 292,
|
||||
MP_KEY_F4 = 293,
|
||||
MP_KEY_F5 = 294,
|
||||
MP_KEY_F6 = 295,
|
||||
MP_KEY_F7 = 296,
|
||||
MP_KEY_F8 = 297,
|
||||
MP_KEY_F9 = 298,
|
||||
MP_KEY_F10 = 299,
|
||||
MP_KEY_F11 = 300,
|
||||
MP_KEY_F12 = 301,
|
||||
MP_KEY_F13 = 302,
|
||||
MP_KEY_F14 = 303,
|
||||
MP_KEY_F15 = 304,
|
||||
MP_KEY_F16 = 305,
|
||||
MP_KEY_F17 = 306,
|
||||
MP_KEY_F18 = 307,
|
||||
MP_KEY_F19 = 308,
|
||||
MP_KEY_F20 = 309,
|
||||
MP_KEY_F21 = 310,
|
||||
MP_KEY_F22 = 311,
|
||||
MP_KEY_F23 = 312,
|
||||
MP_KEY_F24 = 313,
|
||||
MP_KEY_F25 = 314,
|
||||
MP_KEY_KP_0 = 320,
|
||||
MP_KEY_KP_1 = 321,
|
||||
MP_KEY_KP_2 = 322,
|
||||
MP_KEY_KP_3 = 323,
|
||||
MP_KEY_KP_4 = 324,
|
||||
MP_KEY_KP_5 = 325,
|
||||
MP_KEY_KP_6 = 326,
|
||||
MP_KEY_KP_7 = 327,
|
||||
MP_KEY_KP_8 = 328,
|
||||
MP_KEY_KP_9 = 329,
|
||||
MP_KEY_KP_DECIMAL = 330,
|
||||
MP_KEY_KP_DIVIDE = 331,
|
||||
MP_KEY_KP_MULTIPLY = 332,
|
||||
MP_KEY_KP_SUBTRACT = 333,
|
||||
MP_KEY_KP_ADD = 334,
|
||||
MP_KEY_KP_ENTER = 335,
|
||||
MP_KEY_KP_EQUAL = 336,
|
||||
MP_KEY_LEFT_SHIFT = 340,
|
||||
MP_KEY_LEFT_CONTROL = 341,
|
||||
MP_KEY_LEFT_ALT = 342,
|
||||
MP_KEY_LEFT_SUPER = 343,
|
||||
MP_KEY_RIGHT_SHIFT = 344,
|
||||
MP_KEY_RIGHT_CONTROL = 345,
|
||||
MP_KEY_RIGHT_ALT = 346,
|
||||
MP_KEY_RIGHT_SUPER = 347,
|
||||
MP_KEY_MENU = 348;
|
||||
|
||||
static const mp_key_code MP_KEY_MAX = MP_KEY_MENU;
|
||||
typedef enum { MP_KEY_UNKNOWN = -1,
|
||||
MP_KEY_MINUS = 45, // -
|
||||
MP_KEY_PERIOD = 46, // .
|
||||
MP_KEY_SLASH = 47, // /
|
||||
MP_KEY_0 = 48,
|
||||
MP_KEY_1 = 49,
|
||||
MP_KEY_2 = 50,
|
||||
MP_KEY_3 = 51,
|
||||
MP_KEY_4 = 52,
|
||||
MP_KEY_5 = 53,
|
||||
MP_KEY_6 = 54,
|
||||
MP_KEY_7 = 55,
|
||||
MP_KEY_8 = 56,
|
||||
MP_KEY_9 = 57,
|
||||
MP_KEY_SEMICOLON = 59, // ;
|
||||
MP_KEY_EQUAL = 61, // =
|
||||
MP_KEY_A = 65,
|
||||
MP_KEY_B = 66,
|
||||
MP_KEY_C = 67,
|
||||
MP_KEY_D = 68,
|
||||
MP_KEY_E = 69,
|
||||
MP_KEY_F = 70,
|
||||
MP_KEY_G = 71,
|
||||
MP_KEY_H = 72,
|
||||
MP_KEY_I = 73,
|
||||
MP_KEY_J = 74,
|
||||
MP_KEY_K = 75,
|
||||
MP_KEY_L = 76,
|
||||
MP_KEY_M = 77,
|
||||
MP_KEY_N = 78,
|
||||
MP_KEY_O = 79,
|
||||
MP_KEY_P = 80,
|
||||
MP_KEY_Q = 81,
|
||||
MP_KEY_R = 82,
|
||||
MP_KEY_S = 83,
|
||||
MP_KEY_T = 84,
|
||||
MP_KEY_U = 85,
|
||||
MP_KEY_V = 86,
|
||||
MP_KEY_W = 87,
|
||||
MP_KEY_X = 88,
|
||||
MP_KEY_Y = 89,
|
||||
MP_KEY_Z = 90,
|
||||
MP_KEY_LEFT_BRACKET = 91, // [
|
||||
MP_KEY_BACKSLASH = 92, // \ */
|
||||
MP_KEY_RIGHT_BRACKET = 93, // ]
|
||||
MP_KEY_GRAVE_ACCENT = 96, // `
|
||||
MP_KEY_WORLD_1 = 161, // non-US #1
|
||||
MP_KEY_WORLD_2 = 162, // non-US #2
|
||||
MP_KEY_ESCAPE = 256,
|
||||
MP_KEY_ENTER = 257,
|
||||
MP_KEY_TAB = 258,
|
||||
MP_KEY_BACKSPACE = 259,
|
||||
MP_KEY_INSERT = 260,
|
||||
MP_KEY_DELETE = 261,
|
||||
MP_KEY_RIGHT = 262,
|
||||
MP_KEY_LEFT = 263,
|
||||
MP_KEY_DOWN = 264,
|
||||
MP_KEY_UP = 265,
|
||||
MP_KEY_PAGE_UP = 266,
|
||||
MP_KEY_PAGE_DOWN = 267,
|
||||
MP_KEY_HOME = 268,
|
||||
MP_KEY_END = 269,
|
||||
MP_KEY_CAPS_LOCK = 280,
|
||||
MP_KEY_SCROLL_LOCK = 281,
|
||||
MP_KEY_NUM_LOCK = 282,
|
||||
MP_KEY_PRINT_SCREEN = 283,
|
||||
MP_KEY_PAUSE = 284,
|
||||
MP_KEY_F1 = 290,
|
||||
MP_KEY_F2 = 291,
|
||||
MP_KEY_F3 = 292,
|
||||
MP_KEY_F4 = 293,
|
||||
MP_KEY_F5 = 294,
|
||||
MP_KEY_F6 = 295,
|
||||
MP_KEY_F7 = 296,
|
||||
MP_KEY_F8 = 297,
|
||||
MP_KEY_F9 = 298,
|
||||
MP_KEY_F10 = 299,
|
||||
MP_KEY_F11 = 300,
|
||||
MP_KEY_F12 = 301,
|
||||
MP_KEY_F13 = 302,
|
||||
MP_KEY_F14 = 303,
|
||||
MP_KEY_F15 = 304,
|
||||
MP_KEY_F16 = 305,
|
||||
MP_KEY_F17 = 306,
|
||||
MP_KEY_F18 = 307,
|
||||
MP_KEY_F19 = 308,
|
||||
MP_KEY_F20 = 309,
|
||||
MP_KEY_F21 = 310,
|
||||
MP_KEY_F22 = 311,
|
||||
MP_KEY_F23 = 312,
|
||||
MP_KEY_F24 = 313,
|
||||
MP_KEY_F25 = 314,
|
||||
MP_KEY_KP_0 = 320,
|
||||
MP_KEY_KP_1 = 321,
|
||||
MP_KEY_KP_2 = 322,
|
||||
MP_KEY_KP_3 = 323,
|
||||
MP_KEY_KP_4 = 324,
|
||||
MP_KEY_KP_5 = 325,
|
||||
MP_KEY_KP_6 = 326,
|
||||
MP_KEY_KP_7 = 327,
|
||||
MP_KEY_KP_8 = 328,
|
||||
MP_KEY_KP_9 = 329,
|
||||
MP_KEY_KP_DECIMAL = 330,
|
||||
MP_KEY_KP_DIVIDE = 331,
|
||||
MP_KEY_KP_MULTIPLY = 332,
|
||||
MP_KEY_KP_SUBTRACT = 333,
|
||||
MP_KEY_KP_ADD = 334,
|
||||
MP_KEY_KP_ENTER = 335,
|
||||
MP_KEY_KP_EQUAL = 336,
|
||||
MP_KEY_LEFT_SHIFT = 340,
|
||||
MP_KEY_LEFT_CONTROL = 341,
|
||||
MP_KEY_LEFT_ALT = 342,
|
||||
MP_KEY_LEFT_SUPER = 343,
|
||||
MP_KEY_RIGHT_SHIFT = 344,
|
||||
MP_KEY_RIGHT_CONTROL = 345,
|
||||
MP_KEY_RIGHT_ALT = 346,
|
||||
MP_KEY_RIGHT_SUPER = 347,
|
||||
MP_KEY_MENU = 348,
|
||||
MP_KEY_MAX } mp_key_code;
|
||||
|
||||
typedef u8 mp_key_mods;
|
||||
static const mp_key_mods MP_KEYMOD_NONE = 0x00,
|
||||
|
|
|
@ -2276,6 +2276,9 @@ void mp_run_loop()
|
|||
|
||||
void mp_end_input_frame()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//TODO: make sure we call arena clear once per event frame, even when using runloop etc...
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
__mpAppData.inputState.frameCounter++;
|
||||
mem_arena_clear(&__mpAppData.eventArena);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/************************************************************//**
|
||||
*
|
||||
* @file: win32_base_allocator.c
|
||||
* @author: Martin Fouilleul
|
||||
* @date: 17/12/2022
|
||||
* @revision:
|
||||
*
|
||||
*****************************************************************/
|
||||
#include<windows.h>
|
||||
#include"platform_base_allocator.h"
|
||||
|
||||
void mem_base_nop(void* context, void* ptr, u64 size) {}
|
||||
|
||||
void* mem_base_reserve_win32(void* context, u64 size)
|
||||
{
|
||||
void* result = VirtualAlloc(0, size, MEM_RESERVE, PAGE_READWRITE);
|
||||
return(result);
|
||||
}
|
||||
|
||||
void mem_base_commit_win32(void* context, void* ptr, u64 size)
|
||||
{
|
||||
VirtualAlloc(ptr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
|
||||
void mem_base_release_win32(void* context, void* ptr, u64 size)
|
||||
{
|
||||
VirtualFree(ptr, size, MEM_RELEASE);
|
||||
}
|
||||
|
||||
void mem_base_decommit_win32(void* context, void* ptr, u64 size)
|
||||
{
|
||||
VirtualFree(ptr, size, MEM_DECOMMIT);
|
||||
}
|
||||
|
||||
mem_base_allocator* mem_base_allocator_default()
|
||||
{
|
||||
static mem_base_allocator base = {0};
|
||||
if(base.reserve == 0)
|
||||
{
|
||||
base.reserve = mem_base_reserve_win32;
|
||||
base.commit = mem_base_commit_win32;
|
||||
base.decommit = mem_base_decommit_win32;
|
||||
base.release = mem_base_release_win32;
|
||||
}
|
||||
return(&base);
|
||||
}
|
|
@ -17,14 +17,15 @@ static const char* LOG_HEADINGS[LOG_LEVEL_COUNT] = {
|
|||
"Debug"};
|
||||
|
||||
static const char* LOG_FORMATS[LOG_LEVEL_COUNT] = {
|
||||
"\e[38;5;9m\e[1m",
|
||||
"\e[38;5;13m\e[1m",
|
||||
"\e[38;5;10m\e[1m",
|
||||
"\e[38;5;14m\e[1m" };
|
||||
"\033[38;5;9m\033[1m",
|
||||
"\033[38;5;13m\033[1m",
|
||||
"\033[38;5;10m\033[1m",
|
||||
"\033[38;5;14m\033[1m" };
|
||||
|
||||
static const char* LOG_FORMAT_STOP = "\e[m";
|
||||
static const char* LOG_FORMAT_STOP = "\033[m";
|
||||
|
||||
const int LOG_SUBSYSTEM_MAX_COUNT = 16;
|
||||
enum {
|
||||
LOG_SUBSYSTEM_MAX_COUNT = 16 };
|
||||
|
||||
typedef struct log_config
|
||||
{
|
||||
|
@ -37,8 +38,8 @@ typedef struct log_config
|
|||
|
||||
static log_config __log_config = {.out = 0,
|
||||
.level = LOG_DEFAULT_LEVEL,
|
||||
.subsystemNames = {},
|
||||
.subsystemLevels = {}};
|
||||
.subsystemNames = {0},
|
||||
.subsystemLevels = {0}};
|
||||
|
||||
int LogFindSubsystem(const char* subsystem)
|
||||
{
|
||||
|
|
|
@ -23,9 +23,13 @@ extern "C" {
|
|||
const decltype( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - OFFSET_OF_CONTAINER(type,member) );})
|
||||
#else
|
||||
/*
|
||||
#define CONTAINER_OF(ptr, type, member) ({ \
|
||||
const char *__mptr = (char*)(ptr); \
|
||||
(type *)(__mptr - OFFSET_OF_CONTAINER(type,member) );})
|
||||
*/
|
||||
#define CONTAINER_OF(ptr, type, member) (type *)((char*)(ptr) - OFFSET_OF_CONTAINER(type,member))
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -60,11 +60,8 @@
|
|||
def(u32, ##__VA_ARGS__) def(i32, ##__VA_ARGS__) def(u64, ##__VA_ARGS__) def(i64, ##__VA_ARGS__) \
|
||||
def(f32, ##__VA_ARGS__) def(f64, ##__VA_ARGS__)
|
||||
|
||||
// This macro generates the name of a typed variant
|
||||
#define tga_variant_name(name, type) _cat3_(name, _, type)
|
||||
|
||||
// This macro generates a _Generic association between a type and its variant
|
||||
#define tga_variant_association(type, name) , type: tga_variant_name(name, type)
|
||||
// This macro generates one _Generic association between a type and its variant
|
||||
#define tga_variant_association(type, name) , type: _cat3_(name, _, type)
|
||||
|
||||
// This macros selects the appropriate variant for a 2 parameters functions
|
||||
#define tga_select_binary(name, a, b) \
|
||||
|
@ -75,10 +72,10 @@
|
|||
_Generic((a) tga_generate_variants(tga_variant_association, name))(a)
|
||||
|
||||
//NOTE(martin): type generic templates
|
||||
#define minimum_def(type) static inline type tga_variant_name(minimum_safe, type)(type a, type b) {return(a < b ? a : b);}
|
||||
#define maximum_def(type) static inline type tga_variant_name(maximum_safe, type)(type a, type b) {return(a > b ? a : b);}
|
||||
#define square_def(type) static inline type tga_variant_name(square_safe, type)(type a) {return(a*a);}
|
||||
#define cube_def(type) static inline type tga_variant_name(cube_safe, type)(type a) {return(a*a*a);}
|
||||
#define minimum_def(type) static inline type _cat3_(minimum_safe, _, type)(type a, type b) {return(a < b ? a : b);}
|
||||
#define maximum_def(type) static inline type _cat3_(maximum_safe, _, type)(type a, type b) {return(a > b ? a : b);}
|
||||
#define square_def(type) static inline type _cat3_(square_safe, _, type)(type a) {return(a*a);}
|
||||
#define cube_def(type) static inline type _cat3_(cube_safe, _, type)(type a) {return(a*a*a);}
|
||||
|
||||
//NOTE(martin): instantiante our templates for all arithmetic types
|
||||
tga_generate_variants(minimum_def)
|
||||
|
@ -86,7 +83,7 @@
|
|||
tga_generate_variants(square_def)
|
||||
tga_generate_variants(cube_def)
|
||||
|
||||
//NOTE(martin): select the correct variant according to the argument types
|
||||
//NOTE(martin): generate the _Generic associations between each type and its associated variant
|
||||
#define minimum_safe(a, b) tga_select_binary(minimum_safe, a, b)
|
||||
#define maximum_safe(a, b) tga_select_binary(maximum_safe, a, b)
|
||||
#define square_safe(a) tga_select_unary(square_safe, a)
|
||||
|
|
|
@ -20,7 +20,7 @@ static const u32 MEM_ARENA_COMMIT_ALIGNMENT = 1<<20;
|
|||
//--------------------------------------------------------------------------------
|
||||
void mem_arena_init(mem_arena* arena)
|
||||
{
|
||||
mem_arena_init_with_options(arena, &(mem_arena_options){});
|
||||
mem_arena_init_with_options(arena, &(mem_arena_options){0});
|
||||
}
|
||||
|
||||
void mem_arena_init_with_options(mem_arena* arena, mem_arena_options* options)
|
||||
|
@ -68,7 +68,7 @@ void mem_arena_clear(mem_arena* arena)
|
|||
//--------------------------------------------------------------------------------
|
||||
void mem_pool_init(mem_pool* pool, u64 blockSize)
|
||||
{
|
||||
mem_pool_init_with_options(pool, blockSize, &(mem_pool_options){});
|
||||
mem_pool_init_with_options(pool, blockSize, &(mem_pool_options){0});
|
||||
}
|
||||
void mem_pool_init_with_options(mem_pool* pool, u64 blockSize, mem_pool_options* options)
|
||||
{
|
||||
|
@ -112,7 +112,13 @@ void mem_pool_clear(mem_pool* pool)
|
|||
//NOTE(martin): per-thread scratch arena
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
__thread mem_arena __scratchArena = {};
|
||||
//TODO: move that somewhere in context cracking code
|
||||
#ifdef _WIN32
|
||||
#define __thread __declspec(thread)
|
||||
#endif
|
||||
|
||||
__thread mem_arena __scratchArena = {0};
|
||||
|
||||
|
||||
mem_arena* mem_scratch()
|
||||
{
|
||||
|
|
|
@ -9,9 +9,15 @@
|
|||
#ifndef __RINGBUFFER_H_
|
||||
#define __RINGBUFFER_H_
|
||||
|
||||
#include<stdatomic.h>
|
||||
#include"typedefs.h"
|
||||
|
||||
#if defined(_MSC_VER) && defined(__STDC_NO_ATOMICS__)
|
||||
#define _Atomic(t) volatile t
|
||||
#else
|
||||
#include<stdatomic.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,7 @@ str8 str8_slice(str8 s, u64 start, u64 end)
|
|||
|
||||
str8 str8_push_buffer(mem_arena* arena, u64 len, char* buffer)
|
||||
{
|
||||
str8 str = {};
|
||||
str8 str = {0};
|
||||
str.len = len;
|
||||
str.ptr = mem_arena_alloc_array(arena, char, len);
|
||||
memcpy(str.ptr, buffer, len);
|
||||
|
@ -82,7 +82,7 @@ str8 str8_pushfv(mem_arena* arena, const char* format, va_list args)
|
|||
// and every case, and that would be a difficult bug to spot, so it seems better to
|
||||
// waste one byte and be safe.
|
||||
char dummy;
|
||||
str8 str = {};
|
||||
str8 str = {0};
|
||||
va_list argCopy;
|
||||
va_copy(argCopy, args);
|
||||
str.len = vsnprintf(&dummy, 0, format, argCopy);
|
||||
|
@ -151,7 +151,7 @@ void str8_list_pushf(mem_arena* arena, str8_list* list, const char* format, ...)
|
|||
|
||||
str8 str8_list_collate(mem_arena* arena, str8_list list, str8 prefix, str8 separator, str8 postfix)
|
||||
{
|
||||
str8 str = {};
|
||||
str8 str = {0};
|
||||
str.len = prefix.len + list.len + list.eltCount*separator.len + postfix.len;
|
||||
str.ptr = mem_arena_alloc_array(arena, char, str.len);
|
||||
char* dst = str.ptr;
|
||||
|
@ -185,7 +185,7 @@ str8 str8_list_join(mem_arena* arena, str8_list list)
|
|||
|
||||
str8_list str8_split(mem_arena* arena, str8 str, str8_list separators)
|
||||
{
|
||||
str8_list list = {};
|
||||
str8_list list = {0};
|
||||
ListInit(&list.list);
|
||||
|
||||
char* ptr = str.ptr;
|
||||
|
@ -253,7 +253,7 @@ str32 str32_slice(str32 s, u64 start, u64 end)
|
|||
|
||||
str32 str32_push_buffer(mem_arena* arena, u64 len, u32* buffer)
|
||||
{
|
||||
str32 str = {};
|
||||
str32 str = {0};
|
||||
str.len = len;
|
||||
str.ptr = mem_arena_alloc_array(arena, u32, len);
|
||||
memcpy(str.ptr, buffer, len*sizeof(u32));
|
||||
|
@ -289,7 +289,7 @@ void str32_list_push(mem_arena* arena, str32_list* list, str32 str)
|
|||
|
||||
str32 str32_list_collate(mem_arena* arena, str32_list list, str32 prefix, str32 separator, str32 postfix)
|
||||
{
|
||||
str32 str = {};
|
||||
str32 str = {0};
|
||||
str.len = prefix.len + list.len + list.eltCount*separator.len + postfix.len;
|
||||
str.ptr = mem_arena_alloc_array(arena, u32, str.len);
|
||||
char* dst = (char*)str.ptr;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-----------------------------------------------------------------
|
||||
// utf-8 gore
|
||||
//-----------------------------------------------------------------
|
||||
const u_int32_t offsetsFromUTF8[6] = {
|
||||
const u32 offsetsFromUTF8[6] = {
|
||||
0x00000000UL, 0x00003080UL, 0x000E2080UL,
|
||||
0x03C82080UL, 0xFA082080UL, 0x82082080UL };
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include"typedefs.h"
|
||||
#include"macro_helpers.h"
|
||||
#include"strings.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -0,0 +1,232 @@
|
|||
/************************************************************//**
|
||||
*
|
||||
* @file: win32_app.c
|
||||
* @author: Martin Fouilleul
|
||||
* @date: 16/12/2022
|
||||
* @revision:
|
||||
*
|
||||
*****************************************************************/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include<windows.h>
|
||||
|
||||
#include"win32_app.h"
|
||||
#include"ringbuffer.h"
|
||||
|
||||
#define LOG_SUBSYSTEM "Application"
|
||||
|
||||
|
||||
enum { MP_APP_MAX_WINDOWS = 128 };
|
||||
|
||||
typedef struct mp_app_data
|
||||
{
|
||||
bool init;
|
||||
bool shouldQuit;
|
||||
|
||||
mp_window_data windowPool[MP_APP_MAX_WINDOWS];
|
||||
list_info windowFreeList;
|
||||
|
||||
ringbuffer eventQueue;
|
||||
|
||||
} mp_app_data;
|
||||
|
||||
mp_app_data __mpAppData = {0};
|
||||
|
||||
void mp_init_window_handles()
|
||||
{
|
||||
ListInit(&__mpAppData.windowFreeList);
|
||||
for(int i=0; i<MP_APP_MAX_WINDOWS; i++)
|
||||
{
|
||||
__mpAppData.windowPool[i].generation = 1;
|
||||
ListAppend(&__mpAppData.windowFreeList, &__mpAppData.windowPool[i].freeListElt);
|
||||
}
|
||||
}
|
||||
|
||||
mp_window_data* mp_window_alloc()
|
||||
{
|
||||
return(ListPopEntry(&__mpAppData.windowFreeList, mp_window_data, freeListElt));
|
||||
}
|
||||
|
||||
mp_window_data* mp_window_ptr_from_handle(mp_window handle)
|
||||
{
|
||||
u32 index = handle.h>>32;
|
||||
u32 generation = handle.h & 0xffffffff;
|
||||
if(index >= MP_APP_MAX_WINDOWS)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
mp_window_data* window = &__mpAppData.windowPool[index];
|
||||
if(window->generation != generation)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(window);
|
||||
}
|
||||
}
|
||||
|
||||
mp_window mp_window_handle_from_ptr(mp_window_data* window)
|
||||
{
|
||||
DEBUG_ASSERT( (window - __mpAppData.windowPool) >= 0
|
||||
&& (window - __mpAppData.windowPool) < MP_APP_MAX_WINDOWS);
|
||||
|
||||
u64 h = ((u64)(window - __mpAppData.windowPool))<<32
|
||||
| ((u64)window->generation);
|
||||
|
||||
return((mp_window){h});
|
||||
}
|
||||
|
||||
void mp_window_recycle_ptr(mp_window_data* window)
|
||||
{
|
||||
window->generation++;
|
||||
ListPush(&__mpAppData.windowFreeList, &window->freeListElt);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
||||
void mp_queue_event(mp_event* event)
|
||||
{
|
||||
if(ringbuffer_write_available(&__mpAppData.eventQueue) < sizeof(mp_event))
|
||||
{
|
||||
LOG_ERROR("event queue full\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 written = ringbuffer_write(&__mpAppData.eventQueue, sizeof(mp_event), (u8*)event);
|
||||
DEBUG_ASSERT(written == sizeof(mp_event));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
||||
void mp_init()
|
||||
{
|
||||
if(!__mpAppData.init)
|
||||
{
|
||||
memset(&__mpAppData, 0, sizeof(__mpAppData));
|
||||
mp_init_window_handles();
|
||||
|
||||
ringbuffer_init(&__mpAppData.eventQueue, 16);
|
||||
}
|
||||
}
|
||||
|
||||
void mp_terminate()
|
||||
{
|
||||
if(__mpAppData.init)
|
||||
{
|
||||
__mpAppData = (mp_app_data){0};
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT result = 0;
|
||||
|
||||
mp_window_data* mpWindow = GetPropW(windowHandle, L"MilePost");
|
||||
//TODO: put messages in queue
|
||||
|
||||
switch(message)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
{
|
||||
mp_event event = {0};
|
||||
event.window = mp_window_handle_from_ptr(mpWindow);
|
||||
event.type = MP_EVENT_WINDOW_CLOSE;
|
||||
|
||||
mp_queue_event(&event);
|
||||
|
||||
} break;
|
||||
|
||||
default:
|
||||
{
|
||||
result = DefWindowProc(windowHandle, message, wParam, lParam);
|
||||
} break;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
mp_window mp_window_create(mp_rect rect, const char* title, mp_window_style style)
|
||||
{
|
||||
WNDCLASS windowClass = {.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC,
|
||||
.lpfnWndProc = WinProc,
|
||||
.hInstance = GetModuleHandleW(NULL),
|
||||
.lpszClassName = "ApplicationWindowClass",
|
||||
.hCursor = LoadCursor(0, IDC_ARROW)};
|
||||
|
||||
if(!RegisterClass(&windowClass))
|
||||
{
|
||||
//TODO: error
|
||||
goto quit;
|
||||
}
|
||||
|
||||
HWND windowHandle = CreateWindow("ApplicationWindowClass", "Test Window",
|
||||
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
800, 600,
|
||||
0, 0, windowClass.hInstance, 0);
|
||||
|
||||
if(!windowHandle)
|
||||
{
|
||||
//TODO: error
|
||||
goto quit;
|
||||
}
|
||||
|
||||
UpdateWindow(windowHandle);
|
||||
|
||||
//TODO: return wrapped window
|
||||
quit:;
|
||||
mp_window_data* window = mp_window_alloc();
|
||||
window->windowHandle = windowHandle;
|
||||
|
||||
SetPropW(windowHandle, L"MilePost", window);
|
||||
|
||||
return(mp_window_handle_from_ptr(window));
|
||||
}
|
||||
|
||||
void mp_window_bring_to_front_and_focus(mp_window window)
|
||||
{
|
||||
mp_window_data* windowData = mp_window_ptr_from_handle(window);
|
||||
if(windowData)
|
||||
{
|
||||
ShowWindow(windowData->windowHandle, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool mp_should_quit()
|
||||
{
|
||||
return(__mpAppData.shouldQuit);
|
||||
}
|
||||
|
||||
void mp_do_quit()
|
||||
{
|
||||
__mpAppData.shouldQuit = true;
|
||||
}
|
||||
|
||||
void mp_pump_events(f64 timeout)
|
||||
{
|
||||
MSG message;
|
||||
while(PeekMessage(&message, 0, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&message);
|
||||
DispatchMessage(&message);
|
||||
}
|
||||
}
|
||||
|
||||
bool mp_next_event(mp_event* event)
|
||||
{
|
||||
//NOTE pop and return event from queue
|
||||
if(ringbuffer_read_available(&__mpAppData.eventQueue) >= sizeof(mp_event))
|
||||
{
|
||||
u64 read = ringbuffer_read(&__mpAppData.eventQueue, sizeof(mp_event), (u8*)event);
|
||||
DEBUG_ASSERT(read == sizeof(mp_event));
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef LOG_SUBSYSTEM
|
|
@ -0,0 +1,26 @@
|
|||
//*****************************************************************
|
||||
//
|
||||
// $file: win32_app.h $
|
||||
// $author: Martin Fouilleul $
|
||||
// $date: 20/12/2022 $
|
||||
// $revision: $
|
||||
// $note: (C) 2022 by Martin Fouilleul - all rights reserved $
|
||||
//
|
||||
//*****************************************************************
|
||||
#ifndef __WIN32_APP_H_
|
||||
#define __WIN32_APP_H_
|
||||
|
||||
#include"mp_app.h"
|
||||
|
||||
typedef struct mp_window_data
|
||||
{
|
||||
list_elt freeListElt;
|
||||
u32 generation;
|
||||
|
||||
HWND windowHandle;
|
||||
} mp_window_data;
|
||||
|
||||
mp_window_data* mp_window_ptr_from_handle(mp_window handle);
|
||||
//mp_view_data* mp_view_ptr_from_handle(mp_view handle);
|
||||
|
||||
#endif __WIN32_APP_H_
|
|
@ -0,0 +1,176 @@
|
|||
/************************************************************//**
|
||||
*
|
||||
* @file: win32_gl_surface.c
|
||||
* @author: Martin Fouilleul
|
||||
* @date: 01/08/2022
|
||||
* @revision:
|
||||
*
|
||||
*****************************************************************/
|
||||
|
||||
#include<GL/gl.h>
|
||||
#include"GL/wglext.h"
|
||||
|
||||
#include"graphics.h"
|
||||
#include"win32_app.h"
|
||||
|
||||
typedef struct mg_gl_surface
|
||||
{
|
||||
mg_surface_info interface;
|
||||
|
||||
HDC hDC;
|
||||
HGLRC glContext;
|
||||
|
||||
} mg_gl_surface;
|
||||
|
||||
void mg_gl_surface_destroy(mg_surface_info* interface)
|
||||
{
|
||||
mg_gl_surface* surface = (mg_gl_surface*)interface;
|
||||
//TODO
|
||||
}
|
||||
|
||||
void mg_gl_surface_prepare(mg_surface_info* interface)
|
||||
{
|
||||
mg_gl_surface* surface = (mg_gl_surface*)interface;
|
||||
|
||||
wglMakeCurrent(surface->hDC, surface->glContext);
|
||||
}
|
||||
|
||||
void mg_gl_surface_present(mg_surface_info* interface)
|
||||
{
|
||||
mg_gl_surface* surface = (mg_gl_surface*)interface;
|
||||
|
||||
SwapBuffers(surface->hDC);
|
||||
}
|
||||
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
|
||||
PFNWGLMAKECONTEXTCURRENTARBPROC wglMakeContextCurrentARB;
|
||||
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
|
||||
|
||||
mg_surface mg_gl_surface_create_for_window(mp_window window)
|
||||
{
|
||||
mg_surface surfaceHandle = mg_surface_nil();
|
||||
|
||||
mp_window_data* windowData = mp_window_ptr_from_handle(window);
|
||||
if(windowData)
|
||||
{
|
||||
//NOTE: create a dummy window
|
||||
WNDCLASS windowClass = {.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC,
|
||||
.lpfnWndProc = WinProc,
|
||||
.hInstance = GetModuleHandleW(NULL),
|
||||
.lpszClassName = "HelperWindowClass",
|
||||
.hCursor = LoadCursor(0, IDC_ARROW)};
|
||||
|
||||
if(!RegisterClass(&windowClass))
|
||||
{
|
||||
//TODO: error
|
||||
goto quit;
|
||||
}
|
||||
|
||||
HWND helperWindowHandle = CreateWindow("HelperWindowClass", "Test Window",
|
||||
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
800, 600,
|
||||
0, 0, windowClass.hInstance, 0);
|
||||
|
||||
if(!helperWindowHandle)
|
||||
{
|
||||
//TODO: error
|
||||
goto quit;
|
||||
}
|
||||
|
||||
//NOTE(martin): create a dummy OpenGL context, to be able to load extensions
|
||||
HDC dummyDC = GetDC(helperWindowHandle);
|
||||
|
||||
PIXELFORMATDESCRIPTOR pixelFormatDesc =
|
||||
{
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
1,
|
||||
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, // Flags
|
||||
PFD_TYPE_RGBA, // The kind of framebuffer. RGBA or palette.
|
||||
32, // Colordepth of the framebuffer.
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
24, // Number of bits for the depthbuffer
|
||||
8, // Number of bits for the stencilbuffer
|
||||
0, // Number of Aux buffers in the framebuffer.
|
||||
PFD_MAIN_PLANE,
|
||||
0,
|
||||
0, 0, 0
|
||||
};
|
||||
|
||||
int pixelFormat = ChoosePixelFormat(dummyDC, &pixelFormatDesc);
|
||||
SetPixelFormat(dummyDC, pixelFormat, &pixelFormatDesc);
|
||||
|
||||
HGLRC dummyGLContext = wglCreateContext(dummyDC);
|
||||
wglMakeCurrent(dummyDC, dummyGLContext);
|
||||
|
||||
//NOTE(martin): now load extension functions
|
||||
wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
wglMakeContextCurrentARB = (PFNWGLMAKECONTEXTCURRENTARBPROC)wglGetProcAddress("wglMakeContextCurrentARB");
|
||||
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC )wglGetProcAddress("wglSwapIntervalEXT");
|
||||
|
||||
//NOTE(martin): now create the true pixel format and gl context
|
||||
int pixelFormatAttrs[] = {
|
||||
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
|
||||
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
|
||||
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
|
||||
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
|
||||
WGL_COLOR_BITS_ARB, 32,
|
||||
WGL_DEPTH_BITS_ARB, 24,
|
||||
WGL_STENCIL_BITS_ARB, 8,
|
||||
0};
|
||||
|
||||
HDC hDC = GetDC(windowData->windowHandle);
|
||||
u32 numFormats = 0;
|
||||
|
||||
wglChoosePixelFormatARB(hDC, pixelFormatAttrs, 0, 1, &pixelFormat, &numFormats);
|
||||
|
||||
if(!pixelFormat)
|
||||
{
|
||||
//TODO: error
|
||||
}
|
||||
SetPixelFormat(hDC, pixelFormat, &pixelFormatDesc);
|
||||
|
||||
int contextAttrs[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
0};
|
||||
|
||||
HGLRC glContext = wglCreateContextAttribsARB(hDC, dummyGLContext, contextAttrs);
|
||||
|
||||
if(!glContext)
|
||||
{
|
||||
//TODO error
|
||||
int error = GetLastError();
|
||||
printf("error: %i\n", error);
|
||||
}
|
||||
|
||||
//NOTE: destroy dummy context and dummy window
|
||||
wglMakeCurrent(hDC, 0);
|
||||
wglDeleteContext(dummyGLContext);
|
||||
DestroyWindow(helperWindowHandle);
|
||||
|
||||
//NOTE: make gl context current
|
||||
wglMakeCurrent(hDC, glContext);
|
||||
wglSwapIntervalEXT(1);
|
||||
|
||||
//TODO save important info in surface_data and return a handle
|
||||
mg_gl_surface* surface = malloc_type(mg_gl_surface);
|
||||
surface->interface.backend = MG_BACKEND_GL;
|
||||
surface->interface.destroy = mg_gl_surface_destroy;
|
||||
surface->interface.prepare = mg_gl_surface_prepare;
|
||||
surface->interface.present = mg_gl_surface_present;
|
||||
|
||||
surface->hDC = hDC;
|
||||
surface->glContext = glContext;
|
||||
|
||||
surfaceHandle = mg_surface_alloc_handle((mg_surface_info*)surface);
|
||||
}
|
||||
|
||||
quit:;
|
||||
return(surfaceHandle);
|
||||
}
|
Loading…
Reference in New Issue