Skip to content

Commit 67ae63f

Browse files
author
Thiemo Wiedemeyer
committed
fixed type, removed enum, shortened code, initialize serial with default.
1 parent d5def39 commit 67ae63f

File tree

1 file changed

+17
-42
lines changed

1 file changed

+17
-42
lines changed

examples/protonect/Protonect.cpp

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,36 @@ int main(int argc, char *argv[])
5858
libfreenect2::Freenect2 freenect2;
5959
libfreenect2::Freenect2Device *dev = 0;
6060
libfreenect2::PacketPipeline *pipeline = 0;
61-
std::string serial;
6261

63-
enum {
64-
DEFAULT,
65-
CPU,
66-
OPENGL,
67-
OPENCL
68-
} selected_pipeline = DEFAULT;
62+
freenect2.enumerateDevices();
63+
std::string serial = freenect2.getDefaultDeviceSerialNumber();
6964

7065
for(int argI = 1; argI < argc; ++argI)
7166
{
7267
const std::string arg(argv[argI]);
7368

7469
if(arg == "cpu")
7570
{
76-
selected_pipeline = CPU;
71+
if(!pipeline)
72+
pipeline = new libfreenect2::CpuPacketPipeline();
7773
}
7874
else if(arg == "gl")
7975
{
80-
selected_pipeline = OPENGL;
76+
#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT
77+
if(!pipeline)
78+
pipeline = new libfreenect2::OpenGLPacketPipeline();
79+
#else
80+
std::cout << "OpenGL pipeline is not supported!" << std::endl;
81+
#endif
8182
}
8283
else if(arg == "cl")
8384
{
84-
selected_pipeline = OPENCL;
85+
#ifdef LIBFREENECT2_WITH_OPENCL_SUPPORT
86+
if(!pipeline)
87+
pipeline = new libfreenect2::OpenCLPacketPipeline();
88+
#else
89+
std::cout << "OpenCL pipeline is not supported!" << std::endl;
90+
#endif
8591
}
8692
else if(arg.find_first_not_of("0123456789") == std::string::npos) //check if parameter could be a serial number
8793
{
@@ -93,38 +99,7 @@ int main(int argc, char *argv[])
9399
}
94100
}
95101

96-
switch(selected_pipeline)
97-
{
98-
case DEFAULT:
99-
break;
100-
case CPU:
101-
pipeline = new libfreenect2::CpuPacketPipeline();
102-
break;
103-
case OPENGL:
104-
#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT
105-
pipeline = new libfreenect2::OpenGLPacketPipeline();
106-
#else
107-
std::cout << "OpenGL pipeline is not supported! Using default pipeline instead." << std::endl;
108-
#endif
109-
break;
110-
case OPENCL:
111-
#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT
112-
pipeline = new libfreenect2::OpenCLPacketPipeline();
113-
#else
114-
std::cout << "OpenCL pipeline is not supported! Using default pipeline instead." << std::endl;
115-
#endif
116-
break;
117-
}
118-
119-
if(serial.empty() && pipeline)
120-
{
121-
dev = freenect2.openDefaultDevice(pipeline);
122-
}
123-
else if(serial.empty())
124-
{
125-
dev = freenect2.openDefaultDevice();
126-
}
127-
else if(pipeline)
102+
if(pipeline)
128103
{
129104
dev = freenect2.openDevice(serial, pipeline);
130105
}

0 commit comments

Comments
 (0)