Solved

CreateSuface failing

Posted on 1997-06-30
5
273 Views
Last Modified: 2013-12-03
Will somebody please tell me what's wrong with this. CreateSurface is
returning DDERR_INVALIDPARAMS. I'm trying to create a single surface to
display a picture. I'm using the Cygnus GNU-Win32 compiler (beta 18) and
need the code to be in C. I've looked at all the sample code I can find
and can't figure out what's wrong.

LPDIRECTDRAWSURFACE lpDDSPrimary;  
LPDIRECTDRAW lpDD;
HRESULT ddrval;
DDSURFACEDESC ddsd;
DDSCAPS ddscaps;
.
.
ddrval = DirectDrawCreate(NULL,&lpDD,NULL);
ddrval = lpDD->lpVtbl->SetCooperativeLevel(lpDD,hWnd,DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN);
ddrval = lpDD->lpVtbl->SetDisplayMode(lpDD,640,480,8);

memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
ddrval = lpDD->lpVtbl->CreateSurface(lpDD,&ddsd,&lpDDSPrimary,NULL);
if (ddrval != DD_OK)
 {
 lpDD->lpVtbl->Release(lpDD);
 return FALSE;
 }

Thanks in advance...

Nick Gallimore
0
Comment
Question by:guzza
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:byang
ID: 1399697
Your code is too minimalistic. You also need to specify DDSD_HEIGHT|DDSD_WIDTH for dwFlags, and set dwWidth and dwHeight:

ddrval = lpDD->lpVtbl->SetDisplayMode(lpDD,640,480,8);

memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
ddsd.dwHeight=480; ddsd.dwWidth=640;
ddsd.ddsCaps.dwCaps = DDSC
0
 

Author Comment

by:guzza
ID: 1399698
Doesn't make a difference.
0
 
LVL 3

Expert Comment

by:byang
ID: 1399699
Just add more flags. Don't expect CreateSurface to automatically creates a surface matching the current screen mode.
0
 

Author Comment

by:guzza
ID: 1399700
Any ideas/suggestions as to which ones to try? I tried adding DDSD_BACKBUFFERCOUNT,  DDSD_ALPHABITDEPTH and DDSD_PIXELFORMAT, but nothing changed.

0
 
LVL 1

Accepted Solution

by:
YamSeng earned 150 total points
ID: 1399701
There are several possibilities:
1) Use the ddscaps editor provided with dx to check whether the resolution you want is supported. If it's not it will not return a dd_ok.

2) Are u using the directx headers compiled for the cygnus gnu compiler? if u're not u may run into problems

I'm using DX5, my createsurface function requires only 3 parameters.  
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
link access with Quickbooks 9 56
T-SQL Debugging - Temp Object Content 2 54
Having a different time zone on your task bar 3 70
Where did System.Data.Objects go? 2 40
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question