Skip to content

Commit

Permalink
Merge pull request #278 from xlz/refactor-opencl
Browse files Browse the repository at this point in the history
Move loadBufferFromResources() to resource.h from OpenCL depth processor
  • Loading branch information
floe committed Jun 9, 2015
2 parents f11841a + 0f80e61 commit d919b85
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
1 change: 1 addition & 0 deletions examples/protonect/include/libfreenect2/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace libfreenect2
{

bool loadResource(const std::string &name, unsigned char const**data, size_t *length);
bool loadBufferFromResources(const std::string &filename, unsigned char *buffer, const size_t n);

} /* namespace libfreenect2 */
#endif /* RESOURCE_H_ */
21 changes: 0 additions & 21 deletions examples/protonect/src/opencl_depth_packet_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,6 @@
namespace libfreenect2
{

bool loadBufferFromResources(const std::string &filename, unsigned char *buffer, const size_t n)
{
size_t length = 0;
const unsigned char *data = NULL;

if(!loadResource(filename, &data, &length))
{
std::cerr << OUT_NAME("loadBufferFromResources") "failed to load resource: " << filename << std::endl;
return false;
}

if(length != n)
{
std::cerr << OUT_NAME("loadBufferFromResources") "wrong size of resource: " << filename << std::endl;
return false;
}

memcpy(buffer, data, length);
return true;
}

std::string loadCLSource(const std::string &filename)
{
const unsigned char *data;
Expand Down
24 changes: 24 additions & 0 deletions examples/protonect/src/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
*/

#include <libfreenect2/resource.h>
#include <string>
#include <cstring>
#include <iostream>

namespace libfreenect2
{
Expand Down Expand Up @@ -59,4 +62,25 @@ bool loadResource(const std::string &name, unsigned char const**data, size_t *le
return result;
}

bool loadBufferFromResources(const std::string &filename, unsigned char *buffer, const size_t n)
{
size_t length = 0;
const unsigned char *data = NULL;

if(!loadResource(filename, &data, &length))
{
std::cerr << "loadBufferFromResources: failed to load resource: " << filename << std::endl;
return false;
}

if(length != n)
{
std::cerr << "loadBufferFromResources: wrong size of resource: " << filename << std::endl;
return false;
}

memcpy(buffer, data, length);
return true;
}

} /* namespace libfreenect2 */

0 comments on commit d919b85

Please sign in to comment.