is it easier to use OpenGL or DirectX for makeing a 2d rpg style game?? and which is easier to use in general?? (the second half of the question has probably been asked many times before )
is it easier to use OpenGL or DirectX for makeing a 2d rpg style game?? and which is easier to use in general?? (the second half of the question has probably been asked many times before )
Some people prefer OpenGL, some prefer DX. There is no "better". Try one, or both, then decide.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
I believe DirectX has a specific subsystem for 2D (directdraw?)
What it really depends on is who your audiance is, as Microsoft is the only ones supporting DirectX, while many operating systems support OpenGL.
If any part of my post is incorrect, please correct me.
This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.
>>I believe DirectX has a specific subsystem for 2D (directdraw?)
Not anymore. It's just DirectGraphics now (DirectDraw+Direct3D)
They did, however it's been merged now.I believe DirectX has a specific subsystem for 2D (directdraw?)
You may want to read
http://www.xmission.com/~legalize/d3d-vs-opengl.html
I don't do any thing graphical (yet any way) so I haven't been keeping up with it. Most of the stuff I have been messing with in my free time related to that has been OpenGL based any ways, since I use Linux alot more then Windows.
If any part of my post is incorrect, please correct me.
This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.
In order to do 2D in DirectX you must bypass the T&L pipeline.
This will accomplish that.
CObject2D.h
CObject2D.cppCode:#ifndef COBJECT2D #define COBJECT2D #include <d3dx9.h> #include <string> struct TLVertex { D3DXVECTOR3 Position; float rhw; float u,v; static const DWORD FVF; TLVertex(void):Position(0.0f,0.0f,0.0f),rhw(1.0f),u(0.0f),v(0.0f) {} TLVertex(D3DXVECTOR3 _Pos,float _u,float _v):Position(_Pos),u(_u),v(_v) {} }; class CObject2D { protected: D3DXVECTOR3 m_pPosition; D3DXVECTOR3 m_pRotation; IDirect3DDevice9 *m_pDevice; IDirect3DTexture9 *m_pTexture; TLVertex m_pVertices[4]; float m_fHeight; float m_fWidth; public: CObject2D(void):m_pDevice(NULL),m_pTexture(NULL) {} virtual ~CObject2D(void) { if (m_pTexture) { m_pTexture->Release(); m_pTexture=NULL; } } void Create(IDirect3DDevice9 *device,std::string TexFilename,float fWidth,float fHeight); void Render(float fTimeDelta); };
That should get you on the right track.Code:const DWORD TLVertex::FVF=D3DFVF_XYZRHW | D3DFVF_TEX1; void Create(IDirect3DDevice9 *device,std::string TexFilename,float fWidth,float fHeight); { m_pDevice=device; if (FAILED(D3DXCreateTextureFromFile(&Device,TexFilename.c_str(),&m_pTexture))) { ::MessageBox(0,"CObject2D::Create() - Failed to load texture",0,0); return } float Height2=Height*.5f; float Width2=Width *.5f; m_fHeight=fHeight; m_fWidth=fWidth; m_pVertices[0]=TLVertex(D3DXVECTOR3(-Width2,-Height2,0.0f),0.0f,0.0f); m_pVertices[1]=TLVertex(D3DXVECTOR3(Width2,-Height2,0.0f),1.0f,0.0f); m_pVertices[2]=TLVertex(D3DXVECTOR3(-Width2,Height2,0.0f),0.0f,1.0f); m_pVertices[3]=TLVertex(D3DXVECTOR3(Width2,Height2,0.0f),1.0f,1.0f); } void Render(float fTimeDelta) { m_pDevice->SetTexture(0,m_pTexture); m_pDevice->SetFVF(TLVertex::FVF); m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,(TLVertex *)&m_pVertices,sizeof(TLVertex)); }
When Bubba posts on direct3d vs opengl threads i feel like it's political propaganda because Bubba is a d3d .......... (im just playing)
doing 2d is relatively easy (and the code he posted WILL get you on the right track).
OpenGL, is, on the whole, easier to learn, as there tend to be fewer nit picky things that you have to figure out. However, when you get right down to it, for rendering, they're both pretty much the same thing.
if im using OpenGL i need to use Win32 to make a window to use OpenGL in right?(i think i will go with OpenGL for portability) what about linux... what do i use to make the window in linux?? (GTK, GTK+, ...)
you could use either SDL or glut if you want as much portability as possible.
Last edited by Shakti; 03-01-2005 at 10:31 AM.
I have touched on SDL, In Linux at least, and it works quite well. Also their is a new libary called OpenGLUT, which I believe is just trying to implement GLUT's calls in an open source library.
If any part of my post is incorrect, please correct me.
This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.
theres always freeglut. I use it regularly and it works quite well.Originally Posted by Xipher