DirectX vs OpenGL in game engine programming
#1
Posted 19 February 2006 - 01:48 PM
#2
Posted 19 February 2006 - 03:28 PM
DirectX has a crappy COM-like syntax and ugly initialization but once you get used to it the two library are similar.
Everything is 3D and algorithms after all...
#3
Posted 19 February 2006 - 03:29 PM
Quote
#4
Posted 19 February 2006 - 05:51 PM
#5
Posted 19 February 2006 - 06:36 PM
Games and graphics share a very basic commonality. They all operate on the basis of geometry and material properties. Regardless of the API you chose, it should not affect the design and operation of your engine, just like using a 10 cent pen from Staples won’t affect the quality of an artist’s drawing. Learn how to use data structures and abstraction to organize yourself an engine capable of maintaining polygons and materials. Combine the two later into your renderer component to actually draw the objects on the screen. With this approach, you open your engine up to countless other ways to render your scenes. Software, ray tracing, Direct3D, OpenGL, who cares. They all do the same thing in the end.
#6
Posted 19 February 2006 - 06:58 PM
#7
Posted 20 February 2006 - 07:27 PM
#8
Posted 22 February 2006 - 01:13 PM
#10
Posted 22 February 2006 - 05:43 PM
#11
Posted 22 February 2006 - 06:45 PM
#12
Posted 22 February 2006 - 06:55 PM
IDirect3D9 *direct3d = Direct3DCreate9(D3D_SDK_VERSION);
HWND window = CreateWindowEx(0, "static", "BIG", WS_POPUP | WS_VISIBLE, 0, 0, WIDTH, HEIGHT, 0, 0, GetModuleHandle(0), 0);
static D3DPRESENT_PARAMETERS present_parameters = { WIDTH, HEIGHT, D3DFMT_X8R8G8B8, 3, D3DMULTISAMPLE_NONE, 0, D3DSWAPEFFECT_DISCARD, 0, FALSE, 1, D3DFMT_D24S8, 0, D3DPRESENT_RATE_DEFAULT, 0 };
direct3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
versus
DEVMODE devmode = { {0}, 0, 0, sizeof(DEVMODE), 0, DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT, {0}, 0,0,0,0,0,{0},0, BPP, WIDTH, HEIGHT, 0, 0 };
ChangeDisplaySettings((LPDEVMODE)&devmode, CDS_FULLSCREEN);
ShowCursor(FALSE);
win = CreateWindowEx(0, "static", "static", WS_POPUP | WS_VISIBLE, 0, 0, WIDTH, HEIGHT, 0, 0, GetModuleHandle(0), 0);
hdc = GetDC(win);
GLuint pixelformat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, pixelformat, &pfd);
hrc = wglCreateContext(hdc);
wglMakeCurrent(hdc, hrc);
...
#13
Posted 22 February 2006 - 06:57 PM
#14
Posted 22 February 2006 - 09:15 PM
#15
Posted 24 February 2006 - 06:10 PM
kusma said:
IDirect3D9 *direct3d = Direct3DCreate9(D3D_SDK_VERSION);
HWND window = CreateWindowEx(0, "static", "BIG", WS_POPUP | WS_VISIBLE, 0, 0, WIDTH, HEIGHT, 0, 0, GetModuleHandle(0), 0);
static D3DPRESENT_PARAMETERS present_parameters = { WIDTH, HEIGHT, D3DFMT_X8R8G8B8, 3, D3DMULTISAMPLE_NONE, 0, D3DSWAPEFFECT_DISCARD, 0, FALSE, 1, D3DFMT_D24S8, 0, D3DPRESENT_RATE_DEFAULT, 0 };
direct3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
versus
DEVMODE devmode = { {0}, 0, 0, sizeof(DEVMODE), 0, DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT, {0}, 0,0,0,0,0,{0},0, BPP, WIDTH, HEIGHT, 0, 0 };
ChangeDisplaySettings((LPDEVMODE)&devmode, CDS_FULLSCREEN);
ShowCursor(FALSE);
win = CreateWindowEx(0, "static", "static", WS_POPUP | WS_VISIBLE, 0, 0, WIDTH, HEIGHT, 0, 0, GetModuleHandle(0), 0);
hdc = GetDC(win);
GLuint pixelformat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, pixelformat, &pfd);
hrc = wglCreateContext(hdc);
wglMakeCurrent(hdc, hrc);
...
I don't see an instruction in OpenGL in both the codes. This is everything code Windoz:closedeye
I with the setup don't intend whether to open a window but as to execute the rendering of a scene....:wub:
#16
Posted 25 February 2006 - 01:43 AM
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
#17
Posted 25 February 2006 - 11:04 PM
Put simply, if you ever want your code to run on a Mac on Linux (or anything other than Windows or XBox series) use OpenGL.
#18
Posted 26 February 2006 - 05:51 AM
mysticman said:
I with the setup don't intend whether to open a window but as to execute the rendering of a scene....:wub:
Well, that kind of code is mostly just stuff like glDrawElements() versus device->DrawIndexedPrimitives(). this is simple semantics, it is NOT where you end up spending your actual development-time.
SamuraiCode: If you're serious about portability, you don't lock your engine to one API. And in either case, the biggest issue when porting a game to another (real-world) platform is tuning assets.
#19
Posted 28 February 2006 - 05:26 PM
SamuraiCrow said:
Put simply, if you ever want your code to run on a Mac on Linux (or anything other than Windows or XBox series) use OpenGL.
odd...my Unreal-based Xbox/PC game (therefore D3D) that was released last year also made it on Macs as well. Must have been emulated...
Sarcasm aside...Aspyr did the porting and they have this down to a science. Within 3 weeks they had it running on Linux and Macs including translating vertex and pixel shaders into vertex and fragment programs.
Take the advice of everyone who reiterated that it's a non-issue. Pick one and go with it. My criteria forselection is support/updates/sample code. Remember your thought process because it will serve you again once you have to pick a high level shading language
#20
Posted 01 March 2006 - 07:24 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











