Click here to Skip to main content
15,912,578 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: LNK2005 Pin
skaanji14-Oct-03 12:02
skaanji14-Oct-03 12:02 
GeneralRe: LNK2005 Pin
Jonas Larsson14-Oct-03 20:39
Jonas Larsson14-Oct-03 20:39 
Generaldtmf decoding Pin
Member 55624714-Oct-03 10:42
Member 55624714-Oct-03 10:42 
GeneralRe: dtmf decoding Pin
Michael P Butler14-Oct-03 22:50
Michael P Butler14-Oct-03 22:50 
GeneralVC6 compilation problem in oleidl.h Pin
Kuniva14-Oct-03 10:31
Kuniva14-Oct-03 10:31 
GeneralRe: VC6 compilation problem in oleidl.h Pin
Chris Richardson14-Oct-03 11:10
Chris Richardson14-Oct-03 11:10 
QuestionJAXB for C++? Pin
Ravi Bhavnani14-Oct-03 9:57
professionalRavi Bhavnani14-Oct-03 9:57 
General[DDraw] Surface creating problem Pin
furbyhater14-Oct-03 9:36
furbyhater14-Oct-03 9:36 
Hi, this is my first post on the forum, my name's Florian and I'm from Switzerland (where they make the cheese Wink | ;)
Right now I'm beginning DDraw with c++ (where I'm still quite a beginner too), and I have started writing a DDraw class, a wrapper of a sort, to facilitate casual operations. One of the member functions is a function wich takes a LPDIRECTDRAWSURFACE7 as a parameter and should create a offscreen surface & point to it with the given LPDIRECTDRAWSURFACE7. But somehow it doesn't work, because when I check the pointer after having used the function, he's always invalid.
Here's the code:
<br />
// bool bKey checks for color-keying, iMemFlags controls memory<br />
// allocation (system/video memory)<br />
<br />
ENUM_RESULT CDDraw::CreateOffscreen(int iWidth, int iHeight, bool bKey, LPDIRECTDRAWSURFACE7 lpSurface, int iMemFlags)<br />
{<br />
	// clear ddsd and set size<br />
	memset(&itsDdsd,0,sizeof(itsDdsd) );<br />
	itsDdsd.dwSize = sizeof(itsDdsd);<br />
<br />
	// color-keyed surface or not<br />
	if(!bKey)<br />
		itsDdsd.dwFlags =  DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;<br />
<br />
	else<br />
	{<br />
		itsDdsd.dwFlags =  DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CKSRCBLT;<br />
<br />
		// set the defined color key<br />
		itsDdsd.ddckCKSrcBlt.dwColorSpaceLowValue  = itsTransColor;<br />
		itsDdsd.ddckCKSrcBlt.dwColorSpaceHighValue = itsTransColor;<br />
	}<br />
<br />
	itsDdsd.dwWidth		= iWidth;<br />
	itsDdsd.dwHeight	= iHeight;<br />
<br />
	itsDdsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | iMemFlags;<br />
<br />
	// destroy previous surface, if valid<br />
	if(lpSurface)<br />
	{<br />
		lpSurface->Release();<br />
		lpSurface = NULL;<br />
	}<br />
<br />
        // itsLpDD points to a valid DD object<br />
	if(FAILED(itsLpDD->CreateSurface(&itsDdsd, &lpSurface, NULL) ) )<br />
	{<br />
		// error<br />
		return(VID_ERR_CREATEOFFSCREEN);<br />
	}<br />
<br />
	return(OK);<br />
}<br />

All the "its*" variables are class variables (of CDDraw), and I try to create the offscreen surface in another class, CMain, wich contains an instance of CDDraw ("itsVideo"), and a LP to a DD surface, "itsSprite". What I try to do looks like this:
<br />
// Set the color key<br />
  itsVideo.SetColorKey(255,0,255);<br />
<br />
  // Create the sprite surface<br />
  if ( (itsResult = itsVideo.CreateOffscreen( <br />
                             64,64,true,itsLpSprite) ) != OK)<br />
  { <br />
	// error<br />
    itsError.ShowMessage(itsWin.GetHwnd(), itsResult);<br />
  }<br />
<br />
  // check if valid surface has been created<br />
  if(!itsLpSprite)<br />
  { <br />
	// error<br />
    itsError.ShowMessage(itsWin.GetHwnd(), itsResult);<br />
  }<br />


And each time, I get an invalid surface...
Any advice/criticism (I'm sure there's alot to critic Wink | ;) is welcome...
Generalconvert string to double without losing precision Pin
godzooky14-Oct-03 9:18
godzooky14-Oct-03 9:18 
GeneralRe: convert string to double without losing precision Pin
Steve S14-Oct-03 9:24
Steve S14-Oct-03 9:24 
Generalnew class non mfc Pin
thes3cr3t114-Oct-03 8:41
thes3cr3t114-Oct-03 8:41 
GeneralRe: new class non mfc Pin
Steve S14-Oct-03 8:46
Steve S14-Oct-03 8:46 
GeneralRe: new class non mfc Pin
David Crow14-Oct-03 9:05
David Crow14-Oct-03 9:05 
GeneralRe: new class non mfc Pin
Steve S14-Oct-03 9:13
Steve S14-Oct-03 9:13 
GeneralRe: new class non mfc Pin
thes3cr3t114-Oct-03 9:09
thes3cr3t114-Oct-03 9:09 
GeneralRe: new class non mfc Pin
Steve S14-Oct-03 9:20
Steve S14-Oct-03 9:20 
GeneralRe: new class non mfc Pin
thes3cr3t114-Oct-03 21:06
thes3cr3t114-Oct-03 21:06 
QuestionDebug statements/debug dump??? Pin
LukeV14-Oct-03 8:37
LukeV14-Oct-03 8:37 
AnswerRe: Debug statements/debug dump??? Pin
Steve S14-Oct-03 8:43
Steve S14-Oct-03 8:43 
AnswerRe: Debug statements/debug dump??? Pin
Anthony_Yio15-Oct-03 1:31
Anthony_Yio15-Oct-03 1:31 
GeneralRe: Debug statements/debug dump??? Pin
LukeV15-Oct-03 2:41
LukeV15-Oct-03 2:41 
GeneralCreateNewChild question. Pin
Maximilien14-Oct-03 8:34
Maximilien14-Oct-03 8:34 
GeneralRe: CreateNewChild question. Pin
Steve S14-Oct-03 8:38
Steve S14-Oct-03 8:38 
GeneralRe: CreateNewChild question. Pin
Maximilien14-Oct-03 9:08
Maximilien14-Oct-03 9:08 
GeneralRe: CreateNewChild question. Pin
Steve S14-Oct-03 9:13
Steve S14-Oct-03 9:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.