2011년 3월 29일 화요일

Run .bin file in Linux / UNIX

# chmod +x jre-1_5_0-linux-i586.bin
# ./jre-1_5_0-linux-i586.bin

2011년 3월 25일 금요일

Qt 4.72

configure -platform win32-msvc2010
SET QTDIR=C:\Qt\4.7.2
QMAKESPEC=win32-msvc2010

2011년 3월 23일 수요일

Creating a WXWidgets template in XCode


Apple appears to be encouraging people to move toward Cocoa and stop using Carbon.  wxCocoa is in pretty good shape so I've stopped using wxCarbon a few months ago.
Here's how I build the library:
# Build the library for Cocoa

rm -rf build-cocoa-debug
mkdir build-cocoa-debug
cd build-cocoa-debug
../configure --enable-unicode --enable-debug --disable-shared
--with-osx_cocoa
make;cd ..

# Build the samples and demos
cd build-cocoa-debug/samples; make;cd ../..
cd build-cocoa-debug/demos;   make;cd ../..

# Use Finder to run some of the samples to prove to yourself they work
# Then copy one of the samples to your own directory and compile it like
this
  Create an empty directory
  Add the source code files *.h, *.cpp, etc.
  You may also need sample.xpm if it is included in your main .cpp file
  Start XCode
  File, New Project...
  Application, Cocoa Application
  Next
  Set Project Name
  Set Project Directory to be the directory with the source code files.
  Finish
  The project window should appear
  Highlight main.m and delete it
  Change the configuration from "Release" to "Debug"
  Project, Add To Project...
  Highlight all of the .cpp files in the directory
  Add, Add
  Open a terminal window
cd wx/build-cocoa-debug
    ./wx-config --cxxflags   
    ./wx-config --libs
    
It is critical that you use ./wx-config not wx-config in those two
lines.
    You will copy the output of those two lines into Xcode in the next
steps.
  Go back to Xcode
  Click the "info" icon (blue circle with white i)
  Choose the "Build" tab
  Set the Configuration to "Debug"
  Set Show to "All Settings"
  In the Linking section,
    Uncheck ZeroLink
    Set Other Linker Flags to the output of --libs from the terminal window
  In the GCC Code Generation Section
    Uncheck Inline Methods Hidden
    Uncheck Symbols Hidden by Default
    Set Other C Flags to the output of --cxxflags from the terminal window
  In the Packaging section
    Set Product Name to a suitable name
  Close the configuration window
  Return to the project window
  Click Build and Go icon (green circle with hammer)
Thanks,

2011년 3월 22일 화요일

GLnode.cpp

// GLnode.cpp : Defines the entry point for the console application.
//

// test LLVM 2.0 
#include 

#include 
#include 
#include 

#ifndef SAFE_DELETE_VECTOR
#define SAFE_DELETE_VECTOR(x) { for(size_t __i__(0); __i__ < x.size(); ++__i__) delete(x.at(__i__)); x.clear(); }
#endif

template 
class GLvector : public std::vector {
public:
 inline void remove(T t)
 {
    typename std::vector::iterator pos = std::find(std::vector::begin(), std::vector::end(), t);
  if (pos != std::vector::end())
   erase(pos);
 }
};

template 
class GLvectorF : public GLvector {
 class _find_if_pred {
 private:
  std::string _name;
    
 public:
  _find_if_pred(const std::string& name)
    : _name(name)
  {
  }
  template 
  bool operator()(const TT* tt)
  {
   return ((_name.compare(tt->_name)) == 0);
  }
 };
  
public:
 int find(const std::string& name)
 {
  typename std::vector::iterator pos = std::find_if(std::vector::begin(), std::vector::end(), _find_if_pred(name));
  if (pos != std::vector::end())
   return (pos - std::vector::begin());
    
  return -1;
 }

  //if (pos != end())
 T& find_ptr(const std::string& name)
 {
  typename std::vector::iterator pos = std::find_if(std::vector::begin(), std::vector::end(), _find_if_pred(name));
  return *pos;
 }
 const T& find_ptr(const std::string& name) const
 {
  typename std::vector::const_iterator pos = std::find_if(std::vector::begin(), std::vector::end(), _find_if_pred(name));
  return *pos;
 }
};

class GLnode {
 class _for_each_pred {
 public:
  _for_each_pred(float time)
    : _time(time)
  {
  }
    
  template 
  void operator()(T& t) const
  {
   t->_update(_time);
  }
  float _time;
 };
  
public:
 GLnode()
 {
 }
 GLnode(const std::string& name)
  : _name(name)
 {
 }
 virtual ~GLnode()
 {
    SAFE_DELETE_VECTOR(_vec);
 }
  
