Using DirectX For A Beginner

Started by
1 comment, last by [GaNoN] 24 years, 5 months ago
Hello [GaNoN]

Let me assume the following:

LPDIRECTDRAW7 pDD; // Should be initialized first

LPDIRECTDRAWSURFACE7 pSurf; // Should be initialized first

PBYTE pSurfPtr;

DDSURFACEDESC2 ddsd;

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

pSurf->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
pSurfPtr = (PBYTE) ddsd.lpSurface;
pSurfPtr[x + y * ddsd.lPitch] = Color;
pSurf->Unlock(NULL);

That's it.

VirtualNext

Advertisement
I am very used to programming in Djgpp with Allegro and Not. In directX I can create a surface and initialize DX, however I just want to know how to put a pixel on a surface.
NOTE: If you use a PWORD or a PULONG instead of a PBYTE then you have to divide ddsd.lPitch through 2 (PWORD) or 4 (PULONG) because the pitch is in bytes.

This topic is closed to new replies.

Advertisement