MCPcopy
hub / github.com/EngoEngine/engo / CreateWindow

Function CreateWindow

engo_vulkan.go:44–201  ·  view source on GitHub ↗

CreateWindow sets up the GLFW window and prepares the OpenGL surface for rendering

(title string, width, height int, fullscreen bool, msaa int)

Source from the content-addressed store, hash-verified

42
43// CreateWindow sets up the GLFW window and prepares the OpenGL surface for rendering
44func CreateWindow(title string, width, height int, fullscreen bool, msaa int) {
45 CurrentBackEnd = BackEndVulkan
46 err := glfw.Init()
47 fatalErr(err)
48
49 vk.SetGetInstanceProcAddr(glfw.GetVulkanGetInstanceProcAddress())
50 fatalErr(vk.Init())
51
52 if !opts.HeadlessMode {
53 cursorArrow = glfw.CreateStandardCursor(int(glfw.ArrowCursor))
54 cursorIBeam = glfw.CreateStandardCursor(int(glfw.IBeamCursor))
55 cursorCrosshair = glfw.CreateStandardCursor(int(glfw.CrosshairCursor))
56 cursorHand = glfw.CreateStandardCursor(int(glfw.HandCursor))
57 cursorHResize = glfw.CreateStandardCursor(int(glfw.HResizeCursor))
58 cursorVResize = glfw.CreateStandardCursor(int(glfw.VResizeCursor))
59 }
60
61 monitor := glfw.GetPrimaryMonitor()
62
63 var mode *glfw.VidMode
64 if monitor != nil {
65 mode = monitor.GetVideoMode()
66 } else {
67 // Initialize default values if no monitor is found
68 mode = &glfw.VidMode{
69 Width: 1,
70 Height: 1,
71 RedBits: 8,
72 GreenBits: 8,
73 BlueBits: 8,
74 RefreshRate: 60,
75 }
76 }
77
78 gameWidth = float32(width)
79 gameHeight = float32(height)
80
81 if fullscreen {
82 width = mode.Width
83 height = mode.Height
84 glfw.WindowHint(glfw.Decorated, 0)
85 } else {
86 monitor = nil
87 }
88
89 if opts.HeadlessMode {
90 glfw.WindowHint(glfw.Visible, glfw.False)
91 }
92 if opts.NotResizable {
93 glfw.WindowHint(glfw.Resizable, glfw.False)
94 }
95
96 glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI)
97
98 if opts.HeadlessMode {
99 return
100 }
101

Callers

nothing calls this directly

Calls 7

MouseButtonTypeAlias · 0.85
ModifierTypeAlias · 0.85
KeyTypeAlias · 0.85
ExitFunction · 0.85
DispatchMethod · 0.80
fatalErrFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected