• Content count

  • Joined

  • Last visited

Community Reputation

110 Neutral

About musicon

  • Rank
  1. This is quite an advanced XNA topic hence its going here not in Beginners forum. While I can do most standard things in xna (and to a point directx and opengl) I am stumped on the process of finding transparent pixels in an image (for collision detection purposes). I am in need of some simple tutorials somewhere on the web or even a book that explains this properly. Riemers does this in the cannongame tutorial but it feels like running before walking, even with a good knowledge of all the stuff up to that point in that game. So if you have seen a useful explanation (such as setting colors to 2d array in the first place) please post a link.
  2. I am finishing off my Space Invaders game in XNA. One stumbling block I am having is getting all the martians to change direction whenever the furthest right ones reach the end of the screen. Difficult to post code without posting large chunks, but what I have is Ususal Game1 class Player class (Drawable component) Martian class with about 48 instances What I am basically trying to do from the Game class is If last column have reached the end of the screen { For Each instance of Martian { change Xspeed to -Xspeed } } I have tried using foreach Game Component in Components but that hasn't worked. I could make a public struct Martian in the Game1 class but that seems to take away some object orientedness.
  3. C++ and Directx

    I started with Frank Luna's examples on Just make sure you have a version of DirectX SDK appropriate for the examples you are using.
  4. Distance learning (Scotland)

    I wondered if we have any members on gamedev from sunny Scotland and might know how to get some support on game development without being on a full time course. Yes there is a lot to learn from books, online tutorials and google, but there comes a point when you need an expert to tell you if you are on the right path. Only a few unis in Scotland have dedicated games courses and they all say their game courses are full time only, won't entertain part time or distance learning (they may do others this way like Oracle SQL or Java certificates, Cisco etc.). Full time study is not an option for me due to own circumstances. And those who do straight software engineering focus more on Java not C++ with the various game APIs like DirectX. So what choices do I have?
  5. I don't think there is a simple answer to this. How are your C++ skills? (not plain C but proper object oriented programming) That would be a big issue in learning Directx. A local uni does do XNA 2d in semester 1 and Directx 2d in semester 2, but I know several people who advocate 3d in XNA first. Just getting Directx to run in Visual Studio is quite a trial at first, with heaps of libraries to link etc. Being at a similar stage to you, I am continuing the XNA route while trying out Directx and Opengl on the side. Hopefully a more experienced member can answer better.
  6. Windows SDK - objbase.h

    I keep getting a rather annoying error when compiling a program using windows.h with Directx, basically returning a string of objbase.h errors. I can fix this by pasting the Windows SDK in the include window, but it suggests something is not set up correctly. Is anyone familiar with this problem?
  7. Loading images in Opengl

    Never mind. I've got SDL up and running so may not need Devil.
  8. Loading images in Opengl

    Does anyone know a reliable place to download Devil? Unless I'm missing something I'm not getting any meaningful files installed.
  9. Loading images in Opengl

    Sorry if this has come up a gazillion times but I really need some help loading images/photos in Opengl/GLUT. I can do vector graphics but loading pre taken images (bmp/png/jpeg etc.) seem a real pitfall and more complicated than I had hoped. To show what I have tried already I found out about Devil but I downloaded it and found nothing other than an uninstall file. Also much advice I found is from quite a few years ago and is probably outdated (eg NeHe tuts using the Glaux library - now deprecated). So basically what is the current best online tutorial or books for this? My first project I have set myself is a Pong game in Opengl (already done in XNA), then onto shooter type games. Also I use MSVC++ Express 2010 if that helps.
  10. Opengl in Codeblocks

    Thanks for your input. It is all working. The original example was using GLUT and it did use glOrtho. Its the only projection I know but it worked here.
  11. Opengl in Codeblocks

    Thanks for advice. I commented out the Clear line as it was clearing the stripes previously drawn, like clearing the background in an animation program. Projection Matrix is probably the crux of the problem so am looking at that, if I can find example that isn't Einstein maths. I still think iStripeIndex has to be an int as making this float gives conversion problems.
  12. Opengl in Codeblocks

    I am trying to get familiar with Opengl using the Codeblocks template and the gnu compiler (as opposed to Glut in Visual C++). I am trying to draw a stars and stripes flag, partly using xoax sample code and partly the opengl template given by Codeblocks. So far: [code] #include <windows.h> #include <gl/gl.h> LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM); void EnableOpenGL(HWND hwnd, HDC*, HGLRC*); void DisableOpenGL(HWND, HDC, HGLRC); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wcex; HWND hwnd; HDC hDC; HGLRC hRC; MSG msg; BOOL bQuit = FALSE; float theta = 0.0f; /* register window class */ wcex.cbSize = sizeof(WNDCLASSEX); = CS_OWNDC; wcex.lpfnWndProc = WindowProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wcex.lpszMenuName = NULL; wcex.lpszClassName = "GLSample"; wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);; if (!RegisterClassEx(&wcex)) return 0; /* create main window */ hwnd = CreateWindowEx(0, "GLSample", "OpenGL Sample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 950, 700, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, nCmdShow); /* enable OpenGL for the window */ EnableOpenGL(hwnd, &hDC, &hRC); /* program main loop */ while (!bQuit) { /* check for messages */ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { /* handle or dispatch messages */ if (msg.message == WM_QUIT) { bQuit = TRUE; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } else { int iStripeIndex; for(iStripeIndex=0;iStripeIndex<13;iStripeIndex++){ /* OpenGL animation code goes here */ glClearColor(0.0f, 0.0f, 0.7f, 0.0f); //glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); if(iStripeIndex%2==0){ glColor3f(204.0/255.0,0.0,0.0); }else{ glColor3f(1.0,1.0,1.0); } float fStartX=0.0; float fEndX=1.0; float fStartY=iStripeIndex*(1.0/13.0); float fEndY=(iStripeIndex+1)*(1.0/13.0); glBegin(GL_QUADS); glVertex3f(fStartX, fStartY,0.0); glVertex3f(fEndX, fStartY,0.0); glVertex3f(fEndX, fEndY,0.0); glVertex3f(fStartX, fEndY,0.0); glEnd(); //glPopMatrix(); SwapBuffers(hDC); } } } /* shutdown OpenGL */ DisableOpenGL(hwnd, hDC, hRC); /* destroy the window explicitly */ DestroyWindow(hwnd); return msg.wParam; } LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CLOSE: PostQuitMessage(0); break; case WM_DESTROY: return 0; case WM_KEYDOWN: { switch (wParam) { case VK_ESCAPE: PostQuitMessage(0); break; } } break; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 0; } void EnableOpenGL(HWND hwnd, HDC* hDC, HGLRC* hRC) { PIXELFORMATDESCRIPTOR pfd; int iFormat; /* get the device context (DC) */ *hDC = GetDC(hwnd); /* set the pixel format for the DC */ ZeroMemory(&pfd, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; iFormat = ChoosePixelFormat(*hDC, &pfd); SetPixelFormat(*hDC, iFormat, &pfd); /* create and enable the render context (RC) */ *hRC = wglCreateContext(*hDC); wglMakeCurrent(*hDC, *hRC); } void DisableOpenGL (HWND hwnd, HDC hDC, HGLRC hRC) { wglMakeCurrent(NULL, NULL); wglDeleteContext(hRC); ReleaseDC(hwnd, hDC); } [/code] The main issue is the lines are showing but in altogether the wrong part of the window (top right quarter basically instead of the whole screen). I am having problems with the background blue as well.
  13. Frank Luna - DirectX 9.0 A Shader Approach

    Amazingly after a lot of frustration, googling, downloading this and that, banging head off walls etc. it is SOLVED. I downloaded an older SDK from about 2006 (year the book was published) which found the missing libraries, then googled to another post on here about the missing objbase.h problem where you need to add the windows SDK in the directories folder. Maybe I have the determination to be games developer after all. It does make me realise how dated this software is but I need to upgrade to Windows 7 to use Directx 11 so this is a good start.
  14. Frank Luna - DirectX 9.0 A Shader Approach

    [quote name='Marvel Magnum' timestamp='1327732543' post='4906944'] Sometimes when following old books, it happens that the latest SDK gets modified and some code mentioned in the book stops working. So if possible use the SDK version supplied with the book. [/quote] I think that's the long and short of it. I got June 2010 release, although Util and App are actually on his website which I couldn't get to before. I can use code from with no problems but Luna gives all sorts of char conversion problems etc.
  15. Frank Luna - DirectX 9.0 A Shader Approach

    [code] #if defined(DEBUG) | defined(_DEBUG) #ifndef D3D_DEBUG_INFO #define D3D_DEBUG_INFO #endif #endif #include <iostream> #include <d3d9.h> #include <d3dx9.h> #include <d3dUtil.h> #include <d3dApp.h> #include <tchar.h> #include <DxErr.h> #include <crtdbg.h> using namespace std; #if defined(DEBUG) | defined(_DEBUG) #ifndef HR #define HR(x) \ { \ { \ HRESULT hr = x; \ if(FAILED(hr)) \ { \ DXTrace(__FILE__, __LINE__, hr, #x, TRUE); \ } \ } #endif #else #ifndef HR #define HR(x) x; #endif #endif HRESULT DXTrace(CHAR *strFile, DWORD dwline, HRESULT hr, CHAR *strMsg, BOOL bPopMsgBox); class HelloD3DApp : public D3DApp { public: HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP); ~HelloD3DApp(); bool checkDeviceCaps(); void onLostDevice(); void onResetDevice(); void updateScene(float dt); void drawScene(); private: ID3DXFont* mFont; }; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) { #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // enable runtine memory chack for debug builds #if defined(DEBUG) | defined(_DEBUG)_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif HelloD3DApp app(hInstance, "Hello Direct3D", D3DDEVTYPE_HAL, D3DCREATE_HARDWARE_VERTEXPROCESSING); gd3dApp = &app; return gd3dApp->run(); } HelloD3DApp::HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP) : D3DApp(hInstance, winCaption, devType, requestedVP) { HRESULT DXTrace(CHAR *strFile, DWORD dwline, HRESULT hr, CHAR *strMsg, BOOL bPopMsgBox); srand(time_t(0)); if(!checkDeviceCaps()) { MessageBox(0, "checkDeviceCaps() Failed() Failed", 0, 0); PostQuitMessage(0); } D3DXFONT_DESC fontDesc; fontDesc.Height = 80; fontDesc.Width = 40; fontDesc.Weight = FW_BOLD; fontDesc.MipLevels = 0; fontDesc.Italic = true; fontDesc.CharSet = DEFAULT_CHARSET; fontDesc.OutputPrecision = OUT_DEFAULT_PRECIS; fontDesc.Quality = DEFAULT_QUALITY; fontDesc.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; _tcscpy(fontDesc.FaceName, _T("Times New Roman")); HR(D3DXCreateFontIndirect(gd3dDevice, &fontDesc, &mFont)); } HelloD3DApp::~HelloD3DApp() { ReleaseCOM(mFont); } #define ReleaseCOM(x) {if(x) {x->Release();x = 0; } } bool HelloD3DApp::checkDeviceCaps() { return true; } void HelloD3DApp::updateScene(float dt) { } void HelloD3DApp::onLostDevice() { HR(mFont->OnLostDevice()); } void HelloD3DApp::onResetDevice() { HR(mFont->OnResetDevice()); } void HelloD3DApp::drawScene() { HR(gd3dDevice->Clear(0,0,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0F, 0)); RECT formatRect; GetClientRect(mhMainWnd, &formatRect); HR(gd3dDevice->BeginScene()); mFont->DrawTextA(0, _T("Hello Direct3D"), -1, &formatRect, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(rand()% 256, rand() % 256, rand() % 256)); HR(gd3dDevice->EndScene()); HR(gd3dDevice->Present(0,0,0,0,)); } HRESULT IDirect3DDevice9::Clear( DWORD Count, const D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil); INT ID3DXFont::DrawText( LPD3DXSPRITE pSprite, LPCTSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color); [/code] is what I have so far. It doesn't recognise d3dx9.h, d3dUtil.h, d3dApp.h, DxErr.h. Looking through the includes library these are not present so I need a reliable way to get them. I'm also dubious about the macros I have copied in as it is a little vague precisely where they go.