Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

olemann

DX8 (very) newbie problem

This topic is 5893 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve just started looking at DX8 programming (and DX-programming in general). I have worked through Andre LaMothe''s books (WinGame Progr. For Dummies and Tricks of the WinGame progr.gurus...) Recently I bought Peter Walsh''s book on advanced 3-d game programming DX8, and felt quite confident that I would do some simple D3D-programming in a short time. But my problem is that all the programs on the CD that came with the book, runs badly on my computer. Every program that goes fullscreen, just seems to set screen resolution, go fullscreen but then gets transparent. The result is that I only se my Windows Desktop / Visual C++ blown up to the resolution the D3D program is running in, and can''t see the actual program''s window. The program does not crash (I can close it with ESC or alt-f4), just runs like a "see-trough" window on top of my other programs. I''ve both tried to recompile the programs with the source and run the exe-files on the cd. Both give same result. I''ve tried to reinstall DX8.1/DX8 SDK. All other DX-programs are running fine. Is this a ''standard'' problem that someone knows a solution too, or do I just have to live with this. It kinda sucks as I''m not able to program any fullscreen programs and test them (at least with the techniques outlined in Walsh''s book). Maybe this is to vague/newbie, but I try anyway, hoping someone says "All you have to do is...[fill in something]"

Share this post


Link to post
Share on other sites
Advertisement
please, post your system tech info..

it sounds like bad graphics card and/or bad drivers
shouldnt have to do with dx at all

Share this post


Link to post
Share on other sites
The examples from that book preforms very bad on my own comp as well, its a dual AMD MP 1.2g and a GF4 Ti4400 ! He is using a totaly screwed up technique for rendering 2d in d3d 8. The book is great for an introduction to windows programming / and an overview of D3D8 but don try to learn his ways to draw things its just not a good practice to blit to backbuffer in D3D8 !

You can actualy try DEFAULT values for refresh rate and presentation interval it might increase the performance in fullscreen..

Share this post


Link to post
Share on other sites
I thought of that too (beeing a hardware/driver problem), but isn''t it strange that all other games/progs (including MS direct3D test prog) is running smooth?

Anyway, here''s my specs:

Win XP
Athlon 1.1
Geforce2 GTS (w/ 21.83 WHQL) (running this because of Infinite Loop problem in XP)
256 Mb ram
VIA syschip (flashed to newest)

Maybe the somewhat dated nvidia drivers is the problem? Problem is all the newer drivers makes XP crash (the infamous infinite loop)

Thanks for taking your time! :o)

Share this post


Link to post
Share on other sites
quote:
Original post by russian-bear
The examples from that book preforms very bad on my own comp as well, its a dual AMD MP 1.2g and a GF4 Ti4400 ! He is using a totaly screwed up technique for rendering 2d in d3d 8. The book is great for an introduction to windows programming / and an overview of D3D8 but don try to learn his ways to draw things its just not a good practice to blit to backbuffer in D3D8 !

You can actualy try DEFAULT values for refresh rate and presentation interval it might increase the performance in fullscreen..



OK. So his code isn''t exactly something I should try to incorporate as my own way of coding DX? :-) Good to hear that it''s not only me having problems with that code. It would still be nice to find out what causes this problem, though.

Any other books you would recommend that covers the same topics, but with nicer code?

Thanks!

Share this post


Link to post
Share on other sites
quote:
Original post by olemann
Every program that goes fullscreen, just seems to set screen resolution, go fullscreen but then gets transparent. The result is that I only se my Windows Desktop / Visual C++ blown up to the resolution the D3D program is running in, and can't see the actual program's window. The program does not crash (I can close it with ESC or alt-f4), just runs like a "see-trough" window on top of my other programs.



You might try looking the code over really well. Find where the members of the window class structure (WNDCLASS or WNDCLASSEX) are filled out. In his code the hbrBackground member of the WNDCLASSEX structure is probably set to fill the window with the 'hollow' or transparent look you've seen. Try setting the hbrBackground member to (HBRUSH)GetStockObject(BLACK_BRUSH). That'll change it to black (other colors are possible). Hope this helps.


"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein

[edited by - core on May 2, 2002 11:41:27 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Um. Shouldn''t the HBRUSH be set to NULL? And fill the background with directX instead?

Share this post


Link to post
Share on other sites
Now I''ve tried setting the hbrBackground to black. That didn''t make any difference at all, the window is still transparent.

The original code from the cd reads:

wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = GlobalWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = AppInstance();
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = 0;
wcex.lpszClassName = m_name.c_str();
wcex.hIconSm = 0;

I tried with
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);

But as I said, it didn''t mean any difference.

How do I fill the background with DirectX, like one of you said? Could that be the solution to this?

I really appreciate your effort in trying to helping me here. I''ve been tempted to just lay off this whole DX8 programming as I never even got an empty black fullscreen working.. :-)

Share this post


Link to post
Share on other sites
my suggestion is to get another book. make sure its a basic book since you dont seem to know the win32 api yet. learn the win32 api correctly. also, i would ask ppl a good book to use, as well as read user reviews at sites like amazon. this will ensure you get a great book for your level and not something that teaches things wrong to make it "easier". ANY book where the examples dont work would go back to the store if i bought it. worst case is that they dont take it back, but more then likly you can get store credit (dont ask for money, less chance they will consider that). you can then put that towards a better book. amke sure the book is in good condition, cd is in the sleeve, and you do it soon. the longer you wait the harder it becomes. just tell them that the cd is not working and that you think it might be because the stuff is too advanced for your computer. most books dont give system requirements on the cover so you are lucky in that respect.

Share this post


Link to post
Share on other sites
No its nothing like that ithink...
There is some things that have great impact on performance (atleast for my system) i have marked them with *** :


    
d3dpp.BackBufferWidth = bWindowed ? 0 : SCREEN_WIDTH;
d3dpp.BackBufferHeight = bWindowed ? 0 : SCREEN_HEIGHT;
d3dpp.BackBufferFormat = bWindowed ? d3ddm.Format : D3DFMT_A8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWnd;
d3dpp.Windowed = bWindowed;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
***d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
***d3dpp.FullScreen_PresentationInterval = bWindowed ? 0 : D3DPRESENT_INTERVAL_DEFAULT;
***d3dpp.Flags = 0;


You should learn about all those parameters and how they work.
No if you notice the parameter 'd3dpp.Flags = 0' because i dont use the lockable backbuffer. You should avoid that at all costs cause nowdays graphic cards is more optimal for 3D primitives and math than for blitting to backbuffer like the old days.

Now you should realy learn how to use D3D8 for 2D graphics..
If you can aford to by another book you should defenatly go for "Programming Role Playing Games with DX8". This book is so damn great it will blow your mind ! A realy good friend to that book is "Special FX Game Programming With DX8" its great too. And when you realy getting advanced you should aim for "Realtime Rendering Tips And Trics With DX8". If your realy wanna go for hardcore 2D programming in D3D you should get the book "2D in Direct3D". Havent read that one but i have looked inside in the bookstore and it was great.

But start with "Programming RPG with DX" its realy good, thrust me!

If you have any questions just dump them here in the forum. I got alot of help in here since i started with DirectX about five weeks ago!




[edited by - russian-bear on May 2, 2002 1:54:34 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!