Build fixes for clang

This commit is contained in:
Robert Osfield 2013-10-21 09:54:41 +00:00
parent a68f0f26a8
commit 074eb8e41c
3 changed files with 9 additions and 9 deletions

View File

@ -262,7 +262,7 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef image_ref)
size_t the_width = CGImageGetWidth(image_ref); size_t the_width = CGImageGetWidth(image_ref);
size_t the_height = CGImageGetHeight(image_ref); size_t the_height = CGImageGetHeight(image_ref);
CGRect the_rect = {{0, 0}, {the_width, the_height}}; CGRect the_rect = {{0.0f, 0.0f}, {static_cast<CGFloat>(the_width), static_cast<CGFloat>(the_height)}};
size_t bits_per_pixel = CGImageGetBitsPerPixel(image_ref); size_t bits_per_pixel = CGImageGetBitsPerPixel(image_ref);
size_t bytes_per_row = CGImageGetBytesPerRow(image_ref); size_t bytes_per_row = CGImageGetBytesPerRow(image_ref);
@ -374,7 +374,7 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef image_ref)
} }
} }
// Sets up a context to be drawn to with image_data as the area to be drawn to // Sets up a context to be drawn to with image_data as the area to be drawn to
CGContextRef bitmap_context = CGBitmapContextCreate( CGContextRef bitmap_context = CGBitmapContextCreate(
@ -386,26 +386,26 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef image_ref)
color_space, color_space,
bitmap_info bitmap_info
); );
CGContextTranslateCTM(bitmap_context, 0, the_height); CGContextTranslateCTM(bitmap_context, 0, the_height);
CGContextScaleCTM(bitmap_context, 1.0, -1.0); CGContextScaleCTM(bitmap_context, 1.0, -1.0);
// Draws the image into the context's image_data // Draws the image into the context's image_data
CGContextDrawImage(bitmap_context, the_rect, image_ref); CGContextDrawImage(bitmap_context, the_rect, image_ref);
CGContextRelease(bitmap_context); CGContextRelease(bitmap_context);
if (!image_data) if (!image_data)
return NULL; return NULL;
// alpha is premultiplied with rgba, undo it // alpha is premultiplied with rgba, undo it
vImage_Buffer vb; vImage_Buffer vb;
vb.data = image_data; vb.data = image_data;
vb.height = the_height; vb.height = the_height;
vb.width = the_width; vb.width = the_width;
vb.rowBytes = the_width * 4; vb.rowBytes = the_width * 4;
vImageUnpremultiplyData_RGBA8888(&vb, &vb, 0); vImageUnpremultiplyData_RGBA8888(&vb, &vb, 0);
// changing it to GL_UNSIGNED_BYTE seems working, but I'm not sure if this is a right way. // changing it to GL_UNSIGNED_BYTE seems working, but I'm not sure if this is a right way.
// //
data_type = GL_UNSIGNED_BYTE; data_type = GL_UNSIGNED_BYTE;
@ -1163,7 +1163,7 @@ public:
CFRelease(cg_image_ref); CFRelease(cg_image_ref);
if (!osg_image) if (!osg_image)
return ReadResult::INSUFFICIENT_MEMORY_TO_LOAD; return ReadResult::INSUFFICIENT_MEMORY_TO_LOAD;
return osg_image; return osg_image;
} }

View File

@ -171,7 +171,7 @@ bool ConvertImageFormat(unsigned int vtfFormat, int& internalFormat,
supported = true; supported = true;
// Decode the format // Decode the format
switch (vtfFormat) switch (static_cast<int>(vtfFormat))
{ {
case VTF_FORMAT_DEFAULT: case VTF_FORMAT_DEFAULT:
supported = false; supported = false;

View File

@ -63,7 +63,7 @@ bool Object::load(std::istream& fin)
{ {
// read header // read header
char buf[256]; char buf[256];
if (fin.getline(buf, sizeof(buf)) == 0) { if (!fin.getline(buf, sizeof(buf))) {
OSG_WARN << "Failed to read DirectX header\n"; OSG_WARN << "Failed to read DirectX header\n";
return false; return false;
} }