Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

134 Neutral

About K A Z E

  • Rank
  1. I recently got a nice, new computer with a 1680x1050 max resolution widescreen monitor. After downloading VC++ 2005 Express and rewriting my Direct3D program template (for practice), I loaded in a little bitmap I made in the gimp (a shiny ball I made with the gradation tool), and made it so I could drive it around the screen with the arrow keys just to admire all the pixels I have... Well, when I move it to the upper right corner of the screen, I get a distortion. There's like a "rectangle of lagg" up there, where if part of the ball goes in it, it laggs behind the part that's out of it. When the ball is stationary, there's no distortion, but when it moves, the part in the rectangle appears to lagg behind. It can't be a VSync problem, because in my present parameters I specified D3DPRESENT_INTERVAL_ONE. Also, it's too neat for that anyway. It just happens, as I said, in a rectangle region in the upper right corner of the screen, longer than it is tall. Also, if I specify a viewport that's 1/2 of the screen in the x, and the y, it doesn't happen in the upper right corner of the viewport IF the viewport is in the upper left, lower left, or lower right corner of the screen, but if it's in the upper right corner, then it does. Another thing I noticed is that if I turn the resolution down below 1680x1050, the rectangle gets smaller. At 1280x800 the rectangle is quit a bit smaller, and at 1024x768, it's not there at all. Which could be why it never happened on my old computer... And last thing, it only happens when the window is maximized or fullscreen, but not when it's restored. Note that I don't set Windowed = false in my present parameters to fullscreen my window. I use ChangeDisplaySettings to set the resolution then create a WS_POPUP window that stretches across the whole screen. I do it like that because it seems to be work better when I try to Alt+Tab to other windows and stuff. Anyway, I'm sorry I can't explain it better. I can't image what could be causing this. Or what it IS at all... I've tried to take a screenshot of it, but when I do, it turns out looking like it's supposed to... I don't know if anyone can help as vaguely as I've described it, but if you have any ideas as to what it is and/or what could be causing it, I'd appreciate them. Thanks in advance. Functions where I setup D3D and the window, and draw my scene are below: bool SetupWindow() { hInstance = GetModuleHandle(NULL); DWORD Style; DWORD ExStyle; WNDCLASSEX wc; wc.cbSize = sizeof(wc); = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_EXCLAMATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = ProgramName; wc.hIconSm = LoadIcon(NULL, IDI_EXCLAMATION); if(!ClassRegistered && !RegisterClassEx(&wc)) { MessageBox(NULL, "Registry of program windows class failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } ClassRegistered = true; if(Fullscreen) { DEVMODE dm; ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); dm.dmBitsPerPel = ColorBits; dm.dmPelsWidth = XResolution; dm.dmPelsHeight = YResolution; dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if(ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { ChangeDisplaySettings(NULL, NULL); MessageBox(NULL, "Attempt to go to fullscreen mode in specified resolution failed. Switching to fullscreen mode in current resolution, instead.", "Error", MB_OK | MB_ICONSTOP); XResolution = GetSystemMetrics(SM_CXSCREEN); YResolution = GetSystemMetrics(SM_CYSCREEN); } Style = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; ExStyle = WS_EX_APPWINDOW; ClientRect.left = 0; ClientRect.right = XResolution; = 0; ClientRect.bottom = YResolution; } else { Style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | (Maximized ? WS_MAXIMIZE : 0); ExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; ClientRect.left = GetSystemMetrics(SM_CXSCREEN)/2-WindowWidth/2; ClientRect.right = ClientRect.left + WindowWidth; = GetSystemMetrics(SM_CYSCREEN)/2-WindowHeight/2; ClientRect.bottom = + WindowHeight; } AdjustWindowRect(&ClientRect, Style, FALSE); if(!(hWnd = CreateWindowEx(ExStyle, ProgramName, ProgramName, Style, ClientRect.left,, ClientRect.right-ClientRect.left,, NULL, NULL, hInstance, NULL))) { MessageBox(NULL, "Creation of program window failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } if(!InitializeD3D()) return FALSE; ShowWindow(hWnd, Fullscreen ? (SW_SHOW) : (Maximized ? SW_SHOWMAXIMIZED : SW_SHOW)); UpdateWindow(hWnd); SetFocus(hWnd); SetForegroundWindow(hWnd); GetClientRect(hWnd, &ClientRect); SetupView(ClientRect.right, ClientRect.bottom); return TRUE; } bool InitializeD3D() { DWORD VertexProcessing; D3DCAPS9 Caps; // PresentParameters is a global. I did that because I use it when I reset my device and didn't want to have to fill it out again ZeroMemory(&PresentParameters, sizeof(PresentParameters)); if(!(D3DObject = Direct3DCreate9(D3D_SDK_VERSION))) { MessageBox(NULL, "Couldn't setup Direct3D. Creation of the D3D Object failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } if(FAILED(D3DObject->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &Caps))) { MessageBox(NULL, "Couldn't setup Direct3D. Attempt to get device capabilities failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } if(Caps.VertexProcessingCaps) VertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING; else VertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING; PresentParameters.AutoDepthStencilFormat = D3DFMT_D16; PresentParameters.BackBufferCount = 1; PresentParameters.BackBufferFormat = D3DFMT_UNKNOWN; PresentParameters.EnableAutoDepthStencil = TRUE; PresentParameters.PresentationInterval = D3DPRESENT_INTERVAL_ONE; PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; PresentParameters.Windowed = TRUE; if(FAILED(D3DObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, VertexProcessing, &PresentParameters, &D3DDevice))) { MessageBox(NULL, "Couldn't setup Direct3D. Creation of the D3D Device Object failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } // Images is a global array of D3DImage objects, a class I made to get addition information about images I load, such as their width and height before they are made into a texture. It calls the D3DXCreateTextureFromFileEx function to load them. // A shiny silver ball if(!Images[0].Load(D3DDevice, "C:/Documents and Settings/User/Desktop/Ball.bmp", false, true, 0xFFFFFFFF)) return FALSE; // A shiny golden ball if(!Images[1].Load(D3DDevice, "C:/Documents and Settings/User/Desktop/Ball2.bmp", false, true, 0xFFFFFFFF)) return FALSE; SetupD3D(); return TRUE; } void SetupD3D() { if(!D3DDevice) return; D3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE ); D3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE ); D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE ); D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); D3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_NONE); D3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_NONE); D3DDevice->SetFVF(FVF); return; } bool ResetDevice() { if(!D3DDevice) return FALSE; PresentParameters.BackBufferWidth = ClientRect.right; PresentParameters.BackBufferHeight = ClientRect.bottom; if(FAILED(D3DDevice->Reset(&PresentParameters))) { MessageBox(NULL, "Attempt to reset D3D Device failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } SetupD3D(); return TRUE; } void SetupView(int Width, int Height) { if(!D3DDevice) return; if(Height == 0) Height = 1; D3DDevice->SetTransform(D3DTS_PROJECTION, D3DXMatrixOrthoOffCenterRH(&D3DXMATRIX(), 0.0f, (float)Width, 0.0f, (float)Height, -1.0f, 1.0f)); return; } void DrawScene() { if(!D3DDevice) return; D3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFF000000, 1.0f, 0); static float x=0.0f, y=0.0f, x2=0.0f, pause=false; if(KeyDown[VK_LEFT]) x-=500*GetSecondsPassedf(); if(KeyDown[VK_RIGHT]) x+=500*GetSecondsPassedf(); if(KeyDown[VK_UP]) y+=500*GetSecondsPassedf(); if(KeyDown[VK_DOWN]) y-=500*GetSecondsPassedf(); if(KeyDown[VK_SPACE]) {pause = !pause; KeyDown[VK_SPACE] = false;} if(!pause) {x2 += 1.570796f*GetSecondsPassedf(); if(x2 >= 6.283185f) x2 -= 6.283185f;} if(x < 0.0f) x = 0.0f; if(x+(float)Images[0].TextureWidth > (float)ClientRect.right) x = (float)ClientRect.right-(float)Images[0].TextureWidth; if(y < 0.0f) y = 0.0f; if(y+(float)Images[0].TextureHeight > (float)ClientRect.bottom) y = (float)ClientRect.bottom-(float)Images[0].TextureHeight; LPDIRECT3DVERTEXBUFFER9 vb; Vertex* vp; if(FAILED(D3DDevice->CreateVertexBuffer(sizeof(Vertex)*4, D3DUSAGE_WRITEONLY, FVF, D3DPOOL_DEFAULT, &vb, NULL))) return; if(FAILED(vb->Lock(0, 0, (void**)&vp, NULL))) return; // The player-controlled silver ball vp->x = (float)x ; vp->y = (float)y ; vp->z = 0.0f; vp->u = 0.0f; vp->v = 1.0f; ++vp; vp->x = (float)x+(float)Images[0].TextureWidth; vp->y = (float)y ; vp->z = 0.0f; vp->u = 1.0f; vp->v = 1.0f; ++vp; vp->x = (float)x+(float)Images[0].TextureWidth; vp->y = (float)y+(float)Images[0].TextureHeight; vp->z = 0.0f; vp->u = 1.0f; vp->v = 0.0f; ++vp; vp->x = (float)x ; vp->y = (float)y+(float)Images[0].TextureHeight; vp->z = 0.0f; vp->u = 0.0f; vp->v = 0.0f; ++vp; // The golden ball which moves back and forth across the top of the screen vp->x = (float)(ClientRect.right/2-Images[1].TextureWidth/2)+sin(x2)*(float)((ClientRect.right-Images[1].TextureWidth)/2); vp->y = (float)(ClientRect.bottom-Images[1].TextureHeight); vp->z = 0.0f; vp->u = 0.0f; vp->v = 1.0f; ++vp; vp->x = (float)(ClientRect.right/2+Images[1].TextureWidth/2)+sin(x2)*(float)((ClientRect.right-Images[1].TextureWidth)/2); vp->y = (float)(ClientRect.bottom-Images[1].TextureHeight); vp->z = 0.0f; vp->u = 1.0f; vp->v = 1.0f; ++vp; vp->x = (float)(ClientRect.right/2+Images[1].TextureWidth/2)+sin(x2)*(float)((ClientRect.right-Images[1].TextureWidth)/2); vp->y = (float)ClientRect.bottom ; vp->z = 0.0f; vp->u = 1.0f; vp->v = 0.0f; ++vp; vp->x = (float)(ClientRect.right/2-Images[1].TextureWidth/2)+sin(x2)*(float)((ClientRect.right-Images[1].TextureWidth)/2); vp->y = (float)ClientRect.bottom ; vp->z = 0.0f; vp->u = 0.0f; vp->v = 0.0f; ++vp; vb->Unlock(); D3DDevice->BeginScene(); D3DDevice->SetStreamSource(0, vb, 0, sizeof(Vertex)); D3DDevice->SetTexture(0, Images[0].Image); D3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2); D3DDevice->SetTexture(0, Images[1].Image); D3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 4, 2); D3DDevice->EndScene(); vb->Release(); D3DDevice->Present(NULL, NULL, NULL, NULL); return; }
  2. Thanks for the replies yall, and the link nobodynews. I'm gonna go look over it now and see if it has anything about handles and creating objects on the managed heap. And if anyone knows why I can't create an object of this class on the managed heap with the gcnew keyword, I'd appreciate it if you could tell me: // The class public ref class ConvertEntry : System::Object { public: System::String^ Name; System::String^ Filename; System::UInt16 TransparentColor; ConvertEntry() : Name(nullptr), Filename(nullptr), TransparentColor(0x7FFF) { } }; // I try to create an object of the class on the managed heap with the gcnew // keyword like so ConvertEntry^ CE = gcnew ConvertEntry(); // And I get this error c:\documents and settings\owner\desktop\icon folder\direct3d programming stuff\gba bitmap converter\gba bitmap converter\Form1.h(525) : error C2512: 'GBABitmapConverter::ConvertEntry' : no appropriate default constructor available
  3. Okay. I just tried out the windows form designer in VC++ 2005 Express. And it's pretty cool. But when I switched over to look at the code it was generating, it wasn't "normal". It was using keywords and operators I've never seen before (Although I found out after reading the help about the ^ operator that it is apparently a "normal" C++ operator, but had a different meaning in the context in which it was being used.). Well I did some reading of the help files and found that ^ declared a "handle to an object on the managed heap". And you create an object on the managed heap with the gcnew keyword (what does the gc stand for, by the way?). Well this is all interesting, but it's causing me some problems. Like when I went to add a ConvertEntry (a class I made) vector to my Form1 class to hold a variable number of ConvertEntry objects that the user can enter. I got an error about not being able to use native and managed types together or something. I guess because the Form1 class has the ref specifier on it? So I searched the System namespace and quickly found a String object. And found and ArrayList in the System::Collections namespace. So I created an ArrayList object. And I tried to add to it a ConvertEntry object that stores two System::String handles and a System::UInt16 (I had to add the ref keyword to the class to make it work with the String handles). Well I found that the Add method takes a System::Object^, which I thought was neat. Since apparently every object in the System namespace is derived from the Object class, you could store any kind of thing in the array and dynamic_cast it into its original class. After seeing this I derived my class from System::Object and tried it. ConvertList.Add(gcnew ConvertEntry()); Well I got this error: no appropriate default constructor available Why? What does that mean. Could someone explain to me what I'm doing wrong? I just want an array of objects. I didn't think it could be so hard. But I've already spent quite a while fooling around with this wierd CLR stuff and reading the help files and trying to figure this out. Any help would be appreciated. If anyone would just explain this CLR stuff in general, that would also be very helpful too. Thanks in advance. And as usual for my posts, sorry for it being so long. I didnt intend it to be when I started writing. Oh and here's my code: // Near the beginning of my Form1 class definition private: System::Collections::ArrayList ConvertList; // Ran when my form starts up private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { rbBitmapped->Checked = true; ConvertList.Add(gcnew ConvertEntry()); } // My ConvertEntry class public ref class ConvertEntry : System::Object { public: System::String^ Name; System::String^ Filename; System::UInt16 TransparentColor; ConvertEntry() : Name(nullptr), Filename(nullptr), TransparentColor(0x7FFF) { } };
  4. K A Z E

    Reading information from bitmaps

    What do you mean, exaclty? You really need to elaborate on what you're trying to do/how you loaded the bitmap, but since you say you have tried using LockRect to get pixel data, I'm going to assume you have used a function like D3DXCreateTextureFromFile to load the bitmap in and not your own code, and now want to get the actual pixel color component data. Well I just tried LockRect and I was able to get the data that way. I've been using OpenGL and have just fairly recently begun playing around with Direct3D. But from what I can tell, pixel data in D3D texture objects have to be represented by 32-bit values. Even if an image doesn't contain an alpha channel, the pixel data in the texture object will still be represented by 32-bit numbers. The 8 highest-order bits, which would be the alpha component if the image had an alpha channel, will just be set to zero. If you have been trying to read the pixel data using LockRect like this into an array of BYTEs or something, your problem could be that you didn't anticipate these extra 8 bits after the BGR of every pixel. Also, to get the width and height of a bitmap, you could call the GetLevelDesc member function of the IDirect3DTexture9 objects with 0 for the level. I hope that was what you wanted to know. But you didn't make yourself extremely clear as to what your problem was, so I may have just rambled on for nothing =). EDIT: Alternatively, you could just load bitmaps in with your own code and create a texture from it with IDirect3DDevice9::CreateTexture() or D3DXCreateTexture(). Wotsit's Format is a great site for finding file formats, if you don't know the bitmap format.
  5. 1) I was playing around with the SetViewport function I found and noticed that if I created a viewport with the parameters {0, 0, ClientWidth, ClientHeight}, and did that in my SetupView function like I do in OpenGL, which is called whenever I resize my window, when I restore my window, which I created maximized, back to its restored size of 640x480, the viewport is smaller than the client area of the window... (was that sentence a run-on or not? With all the commas I put, it kind of sounds right to me. =) ) Well, after looking through the D3D docs a while, I realized this is because the back buffer size of my D3DDevice is still 1024x712, the size of the client area of my maximized window. Well I thought no big deal, if I wanted to have multiple viewports I would just set their width and height to a fraction of the back buffer width instead of the actual client area of the window. Then I noticed that when I shrink my window or worse, enlarge it from whatever the original client area of the window was when I created it (and thus the back buffer width), the whole scene would be scrunched or stretched to fit the new client area. Yikes. Not pretty. Especially if I created the window NOT maximized and then maxed it. Well after looking through the docs some more, I found a way to fix it. The Reset function of the IDirect3DDevice9 object. Whoops. Another problem. If I did this, I would have to re-create all my textures and stuff. And that wouldn't be good if I had a lot of them. So what can I do about this? Is there any way to resize the back buffer OTHER than resetting? 2) I posted this in for beginners a few days ago but never got it answered. I'm trying to make an image loader class that manually loads images in and creates a texture for them instead of using D3DXCreateTextureFromFile because I want to keep information about the images like width, height, etc... Well I just copied/pasted the loading code I wrote for my OpenGL image loader, and then set about making a GenerateTexture function. The problem is, it failes when I call the IDirect3DDevice9 CreateTexture function. Here's the code from the function: void D3DImage::GenerateTexture(LPDIRECT3DDEVICE9 D3DDevice, UINT MipmapLevels) { DeleteTexture(); // If, for whatever reason, this function has already been // called and a texture exists, release it before generating // this one // Width (UINT), Height (UINT), bAlpha (bool), and Texture (LPDIRECT3DTEXTURE9) // are member variables if(FAILED(D3DDevice->CreateTexture(Width, Height, MipmapLevels, 0, bAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_R8G8B8, D3DPOOL_MANAGED, &Texture, NULL))) {blah blah...;} ... } The image is 512x512, 24-bit, and I'm trying to generate only 1 level. The function is returning D3DERR_INVALIDCALL. So what am I doing wrong here? Why is it failing? Any help would be appreciated. Thanks in advance. And sorry for post being so long. I didn't intend it to be. =) EDIT: Solved problem 2. Apparently it was failing because of the D3DFMT_R8G8B8. It has to be D3DFMT_X8R8G8B8 instead. [Edited by - K A Z E on September 28, 2006 3:46:26 AM]
  6. K A Z E

    D3D CreateTexture fails

    Ah, okay, sorry. The image is 512x512. And I put 0 in for the mipmap levels which the D3D docs said should have it generate levels down to 1x1. Then I tried 1 when that didn't work. I'll go try and enable the Direct3D runtime now and see what it says. Thanks for the info.
  7. K A Z E

    GL_RGBA & glTexImage2D()

    Here's one problem: myRGBA = myRGB; myRGBA[i+1] = myRGB[i+1]; myRGBA[i+2] = myRGB[i+2]; You set the RGBA array's red, green, and blue components equal to your RGB array's R, G, and B. Then you add the alpha depending on color. Well when it loops around again and i=3 you then overwrite the first pixel's alpha value in your RGBA array with the second pixel's red value from the RGB array. So you should do it something like this: int n=0; for(int i=0;i<RGBsize;i+=3) { //convert BGR to RGB temp = myRGB; myRGB = myRGB[i+2]; myRGB[i+2] = temp; //create new RGB data with alpha channel myRGBA[n] = myRGB; myRGBA[n+1] = myRGB[i+1]; myRGBA[n+2] = myRGB[i+2]; //create alpha channel data //(pink pixels are color key) if (myRGBA[n] == 255 && myRGBA[n+1] == 0 && myRGBA[n+2] == 255) { myRGBA[n+3] = 0; } else { myRGBA[n+3] = 255; } n+=4; } Also, whatever m_pixel_data is (a BYTE* maybe), I don't see why you would want to set it equal to myRGBA every loop through.
  8. K A Z E

    D3D CreateTexture fails

    Width and Height are member variables of the class. I guess I assumed you would assume that since I said I wanted to store that info. MipmapLevels is one of the function parameters. I said it takes the number of mipmap levels to generate as a parameter, though I guess I never actually said MipmapLevels was that parameter. But anyway, how does it matter? It shouldn't fail no matter what I insert in Width and Height should it? Well, assuming they're powers of 2. And unless maybe Width and Height were really huge and there wasn't enough VRAM. Adapter format... Well I'm not exactly sure what the 'adapter' is. But when I created my D3D Device object with CreateDevice I gave it D3DADAPTER_DEFAULT as the first parameter. That what you wanted to know? And what is the 'debug d3d runtime' exactly? Eh, also. If it helps, the function returns D3DERR_INVALIDCALL when I call it. And thanks for the reply.
  9. I've modified my OpenGL image loading class to work for D3D. I want to manually load the images myself and create a texture from them. I don't want to use the D3DXCreateTextureFromFile function because I want to store information about the image (like width, height, if it has an alpha channel or not). Well, everything works except the function that creates the D3D texture. The function takes 2 parameters: an IDirect3DDevice9 pointer and the number of mipmap levels to generate. Well here's the line that creates the texture: if(FAILED(D3DDevice->CreateTexture(Width, Height, MipmapLevels, 0, bAlpha ? D3DFMT_A8R8G8B8 : D3DFMT_R8G8B8, D3DPOOL_MANAGED, &Texture, NULL))) {blah blah...;} Well. It fails. But why? Could it have to do with the pool parameter? I don't even know what that is, I use D3DPOOL_MANAGED because the D3D documentation said I can't lock a texture that was created with D3DPOOL_DEFAULT. And I read somewhere in there that D3DPOOL_MANAGED was better to use for textures... Or could it be something else? I am using the right D3DFMT_'s right? bAlpha is a member variable of the class. So if it has an alpha channel I use D3DFMT_A8R8G8B8 and if not R8G8B8... That seems right to me. And of course texture is an IDirect3DTexture9 pointer. So could someone tell me what I'm doing wrong here? I'd appreciate it. Thanks in advance.
  10. Ah cool. Thanks again for the links. =) I'll rate ya up.
  11. "#include is just a preprocessor command that does textual substitution" So #include just "pastes" the code in the header in the spot I #include it? And it has link errors because it finds the declarations of the functions but not the actual code for them then? Also, about the files in the include directory. They have headers there and the actual workings of the functions and stuff in the headers are in the libs I link right? I've opened 'em up with notepad and found binary and some ascii. What's the deal with this? I'm kind of vague on why/how this is done and stuff. Why do it like this? Why not write out the function code and stuff in a cpp file? Also HOW do you do it like this? And thanks for the reply jpetrie. EDIT: Ah. Thanks for the links everyman.
  12. I got two unrelated questions: 1) When I #include my image loader class if I don't add it to my project I get these link errors: Image Loader Revampatation.obj : error LNK2019: unresolved external symbol "public: __thiscall Image::Image(void)" (??0Image@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'Images''(void)" (??__EImages@@YAXXZ) Image Loader Revampatation.obj : error LNK2019: unresolved external symbol "public: __thiscall Image::~Image(void)" (??1Image@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'Images''(void)" (??__EImages@@YAXXZ) C:\Documents and Settings\Owner\Desktop\Icon Folder\OpenGL Programming Stuff\Image Loader Revampatation\Debug\Image Loader Revampatation.exe : fatal error LNK1120: 2 unresolved externals I notice that if I include a structure/class w/o member functions, I do not get these errors. Why is this? And how do I fix it? This isn't really a problem, this far I've just been including my image loader class into all my projects which solves the problem, but I just want to know. 2) I've heard of a thing called assembly language. And have seen some of it. And stuff written in assembly is supposed to be faster than stuff written in C++. Well what is assembly language, and why does it run faster? Thanks in advance.
  13. I'm trying to setup DirectMusic and get it to play a wav. And it works. Problem is when I try to switch the window to fullscreen/windowed it crashes. I'm using a modified version of NeHe's OpenGL template. And to switch to fullscreen/windowed I destroy the window and re-create it (either with WS_POPUP for fullscreen or WS_OVERLAPPEDWINDOW for windowed, and call ChangeDisplaySettings for fullscreen mode). It does NOT crash, however, if I exit and just destroy the window. So re-creating it must be doing it... I call CoUninitialize when I destroy the window, and I release all my objects, so I don't know what's wrong. Sometimes I get that blah blah has encountered an error and needs to close error box and sometimes I get "The instruction at 0x6c994984 referenced memory at 0x6c994984. The memory could not be read." I have ran through in debug mode and try to see if any of my interface pointers had that address, but none that I saw did. Here's my code for setting up DirectMusic: // My globals IDirectMusicPerformance8* DMPerformance = NULL; IDirectMusicLoader8* DMLoader = NULL; IDirectMusicSegment8* DMSegment = NULL; // The code from my CleanUp function that's called when I destroy the window if(DMPerformance) { DMPerformance->Stop(NULL, NULL, 0, NULL); DMPerformance->CloseDown(); DMPerformance->Release(); DMPerformance = NULL; } if(DMLoader) { DMLoader->Release(); DMLoader = NULL; } if(DMSegment) { DMSegment->Release(); DMSegment = NULL; } CoUninitialize(); // Sets up DirectMusic bool InitializeDMusic() { CoInitialize(NULL); if(FAILED(CoCreateInstance(CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC, IID_IDirectMusicPerformance8, (void**)&DMPerformance))) { MessageBox(NULL, "Couldn't initialize DirectMusic. Creation of the performance object failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } if(FAILED(DMPerformance->InitAudio(NULL, NULL, hWnd, DMUS_APATH_SHARED_STEREOPLUSREVERB, 64, DMUS_AUDIOF_ALL, NULL))) { MessageBox(NULL, "Couldn't initialize DirectMusic. DMPerformance->InitAudio failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } if(FAILED(CoCreateInstance(CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader8, (void**)&DMLoader))) { MessageBox(NULL, "Couldn't initialize DirectMusic. Creation of the loader object failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } if(FAILED(CoCreateInstance(CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC, IID_IDirectMusicSegment8, (void**)&DMSegment))) { MessageBox(NULL, "Couldn't initialize DirectMusic. Creation of the segment object failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } DMLoader->SetSearchDirectory(GUID_DirectMusicAllTypes, L"C:/Documents and Settings/Owner/Desktop/", FALSE); if(FAILED(DMLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, L"Music.wav", (void**)&DMSegment))) { MessageBox(NULL, "Couldn't initialize DirectMusic. Attempt to load the music file failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } if(FAILED(DMSegment->Download(DMPerformance))) { MessageBox(NULL, "Couldn't initialize DirectMusic. DMSegment->Download failed.", "Error", MB_OK | MB_ICONSTOP); return FALSE; } DMSegment->SetRepeats(DMUS_SEG_REPEAT_INFINITE); DMPerformance->PlaySegmentEx(DMSegment, NULL, NULL, NULL, 0, NULL, NULL, NULL); return TRUE; } As a side question, is there a way to change the window style of a window without having to recreate it? Help would be appreciated. Thanks in advance.
  14. Illco: Ahah! So there is a function for getting width and height in the LPDIRECT3DTEXTURE9 object (among other info apparently). Thanks =). Ebola0001: Wow. I can't believe I missed those ortho functions. I checked the DirectX documentation and was typing in things in the index section trying to guess the name of an ortho function but never found it. Thanks =). EDIT: Ajit: Thanks for site link.
  15. First Question: I have learned to create textures in D3D using the D3DXCreateTextureFromFile function. Well I want to know the width and height of the image I load in. How do I do this? I haven't seen any functions in the LPDIRECT3DTEXTURE9 object for getting the width or height. Also, is there any way to create a texture in a similar was as OpenGL? Like by giving it an array of bytes I load in with my own code? Second Question: Could someone explain to me or direct me to a web page that explains the projection matrix? Because I want to set the matrix up to do 2D graphics. I tried setting the matrix up in the same was as glOrtho sets up the projection matrix in OpenGL but the x and y directions were like inverted. I could probably fiddle around with it enough to make it work like I want but I'd really rather understand it. Also, could someone explain to me the difference of a right handed and left handed projection matrix. I'm thinking that in the modelview matrix right handed means that with an identity matrix, you're at 0, 0, 0 looking down the negative z axis, and with left handed your looking down the positive z axis? If that's not right tell me and explain the difference between the two in the modelview matrix too please. ... Ok one more question. D3D seems to have two "modelview" matrices. The world and the view matrix. This is kind of weird to me. Could someone explain or link me to a site that explains how they fit together? In OpenGL there was only one matrix that described the translation/rotation of things. Well, I asked more questions than I had originally intended to. When I started thinking about the matrices I realized there were several questions I had about them. Heh. Well as I said above, a link to a site would also be good, since I doubt you want to try to explain all that to me =). Thanks in advance.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!