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): - int InitDirectDraw(HWND hWnd)
-
{
-
DDSURFACEDESC2 ddsd;
-
DDSCAPS2 ddscaps;
-
HRESULT hRet;
-
-
// Create the main DirectDraw object.
-
hRet = DirectDrawCreateEx(NULL, (VOID**)&lpDD, IID_IDirectDraw7, NULL);
-
if( hRet != DD_OK ) return -1;
-
-
// Get exclusive mode.
-
hRet = lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | DDSCL_ALLOWREBOOT);
-
if( hRet != DD_OK ) return -2;
-
-
// Set the video mode to 640x480x16.
-
hRet = lpDD->SetDisplayMode(640, 480, 16, 0, 0);
-
if( hRet != DD_OK ) return -3;
-
-
// Prepare to create the primary surface by initializing
-
// the fields of a DDSURFACEDESC2 structure.
-
ZeroMemory(&ddsd, sizeof(ddsd));
-
ddsd.dwSize = sizeof(ddsd);
-
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
-
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
-
ddsd.dwBackBufferCount = 1;
-
-
// Create the primary surface.
-
hRet = lpDD->CreateSurface(&ddsd, &lpDDSFront, NULL);
-
if( hRet != DD_OK ) return -1;
-
-
// Get a pointer to the back buffer.
-
ZeroMemory(&ddscaps, sizeof(ddscaps));
-
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
-
hRet = lpDDSFront->GetAttachedSurface(&ddscaps, &lpDDSBack);
-
if( hRet != DD_OK ) return -1;
-
-
// Clipper Initialization
-
-
// Create the clipper using the DirectDraw object
-
lpDD->CreateClipper(0, &lpDDClipper, NULL);
-
-
// Assign your window's HWND to the clipper
-
lpDDClipper->SetHWnd(0, hWnd);
-
-
// Attach the clipper to the primary surface
-
lpDDSFront->SetClipper(lpDDClipper);
-
-
return 0;
-
}
And here is how it's called: - int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow)
-
{
-
hInst = hInstance;
-
hWnd = InitWindow(hInst, nCmdShow);
-
-
if(!hWnd) return -1;
-
-
if(InitDirectDraw(hWnd) < 0)
-
{
-
CleanUp();
-
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);
-
return 0;
-
}
-
-
. . .
-
-
CleanUp();
-
-
return 0;
-
}
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! :)
This code: -
lpDD->CreateClipper(0, &lpDDClipper, NULL);
-
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. -
lpDDClipper->SetHWnd(0, hWnd);
-
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?
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...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nieuwsgroep |
last post by:
Is it possible to open clipper databases and .ntx indexes ?
Can I search etc. ?
|
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...
|
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...
|
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?
|
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...
|
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;...
|
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...
|
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...
|
by: Tyson Ackland |
last post by:
Is there a good site folks know of that leads a beginner through DirectDraw
using VB.NET?
TyBreaker
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |