   What graphics library to use?
  Hi,I've finally gotten good at C++ and I want to start using graphics. I've looked into Direct3D (the one that came out in march) but it looks so complicated and confusing... Today I tried using SDL but encountered a lot of problems with it. The kind of stuff I'd want to do once I've gotten good at it is probably make a 2D sidescroller of some sort, then as I got better at it start moving on to 3D RPGs. Should I learn Direct SDK even though its so complicated? Or do you recommend something else?Also I really don't want some fake thing that realy game companies dont use... I want to learn (or try) to program like the pros and see what I can do.PS When I tried downloading the Directx SDK and tried to run the samples they wouldnt compile... lots of errors. Does anyone know why?#include <windows.h>#include <d3d9.h>HWND hWindow;IDirect3D9* D3D;IDirect3DDevice9* Device;struct Vertex{float x, y, z, rhw;D3DCOLOR Color;};#define FVF_VERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)LRESULT WINAPI WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ){switch( msg ){case WM_CLOSE:PostQuitMessage( 0 );return 0;case WM_PAINT:ValidateRect( hWnd, NULL );return 0;}return DefWindowProc( hWnd, msg, wParam, lParam );}int main(){HINSTANCE hInstance = GetModuleHandle( NULL );//create a windowWNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0, 0, hInstance, NULL, NULL, NULL, NULL, "MiniD3D", NULL };RegisterClassEx( &wc );hWindow = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, "MiniD3D", "MiniD3D", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, hInstance, NULL );ShowWindow( hWindow, SW_SHOW );UpdateWindow( hWindow );//Set up d3dD3D = Direct3DCreate9( D3D_SDK_VERSION );D3DPRESENT_PARAMETERS d3dpp = { 0 };d3dpp.Windowed = TRUE;d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;D3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &Device );//now create our triangleVertex Triangle[3] = {{ 150.0f, 50.0f, 0.5f, 1.0f, D3DCOLOR_XRGB( 255, 0, 0 ) },{ 250.0f, 250.0f, 0.5f, 1.0f, D3DCOLOR_XRGB( 0, 255, 0 ) },{ 50.0f, 250.0f, 0.5f, 1.0f, D3DCOLOR_XRGB( 0, 0, 255 ) }};MSG msg;bool RunApp = true;while( RunApp ){if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ){if( msg.message == WM_QUIT )RunApp = false;TranslateMessage( &msg );DispatchMessage( &msg );}//render stuffDevice->Clear( 0, 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 );Device->BeginScene();Device->SetFVF( FVF_VERTEX );Device->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 1, Triangle, sizeof(Vertex) );Device->EndScene();Device->Present( 0, 0, 0, 0 );}Device->Release();D3D->Release();DestroyWindow( hWindow );return 0;}1>   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style casterror C2440: 'initializing' : cannot convert from 'const char [8]' to 'LPCWSTR'error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'   
  See Should I learn DirectX?.   ;Quote:Original post by ChocolatePS When I tried downloading the Directx SDK and tried to run the samples they wouldnt compile... lots of errors. Does anyone know why?Not without seeing what kind of errors you are getting.   ;  Well clearly you've edited your post now, so my previous response doesn't exactly match.On another note CreateWindowExW expects a 16-bit wide-character (hence the 'W') format, not the 8-bit format. Therefore you must explicitly tell the compiler that the strings are meant to be interpreted as wide-character strings:Window = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, L"MiniD3D", L"MiniD3D", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, hInstance, NULL );At any rate, if you really want to "program like the pros do", then learn like the pros did as well. Generally that means starting out with a smaller task, not taking on something that appears to be out of your scope right now. The professionals didn't just pop up and learn the complex things they know now, but rather took baby steps to achieve their goals.SDL is a very well respected library also, just so you know.   ;  I use OpenGL pretty much straight-up.  I use bits and pieces of various other libraries (STL, Boost, stuff I've written, stuff I've written primarily due to the help of gamedev!) to help out with control logic and whatnot.   ;  I strongly suggest OpenGL to you.It's widely used in the industry (I know because I use it).It's cross platform (DirectX won't help you say if you land a job with Apple or anyone that does things for Macs).It seems to have a much nice learning curve in which you can start producing pretty quick.However, you never know. I suggest at least learning a little bit of both, DirectX has a lot of nice things too, I just don't have extensive experience with it.   ;  okim going to make a controversial suggestion In the long run, it really doesn't matter what i will suggest however is pick the API which has the best tools to help you learn how to write graphics code. and for me, thats DirectX hands down.  Learn how to use PIX, learn how to use NVPerfHUD (if you have a nvidia card). they will help you immensely in working out why the heck things aren't rendering, or why things look screwy. If you want to learn OpenGL later, sure, go for it, the gap between the API's these days is so small that its really not that much of an effort jump from one to the other (and the same goes for HLSL, GLSL, and CG). Spend less time agonizing over an API, more time learning how to render stuff :) the decision you make at this point isn't a for-life thing, and you more than likely will end up dabbling in both API's over the course of your time playing with game development :);  Hard to argue with that.  Matt_D's argument is solid, though I should probably note that the preference between OpenGL and DirectX is fairly evenly split in the community.   ;  I recommend going higher level than DirectX or OpenGL and using a graphics engine such as Ogre3D http://www.ogre3d.org/This way you will (almost completely) isolate yourself from DirectX and OpenGL. And you will be able to use either one with very minimal effort in the same application, by toggling a setting which one you want to use.And that way it will be much easier to develop your application to multiple platforms like for Windows, Linux and Mac.Nowadays Ogre3D even allows static linking with the same license terms as it allows dynamic linking.   ;  Also another reason to use a library such as Ogre3D would be that when new rendering APIs are published, like Direct3D10, *you* do not need to write the code to use it, just let the Ogre3D project developers do it for you.The rendersystems are plugins and you can at the moment use OpenGL, Direct3D9 or Direct3D10 with the newest version of Ogre3D.To me this is ideal, to let someone else write and maintain the code which communicates with DirectX or OpenGL interfaces.One reason why you wouldn't want to do this would be if you are really keen to learn the DirectX or OpenGL APIs by yourself - you will have to judge what is it that you are actually trying to accomplish. If it is to develop a game as soon as possible then it would be easier to use Ogre3D, but if you want to learn DirectX or OpenGL, like in academics, then you would not use Ogre3D.   