Apollo 11.0
自动驾驶开放平台
main.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#include <QtGui/QOffscreenSurface>
18#include <QtGui/QOpenGLFunctions>
19#include <QtWidgets/QApplication>
20
22
23int main(int argc, char* argv[]) {
24 QApplication a(argc, argv);
25 int major, minor;
26 {
27 QOffscreenSurface surf;
28 surf.create();
29
30 QOpenGLContext ctx;
31 ctx.create();
32 ctx.makeCurrent(&surf);
33
34 std::stringstream strStreamObj;
35 strStreamObj << (const char*)ctx.functions()->glGetString(
36 GL_SHADING_LANGUAGE_VERSION);
37 double version;
38 strStreamObj >> version;
39 major = static_cast<int>(version);
40 minor = static_cast<int>(version * 10.0 - major * 10);
41 if (major < 3 && minor < 3) {
42 std::cout << "Shading Language Version ( " << version
43 << ") is much lower than 3.3" << std::endl;
44 return -1;
45 }
46 }
47 QSurfaceFormat format;
48
49 format.setVersion(major, minor);
50 format.setRenderableType(QSurfaceFormat::RenderableType::OpenGL);
51 format.setSwapBehavior(QSurfaceFormat::SwapBehavior::DoubleBuffer);
52 QSurfaceFormat::setDefaultFormat(format);
53
54 a.setStyleSheet(
55 "QSplitter::handle {"
56 " background: lightGray;"
57 " border-radius: 2px; "
58 "}");
59
60 apollo::cyber::Init(argv[0]);
61
62 MainWindow w;
63
64 auto topologyCallback =
65 [&w](const apollo::cyber::proto::ChangeMsg& change_msg) {
66 w.TopologyChanged(change_msg);
67 };
68
69 auto channelManager =
70 apollo::cyber::service_discovery::TopologyManager::Instance()
71 ->channel_manager();
72 channelManager->AddChangeListener(topologyCallback);
73
74 std::vector<apollo::cyber::proto::RoleAttributes> role_attr_vec;
75 channelManager->GetWriters(&role_attr_vec);
76 for (auto& role_attr : role_attr_vec) {
77 w.AddNewWriter(role_attr);
78 }
79
80 w.show();
81
82 return a.exec();
83}
void AddNewWriter(const apollo::cyber::proto::RoleAttributes &role)
void TopologyChanged(const apollo::cyber::proto::ChangeMsg &change_msg)
int main(int argc, char *argv[])
Definition main.cc:74
bool Init(const char *binary_name, const std::string &dag_info)
Definition init.cc:99