Sojourn

Still a Long Way To Go

  • Home
  • About

8

Jul

Error LNK2019 Saat Mengcompile DirectX pada Visual C++ 2008

Posted by ulimhd  Published in Game Programming, Tutorial, Visual Studio 2008

Akhirnya masuk juga ke pembahasan tentang DirectX, setelah sebelumnya berkutat dengan GDI dan kawan-kawannya.

Problem pertama yang saya temui ketika akan meng-compile source code adalah munculnya pesan error berikut:

error LNK2019: unresolved external symbol _DirectDrawCreateEx@16 referenced in function “int __cdecl Game_Init(void *,int)” (?Game_Init@@YAHPAXH@Z)

Seperti biasa, untuk memecahkan masalah ini, Google sangat membantu.

Ternyata link error ini karena saya belum memasukkan library dari DirectX ke dalam project. Untuk memasukkan library DirectX, yang perlu dilakukan adalah menambahkan folder library tersebut pada directory yang ada pada menu Tools >> Options >> Projects and Solutions >> VC++ Directories >> Show Directories for Library.

Directory library dari DirectX ini biasanya terletak pada Program Files\Microsoft DirectX SDK\Lib

Jangan lupa tambahkan juga folder Include. Terus terang saya belum tau efeknya apabila folder ini tidak dimasukkan.

Setelah itu, pada menu Project >> Properties >> Configuration Properties >> Input >> Additional Dependencies, masukkan 3 buah library ini: dxguid.lib ddraw.lib dinput8.lib

Compile ulang. Seharusnya setelah langkah-langkah di atas dijalani, error yang tadi tidak akan muncul lagi.

Silakan download source code-nya disini.

Tags: C/C++, Game Programming

no comment

17

Jun

Error Compiling iostream.h di Visual C++ 2008

Posted by ulimhd  Published in Tutorial, Visual Studio 2008

Sewaku mencoba meng-compile prototype Game di Visual C++ 2008 Express Edition ini, muncul error seperti ini:

error C2440: ‘=’ : cannot convert from ‘const char [10]‘ to ‘LPCWSTR’

padahal error ini ga muncul di Visual C++ 6.

Akhirnya kembali berpaling ke Google. Di suatu situs dijelaskan karena project yang dibangun ini menggunakan Character Set tipe Unicode yang seharusnya Multi-Byte. Solusinya, masuk ke menu project properties lewat Project >> Properties. Pilih menu General, seperti yang terlihat pada gambar di bawah ini.

Re-compile dengan tombol F7. Seharusnya error itu ga muncul lagi.

no comment

16

Jun

New To Visual C++ 2008 Express Edition

Posted by ulimhd  Published in Tutorial, Visual Studio 2008

Just got back to Visual C++ 2008 Express Edition. I already installed it months ago but haven’t use it because it can not edit .rc file, you know, the file to build resources to your program.

I planned to use this version of Visual C++ from now on. Visual C++ 6 is very old, I’m afraid that my programs won’t work well in Vista if I keep using that version. As for the .rc issue, I’ll figure it out later.

The first issue I encounter in VC++ 2008 is it don’t recognize iostream.h . When I tried to build my program, an error occurred like this:

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

After do some Google, I’ve found out that VC++ 2008 doesn’t support iostream.h anymore. They are now recognize it only as iostream (leave the .h extension).  So just put

#include <iostream>

and the error is gone!

Wondering what error will occurred again in this version changing process.

Tags: C++, Visual Studio

1 comment

19

May

Alur Kerja Window-based Program

Posted by ulimhd  Published in Game Programming, Tutorial

Sebelum kita lihat satu per satu arti dari tiap baris dari prototype, ada baiknya kita lihat terlebih dahulu diagram alir berikut ini:

Sumber: Windows Game Programming Gurus

Diagram di atas menggambarkan proses umum dari window-based program, termasuk untuk game.

Dari diagram, terlihat ada 3 buah proses utama yang membentuk alur program tersebut:

1. Message Queue
Message (pesan) adalah inti dari user-based program. Message merupakan respon dari program terhadap input atau proses yang terjadi pada program yang kita buat. Input disini tidak selalu berupa ketikan karakter dari keyboard. Perpindahan mouse sekecil apapun merupakan suatu input, dan perpindahan tersebut juga menghasilkan message. Message ini lah yang akan direspon oleh program yang kita buat untuk diterjemahkan ke dalam perintah-perintah yang bermakna yang mempengaruhi program kita tersebut. Misalkan, apabila kita klik tanda silang pada pojok kanan atas dari window untuk menutup window, program akan menggenerate suatu message berdasarkan tindakan kita itu, untuk kemudian menerjemahkan message itu ke dalam perintah yang menutup window.

2. WinMain
Bagian ini adalah inti dari program. Message yang dihasilkan oleh program akan diterjemahkan dalam proses ini. Dari diagram terlihat, message pertama kali akan di proses oleh perintah GetMessage(), untuk kemudian di terjemahkan oleh TranslateMessage() dan setelah itu fungsi DispatchMessage() akan memanggil proses berikutnya yaitu Event Handler. Dari diagram juga terlihat terdapat proses Game Logic. Disinilah proses dari seluruh game/program yang kita buat berjalan. Seluruh proses WinMain ini berlangsung dalam sebuah loop, suatu hal yang wajar, karena kita ingin program yang kita buat ini berjalan terus menerus sampai kita perintahkan untuk berhenti.

3. Event Handler
Disinilah seluruh message yang dihasilkan akan diproses. Terdapat banyak message yang secara default dikenali Windows. Untuk daftar lengkap message, silakan lihat secara online dari situs Microsoft.com

Tidak terlalu sulit. Mudah-mudahan bagian selanjutnya juga mudah untuk dimengerti.

Tulisan Terkait:

Prototype Game Programming

Tags: C/C++, Game Programming

no comment

17

May

Setting Sony Ericsson K618i Internet Connection Using XL SIM Card

Posted by ulimhd  Published in Tutorial

This is how you setup your Sony Ericsson K618i to make it ready to surf the net using XL card

1. You need a profile to connect with. Go to menu Settings >> Connectivity >> Data Comm. >> New Account
2. Enter the name you wish to have for this profile. Any name would be okay.
3. After, enter all these information to its appropriate menu

  • APN: www.xlgprs.net
  • Username: xlgprs
  • Password: proxl
  • Login Request: Off
  • Leave the IP Address and DNS Address empty

4. Then, go back to Connectivity menu, select Internet Settings >> Internet Profiles
5. Again, enter the name you wish to have
6. In the Connect Using menu, choose the Data Comm. profile you already made earlier
7. Fill all these information

  • Use Proxy: Yes
  • Proxy Address: 202.152.240.50
  • Port Number: 8080
  • Username: xlgprs
  • Password: proxl
  • Save it, and your profile will be ready

That’s it! Now, test it using the internet key in your cell phone.
Have a fun browsing…

Tags: K618, Xplor

no comment

16

May

Prototype Game Programming

Posted by ulimhd  Published in Game Programming, Tutorial

Ini adalah prototype yang saya gunakan untuk game programming. Saya ambil dari buku “Windows Game Programming Gurus“. Penjelasan lebih lengkap mengenai prototype ini saya jelaskan di tulisan lain.

// Generic Game Console
// The basis of all Windows Game from now on

#define WIN32_LEAN_AND_MEAN // just say no to MFC

#include <windows.h> // include all the windows headers
#include <windowsx.h> // include useful macros
#include <mmsystem.h> // include winmm.lib
#include <iostream.h> // include important C/C++ stuff
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include <io.h>
#include <fcntl.h>

#define WINDOW_CLASS_NAME “WINCLASS1″ // define WINDOWCLASS

#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0×8000) ? 1 : 0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0×8000) ? 0 : 1)

HWND main_window_handle = NULL; // globally track main window
HINSTANCE hinstance_app = NULL; // globally track instance
HDC global_dc;

char buffer[80]; // general printing buffer

// Start Window Message Processing
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
char buffer[80];

// create scenario for every message occured
switch(msg)
{
case WM_CREATE:
{
// do initialization stuff here

// return success
return(0);
}
break;

case WM_PAINT:
{
// simply validate the window
hdc = BeginPaint(hwnd,&ps);

// you would do all your painting here

EndPaint(hwnd,&ps);

// return success
return(0);
}
break;

case WM_DESTROY:
{
// kill the application, this sends a WM_QUIT message
PostQuitMessage(0);

// return success
return(0);
}
break;

default:
break;

} // end switch

