Commits

filipkunc  committed 14f1034

Added Exceptions.h and fixed compilation on Mac version.

  • Participants
  • Parent commits 1a7ecfc

Comments (0)

Files changed (6)

File Classes/Exceptions.h

+//
+//  Exceptions.h
+//  MeshMaker
+//
+//  Created by Filip Kunc on 2/6/13.
+//
+//
+
+#pragma once
+
+#include <exception>
+
+struct UnsupportedImageFormatException : std::exception
+{
+    virtual const char* what() const throw() { return "UnsupportedImageFormat"; }
+};
+
+struct IndexOutOfRangeException : std::exception
+{
+    virtual const char* what() const throw() { return "IndexOutOfRangeException"; }
+};
+

File Classes/MeshForwardDeclaration.h

 #pragma once
 
 #include "Enums.h"
+#include "Exceptions.h"
 #include "MathDeclaration.h"
 #include "FPArrayCache.h"
 #include "SimpleNodeAndList.h"

File Classes/OpenGLDrawing.h

 #endif
 #include "MathDeclaration.h"
 #include "Enums.h"
+#include "Exceptions.h"
 
 void DrawCube(float size);
 void DrawSphere(float radius, int lats, int longs);

File Classes/Texture.cpp

 		else if (components == 4)
 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
 		else
-			throw std::exception("Unsupported image format");
+			throw UnsupportedImageFormatException();
 	}
 	
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
 	_needUpdate = false;
 
-	System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, _image->Width, _image->Height);
+	System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, _image->Width, _image->Height);
 	BitmapData ^data = _image->LockBits(rect, ImageLockMode::ReadOnly, PixelFormat::Format32bppArgb);
 
 	CreateTexture((GLubyte *)data->Scan0.ToPointer(), 4, &_textureID, rect.Width, rect.Height, false);
 
 void Texture::setImage(NSImage *image)
 {
-    _image = [other._image copy];
+    _image = [image copy];
 	_needUpdate = true;
 }
 
 
 #elif defined(WIN32)
 
-    System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, _image->Width, _image->Height);
+    System::Drawing::Rectangle rect = System::Drawing::Rectangle(0, 0, _image->Width, _image->Height);
 	BitmapData ^data = _image->LockBits(rect, ImageLockMode::ReadOnly, PixelFormat::Format32bppArgb);
 
 	CreateTexture((GLubyte *)data->Scan0.ToPointer(), 4, &_textureID, rect.Width, rect.Height, false);    

File Classes/Triangle.cpp

     if (index < count())
         return _nodes[index];
 
-	throw std::exception("index out of range in Triangle2::node(int index) const");
+    throw IndexOutOfRangeException();
 }
 
 Triangle2::PackedNode &Triangle2::node(uint index)
     if (index < count())
         return _nodes[index];
 
-	throw std::exception("index out of range in Triangle2::node(int index)");
+	throw IndexOutOfRangeException();
 }
 
 void TriangleNode::addToVertices()

File MeshMaker.xcodeproj/project.pbxproj

 		A718D5F51539714000589FFF /* FPTextureBrowserWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FPTextureBrowserWindowController.h; path = Classes/FPTextureBrowserWindowController.h; sourceTree = "<group>"; };
 		A718D5F61539714000589FFF /* FPTextureBrowserWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = FPTextureBrowserWindowController.mm; path = Classes/FPTextureBrowserWindowController.mm; sourceTree = "<group>"; };
 		A718D5F71539714000589FFF /* FPTextureBrowserWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = FPTextureBrowserWindowController.xib; path = Classes/FPTextureBrowserWindowController.xib; sourceTree = "<group>"; };
-		A719913F16BD82EB00197729 /* libosdCPU.a */ = {isa = PBXFileReference; lastKnownFileType = file; name = libosdCPU.a; path = Submodules/OpenSubdiv/lib/Debug/libosdCPU.a; sourceTree = "<group>"; };
+		A719913F16BD82EB00197729 /* libosdCPU.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libosdCPU.a; path = Submodules/OpenSubdiv/lib/Debug/libosdCPU.a; sourceTree = "<group>"; };
 		A720B09416470E9600FDCC97 /* MGSFragaria.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = MGSFragaria.framework; path = "/Users/filipkunc/Library/Developer/Xcode/DerivedData/MeshMaker-baqktewznrqnwkchvptjdgcqmovn/Build/Products/Debug/MGSFragaria.framework"; sourceTree = "<absolute>"; };
 		A729F1781538B038002759BB /* SubdivisionTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SubdivisionTemplate.png; sourceTree = "<group>"; };
 		A736599D13D228B100F9D7D1 /* CylinderTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CylinderTemplate.png; sourceTree = "<group>"; };
 		A73E3190151E409A00BCCEC2 /* MemoryStreaming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MemoryStreaming.h; path = Classes/MemoryStreaming.h; sourceTree = "<group>"; };
 		A7425A3D16B32EEE00440E61 /* TextureCollection.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = TextureCollection.cpp; path = Classes/TextureCollection.cpp; sourceTree = "<group>"; };
 		A7425A3E16B32EEE00440E61 /* TextureCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextureCollection.h; path = Classes/TextureCollection.h; sourceTree = "<group>"; };
+		A74BB39816C2FFC900B9C624 /* Exceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Exceptions.h; path = Classes/Exceptions.h; sourceTree = "<group>"; };
 		A74FBFF5139A74AC00349A4C /* FPNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FPNode.h; path = Classes/FPNode.h; sourceTree = "<group>"; };
 		A754C41D0FF92F8600A48E13 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
 		A767E0E3153B544700A175DE /* IcosahedronTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = IcosahedronTemplate.png; sourceTree = "<group>"; };
 				A7D0685114BA00340091B657 /* VertexEdge.h */,
 				A7777AB116B483F400FF965A /* FPImageView.h */,
 				A7777AB216B483F400FF965A /* FPImageView.m */,
+				A74BB39816C2FFC900B9C624 /* Exceptions.h */,
 			);
 			name = Classes;
 			sourceTree = "<group>";