Wednesday, June 27, 2012

hackintosh on pc

I tried many ways to make hackintosh on my PCs. I will not talk about install process here as there are tons of guides online. I just wanna discuss what I can reach.

1. Desktop PC. This is the easiest part I have. I use iATKOS L2. Other source may also work. Everything is fine. Install, boot, config, running. Drivers are easy to find online as "http://tonymacx86.com/". Everything works. Graphics, network, usb. Sleep may not working, but I do not care as it is a desktop.

2. Laptop with nvidia optimus. This gives me most headaches. It's a dell xps l401x with intel HD + nvidia 420m. Even on windows, the driver the outdated. Nvidia refuse to write driver for it, and the lasted driver from dell is around 2010, which support only CUDA 3.1. I installed nvidia 296.10 anyway.It seems to works. Later drivers make my win7 unbootable. Linux got stable support by bumblebee around a year ago. Let's get back to our topic. No doubt, it will not go smoothly for hackintosh. I can install iATKOS, boot, and run mac. There is no driver for wireless. I got another usb wireless adapter. It works partially. But, I can never got Graphics to work. It won't boot by default. I have to delete all stock intel drivers from the system. And then install some patched drivers. So I can boot with GraphicsEnabler=Yes. There should be hardware acceleration. But resolution is stuck at 1024x768. Nvidia is also running for nth but consuming power. Some other model can disable nvidia in bois, but no luck with my dell. This is what I have now. 1024x768 for ever with nvidia running. I believe laptops with single video card will have less problems. But for my dell, I don't think it is usable right now.

3. VMs. I use virtualbox and vmware. virtualbox is ready for mac. Install following regular guide. Everything works as it is. The main problem is that virtual graphics can only recognize 3m or 4m vram. The overall performance is acceptable, with a little lag. vmware has some booting problems. I convert my virtualbox disk to vmware format with patched AppleSMC.kext. Then vmware version boots under workstation 8.0.4. By default, vmware's perform is much worse. However there is a mac graphics driver, SVGA II. With this driver, my vmware mac is more smoother. I will stay with vmware at this time.

In conclusion, With regular video card, no optimus, I will install mac directly on hardware. Otherwise, I will use vmware with SVGA II driver.

Tuesday, June 19, 2012

GLKViewController not in the "subclass of" list

Maybe it is a problem only happens on my machines, lion  with xcode 4.3.3 from app store.

I create an empty project and try to add a file to be the subclass of GLKViewController. But I can not find it in the drop list. I can paste it into the blank anyway. Then the new files are nearly blank, instead of being with some initial codes.

Here is my solution. #import <GLKit/GLKit.h> some where. Reload the the project to make it re-index. Then I will find GLKViewController in the list.

Sunday, June 10, 2012

naclports tutorial

NaCl Ports: http://code.google.com/p/naclports/
It is a project to port existing c/c++ projects to Chrome NaCl platform. There are already some projects like freetype and zlib ported. But there is nearly no doc in naclports. I just try to write what I have done to make it work and what problem I have meet.

1. Download NaCl sdk. I am on peper19 so far
2. export NACL_SDK_ROOT="the folder contains toolchains"
3. Download with depot_tools with "git clone https://git.chromium.org/chromium/tools/depot_tools.git /your/local/depot_path"
4. export PATH="$PATH":/your/local/depot_path
5. Download naclports with depot tools with "gclient config https://naclports.googlecode.com/svn/trunk/src" and "gclient sync"


So far, we have all the codes.

6. cd your naclports root folder which contains a Makefile.
7. NACL_PACKAGES_BITSIZE=32 make
8. NACL_PACKAGES_BITSIZE=64 make

If everything is fine, we should have all the projects setup in the NaCl sdk. It is said that you do not need extra -I/-L for the path. However for me it is never a sweet procedure. When I make, I have checksum fail issue. I re-check some sha1 in the folder. They match without any problem. I have to disable checksum by commenting out all the "exit -1" in the build scripts such as common.sh. There could be some problem, but it works so far.

I just have everything setup, have never tested and linked them.

Thursday, June 7, 2012

libRocket mingw32 win32

libRocket is a mit licensed gui lib, which works with ogre 3d. Under windows it support vc++ 2010 by default. I try to build it with mingw32.

I had these problems.
error: invalid suffix "fh" on integer constant and strcpy_s not declared. Those are vc++ related. And freetype2 directory should also be modified. I have to patch the source code.

Here is my patch:

Only in patched//Build: .E
Only in patched//Build: CMakeCache.txt
Only in patched//Build: CMakeFiles
diff -rup libRocket//Build/CMakeLists.txt patched//Build/CMakeLists.txt
--- libRocket//Build/CMakeLists.txt    2010-11-30 17:53:58 -0500
+++ patched//Build/CMakeLists.txt    2012-06-08 11:13:54 -0400
@@ -53,9 +53,9 @@ endif()

 # FreeType
 if(WIN32)