// process any message that didn’t take care of
return (DefWindowProc(hwnd, msg, wparam, lparam));
}

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// main loop for the game, do all the game process here

// test if the user press ESC key
// use it to send WM_CLOSE message to winproc
if(KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle, WM_CLOSE, 0, 0);

return(1);
}

int Game_Init(void *parms = NULL, int num_parms = 0)
{
// this is called after the initial window is created and
// before the main event loop (Game_Main function) run.
// do all the initialization here

return(1);
}

int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited
// and the main event loop “while” is exited.
// do all the cleanup and shutdown here

return(1);
}

// this is the main function, specify every event occured in and for the window
int WINAPI WinMain( HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
WNDCLASSEX winclass; // this will hold the class we create
HWND hwnd; // generic window handle
MSG msg; // generic message
HDC hdc;

winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

hinstance_app = hinstance;

// register the window class
if(!RegisterClassEx(&winclass))
return(0);

// create the window
if(!(hwnd = CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
“Generic Game Console, For All Your Gaming Solutions”,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
400, 300,
NULL,
NULL,
hinstance,
NULL)))
return (0);

// save the main window handle
main_window_handle = hwnd;

// intialize game here
Game_Init();

// main event loop. this is where the game logic running
while(TRUE)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT) // test to see if the message is to quit
break;

// translate message
TranslateMessage(&msg);

DispatchMessage(&msg);

}
// this is where the main processing occured
Game_Main();
}

Game_Shutdown();

return(msg.wParam);
}

Tags: C/C++, Game Programming

no comment

Search Here

 

September 2010
M T W T F S S
« Mar    
 12345
6789101112
13141516171819
20212223242526
27282930  

Recent Comments

  • suta on SMS 1717
  • suta on SMS 1717
  • dhika on Install MS-Office 2007 di Ubuntu 9.04
  • panji on Rubik’s Cube
  • Hcmsu on Tidak Bisa Mengaktifkan Visual Effect

Recent Posts

  • Rubik’s Cube
  • Cahaya Mata
  • Bandung Lagi Deh
  • Sekedarnya
  • EPL Joke

Categories

  • Bike
  • Blogsome
  • Chit Chat
  • Comic
  • Extra Post
  • Game Programming
  • General Info
  • Internet and Technology
  • Joke
  • That a Science?
  • Thought
  • Tutorial
  • Ubuntu
  • Uncategorized
  • Vista Stuff
  • Visual Studio 2008
  • Windows
  • Word of The Day

Blogroll

  • Documentation
  • Themes
  • WordPress Planet

Contributors

  • Words of A Mind

Friends

  • Achai
  • Deni Yulian
  • Detri
  • Effendi
  • Eric
  • Ericson
  • Nico
  • Sigit
  • Siti

Archives

  • March 2010
  • January 2010
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008

Recent Entries

  • Rubik’s Cube
  • Cahaya Mata
  • Bandung Lagi Deh
  • Sekedarnya
  • EPL Joke
  • Hujan di Pagi Hari
  • Akhirnya Koala Juga
  • Error Saat Menjalankan Perintah Configure
  • Unbounce di Googlegroups
  • Time to Upgrade?

Recent Comments

  • suta in SMS 1717
  • suta in SMS 1717
  • dhika in Install MS-Office 2007 di Ubuntu 9.04
  • panji in Rubik's Cube
  • Hcmsu in Tidak Bisa Mengaktifkan Visual Effect
  • aseta in Rubik's Cube
  • union in Verifikasi PayPal Tanpa Kartu Kredit
  • ulimhd in Rubik's Cube
  • siti in Rubik's Cube
  • ulimhd in Hati-hati Penipuan Produk Aowa
  • Random Selection of Posts

    • Hello world!
    • Trayek Angkutan Umum Jakarta
    • Upgrading Firefox 3.0 Beta in Ubuntu 8.04
    • Lynx, anyone?
    • Error Saat Menjalankan Perintah Configure
    • Day 1 Without AV
    • Error 1747 : The Authentication Service is Unknown
© 2008 Sojourn is proudly powered by WordPress
Theme designed by Roam2Rome