 virtual void update(float time)
 {
  std::for_each(_vec.begin(), _vec.end(), _for_each_pred(time));
 }
  
protected:
 virtual void _update(float time) const
 {
    
 }
  
 /// attribute
public:
 std::string _name;
  
 /// operation
public:
  GLvectorF _vec;
};

char* itoa(int val, int base)
{
  static char buf[32] = {0};
  int i = 30;
  for(; val && i ; --i, val /= base)
    buf[i] = "0123456789abcdef"[val % base];
  return &buf[i+1];
} 

int main (int argc, const char * argv[])
{

  // insert code here...
  std::cout << "Hello, World!\n";
  
 GLnode _node;
  
 for (int i=0; i<10; i++)
 {
  char* ib = itoa(i, 10);
  _node._vec.push_back(new GLnode(ib));
 }
  
 int index = _node._vec.find("9");
  if (index != -1)
  {
    const GLnode* at = _node._vec.at(index);
    std::cout << "at= " << at->_name << std::endl;
  }
  
 const GLnode* ptr = _node._vec.find_ptr("9");
  if (ptr != *_node._vec.end())
    std::cout << "ptr= " << ptr->_name << std::endl;
  
 size_t size = _node._vec.size();
  std::cout << "size= " << size << std::endl;
  
 const GLnode* begin = *_node._vec.begin();
 const GLnode* end = *_node._vec.end();
  
  return 0;
}

2011년 3월 19일 토요일

c++ 0x

#if _HAS_CPP0X

GLnode.cpp


// GLnode.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include 
#include 
#include 
#include 

#ifndef SAFE_DELETE_VECTOR
#define SAFE_DELETE_VECTOR(x) { for(size_t __i__(0); __i__ < x.size(); ++__i__) delete(x.at(__i__)); x.clear(); }
#endif

template 
class GLcontainer {
public:
 virtual ~GLcontainer()
 {
  SAFE_DELETE_VECTOR(_vec);
 }

 void push_back(T* t)
 {
  _vec.push_back(t);
 }
 void remove(T* t)
 {
  std::vector::iterator pos = std::find(_vec.begin(), _vec.end(), t);
  if (pos != _vec.end())
   _vec.erase(pos);
 }

 const T* at(int pos) const
 {
  return _vec.at(pos);
 }

 const std::vector& get() const
 {
  return _vec;
 }
protected:
 std::vector _vec;
};

template 
class GLcontainerF : public GLcontainer {
 class _find_if_pred {
 private:
  std::string _name;

 public:
  _find_if_pred(const std::string& name)
   : _name(name)
  {
  }
  template 
  bool operator()(const TT* tt)
  {
   return ((_name.compare(tt->_name)) == 0);
  }
 };

public:
 const int find(const std::string& name) const
 {
  std::vector::const_iterator pos = std::find_if(_vec.begin(), _vec.end(), _find_if_pred(name));
  if (pos != _vec.end())
   return (pos - _vec.begin());

  return -1;
 }
 const T* find_ptr(const std::string& name) const
 {
  std::vector::const_iterator pos = std::find_if(_vec.begin(), _vec.end(), _find_if_pred(name));
  if (pos != _vec.end())
   return (*pos);

  return NULL;
 }
};

class GLnode : public GLcontainerF {
 class _for_each_pred {
 public:
  _for_each_pred(float time)
   : _time(time)
  {
  }

  template 
  void operator()(T * t) const
  {
   t->_update(_time);
  }
  float _time;
 };

public:
 GLnode()
 {
 }
 GLnode(const std::string& name)
  : _name(name)
 {
 }
 virtual ~GLnode()
 {
 }

 virtual void update(float time)
 {
  std::for_each(_vec.begin(), _vec.end(), _for_each_pred(time));
 }

protected:
 virtual void _update(float time) const
 {

 }

 /// attribute
public:
 std::string _name;

 /// operation
public:
};

int _tmain(int argc, _TCHAR* argv[])
{
 GLnode _node;

 for (int i=0; i<10; i++)
 {
  char ib[10];
  itoa(i, ib, 10);

  _node.push_back(new GLnode(ib));
 }

 int index = _node.find("9");
 const GLnode * ptr = _node.find_ptr("9");

 const GLnode * res = _node.at(index);

 return 0;
}

2011년 3월 9일 수요일

Node

std::for_each(IGame.Node.begin(), IGame.Node.end(), 
 [&] (IGameImporter::Node Node)
 {
  IGameImporter::Mesh Mesh = Node.Mesh;
  float * vf = Mesh.Vertices.data();
  float * nf = Mesh.Normals.data();
}