38 int errorBase, eventBase;
39 Bool success = glXQueryExtension(
mDisplay, &errorBase, &eventBase);
42 LogError(
"glXQueryExtension failed, errorBase = " 43 + std::to_string(errorBase)
45 + std::to_string(eventBase)
62 attributes[i++] = GLX_RGBA;
63 attributes[i++] = GLX_RED_SIZE;
65 attributes[i++] = GLX_GREEN_SIZE;
67 attributes[i++] = GLX_BLUE_SIZE;
69 attributes[i++] = GLX_ALPHA_SIZE;
73 attributes[i++] = GLX_DEPTH_SIZE;
75 attributes[i++] = GLX_STENCIL_SIZE;
79 attributes[i++] = GLX_DOUBLEBUFFER;
86 int screen = DefaultScreen(
mDisplay);
87 XVisualInfo* visualInfo = glXChooseVisual(
mDisplay, screen, attributes);
95 GLXContext sharedList =
nullptr;
96 Bool directRender = True;
97 context = glXCreateContext(
mDisplay, visualInfo, sharedList, directRender);
100 LogError(
"glXCreateContext failed.");
107 XID rootWindow = RootWindow(
mDisplay, visualInfo->screen);
108 Colormap colorMap = XCreateColormap(
mDisplay, rootWindow, visualInfo->visual, AllocNone);
112 XSetWindowAttributes windowAttributes;
113 windowAttributes.colormap = colorMap;
114 windowAttributes.border_pixel = 0;
115 windowAttributes.event_mask =
127 unsigned int xOrigin = 0, yOrigin = 0, xSize = 16, ySize = 16;
128 unsigned int borderWidth = 0;
129 unsigned long valueMask = CWBorderPixel | CWColormap | CWEventMask;
130 window = XCreateWindow(
mDisplay, rootWindow, xOrigin,
131 yOrigin, xSize, ySize, borderWidth,
132 visualInfo->depth, InputOutput, visualInfo->visual, valueMask, &windowAttributes);
135 hints.flags = PPosition | PSize;
139 hints.height = ySize;
140 XSetNormalHints(
mDisplay, window, &hints);
143 Pixmap iconPixmap = None;
144 int numArguments = 0;
145 char** arguments =
nullptr;
146 XSetStandardProperties(
mDisplay, window, title.c_str(),
147 title.c_str(), iconPixmap, arguments, numArguments, &hints);
151 Atom wmDelete = XInternAtom(
mDisplay,
"WM_DELETE_WINDOW", False);
152 XSetWMProtocols(
mDisplay, window, &wmDelete, 1);
163 attributes[i++] = GLX_RGBA;
164 attributes[i++] = GLX_RED_SIZE;
166 attributes[i++] = GLX_GREEN_SIZE;
168 attributes[i++] = GLX_BLUE_SIZE;
170 attributes[i++] = GLX_ALPHA_SIZE;
174 attributes[i++] = GLX_DEPTH_SIZE;
175 attributes[i++] = 24;
176 attributes[i++] = GLX_STENCIL_SIZE;
180 attributes[i++] = GLX_DOUBLEBUFFER;
187 int screen = DefaultScreen(
mDisplay);
188 XVisualInfo* visualInfo = glXChooseVisual(
mDisplay, screen, attributes);
191 LogError(
"glXChooseVisual failed.");
197 GLXContext sharedList =
nullptr;
198 Bool directRender = True;
199 GLXContext context = glXCreateContext(
mDisplay, visualInfo, sharedList, directRender);
202 LogError(
"glXCreateContext failed.");
210 XID rootWindow = RootWindow(
mDisplay, visualInfo->screen);
211 Colormap colorMap = XCreateColormap(
mDisplay, rootWindow, visualInfo->visual, AllocNone);
215 XSetWindowAttributes windowAttributes;
216 windowAttributes.colormap = colorMap;
217 windowAttributes.border_pixel = 0;
218 windowAttributes.event_mask =
230 unsigned int borderWidth = 0;
231 unsigned long valueMask = CWBorderPixel | CWColormap | CWEventMask;
234 visualInfo->depth, InputOutput, visualInfo->visual, valueMask, &windowAttributes);
237 hints.flags = PPosition | PSize;
240 hints.width = parameters.
xSize;
241 hints.height = parameters.
ySize;
245 Pixmap iconPixmap = None;
246 int numArguments = 0;
247 char** arguments =
nullptr;
248 XSetStandardProperties(
mDisplay, parameters.
window, title.c_str(),
249 title.c_str(), iconPixmap, arguments, numArguments, &hints);
253 Atom wmDelete = XInternAtom(
mDisplay,
"WM_DELETE_WINDOW", False);
257 auto engine = std::make_shared<GLXEngine>(
mDisplay, parameters.
window, context,
259 if (!engine->MeetsRequirements())
261 LogError(
"OpenGL 4.3 or later is required.");
263 parameters.
engine =
nullptr;
269 if (engine->GetDisplay())
272 parameters.
engine = engine;
273 parameters.
factory = std::make_shared<GLSLProgramFactory>();
278 LogError(
"Cannot create graphics engine.");
281 parameters.
engine =
nullptr;
void CreateFrom(Window::Parameters ¶meters)
GLsizei const GLchar *const * string
std::shared_ptr< ProgramFactory > factory
#define LogError(message)
unsigned int deviceCreationFlags
std::shared_ptr< WindowType > Create(typename WindowType::Parameters ¶meters)
char const * mDisplayName
std::shared_ptr< BaseEngine > engine
GTE_IMPEXP WindowSystem TheWindowSystem