MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / initDisplay

Function initDisplay

src/bzflag/bzflag.cpp:1125–1434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1123
1124
1125int initDisplay(void) {
1126 // make platform factory
1127 platformFactory = PlatformFactory::getInstance();
1128
1129 // open display
1130 display = platformFactory->createDisplay(NULL, NULL);
1131 if (!display) {
1132 printFatalError("Can't open display. Exiting.");
1133 return bail(1);
1134 }
1135
1136 // choose visual
1137 visual = platformFactory->createVisual(display);
1138 setVisual(visual);
1139
1140 // make the window
1141 window = platformFactory->createWindow(display, visual);
1142 if (!window->isValid()) {
1143 printFatalError("Can't create window. Exiting.");
1144 return bail(1);
1145 }
1146 window->setTitle("bzflag");
1147
1148 // create & initialize the joystick
1149 joystick = platformFactory->createJoystick();
1150 joystick->initJoystick(BZDB.get("joystickname").c_str());
1151 joystick->setXAxis(BZDB.get("jsXAxis"));
1152 joystick->setYAxis(BZDB.get("jsYAxis"));
1153
1154 initAudio();
1155
1156 // initialize font system
1157 FontManager& fm = FontManager::instance();
1158 // load fonts from data directory
1159 if (fm.loadAll(PlatformFactory::getMedia()->getMediaDirectory() + "/fonts") == 0) {
1160 printFatalError("No fonts found (the -directory option may help). Exiting");
1161 return bail(1);
1162 }
1163
1164 bool setPosition = false, setSize = false;
1165 int x = 0, y = 0, w = 0, h = 0;
1166
1167 // set window size (we do it here because the OpenGL context isn't yet bound)
1168
1169 if (BZDB.isSet("geometry")) {
1170 char xs, ys;
1171 const std::string geometry = BZDB.get("geometry");
1172 const int count = sscanf(geometry.c_str(), "%dx%d%c%d%c%d", &w, &h, &xs, &x, &ys, &y);
1173
1174 if (geometry == "default" || (count != 6 && count != 2) || w < 0 || h < 0) {
1175 BZDB.unset("geometry");
1176 }
1177 else if (count == 6 && ((xs != '-' && xs != '+') || (ys != '-' && ys != '+'))) {
1178 BZDB.unset("geometry");
1179 }
1180 else {
1181 setSize = true;
1182 if (w < 256) {

Callers 1

mainFunction · 0.85

Calls 15

printFatalErrorFunction · 0.85
setVisualFunction · 0.85
initAudioFunction · 0.85
needsFullscreenFunction · 0.85
c_strMethod · 0.80
loadAllMethod · 0.80
getMediaDirectoryMethod · 0.80
isSetMethod · 0.80
unsetMethod · 0.80
setPassthroughSizeMethod · 0.80
isInFaultMethod · 0.80
findResolutionMethod · 0.80

Tested by

no test coverage detected