473,398 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

DirectDraw Clipper

Howdy!
I'm having a bit of trouble with my DirectDraw clipper. The code compiles fine and runs without a hitch; however, it doesn't work. That is, there is no clipping! I get the exact same behavior as when I have no clipper used. It's all very mysterious as I've compared my code with dozens of others' that work, yet I can't find any differences in mine. I've tried to reduce my relevant code to as little as possible. Here is the function that initializes all my DirectX Stuff and returns the hWnd (minus some error-catching calls to simplify things):

Expand|Select|Wrap|Line Numbers
  1. int InitDirectDraw(HWND hWnd)
  2. {
  3.     DDSURFACEDESC2    ddsd;
  4.     DDSCAPS2        ddscaps;
  5.     HRESULT            hRet;
  6.  
  7.     // Create the main DirectDraw object.
  8.     hRet = DirectDrawCreateEx(NULL, (VOID**)&lpDD, IID_IDirectDraw7, NULL);
  9.     if( hRet != DD_OK ) return -1;
  10.  
  11.     // Get exclusive mode.
  12.     hRet = lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | DDSCL_ALLOWREBOOT);
  13.     if( hRet != DD_OK ) return -2;
  14.  
  15.     // Set the video mode to 640x480x16.
  16.     hRet = lpDD->SetDisplayMode(640, 480, 16, 0, 0);
  17.     if( hRet != DD_OK ) return -3;
  18.  
  19.     // Prepare to create the primary surface by initializing
  20.     // the fields of a DDSURFACEDESC2 structure.
  21.     ZeroMemory(&ddsd, sizeof(ddsd));
  22.     ddsd.dwSize = sizeof(ddsd);
  23.     ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
  24.     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
  25.     ddsd.dwBackBufferCount = 1;
  26.  
  27.     // Create the primary surface.
  28.     hRet = lpDD->CreateSurface(&ddsd, &lpDDSFront, NULL);
  29.     if( hRet != DD_OK ) return -1;
  30.  
  31.     // Get a pointer to the back buffer.
  32.     ZeroMemory(&ddscaps, sizeof(ddscaps));
  33.     ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
  34.     hRet = lpDDSFront->GetAttachedSurface(&ddscaps, &lpDDSBack);
  35.     if( hRet != DD_OK ) return -1;
  36.  
  37.     // Clipper Initialization
  38.  
  39.     // Create the clipper using the DirectDraw object
  40.     lpDD->CreateClipper(0, &lpDDClipper, NULL);
  41.  
  42.     // Assign your window's HWND to the clipper
  43.     lpDDClipper->SetHWnd(0, hWnd);
  44.  
  45.     // Attach the clipper to the primary surface
  46.     lpDDSFront->SetClipper(lpDDClipper);
  47.  
  48.     return 0;
  49. }
And here is how it's called:

Expand|Select|Wrap|Line Numbers
  1. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow)
  2. {
  3.     hInst = hInstance;
  4.     hWnd = InitWindow(hInst, nCmdShow); 
  5.  
  6.     if(!hWnd) return -1;
  7.  
  8.     if(InitDirectDraw(hWnd) < 0)
  9.     {
  10.         CleanUp();
  11.         MessageBox(hWnd, "Could not start DirectX engine in your computer. Make sure you have at least version 7 of DirectX installed.", "Error", MB_OK | MB_ICONEXCLAMATION);
  12.         return 0;
  13.     }
  14.  
  15.     . . .
  16.  
  17.     CleanUp();
  18.  
  19.     return 0;
  20. }
Apr 28 '07 #1
3 4065
I'm afraid my post may not have been noticed so, per forum rules, I am posting this message. I'm working on a large project, but will unfortunately be completely unable to progress until this issue has been solved.

Thanks in advance! :)
May 2 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
This code:
Expand|Select|Wrap|Line Numbers
  1. lpDD->CreateClipper(0, &lpDDClipper, NULL);
  2.  
has these return values:

DDERR_INVALIDOBJECT The object is invalid.
DDERR_INVALIDPARAMS One or more of the input parameters is invalid.
DDERR_OUTOFMEMORY DirectDraw does not have enough memory to perform the operation.
DDERR_NOCOOPERATIVELEVELSET

but I don't see that you check for them.

Expand|Select|Wrap|Line Numbers
  1. lpDDClipper->SetHWnd(0, hWnd);
  2.  
also has return values that are not checked for:

DDERR_INVALIDCLIPLIST
DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS
DDERR_OUTOFMEMORY


Are you sure your calls are working as expected?
May 2 '07 #3
Yeah, for the sake of simplicity I left out the error-checking, but it's there. There are no errors. It's just not doing anything...
May 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nieuwsgroep | last post by:
Is it possible to open clipper databases and .ntx indexes ? Can I search etc. ?
3
by: ads | last post by:
Hi Everyone, I'm starting learning python about 2 weeks, and still have difficulties to create GUI based application because I never learn about classes and other OOP things. Does anyone knows...
1
by: ads | last post by:
Thank you for the respon, But right now I'm still not ready using linux, a lot of my client were using windows. Is someone know what should I use to create text console application like clipper...
10
by: level8 | last post by:
I would like to see a Clipper/dbase DBF file as a table in SQL Server 7.0. How can I SELECT rows from DBF file? Should I use OLE DB Provider or ODBC, and how?
3
by: Rob | last post by:
Hi, I have been asked by a customer to try to resurrect a rather ancient application their organisation uses that was written in Clipper. This I am fine with. However, there is a module that was...
0
by: Tim Bücker | last post by:
Hello. I want to render in a picturebox (pbD3DSurface) using DirectDraw. This is working more or less but the coordinates are always screen oriented and not pictureBox oriented. x = 10;...
6
by: Tim Bücker | last post by:
Hello. What is the best to use? DirectDraw from DirectX 7.0 or Direct3D from DirectX 8.0 when the only thing one wants to do is to draw bitmaps fast on the screen in fullscreen mode. I think...
0
by: Tim Bücker | last post by:
Hello. I am using the namespace Microsoft.DirectX.DirectDraw. How is it possible to create a surface from - a System.Drawing.Image object (or System.Drawing.Bitmap object) - an image that...
6
by: Tyson Ackland | last post by:
Is there a good site folks know of that leads a beginner through DirectDraw using VB.NET? TyBreaker
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.