Pixel Plotting

Hello.


I thought I had a pixel plotting function which worked, but know that I use it ever time in my main loop (other tests were only once in whole running of app), it works, however when I exit the application it barfs up the Windows error dialog saying the usual (This program has performed an illegal operation and will be shut down...)


I cant put my finger on what the problem is in the pixel plotting routine (although I have isolated the bug down to that routine :)


Oh yeah, it may be worth mentioning I didnt check to see if the function call returned an error. I assumed all went well because the pixel was displayed, but perhaps I am being stupid in that assumption.


here it is:


BOOL WritePixel( LPDIRECTDRAWSURFACE lpiDestinationSurface, LONG iX, LONG iY,

BYTE iR, BYTE iG, BYTE iB )

{

HRESULT ddreturn;


ZeroMemory(&ddsd, sizeof(ddsd));

ddsd.dwSize = sizeof( DDSURFACEDESC );

BYTE* surfacePixels;


ddreturn = lpiDestinationSurface->Lock( NULL, &ddsd, DDLOCK_WAIT, NULL );

if( ddreturn != DD_OK )

return false;



// ixUnlock( NULL );

if( ddreturn != DD_OK )

return false;


return true;

}


Comments

  • BOOL WritePixel( LPDIRECTDRAWSURFACE lpiDestinationSurface, LONG iX, LONG iY,

    BYTE iR, BYTE iG, BYTE iB )

    {

    HRESULT ddreturn;


    ZeroMemory(&ddsd, sizeof(ddsd));

    ddsd.dwSize = sizeof( DDSURFACEDESC );

    BYTE* surfacePixels;


    ddreturn = lpiDestinationSurface->Lock( NULL, &ddsd, DDLOCK_WAIT, NULL );

    if( ddreturn != DD_OK )

    return false;



    // ixUnlock( NULL );

    if( ddreturn != DD_OK )

    return false;


    return true;

    }


  • im sorry. for some strange reason, It is not pasting what I am copying and pasting. dont ask me why.


    sorry about wasting your time. Obviously if I cant copy and paste into a #$%^ box, I shouldnt be programming.




  • BOOL WritePixel( LPDIRECTDRAWSURFACE lpiDestinationSurface, LONG iX, LONG iY,

    BYTE iR, BYTE iG, BYTE iB )

    {

    HRESULT ddreturn;


    ZeroMemory(&ddsd, sizeof(ddsd));

    ddsd.dwSize = sizeof( DDSURFACEDESC );

    BYTE* surfacePixels;


    ddreturn = lpiDestinationSurface->Lock( NULL, &ddsd, DDLOCK_WAIT, NULL );

    if( ddreturn != DD_OK )

    return false;



    // ixUnlock( NULL );

    if( ddreturn != DD_OK )

    return false;


    return true;

    }


  • i dont know what is happening. I paste the code into the field, and it looks allright, but then when I click submit follow up, the final thing doesnt turn out correct. It cuts it up.


  • In that bit of code I saw, you forgot to Unlock() the surface. Or maybe it was just cut out?


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories