]> git.cworth.org Git - apitrace/blobdiff - formatter.hpp
Handle VBO draw elements .
[apitrace] / formatter.hpp
index c1568a62bb8f2ed9c4c25a13dc4db1f9b9d396f3..2ae789d4e9e53757fa3e5a5dca9f6a2ee7bdddbc 100644 (file)
@@ -40,7 +40,7 @@ class Attribute {
 public:
    virtual ~Attribute() {}
 
-   virtual std::ostream& apply(std::ostream& os) const { return os; }
+   virtual void apply(std::ostream &) const {}
 };
 
 
@@ -58,7 +58,7 @@ public:
    virtual Attribute *normal(void) const { return new Attribute; }
    virtual Attribute *bold(void) const { return new Attribute; }
    virtual Attribute *italic(void) const { return new Attribute; }
-   virtual Attribute *color(Color color) const { return new Attribute; }
+   virtual Attribute *color(Color) const { return new Attribute; }
 };
  
 
@@ -67,8 +67,8 @@ protected:
    const char *escape;
 public:
    AnsiAttribute(const char *_escape) : escape(_escape) {}
-   std::ostream & apply(std::ostream& os) const {
-      return os << "\33[" << escape;
+   void apply(std::ostream& os) const {
+      os << "\33[" << escape;
    }
 };
 
@@ -96,7 +96,8 @@ public:
 
 
 inline std::ostream& operator<<(std::ostream& os, const Attribute *attr) {
-   return attr->apply(os);
+   attr->apply(os);
+   return os;
 }
 
 
@@ -109,17 +110,20 @@ protected:
    WORD wAttributes;
 public:
    WindowsAttribute(WORD _wAttributes) : wAttributes(_wAttributes) {}
-   std::ostream & apply(std::ostream& os) const {
+   void apply(std::ostream& os) const {
       DWORD nStdHandleOutput;
       if (os == std::cout) {
          nStdHandleOutput = STD_OUTPUT_HANDLE;
       } else if (os == std::cerr) {
          nStdHandleOutput = STD_ERROR_HANDLE;
       } else {
-         return os;
+         return;
       }
-
       HANDLE hConsoleOutput = GetStdHandle(nStdHandleOutput);
+      if (hConsoleOutput == INVALID_HANDLE_VALUE) {
+         return;
+      }
+
       SetConsoleTextAttribute(hConsoleOutput, wAttributes);
    }
 };