-    set(FREETYPE_INCLUDE_DIRS ../../support/freetype/include)
-    set(FREETYPE_LIBRARY freetype243MT.lib)
-    set(FREETYPE_LINK_DIRS ../../support/lib)
+    set(FREETYPE_INCLUDE_DIRS ../../freetype-2.4.9/include)
+    set(FREETYPE_LIBRARY libfreetype-6.dll)
+    set(FREETYPE_LINK_DIRS ../../freetype-2.4.9/objs/.libs)
     set(FREETYPE_FOUND TRUE)
 else()
     find_package(Freetype REQUIRED)   
Only in patched//Build: Makefile
Only in patched//Build: cmake_install.cmake
Only in patched//Build: libRocketControls.dll
Only in patched//Build: libRocketControls.dll.a
Only in patched//Build: libRocketCore.dll
Only in patched//Build: libRocketCore.dll.a
Only in patched//Build: libRocketDebugger.dll
Only in patched//Build: libRocketDebugger.dll.a
diff -rup libRocket//Source/Controls/Clipboard.cpp patched//Source/Controls/Clipboard.cpp
--- libRocket//Source/Controls/Clipboard.cpp    2010-11-30 19:48:44 -0500
+++ patched//Source/Controls/Clipboard.cpp    2012-06-08 11:36:01 -0400
@@ -107,8 +107,11 @@ void Clipboard::Set(const Core::WString&
         _content.ToUTF8(win32_content);

         HGLOBAL clipboard_data = GlobalAlloc(GMEM_FIXED, win32_content.Length() + 1);
+#if defined (__MINGW32__)       
+        strncpy((char*) clipboard_data, win32_content.CString(), win32_content.Length() + 1);
+#else
         strcpy_s((char*) clipboard_data, win32_content.Length() + 1, win32_content.CString());
-
+#endif
         if (SetClipboardData(CF_TEXT, clipboard_data) == NULL)
         {
             CloseClipboard();
diff -rup libRocket//Source/Core/Math.cpp patched//Source/Core/Math.cpp
--- libRocket//Source/Core/Math.cpp    2010-11-30 19:48:44 -0500
+++ patched//Source/Core/Math.cpp    2012-06-08 11:25:17 -0400
@@ -144,7 +144,7 @@ ROCKETCORE_API int RoundDown(float value
 // Efficiently truncates a floating-point value into an integer.
 ROCKETCORE_API int RealToInteger(float value)
 {
-#if defined ROCKET_PLATFORM_WIN32
+#if defined (ROCKET_PLATFORM_WIN32) && !defined (__MINGW32__)
     int i;
     _asm
     {

Friday, June 1, 2012

SDL 2.0 with vc 2010

SDL 2.0 goes to zib instead lgpl in SDL 1.x. It is still in developing stage, I am not sure how stable it is.

I want to give it a try with my ogre project. But it won't compile with vc 2010. I found that 2 files are not added into the solution.

I added SDL_rotate.c/SDL_rotate.h back and the SDL lib compiled. But the tests still did not.

I tried report this on SDL forums, but I can not start a new post.

Ogre 3d linux gcc4.7

I have some issue with ogre 3d on my archlinux with gcc4.7.

I filed a bug report in arch, but I think it is an upstream bug and arch won't do anything about it. I still post my work around there. It works for me.

Details

Description:
Skeletal animation makes ogre crash.

Additional info:
* package version(s)
1.8.0
* config and/or log files etc.
ABS config

Steps to reproduce:
1. Runs /opt/OGRE/samples/SampleBrowser
2. Choose any sample using skeletal animation, such as Character, Dynamic Texturing, New Instancing or Skeletal Animation.
3. See the crash immediately.

Or, make you own ogre code using skeletal animation like official tutorial on ogre wiki. It will also crash.

It seems a historical bug back to 1.7 or more. It effects linux at least arch. It works fine on my win7.

It is a upstream bug not arch. But I have found a way to make work here. It is all about OgreOptimisedUtilSSE.cpp which can not be optimized more than -O1 with gcc 4.7. So I hardcoded with following steps:

cd ogre_src_v1-8-0
cd OgreMain/src/
g++ -c -O1 -march=native -msse -fPIC OgreOptimisedUtilSSE.cpp -I ../include/ -I ../../build/include/
cp OgreOptimisedUtilSSE.o ../../build/OgreMain/CMakeFiles/OgreMain.dir/src/OgreOptimisedUtilSSE.cpp.o
cd ../../build
make

Then, there is no crash any more.

I can put those into PKGBUILD to make it work. And there should be other better way than hardcoding. I found "set_source_files_properties" of cmake can set CFLAGS individually for source files. It might be better to patch CMakeLists.txt.