Программирование игр, создание игрового движка, OpenGL, DirectX, физика, форум
GameDev.ru / Программирование / Форум / Как синхронизироваться с обратным ходом луча в DirectX7?

Как синхронизироваться с обратным ходом луча в DirectX7?

AlexNorНовичокwww5 апр. 200515:02#0
Мне надо выводить в окно растр - который меняет положение каджые 10-20 мс - я пытался через WaitForVerticalBlank - ничего хорошего - и 100% время проца сьедает и иногда пропускает время начала обратного хода луча.
Через GeScanLine - тоже самое - если всё время опрашивать - процессор загружает, если засыпать - можно пропустить время обратного хода луча....
Pre_AlFaНовичокwww5 апр. 200515:17#1
IDirectDrawSurface7::Flip
The IDirectDrawSurface7::Flip method makes the surface memory associated with the DDSCAPS_BACKBUFFER surface become associated with the front-buffer surface.

HRESULT Flip(
  LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride,
  DWORD dwFlags
);

Parameters
lpDDSurfaceTargetOverride
Address of the IDirectDrawSurface7 interface for an arbitrary surface in the flipping chain. The default for this parameter is NULL, in which case DirectDraw cycles through the buffers in the order that they are attached to each other. If this parameter is not NULL, DirectDraw flips to the specified surface, instead of the next surface in the flipping chain. The method fails if the specified surface is not a member of the flipping chain.
dwFlags
Flags specifying flip options.
DDFLIP_DONOTWAIT
On IDirectDrawSurface7 interfaces, the default is DDFLIP_WAIT. If you want to override the default and use time when the accelerator is busy (as denoted by the DDERR_WASSTILLDRAWING return value), use DDFLIP_DONOTWAIT.
DDFLIP_EVEN
For use only when displaying video in an overlay surface. The new surface contains data from the even field of a video signal. This flag cannot be used with the DDFLIP_ODD flag.
DDFLIP_STEREO
DirectDraw flips and displays a main stereo surface. When this flag is set, stereo autoflipping is enabled. The hardware automatically flips between the left and right buffers during each screen refresh.
DDFLIP_INTERVAL2
DDFLIP_INTERVAL3
DDFLIP_INTERVAL4
These flags indicate how many vertical retraces to wait between each flip. The default is 1. DirectDraw returns DERR_WASSTILLDRAWING for each surface involved in the flip until the specified number of vertical retraces has occurred. If DDFLIP_INTERVAL2 is set, DirectDraw flips on every second vertical sync; if DDFLIP_INTERVAL3, on every third sync; and if DDFLIP_INTERVAL4, on every fourth sync.
These flags are effective only if DDCAPS2_FLIPINTERVAL is set in the DDCAPS structure returned for the device.

DDFLIP_NOVSYNC
Causes DirectDraw to perform the physical flip as close as possible to the next scan line. Subsequent operations involving the two flipped surfaces do not check whether the physical flip has finished—that is, they do not return DDERR_WASSTILLDRAWING for that reason (but might for other reasons). This allows an application to perform flips at a higher frequency than the monitor refresh rate, but might introduce visible artifacts.
If DDCAPS2_FLIPNOVSYNC is not set in the DDCAPS structure returned for the device, DDFLIP_NOVSYNC has no effect.

DDFLIP_ODD
For use only when displaying video in an overlay surface. The new surface contains data from the odd field of a video signal. This flag cannot be used with the DDFLIP_EVEN flag.
DDFLIP_WAIT
Typically, if the flip cannot be set up because the state of the display hardware is not appropriate, the DDERR_WASSTILLDRAWING error returns immediately, and no flip occurs. Setting this flag causes the method to continue trying to flip if it receives the DDERR_WASSTILLDRAWING error from the hardware abstraction layer (HAL). The method does not return until the flipping operation has been successfully set up or another error, such as DDERR_SURFACEBUSY, is returned.
Return Values
If the method succeeds, the return value is DD_OK.

If it fails, the method can return one of the following error values:

DDERR_GENERIC
DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS
DDERR_NOFLIPHW
DDERR_NOTFLIPPABLE
DDERR_SURFACEBUSY
DDERR_SURFACELOST
DDERR_UNSUPPORTED
DDERR_WASSTILLDRAWING


Remarks
With IDirectDrawSurface7, the default behavior of this method is to wait for the accelator to finish. Therefore, under default conditions, this method never returns DDERR_WASSTILLDRAWING. If you want to see the error codes and not wait until the flip operation succeeds, use the DDFLIP_DONOTWAIT flag.

This method can be called only for a surface that has the DDSCAPS_FLIP and DDSCAPS_FRONTBUFFER capabilities. The display memory previously associated with the front buffer is associated with the back buffer.

The lpDDSurfaceTargetOverride parameter is used in rare cases in which the back buffer is not the buffer that should become the front buffer. Typically, this parameter is NULL.

The IDirectDrawSurface7::Flip method is always synchronized with the vertical blank. If the surface has been assigned to a video port, this method updates the visible overlay surface and the target surface of the video port.

For more information, see Flipping Surfaces.

Requirements
  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 98.
  Header: Declared in ddraw.h.

See Also
IDirectDrawSurface7::GetFlipStatus
AlexNorНовичокwww5 апр. 200516:58#2
Спасибо.
Но Flip - это для fullscreen - а у меня оконное приложение
Pre_AlFaНовичокwww6 апр. 200511:03#3
"Ой, какой ты нудный!" (с) анекдот

Еще раз: любыми средствами найди SDK! 7-ой, 8-ой - неважно. А пока - так и быть, держи:

IDirectDrawSurface7::Blt
The IDirectDrawSurface7::Blt method performs a bit block transfer (blit). This method does not support z-buffering or alpha blending (see alpha channel) during blit operations.

HRESULT Blt(
  LPRECT lpDestRect,
  LPDIRECTDRAWSURFACE7 lpDDSrcSurface,
  LPRECT lpSrcRect,
  DWORD dwFlags,
  LPDDBLTFX lpDDBltFx
);

Parameters
lpDestRect
Address of a RECT structure that defines the upper-left and lower-right points of the rectangle to blit to on the destination surface. If this parameter is NULL, the entire destination surface is used.
lpDDSrcSurface
Address of an IDirectDrawSurface7 interface for the DirectDrawSurface object that is the source of the blit.
lpSrcRect
Address of a RECT structure that defines the upper-left and lower-right points of the rectangle to blit from on the source surface. If this parameter is NULL, the entire source surface is used.
dwFlags
A combination of flags that determine the valid members of the associated DDBLTFX structure, specify color-key information, or request special behavior from the method. The following flags are defined:
Validation flags
DDBLT_COLORFILL
Uses the dwFillColor member of the DDBLTFX structure as the RGB color that fills the destination rectangle on the destination surface.
DDBLT_DDFX
Uses the dwDDFX member of the DDBLTFX structure to specify the effects to use for this blit.
DDBLT_DDROPS
Uses the dwDDROP member of the DDBLTFX structure to specify the raster operations (ROPS) that are not part of the Microsoft® Win32® API.
DDBLT_DEPTHFILL
Uses the dwFillDepth member of the DDBLTFX structure as the depth value with which to fill the destination rectangle on the destination z-buffer surface.
DDBLT_KEYDESTOVERRIDE
Uses the ddckDestColorkey member of the DDBLTFX structure as the color key for the destination surface.
DDBLT_KEYSRCOVERRIDE
Uses the ddckSrcColorkey member of the DDBLTFX structure as the color key for the source surface.
DDBLT_ROP
Uses the dwROP member of the DDBLTFX structure for the ROP for this blit. These ROPs are the same as those defined in the Win32 API.
DDBLT_ROTATIONANGLE
Uses the dwRotationAngle member of the DDBLTFX structure as the rotation angle (specified in 1/100s of a degree) for the surface.
Color key flags
DDBLT_KEYDEST
Uses the color key associated with the destination surface.
DDBLT_KEYSRC
Uses the color key associated with the source surface.
Behavior flags
DDBLT_ASYNC
Performs this blit asynchronously through the first in, first out (FIFO) hardware in the order received. If no room is available in the FIFO hardware, the call fails.
DDBLT_DONOTWAIT
New for DirectX 7.0. Returns without blitting and also returns DDERR_WASSTILLDRAWING if the blitter is busy.
DDBLT_WAIT
Postpones the DDERR_WASSTILLDRAWING return value if the blitter is busy, and returns as soon as the blit can be set up or another error occurs.
Obsolete and unsupported flags
All DDBLT_ALPHA flag values.
Not currently implemented.
All DDBLT_ZBUFFER flag values
This method does not currently support z-aware blit operations. None of the flags beginning with "DDBLT_ZBUFFER" are supported in this release of DirectX.
lpDDBltFx
Address of the DDBLTFX structure.
Return Values
If the method succeeds, the return value is DD_OK.

If it fails, the method can return one of the following error values:

DDERR_GENERIC
DDERR_INVALIDCLIPLIST
DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS
DDERR_INVALIDRECT
DDERR_NOALPHAHW
DDERR_NOBLTHW
DDERR_NOCLIPLIST
DDERR_NODDROPSHW
DDERR_NOMIRRORHW
DDERR_NORASTEROPHW
DDERR_NOROTATIONHW
DDERR_NOSTRETCHHW
DDERR_NOZBUFFERHW
DDERR_SURFACEBUSY
DDERR_SURFACELOST
DDERR_UNSUPPORTED
DDERR_WASSTILLDRAWING


Remarks
This method is capable of synchronous or asynchronous blits (the latter is the default behavior), either display memory to display memory, display memory to system memory, system memory to display memory, or system memory to system memory. The blits can be performed by using source color keys and destination color keys. Arbitrary stretching or shrinking is performed if the source and destination rectangles are not the same size.

Typically, IDirectDrawSurface7::Blt returns immediately with an error if the blitter is busy and the blit could not be set up. Specify the DDBLT_WAIT flag to request a synchronous blit. When you include the DDBLT_WAIT flag, the method waits until the blit can be set up or another error occurs before it returns.

RECT structures are defined so that the right and bottom members are exclusive—therefore, right minus left equals the width of the rectangle, not 1 less than the width.
Pre_AlFaНовичокwww6 апр. 200511:12#4
Еще раз, на всякий случай: без SDK заниматься программированием под DirectX (любой версии) - НЕРЕАЛЬНО.

Это - справочник, который должен быть всегда под рукой, ибо вопросов, особенно в начале, возникает масса,
и никто тебе не будет вот такие вот куски оттуда постоянно выкладывать.

Поэтому - SDK любой ценой. DIXI.

AlexNorНовичокwww7 апр. 200522:00#5
Pre_AlFa - я не нудный - у меня SDK нету  - наверное плохо ищу...
На сайте MS есть токо 9-ый - его пока и качаю...

Blt - не синхронизируется с обратным ходом луча - во всяком в случае если вывод происходит в окно  (не fullscreen режим) - 100%.

/ Форум / Программирование игр / Графика

Тема в архиве.

2001—2018 © GameDev.ru — Разработка игр