wgl.odin 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // +build windows
  2. package win32
  3. foreign import "system:opengl32.lib"
  4. CONTEXT_MAJOR_VERSION_ARB :: 0x2091;
  5. CONTEXT_MINOR_VERSION_ARB :: 0x2092;
  6. CONTEXT_FLAGS_ARB :: 0x2094;
  7. CONTEXT_PROFILE_MASK_ARB :: 0x9126;
  8. CONTEXT_FORWARD_COMPATIBLE_BIT_ARB :: 0x0002;
  9. CONTEXT_CORE_PROFILE_BIT_ARB :: 0x00000001;
  10. CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :: 0x00000002;
  11. Hglrc :: distinct Handle;
  12. Color_Ref :: distinct u32;
  13. Layer_Plane_Descriptor :: struct {
  14. size: u16,
  15. version: u16,
  16. flags: u32,
  17. pixel_type: u8,
  18. color_bits: u8,
  19. red_bits: u8,
  20. red_shift: u8,
  21. green_bits: u8,
  22. green_shift: u8,
  23. blue_bits: u8,
  24. blue_shift: u8,
  25. alpha_bits: u8,
  26. alpha_shift: u8,
  27. accum_bits: u8,
  28. accum_red_bits: u8,
  29. accum_green_bits: u8,
  30. accum_blue_bits: u8,
  31. accum_alpha_bits: u8,
  32. depth_bits: u8,
  33. stencil_bits: u8,
  34. aux_buffers: u8,
  35. layer_type: u8,
  36. reserved: u8,
  37. transparent: Color_Ref,
  38. }
  39. Point_Float :: struct {x, y: f32};
  40. Glyph_Metrics_Float :: struct {
  41. black_box_x: f32,
  42. black_box_y: f32,
  43. glyph_origin: Point_Float,
  44. cell_inc_x: f32,
  45. cell_inc_y: f32,
  46. }
  47. Create_Context_Attribs_ARB_Type :: #type proc "c" (hdc: Hdc, h_share_context: rawptr, attribList: ^i32) -> Hglrc;
  48. Choose_Pixel_Format_ARB_Type :: #type proc "c" (hdc: Hdc, attrib_i_list: ^i32, attrib_f_list: ^f32, max_formats: u32, formats: ^i32, num_formats : ^u32) -> Bool;
  49. Swap_Interval_EXT_Type :: #type proc "c" (interval: i32) -> bool;
  50. Get_Extensions_String_ARB_Type :: #type proc "c" (Hdc) -> cstring;
  51. // Procedures
  52. create_context_attribs_arb: Create_Context_Attribs_ARB_Type;
  53. choose_pixel_format_arb: Choose_Pixel_Format_ARB_Type;
  54. swap_interval_ext: Swap_Interval_EXT_Type;
  55. get_extensions_string_arb: Get_Extensions_String_ARB_Type;
  56. foreign opengl32 {
  57. @(link_name="wglCreateContext")
  58. create_context :: proc(hdc: Hdc) -> Hglrc ---;
  59. @(link_name="wglMakeCurrent")
  60. make_current :: proc(hdc: Hdc, hglrc: Hglrc) -> Bool ---;
  61. @(link_name="wglGetProcAddress")
  62. get_gl_proc_address :: proc(c_str: cstring) -> rawptr ---;
  63. @(link_name="wglDeleteContext")
  64. delete_context :: proc(hglrc: Hglrc) -> Bool ---;
  65. @(link_name="wglCopyContext")
  66. copy_context :: proc(src, dst: Hglrc, mask: u32) -> Bool ---;
  67. @(link_name="wglCreateLayerContext")
  68. create_layer_context :: proc(hdc: Hdc, layer_plane: i32) -> Hglrc ---;
  69. @(link_name="wglDescribeLayerPlane")
  70. describe_layer_plane :: proc(hdc: Hdc, pixel_format, layer_plane: i32, bytes: u32, pd: ^Layer_Plane_Descriptor) -> Bool ---;
  71. @(link_name="wglGetCurrentContext")
  72. get_current_context :: proc() -> Hglrc ---;
  73. @(link_name="wglGetCurrentDC")
  74. get_current_dc :: proc() -> Hdc ---;
  75. @(link_name="wglGetLayerPaletteEntries")
  76. get_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 ---;
  77. @(link_name="wglRealizeLayerPalette")
  78. realize_layer_palette :: proc(hdc: Hdc, layer_plane: i32, realize: Bool) -> Bool ---;
  79. @(link_name="wglSetLayerPaletteEntries")
  80. set_layer_palette_entries :: proc(hdc: Hdc, layer_plane, start, entries: i32, cr: ^Color_Ref) -> i32 ---;
  81. @(link_name="wglShareLists")
  82. share_lists :: proc(hglrc1, hglrc2: Hglrc) -> Bool ---;
  83. @(link_name="wglSwapLayerBuffers")
  84. swap_layer_buffers :: proc(hdc: Hdc, planes: u32) -> Bool ---;
  85. @(link_name="wglUseFontBitmaps")
  86. use_font_bitmaps :: proc(hdc: Hdc, first, count, list_base: u32) -> Bool ---;
  87. @(link_name="wglUseFontOutlines")
  88. use_font_outlines :: proc(hdc: Hdc, first, count, list_base: u32, deviation, extrusion: f32, format: i32, gmf: ^Glyph_Metrics_Float) -> Bool ---;
  89. }