About My Skills in 3D Animation (MEL, Animation, Rendering)

My friends and Colleagues were surprised with my UI skills no matter on WPF or Windows Form or Web applications. Most of my software could have much more beautiful than other software developers. I can not tell you what the exact reason is, but I can tell you I do NOT ONLY have bachelor’s degree of Computer Science with many years software development experiences. BUT ALSO I own 3D Animation Certificate from a popular Canadian Public College, I guess I have more sensitive feeling and better ideas on some art works than other software developers

I had a blog which was about my computer programming and 3D Animation stuff. There were lots of interesting content, but finally the blog was closed by 3rd party service. The possible reason was because I did not maintaining and updating long time.

Continue reading “About My Skills in 3D Animation (MEL, Animation, Rendering)”

Using AnkhSVN to Add a new project on SVN Server

I have introduced AnkhSVN, which is a SVN plugin for Visual Studio. But I just realized I never gave some real steps which about how I used this plugin.

Sometimes, if I spent longer time to write code, I found I forgot to how to add a new project to SVN server using AnkhSVN. So this is the first thing which I want to write down it:

Continue reading “Using AnkhSVN to Add a new project on SVN Server”

Cannot open include file ‘fstream.h’ in Visual Studio 2010

There is a C++ project which is migrated from old VC++ 6.0, We use Visual Studio 2010 now.

We have the following small piece of C++ header code in a .h file:

#include "Accessor.h"
#include "SvMemDB.H"
#include "cnserver.h"
#include <fstream.h>

When we compile the project, we first got the following compile error:

error C1083: Cannot open include file: ‘fstream.h’: No such file or directory

The reason is in .NET 4.0, seems there is no more fstream.h, even all .h file is not recommanded.

please read the following explanation from StackOverflow:

The difference between fstream and fstream.h
fstream is somewhat more restrictive than the older fstream.h. One would possibly avoid problems by careful use of namespaces, but it would be a lot smarter to stick with one or the other.

You should avoid using the *.h version as much as possible, because some implementations have bugs in their *.h version. Moreover, some of them support non-standard code that is not portable, and fail to support some of the standard code of the STL.

Furthermore, the *.h version puts everything in the global namespace. The extension-less version is more stable and it’s more portable. It also places everything in the std namespace.

Conclusion
fstream.h is an old style method of including std C++ headers, and in opposite to fstream you don’t have to declare that you’re using the std namespace.

It is sometimes recommended to use:
 
#include <fstream>
using namespace std;

Install Eclipse for C/C++ Windows Edition

We have a C++ project based on Linux system, so we need a good Editor but not Visual Studio since the C++ is for Linux.

And, we do not want to use Ubuntu but just use Windows 7. So we decide to download Eclipse for C/C++ Windows Edition from Eclipse official site. (Note: our Windows 7 is 64-bit so we chose Eclipse 64-bit edition)

Please know also “[Canada] University of Waterloo Computer Science Club (http)” is the server for downloading Eclipse.

After you download, unzip it and double click eclipse.exe to run, but you might see the following error message:

eclipse4c00

Then just like install Eclipse for Java, we have to install Java runtime environment or JDK. Just check our posts for Eclipse for Java installation.

OK, we install JRE.

eclipse4c01

After JRE installation, we then can continue to install Eclipse for C/C++:

eclipse4c02

Specify a work folder:

eclipse4c03

After some while for installation process, the Eclipse install successfully.

eclipse4c04

Hello World Example in Different Languages

If you are learning C, C++ or even Java, the first code example might be similar, they are all a example named Hello World.

We found a interesting article which collects all Hello World example in different languages.

For example:

In C:

#include <stdio.h>
 
int main(void)
{
  printf("Hello world\n");
  return 0;
}

In C++:

#include <iostream>
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}

In Java:

public class HelloWorld {
   public static void main(String[] args) {
       System.out.println("Hello world!");
   }
}

Please read more in all other languages from Wikipedia

Difference between ‘struct’ and ‘typedef struct’ in C++?

Question:

In C++, is there any difference between:
struct Foo { … };
and
typedef struct { … } Foo;

Answer:

90 down vote accepted
   

In C++, there is no difference. It’s a holdover from C, in which it made a difference.

In C, there are two different namespaces of types: a namespace of struct/union/enum tag names and a namespace of typedef names. If you just said

struct Foo { … };
Foo x;

You would get a compiler error, because Foo is only defined in the tag namespace. You’d have to declare it as

struct Foo x;

Any time you want to refer to a Foo, you’d always have to call it a struct Foo. This gets annoying fast, so you can add a typedef:

struct Foo { … };
typedef struct Foo Foo;

Now both struct Foo (in the tag namespace) and just plain Foo (in the typedef namespace) both refer to the same thing, and you can freely declare objects of type Foo without the struct keyword. The construct

typedef struct Foo { … } Foo;

is just an abbreviation for the declaration and typedef. Finally,

typedef struct { … } Foo;

declares an anonymous structure and creates a typedef for it. Thus, with this construct, it doesn’t have a name in the tag namespace, only a name in the typedef namespace. This means it also can’t be forward-declared. If you want to make a forward declaration, you have to give it a name in the tag namespace.

In C++, all struct/union/enum/class declarations act like they are implicitly typedef’ed, as long as the name is not hidden by another declaration with the same name. See Michael Burr’s answer for the full details.

from Stackoverflow

C++ GBK to UTF8

GBK to UTF8
xmwen@126.com
*/
char *gbk2utf8(const char *strGBK){
int len;
wchar_t *strUnicode;
char *strUTF8;
if (!strGBK){return NULL;}
len = MultiByteToWideChar(CP_GBK, 0,strGBK, -1, NULL,0);
if (len <1){return NULL;}
strUnicode = (wchar_t *) malloc(sizeof(wchar_t) * len);
if (!strUnicode){return NULL;}
len = MultiByteToWideChar(CP_GBK, 0, strGBK, -1, strUnicode, len);
if (len<1){free(strUnicode);return NULL;}
len = WideCharToMultiByte(CP_UTF8, 0, strUnicode, -1, NULL, 0, NULL, NULL);
if (len<1){free(strUnicode);return NULL;}
strUTF8 = (char *) malloc(sizeof(char) * len);
if (!strUTF8){free(strUnicode);return NULL;}
len = WideCharToMultiByte (CP_UTF8, 0, strUnicode, -1, strUTF8, len, NULL,NULL);
free(strUnicode);
if (len<1){free(strUTF8);return NULL;}
return strUTF8;
}

OpenFileMapping and CreateFileMapping

In C++ projects, to share data, multiple processes can use memory-mapped files that the system paging file stores.

First process create memory file and other process open this memory file.

CreateFileMapping Function

OpenFileMapping Function

The name of the file mapping object to be opened has the following rules (from MSDN):

    Terminal Services:  The name can have a “Global\” or “Local\” prefix to explicitly open an object in the global or session name space. The remainder of the name can contain any character except the backslash character (\). For more information, see Kernel Object Name Spaces.

    Windows XP:  Fast user switching is implemented using Terminal Services sessions. The first user to log on uses session 0, the next user to log on uses session 1, and so on. Kernel object names must follow the guidelines outlined for Terminal Services so that applications can support multiple users.

    Windows 2000:  If Terminal Services is not running, the “Global\” and “Local\” prefixes are ignored. The remainder of the name can contain any character except the backslash character.

In new OS such as Windows 7, the mapping object name should include with “Global\” so that other processes can access this mapping object.

There is a good example on MSDN:
Creating Named Shared Memory