Skip to content

Commit

Permalink
Fix up on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenlovegrove committed Mar 3, 2017
1 parent 50b16f8 commit 26756e6
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 61 deletions.
2 changes: 1 addition & 1 deletion include/pangolin/log/packet_index.h
Expand Up @@ -50,7 +50,7 @@ class PacketIndex: std::map<PacketStreamSourceId, std::map<size_t, std::streampo
}

bool has(PacketStreamSourceId source, size_t frame) const {
return count(source) ? at(source).count(frame) : false;
return count(source) ? (at(source).count(frame) > 0) : false;
}

std::streampos position(PacketStreamSourceId source, size_t frame) const {
Expand Down
2 changes: 1 addition & 1 deletion include/pangolin/scene/axis.h
Expand Up @@ -48,7 +48,7 @@ struct Axis : public Renderable, public Interactive
{
#ifdef HAVE_EIGEN
if((button == MouseWheelUp || button == MouseWheelDown) ) {
float scale = (button == MouseWheelUp) ? 0.01 : -0.01;
float scale = (button == MouseWheelUp) ? 0.01f : -0.01f;
if(button_state & KeyModifierShift) scale /= 10;

Eigen::Vector3d rot = Eigen::Vector3d::Zero();
Expand Down
40 changes: 20 additions & 20 deletions include/pangolin/scene/scenehandler.h
Expand Up @@ -9,32 +9,32 @@ namespace pangolin {
inline void gluPickMatrix(
GLdouble x, GLdouble y,
GLdouble width, GLdouble height,
GLint viewport[4])
{
GLint viewport[4]
) {
GLfloat m[16];
GLfloat sx, sy;
GLfloat tx, ty;
sx = viewport[2] / width;
sy = viewport[3] / height;
tx = (viewport[2] + 2.0 * (viewport[0] - x)) / width;
ty = (viewport[3] + 2.0 * (viewport[1] - y)) / height;
sx = viewport[2] / (GLfloat)width;
sy = viewport[3] / (GLfloat)height;
tx = (viewport[2] + 2.0f * (viewport[0] - (GLfloat)x)) / (GLfloat)width;
ty = (viewport[3] + 2.0f * (viewport[1] - (GLfloat)y)) / (GLfloat)height;
#define M(row, col) m[col*4+row]
M(0, 0) = sx;
M(0, 1) = 0.0;
M(0, 2) = 0.0;
M(0, 1) = 0.0f;
M(0, 2) = 0.0f;
M(0, 3) = tx;
M(1, 0) = 0.0;
M(1, 0) = 0.0f;
M(1, 1) = sy;
M(1, 2) = 0.0;
M(1, 2) = 0.0f;
M(1, 3) = ty;
M(2, 0) = 0.0;
M(2, 1) = 0.0;
M(2, 2) = 1.0;
M(2, 3) = 0.0;
M(3, 0) = 0.0;
M(3, 1) = 0.0;
M(3, 2) = 0.0;
M(3, 3) = 1.0;
M(2, 0) = 0.0f;
M(2, 1) = 0.0f;
M(2, 2) = 1.0f;
M(2, 3) = 0.0f;
M(3, 0) = 0.0f;
M(3, 1) = 0.0f;
M(3, 2) = 0.0f;
M(3, 3) = 1.0f;
#undef M
glMultMatrixf(m);
}
Expand Down Expand Up @@ -150,14 +150,14 @@ struct SceneHandler : public Handler3D
float x, float y, float p1, float p2, float p3, float p4,
int button_state)
{
GetPosNormal(view, x, y, p, Pw, Pc, n);
GetPosNormal(view, (int)x, (int)y, p, Pw, Pc, n);

bool handled = false;

if (inType == pangolin::InputSpecialScroll)
{
m_selected_objects.clear();
ComputeHits(view, *cam_state, x, y, 2*hwin+1, m_selected_objects);
ComputeHits(view, *cam_state, (int)x, (int)y, 2*hwin+1, m_selected_objects);

const MouseButton button = p2 > 0 ? MouseWheelUp : MouseWheelDown;

Expand Down
10 changes: 6 additions & 4 deletions src/log/packetstream_reader.cpp
Expand Up @@ -102,16 +102,18 @@ size_t PacketStreamReader::Stream::read(char* target, size_t len)
_tag = 0;
_frame.src = static_cast<decltype(_frame.src)>(-1);
Base::read(target, len);
if (_data_len)
_data_len = std::max(_data_len - gcount(), 0ul);
if (_data_len) {
_data_len = std::max( (int)_data_len - (int)gcount(), (int)0);
}
return gcount();
}

size_t PacketStreamReader::Stream::skip(size_t len)
{
ignore(len);
if (_data_len)
_data_len = std::max(_data_len - len, 0ul);
if (_data_len) {
_data_len = std::max( (int)_data_len - (int)gcount(), (int)0);
}
_tag = 0;
_frame.src = static_cast<decltype(_frame.src)>(-1);
return len;
Expand Down
7 changes: 4 additions & 3 deletions src/video/drivers/pango.cpp
Expand Up @@ -169,10 +169,11 @@ int PangoVideo::Seek(int frameid)

auto fi = _reader.Seek(_src_id, frameid, _realtime ? &_realtime_sync : nullptr);

if (fi.None())
if (fi.None()) {
return -1;
else
return fi.sequence_num;
} else {
return (int)fi.sequence_num;
}
}

int PangoVideo::FindSource()
Expand Down
63 changes: 31 additions & 32 deletions src/video/drivers/pango_video_output.cpp
Expand Up @@ -91,40 +91,39 @@ void PangoVideoOutput::SetStreams(const std::vector<StreamInfo>& st, const std::

if (packetstreamsrcid == -1)
{
input_uri = uri;
streams = st;
device_properties = properties;

json::value json_header(json::object_type, false);
json::value& json_streams = json_header["streams"];
json_header["device"] = device_properties;

total_frame_size = 0;
for (unsigned int i = 0; i < streams.size(); ++i)
{
StreamInfo& si = streams[i];
total_frame_size = std::max(total_frame_size, (size_t) si.Offset() + si.SizeBytes());

json::value& json_stream = json_streams.push_back();
json_stream["encoding"] = si.PixFormat().format;
json_stream["width"] = si.Width();
json_stream["height"] = si.Height();
json_stream["pitch"] = si.Pitch();
json_stream["offset"] = (size_t) si.Offset();
}

PacketStreamSource pss;
pss.driver = pango_video_type;
pss.uri = input_uri;
pss.info = json_header;
pss.data_size_bytes = total_frame_size;
pss.data_definitions = "struct Frame{ uint8 stream_data[" + pangolin::Convert<std::string, size_t>::Do(total_frame_size) + "];};";

packetstreamsrcid = packetstream.AddSource(pss);
input_uri = uri;
streams = st;
device_properties = properties;

json::value json_header(json::object_type, false);
json::value& json_streams = json_header["streams"];
json_header["device"] = device_properties;

total_frame_size = 0;
for (unsigned int i = 0; i < streams.size(); ++i)
{
StreamInfo& si = streams[i];
total_frame_size = std::max(total_frame_size, (size_t) si.Offset() + si.SizeBytes());

json::value& json_stream = json_streams.push_back();
json_stream["encoding"] = si.PixFormat().format;
json_stream["width"] = si.Width();
json_stream["height"] = si.Height();
json_stream["pitch"] = si.Pitch();
json_stream["offset"] = (size_t) si.Offset();
}

PacketStreamSource pss;
pss.driver = pango_video_type;
pss.uri = input_uri;
pss.info = json_header;
pss.data_size_bytes = total_frame_size;
pss.data_definitions = "struct Frame{ uint8 stream_data[" + pangolin::Convert<std::string, size_t>::Do(total_frame_size) + "];};";

packetstreamsrcid = (int)packetstream.AddSource(pss);
} else {
throw std::runtime_error("Unable to add new streams");
}
else
throw std::runtime_error("Unable to add new streams");
}

int PangoVideoOutput::WriteStreams(const unsigned char* data, const json::value& frame_properties)
Expand Down

0 comments on commit 26756e6

Please sign in to comment.