Skip to main content
gamedev.net
🔒 Locked

Stupid Question

Started by Morkhai Jul 6, 2000 at 9:54 AM 15 replies 600+ views
Original Post
Morkhai
Morkhai
Ok... I''m trying to go through the DirectDraw tutorials in the DX7 SDK. I''m only on the first one. I have created my window, created my DD object, changed the video mode, and created my primary surface and back buffer. I have essentially cut and pasted the code from the tutorial. AT WHAT POINT IS MY FREAKIN UGLY WINDOW SUPPOSED TO DISAPPEAR AND LEAVE ME WITH A SCREEN TO DRAW ON?! It changes video modes and the window stays. It creates the primary surface and the window stays. How do I make that god-awful piece of bad UI design go away? thanks
NuffSaid
NuffSaid
Specify
    
WS_VISIBLE/WS_POPUP

whem you call CreateWindow, instead of the usual WS_OVERLAPPEDWINDOW. That would do the trick.

========================================================
If something sounds stupid but works, it's not stupid
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
TheTwistedOne
TheTwistedOne
It won''t disappear. Not until you put something on the primary surface. Try clearing the backbuffer, and flipping the primary surface.

In a lot of cases (on nVidia graphics cards, anyway), the primary surface is what Windows draws on. It''s not some mystical construct, or anything.

TheTwistedOne
http://www.angrycake.com
TheTwistedOnehttp://www.angrycake.com
Gladiator
Gladiator
I think I know what you''re talking about (not 100% sure)...

In your CreateWindow() function instead of having WS_OVERLAPPEDWINDOW use WS_POPUP.. that should solve the problem.. hopefully...

..-=ViKtOr=-..
Gladiator
Gladiator
apology for repeating what NuffSaid has said

I open all the threads from gamedev.net, and by the time i got to this one, 100 people have answered the question already.. what a shame
kill
kill
Come on, give M$ a break. The design is not that bad. I actually like it, because it''s the best I''ve seen so far.

The window isn''t supposed to disappear by itself. If you just create the primary surface and the backbuffer, and change the video mode, the window will stay. It dissappears when you start flipping the prim surface and the backbuffer. Another words, clear the back buffer, flip, and the window will disappear.

P.S. Not everything M$ does it bad. Don''t let prejudice screw up your ability to look at things objectively.
Morkhai
Morkhai
Thanks for the help guys. I knew it was a stupid question!
After I posted I thought about it and decided that was probably it.

As for M$, I''m not really that prejudiced against them. In fact, I''m not a Linux nut or anything... I like Windows... I just like the elegance of the BeOS UI better.

However, there aren''t many opportunities to get into the gaming industry on the BeOS at the moment, so...


anyhow, thanks again for all the help!
x3r0
x3r0
Dudez, are u ppl crazy? Ignorant?
Yez the primary surface is the GDI surface
so therefore when your directx program starts
u will see the window, probably covering the whole screen.

Windows will still draw on this for ur program.
If u dont want the window to be seen, DRAW SOME CRAP OVER IT!
My Direct Draw engine always clears the screen when it starts
after the window has been created.

-John
X E R O-D E V E L O P M E N THTTP://WWW.X3R0.COM
Gladiator
Gladiator
noz... we r ! nutz... we knowz what i r talk''n ''bout.. don getz crazy witz uz now...
IO Fission
IO Fission
What a quaint little language you people have here...

- IO Fission

Tearing 'em apart for no particular reason...
TheTwistedOne
TheTwistedOne
x3r0 - what was the point of that? Why do people insist on repeating what''s already been said, but doing it in l33t hAx0r sp34k, mixing in insults too?

Of course, there is no point.

TheTwistedOne
http://www.angrycake.com
TheTwistedOnehttp://www.angrycake.com
Gladiator
Gladiator
Exactly! That''s the point I was trying to make. o O
JoeyBlow2
JoeyBlow2
You will want to create your window, then create your dd7 object and your front/back buffer. After doing so, clear the back buffer then "show" your window... You might have to clear the front buffer as well (do the same thing on your front buffer surface... My example is on the back buffer.

// Clear buffer
DDBLTFX caps;
memset(∩︀, 0, sizeof(caps));

caps.dwSize = sizeof(caps);
caps.dwFillColor = D3DRGB(0,0,0);

global.ddsb->Blt(NULL, NULL, NULL, DDBLT_WAIT / DDBLT_COLORFILL , ∩︀);

// Update the "real window" with our display.
ShowWindow(mainhwnd, cmdshow);
UpdateWindow(mainhwnd);
win32mfc
win32mfc

Yes, the first thing I do is make a black pop-up window that covers the entire screen. It''s in C++ w/ MFC, but here''s the code I wrote to do it. Note the WS_VISIBLE / WS_POPUP window style, and the BLACK brush.

// CHRIS

    
BOOL CMDDraw::Create(HINSTANCE hInstance, int ResX, int ResY)
{
TRACE("CMDDraw::Create()\n");

DDSURFACEDESC ddsd;
DDSCAPS ddscaps;
HRESULT ddrv;

// Register window class for GameWindow

CString strWindowClass = AfxRegisterWndClass(CS_HREDRAW / CS_VREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(BLACK_BRUSH));
m_GameWindow = new CGameWindow;
CRect rc(0,0, ::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN));
DWORD dwStyle = WS_VISIBLE / WS_POPUP;

// Create GameWindow; just a black window covering entire screen

if(!m_GameWindow->CreateEx(0,
strWindowClass,
"GameWindow",
dwStyle,
rc.left, rc.top, rc.Width(), rc.Height(),
NULL, // NO HWND = DESKTOP; for main window use AfxGetMainWnd()->GetSafeHwnd()
NULL))
{
TRACE("CMDDraw::Create() - m_GameWindow->CreateEx() Failed!\n");
Release();
return FALSE;
}

// Ensure window is visible

m_GameWindow->ShowWindow(SW_SHOWNORMAL);
m_GameWindow->UpdateWindow();
m_GameWindow->SetFocus();

/*
* create the main DirectDraw object
*/

if(DirectDrawCreate( NULL, &m_lpDD, NULL ) != DD_OK)
{
TRACE("CMDDraw::Create() - DirectDrawCreate() Failed!\n");
m_lpDD = NULL;
Release();
return FALSE;
}

// Get exclusive mode

if(m_lpDD->SetCooperativeLevel( m_GameWindow->m_hWnd, DDSCL_EXCLUSIVE / DDSCL_FULLSCREEN ) != DD_OK)
{
TRACE("CMDDraw::Create() - SetCooperativeLevel() Failed!\n");
Release();
return FALSE;
}

// Set the video mode to ResX x ResY x 8-BPP

if(m_lpDD->SetDisplayMode( ResX, ResY, 8) != DD_OK)
{
TRACE("CMDDraw::Create() - SetDisplayMode() Failed!\n");
Release();
return FALSE;
}

// Create the primary surface with 1 back buffer

ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS / DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE /
DDSCAPS_FLIP /
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
if( m_lpDD->CreateSurface( &ddsd, &m_lpDDSPrimary, NULL ) != DD_OK )
{
TRACE("CMDDraw::Create() - CreateSurface(m_lpDDSPrimary) Failed!\n");
Release();
return FALSE;
}

ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrv = m_lpDDSPrimary->GetAttachedSurface(&ddscaps, &m_lpDDSBack);
if( ddrv != DD_OK )
{
TRACE("CMDDraw::Create() - GetAttachedSurface() Failed!\n");
Release();
return FALSE;
}

// Palette and Other Surfaces created here.. <REMOVED>


// Return Success

return TRUE;
}

// CHRIS [win32mfc]
furby100
furby100
EEk!
MFC!

------------------------------
#pragma twice
Gladiator
Gladiator
MFC rulez... that''s what i use all the time for DX and all my other projects..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.