DirectX5.0 Latest Game Programming Guide DirectDraw Articles Third, DirectDraw Elements (4)

zhaozj2021-02-11  193

5, the palette (PALETTE) toning surface requires a palette to display it correctly. A toning surface (both color index) is a simple set of numbers, each of which is characterized by a pixel. The value of the number is an index of a color table, which tells DirectDraw to display what color when each pixel is used. The DirectDrawPalette object is often referred to as a palette that provides a simple way to manage color tables. The palette is not used using a 16-bit or higher pixel format. The DirectDrawPalette object characterizes an index color table for a color index surface with 2, 4, 16 or 256 entities. Each entity in the palette is a RGB ternary group, which describes the color used in the display surface. Color tables can include 16-bit and 24-bit RGB ternary groups to characterize the color used. For a 16-color palette, the color table can also contain an index of another 256-color palette. The palette can be applied to textures, exterior surfaces, and coverage surfaces, they do not require the same palette as the main surface. You can call the iDirectdraw2 :: createPalette method to create a palette that acquires the pointer of the IDirectdrawPalette interface of the palette object. Then, the method of the interface can then be used to process the entity of the palette, and obtain information or initialization objects related to the ability of the object (if the palette is created with the COM function CoCreateInstance). Call the idirectdrawsurface3 :: setPalette method to attach a palette on a surface. A single palette can be applied to multiple surfaces. The DirectDrawPalette object retains entities 0 and entities 255 to 8-bit palette, unless you specify that DDPCAPS_ALLOW256 flags are available for both entities available. You can get a palette entity with the idirectdrawpalette :: getEntries method, modify the palette entity with the IDirectDrawpalette :: STENTRIES method. 5.1, palette type DirectDraw supports 1 bit, 2-bit, 4-bit, and 8-bit palette. A palette can only be attached to a surface with the same pixel format. For example, a 2 entity palette created by the DDPCAPS_1bit flag can only be attached to the 1-bit surface created with the DDPF_PALETTEINDEXED1 flag. Alternatively, you can create a palette that does not contain color tables, ie the index palette. Different from the color table, the index palette contains an index value, which is characterized by another palette color table. To create an index palette, call the idirectdraw2 :: createpalette method, specify the DDPCAPS_8BITENTRIES logo. For example, to create a 4-bit palette, you also need to specify DDPCAPS_4BIT and DDPCAPS_8BITENTRIES flags. When you create an index palette, pass a pointer to the byte array. 5.2. Setting the setting palette on the non-main surface (SETTING) palette can be attached to any toning surface (main surface, background buffer, exterior surface and texture map), but only attached The palette on the main surface can affect the system palette. It must be noted that the DirectDRAW bit block transmission does not perform a color transform operation, and any source surface and destination surface attached to the bit block are ignored. The palettes on the non-main surface are mainly used for Direct3D applications. 5.3, Sharing Palettes palette can be shared between multiple surfaces. The same palette can be attached to a forward buffer and background buffer, or a plurality of texture surfaces.

When using the idirectdrawsurface3 :: setPalette method, the surface increases the index value of the palette when the index value of the surface reaches 0, which reduces the palette attached. The index value. In addition, if a palette is separated from the same surface, the index value of the palette of the surface is also reduced. 5.4, ​​Palette Animation Moving Panel Animation refers to the process of changing the appearance of the surface by changing the surface of the surface by changing the surface of the surface. Repeat the palette again, the surface looks like a change, but in fact, the true content of the surface has no change. Therefore, the palette animation provides a method of changing the display performance of the surface without changing the specific content of the surface. Two methods can be provided for linear palette animations: i. Modify the palette entity II in a single palette. Switching between multiple palettes, you can change the tumble The entities of those related colors are called in the board, then call the IDirectDrawpalette :: setEntries method to reset these entities at a time. The second method requires 2 or more DirectDrawPalette objects, and then calls the iDirectdrawSurface3 :: setPalette method to attach a palette object to the surface object to generate an animation. Both methods are independent of hardware, so which way to use is mainly to see if the application is suitable.

6, the clipper (Clipper) or the DirectDrawClipper object allows the bit block to be transmitted to the selected part of the surface. A clipboard object pulls a list of one or more clipboards in the sea. A list of clipboards is a bounded rectangular or several bounded rectangular columns, which is a piece of block or several areas that allow bit blocks to be transferred in the surface. These areas are represented by the Rect structure in a screen coordinate. The clip list is a very useful tool, which is the most commonly used to prohibit the application to write data blocks to places that are outside the screen. For example, if you want to display a wizard from the screen boundary, you don't want the elf to pop up, and slowly move slowly from the screen border to the center of the screen. If there is no clipboard object, you need to include the logic that restrict bit block operations to protect surface memory. The following figure shows the shear of this class. You can use the shear board object to be a certain area of ​​a destination rectangle, and DirectDRAW will transfers the bit block to the bit block to protect the specified pixels other than the specified shear rectangle. This cutting method is shown below: 6.1, Clip List DirectDraw uses DirectDrawClipper objects to manage the clip list. A clip-cut list is a series of rectangles that describe the surface visible area. A DirectDrawClipper object can be attached to any surface. One window handle can also be attached to the DirectDrawClipper object. In this case, DirectDraw will use the clip list updated in the window to modify the DirectDrawClipper clippers. Although the clipping list in DirectDraw Hal is visible, DirectDraw also calls HAL only when using rectangular bit blocks to meet the clip list requirements. For example, if the upper left corner rectangle of a surface is cut off, when the application writes the surface block to the main surface, DirectDRAW will use HAL to perform two bit block transmission operations, the first time, the upper left corner of the transmission surface, The second operation is the lower half of the transmission surface. This clipped list can be transferred to the driver (if the driver supports cut), instead of calling the driver if the driver supports shearing. In addition, you can call the idirectdrawclipper :: sethwnd method to a single window by the handle of the specified window. The cover surface supports the shear feature only when the cover hardware supports shear or the destination Color Key is not activated. 6.1, Sharing DirectDrawclipper object DirectDrawClipper objects can be shared between multiple surfaces. For example, the same DirectDrawClipper object can be used at the same time and the front desk and background buffers of the chain. When the application uses the IDirectdrawSurface3 :: setClipper method to attach a DirectDrawClipper object at a surface, the secondary surface adds the index value of the object. If a DirectDrawClipper object is the same surface (this surface is created with the idirectdrawsurface3 :: setClipper method) separated by an empty shear board interface pointer, the index value of the DirectDrawclipper object will be reduced. 6.3, stand-alone clipboard object You can create a DirectDrawClipper object that is not directly from any DirectDraw object. This clipboard object can be shared between multiple DirectDRAW objects. The driver independent clipboard object can be created with a new DirectDraw function DirectDrawCreateClipper, which calls the function before creating any DirectDRAW object. Because the DirectDRAW object cannot own these independent DirectDrawClipper objects, these DirectDrawClipper objects are not automatically released when the objects in the app are released.

转载请注明原文地址:https://www.9cbs.com/read-4908.html

New Post(0)