2010年8月30日 星期一

用mingw編譯freetype

下載ft242.zip,解壓縮

1.devcpp+mingw
set PATH=C:\Dev-Cpp\bin
set PATH=%PATH%;C:\Dev-Cpp\mingw\bin
set PATH=%PATH%;%SystemRoot%\System32
set make=mingw32-make
set make=%make%
make
make
copy objs\freetype.a C:\Dev-Cpp\lib\libfreetype.a /Y
xcopy include\* C:\Dev-Cpp\include /Y /S
pause

將上面的文字檔存成t.bat檔,放在解壓縮後的freetype資料夾,點擊t.bat

2.qt+mingw
set QTDIR=C:\Qt\2010.04\qt
set PATH=C:\Qt\2010.04\qt\bin
set PATH=%PATH%;C:\Qt\2010.04\bin;C:\Qt\2010.04\mingw\bin
set PATH=%PATH%;%SystemRoot%\System32
set QMAKESPEC=win32-g++
set make=mingw32-make
set make=%make%
make
make
copy objs\freetype.a C:\Qt\2010.04\mingw\lib\libfreetype.a /Y
xcopy include\* C:\Qt\2010.04\mingw\include /Y /S
pause

2010年8月16日 星期一

避免打開雙視窗

#include <windows.h>

#define Executable "test.exe"
char TITLE[] = "The SoftW";//full title name "The SoftWare"
int size;

BOOL CALLBACK EnumWindowsProc(HWND hwnd, DWORD lParam)
{
//get hwnd title
char buffer[255];
SendMessage(hwnd,WM_GETTEXT,255,(long)buffer);

//check title is we want
if(strncmp(buffer,TITLE,size)==0)
{
//if window is iconic, show it as normal
if(IsIconic(hwnd))
ShowWindow(hwnd, SW_RESTORE);

//show it at top of desktop
SetForegroundWindow(hwnd);

//we got it
return FALSE;
}

//to check next hwnd
return TRUE;
}

int main(int argc, char** argv)
{
//check title size,remove '\0'
size = sizeof(TITLE)/sizeof(char);
size--;

//check window is show or not
if(EnumWindows((WNDENUMPROC)EnumWindowsProc,0)==TRUE)
{
//if window not show, to execute it
WinExec(Executable,SW_SHOW);
}

return 0;
}

2010年8月10日 星期二

使用glut時,不顯示控制台視窗

prevent opening a console window in addition to your GLUT window when it is run

in vc
menu option ( Project → Properties )
From the Configuration: list box, select All Configurations.
select the Linker subtree and then Command Line option in the left pane. Then add the following code to the Additional Options: text box
Copy & Paste: /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup

in mingw
click on Project and go to Project Options.
Click on the Parameters tab.
On the 3rd box, Linker, you will need to add in the following code to your project
-Wl,--subsystem,windows