Skip to main content
gamedev.net
🔒 Locked

DirectX Lock Problem

Started by lshadow 3 replies 750+ views
Original Post
lshadow
lshadow
I''m trying to lock a surface so I can load a bitmap onto it, but each time I run the program it fails right after the lock. I thought their might be an error, so I checked the lock for return values and it gave me DD_OK. So I''m wondering how can I have DD_OK and a program error? Oh, I''ve been getting this error every time I try to lock the surface in a member fuction of a class. Using visual c++ and DirectX 7.
Working on: DoP
Spellbound
Spellbound
What call is it that fails?
CGameProgrammer
CGameProgrammer
Just in case you''re not doing it right:

HRESULT hrValue;
DDSURFACEDESC DDSurfDesc;

ZeroMemory( &DDSurfDesc, sizeof DDSurfDesc );
DDSurfDesc.dwSize = sizeof DDSurfDesc;

hrValue = lpSurface->Lock( NULL, &DDSurfDesc, DDLOCK_WAIT, NULL );

Otherwise, I have no idea what can be causing that problem.

~CGameProgrammer( );

~CGameProgrammer( ); Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
TV
TV
As CGameProgrammer stated, you MUST clear the DDSURFACEDESC structure, and set dwSize to sizeof(DDSURFACEDESC). If you fail to do this, not only will it not work, but the Lock() function misleading returns DD_OK.
lshadow
lshadow
Actually found that the error was after the Lock. When locking the surface, no debug strings could be output, so I found my error after commenting out certain portions of the code. Code is in topic - DirectX Mysteries
Working on: DoP

Topic Locked

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

Sign in to reply to this topic.