• Advertisement

Archived

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

Set Display Mode

This topic is 5756 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 have the following code to set the screen mode: // Set the Display Mode if ( DD_OK != ( gpDD->SetDisplayMode ( intScreenWidth, intScreenHeight, 16, 0, 0 ))) { return ( "Set Display Mode Failed." ); } and I have my resolution set to 1600 * 1200. I have been fiddling with different colour settings and have got some very wierd results. If I set it 8 then I can draw on the screen but if I draw something in the middle of the screen (800,600) then it appears on the far right of the screen half way down, any further to the right it is drawn on the left of the screen. If I set the colour to 24 bit then I get a Set Display Mode Failed Message (I have a GeForce 3 Ti 500) and if I set it to 32 then again I can draw on the screen but objects in the middle of the screen seem to be displayed again halfway down the screen but only 1/4 of the way across the screen from left to right. I want to set the colour depth to 24 bit. What am I doing wrong. The code used to set up the windows and direct draw is taked from another application written by someone else (I have permission) so I don''t understand most of it. It works fine in 16 bit though. Hope you can help Giles

Share this post


Link to post
Share on other sites
Advertisement
Hi,

Try a different resolution then 1600X1200, I'm not even really sure that resolution even exsists

If you still want a big resolution - try something like 1280x960, you might get more expected results and 24 bit might actually work.

The drawing oddities may be your drawing code, what exactly are you drawing? If it's dependant on bpp or the screen resolution (pitch), it could be the reason for diffrent results in different resolutions / bpp.

Hope that helps,

Destroyer

//----------------------------
I'm almost never right,
and almost always left...
----------------------------\

[edited by - Destroyer on April 17, 2002 8:20:44 AM]

Share this post


Link to post
Share on other sites
Thanks for the post. I have just tried 8 bit and 24 bit in 1024 * 768 resolution and get the exact same results. I can assure you that 1600 * 1200 is a valid resolution as it is what I have my desktop set to. I don''t really need this for my app though I just used it as it what I usually use.

All I am drawing is individiual pixels so I do use the pitch.

Here is my DD initialization code:

// DD_Start () /////////////////////////////////////////////////////////////
// This function initializes DirectDraw /////////////////////////////////////////////////////

char* DD_Start ( void )
{

// Create the DirectDraw Object
if ( DD_OK != ( DirectDrawCreateEx ( NULL, (VOID**) &gpDD, IID_IDirectDraw7, NULL )))
{
return ( "Create DD Object Failed." );
}


// Set the Co-operative level for DirectDraw
if ( DD_OK != ( gpDD->SetCooperativeLevel ( g_hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT )))
{
return ( "Set DD Co-operative Level Failed." );
}


// Set the Display Mode
if ( DD_OK != ( gpDD->SetDisplayMode ( intScreenWidth, intScreenHeight, 8, 0, 0 )))
{
return ( "Set Display Mode Failed." );
}


// Complete a DDSURFACEDESC2 struct for the Primary Surface
DDSURFACEDESC2 ddsd;
ZeroMemory ( &ddsd, sizeof ( DDSURFACEDESC2 ));

ddsd.dwSize = sizeof ( DDSURFACEDESC2 );
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 2;


// Create the Primary Surface
if ( DD_OK != ( gpDD->CreateSurface ( &ddsd, &gpDDSPrimary, NULL )))
{
return ( "Create Primary Surface Failed." );
}


// Get Address of Back Buffer
DDSCAPS2 ddscaps;
ZeroMemory ( &ddscaps, sizeof ( DDSCAPS2 ));
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;

if ( DD_OK != ( gpDDSPrimary->GetAttachedSurface ( &ddscaps, &gpDDSBackBuffer )))
{
return ( "Get Back-buffer Address failed." );
}


// Complete a BltFX struct
ZeroMemory( &ddbltfx, sizeof ( ddbltfx ) );
ddbltfx.dwSize = sizeof ( ddbltfx );
ddbltfx.dwFillColor = 0;


// Return success
return ( NULL );

}

and here is the code for drawing a frame with a sample of how I draw pixles. in reality there is a function call instead that draws my mesh.:

char* Game_Main ( void )
{
// Clear the Draw Surface
if ( FAILED ( gpDDSBackBuffer->Blt ( NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx )))
{
return ( "Clear Draw Surface with Blit Failed." );
}


DDSURFACEDESC2 ddsd; // DirectDraw Surface Description
ZeroMemory ( &ddsd, sizeof ( DDSURFACEDESC2 ));
ddsd.dwSize = sizeof ( DDSURFACEDESC2 );

// Lock Draw Surface
if ( FAILED ( gpDDSBackBuffer->Lock ( NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL )))
{
return ( "Lock Draw Surface failed." );
}

// Store vertical pitch of BackBuffer surface
pitch = (ddsd.lPitch >> 1);

// Store pointer to video-memory
video_buffer = (USHORT *)ddsd.lpSurface;


putPixel(x, y, (31 % 32) + ((31 % 64) << 6) + ((31 % 32 ) << 11));


// Unlock Draw Surface, we have finished drawing onto it
if ( FAILED ( gpDDSBackBuffer->Unlock ( NULL )))
{
return ( "Unlock Draw Surface Failed." );
}


// Flip BackBuffer to Primary surface
if ( FAILED ( gpDDSPrimary->Flip ( NULL, DDFLIP_WAIT )))
{
return ( "Flip BackBuffer to Primary Failed" );
}



// Return success
return ( NULL );

}

Hope this helps you work out what is wrong!

Thanks again

Giles

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi Roaders, are you running the dubug version of the directx runtime libraries with maximum debug output? You can check by going into control panel and checking your directx settings there. If you are, then if you are using Visual C++ then debug that line of code (and any other suspicious stuff) and make sure that the output window is enabled. The debug runtime libraries will dump lots of useful textual debug info into this window, which should help!

Kind regards,
Kevin

Share this post


Link to post
Share on other sites
Tnaks Kevin. I am using the debug version but I''m not getting any debug output. I have the little Debug tab pressed in the window at the bottom of the screen that brings up compile errors but it is blank. How do I debug that line of code?

Also this won''t work for the 32 bit mode which draws things on the screen but it is distorted. - maybe this is something to do with the pitch that I use to plot the pixels?

Share this post


Link to post
Share on other sites

  • Advertisement