지혜는 경험에서 우러나온다. 경험은 어리석음 속에서 얻어진다. ―사샤 기트리
<!>
Contents
- 1 DX8 SDK를 설치한 후에, 이전에 작성한 내 프로그램 소스를 컴파일하는데 error LNK1104: Cannot Open File "d3dim.lib"라는 에러가 뜬다.
- 2 화면에 D3D를 사용하여 타일 맵을 그리려고 한다. 왜 경계끼리 서로서로 정확히 맞지 않는 것인가?
- 3 When I use the D3DX shape creation functions to generate a mesh, there are no texture coordinates in the vertices. How can I set texture coordinates?
- 4 DX 8 Graphics로 어떻게 다중 윈도우로 랜더링을 할 수 있는가?
- 5 When loading a texture with the D3DX texture creation functions I specify a color key, but no transparency appears when I render the image.
- 6 I am rendering with alpha blending and setting the alpha of the diffuse vertex component to determine the opacity. It works when there is no texture set, but as soon as I set a texture the alpha that I set is no longer applied. Why?
- 7 Why does rendering of pre-transformed vertices appear to be slower in DX 8?
- 8 Why does rendering of an ID3DXMesh object slow down significantly after I define subsets?
- 9 Why doesn't Intellisense offer code completion options for DX 8 interfaces under VC++?
- 10 Will applications that I compile with the DirectX 8.1 SDK be compatible with systems with the DirectX 8.0 runtimes?
- 11 I have heard that DirectX 8.1 no longer supports Windows 95. Can I compile applications compatible with Windows 95 if I have the DirectX 8.1 SDK installed?
- 12 Why do my calls to IDirect3DDevice8::Getxxxx fail?
- 13 ID3DXSprite::Draw()를 사용해서 1:1 비율로 이미지를 그리려고 할때, 스프라이트가 원본 이미지와 다르다. 이유는?
- 14 Why does my programmable vertex shader fail during creation on some hardware?
1 DX8 SDK를 설치한 후에, 이전에 작성한 내 프로그램 소스를 컴파일하는데 error LNK1104: Cannot Open File "d3dim.lib"라는 에러가 뜬다. #
DX 8 SDK를 설치한 후에, 이전 버젼의 DX 소스를 컴파일하면 다음과 같은 에러가 뜰 때가 있다:
LINK : fatal error LNK1104: cannot open file "d3dim.lib"이것은 D3D Immediate Mode (지금은 DirectGraphics으로 불린다) 라이브러리가 d3d8.lib로 화일명이 변경되었기 때문이다. 이것은 수정하려면 프로젝트의 링크설정에서 d3dim.lib로 지정된 것을 d3d8.lib로 변경해라.
2 화면에 D3D를 사용하여 타일 맵을 그리려고 한다. 왜 경계끼리 서로서로 정확히 맞지 않는 것인가? #
이것은 삼각형을 랜더링할 때 어느 픽셀을 그려야하는지, 삼각형으로 둘러싸인 각 픽셀중 중심이 어느것인지 알아내는데 사용되는 알고리즘때문에 일어나는 현상이다. 픽셀의 중심은 정수값으로 지정되어있으므로 만약 직사각형을 정의하기 위해 정수 좌표들을 사용하고 있다면 각 면들은 픽셀들에 걸쳐져있게 될 것이다. (다시말하면, 딱 맞게 지정되지않는다. 정수좌표로는 정확한 빗면을 지정하기 어렵기 때문이다.)
이것에 대한 대책으로, 당신이 작성한 기변형된 폴리곤요소(pre-transformed primitive)를 0.5픽셀만큼 각 방향으로 확장시켜라. 이것에 대한 예제를 보려면,
A Simple Blit Function for Direct3D의 예제를 참조해라.
A Simple Blit Function for Direct3D의 예제를 참조해라.
3 When I use the D3DX shape creation functions to generate a mesh, there are no texture coordinates in the vertices. How can I set texture coordinates? #
To add texture coordinates, you will first have to use the D3DXCloneMeshFVF function to create a duplicate of the mesh with a new vertex format which contains elements for storing texture coordinates (tu,tv). For an example of how to do this, take a look at the source code in Spherical Texture Mapping.
4 DX 8 Graphics로 어떻게 다중 윈도우로 랜더링을 할 수 있는가? #
This can be accomplished by creating a swap chain for each window, using IDirect3DDevice8::CreateAdditionalSwapChain(), then setting the appropriate chain's frame buffer as the render target before rendering.
For more information, see
Rendering to Multiple Windows.
Rendering to Multiple Windows.
5 When loading a texture with the D3DX texture creation functions I specify a color key, but no transparency appears when I render the image. #
Color keying is not directly supported in DirectX 8, transparency instead being handled through alpha blending. If you need to render color keyed images with transparency, the D3DX texture creation functions bridge the gap by automatically generating an alpha mask that culls out pixels of a specified color.
There are a couple of reasons that this may occur. Probably the most common error is in specifying a key color with an alpha of zero. Since bitmaps are assumed to be opaque, all pixel values read from the file will be assigned an alpha of 255. Unless the key color has a matching alpha value, the color key test will fail. You can prevent this by using a color function that allows you to specify alpha, or by OR'ing your color value with 0xff000000.
The other reason that color keying may fail is that the proper alpha blending states have not been set. The following should be set prior to rendering to achieve transparency:
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
6 I am rendering with alpha blending and setting the alpha of the diffuse vertex component to determine the opacity. It works when there is no texture set, but as soon as I set a texture the alpha that I set is no longer applied. Why? #
The problem originates in the texture blending stages, rather than in the subsequent alpha blending. Alpha can come from several possible sources. If this has not been specified, then the alpha will be taken from the texture, if one is selected. If no texture is selected, then the default will use the alpha channel of the diffuse vertex component.
Explicitly specifying the diffuse vertex component as the source for alpha will insure that the alpha is drawn from the alpha value you set, whether a texture is selected or not:
pDevice->SetTextureStageState(D3DTSS_ALPHAOP,D3DTOP_SELECTARG1); pDevice->SetTextureStageState(D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);If you later need to use the texture alpha as the source, set D3DTSS_ALPHAARG1 to D3DTA_TEXTURE.
8 Why does rendering of an ID3DXMesh object slow down significantly after I define subsets? #
You probably have not optimized the mesh after defining the face attributes. If you specify attributes and then call ID3DXMesh::DrawSubset(), this method must perform a search of the mesh for all faces containing the requested attributes. In addition, the rendered faces are likely in a random access pattern, thus not utilizing vertex cache. After defining the face attributes for your subsets, call the ID3DXMesh::Optimize or ID3DXMesh::OptimizeInPlace methods with the D3DXMESHOPT_ATTRSORT flag. See Creating Subsets in ID3DXMesh for more information.
9 Why doesn't Intellisense offer code completion options for DX 8 interfaces under VC++? #
The problem is that the IDE is drawing its information from the older headers that were installed with VC++. It will also use information from the headers in your project files, though simply using #include does not cause them to be inventoried from the new headers. You can enable Intellisense with the new interface by adding the header files containing the definitions to your project (e.g. D3DX8.H and D3D8.H for Direct3D). Right click on your project in the FileView pane, select "Add Files to Project...", then select the necessary include files from the DXSDK\INCLUDE\ directory.
10 Will applications that I compile with the DirectX 8.1 SDK be compatible with systems with the DirectX 8.0 runtimes? #
By default, applications compiled under 8.1 will require the 8.1 runtimes to run, because some of the interfaces have changed and have different GUIDs. However, you can specify a constant when creating the Direct3D object that will use the 8.0 interfaces. Rather than creating an object as shown in the docs with
g_pD3D=Direct3DCreate8(D3D_SDK_VERSION);instead use
g_pD3D=Direct3DCreate8(120);The value 120 is equal to the D3D_SDK_VERSION that was specified in the DirectX 8.0 headers, which has been changed in the 8.1 SDK. Specifying the original value will cause 8.0 version interfaces to be used by Direct3D, providing compatibility with 8.0. Note that new features in 8.1, such as the latest pixel shader versions (1.2 - 1.4), will not be available.
11 I have heard that DirectX 8.1 no longer supports Windows 95. Can I compile applications compatible with Windows 95 if I have the DirectX 8.1 SDK installed? #
The DirectX 8.1 interfaces require Windows 98 or higher, and will thus not be available on Windows 95. However, you can force applications compiled under the DirectX 8.1 SDK to use the 8.0 interfaces, allowing for Windows 95 compatibility. For information on how to specify creation of 8.0 interface explicitly, go here.
12 Why do my calls to IDirect3DDevice8::Getxxxx fail? #
This usually occurs when using a pure device, that is, a device created with the D3DCREATE_PUREDEVICE flag. Such a device does not support any of the Get*() functions for any values that can be stored in state blocks.
13 ID3DXSprite::Draw()를 사용해서 1:1 비율로 이미지를 그리려고 할때, 스프라이트가 원본 이미지와 다르다. 이유는? #
이미지 화일이 텍스쳐로 읽혀들여질때, 비트맵은 하드웨어의 성능에 맞추기위해 비율이 조정된다. 일반적으로 이것은 2의 승수가 아닌 해상도를 가진 이미지들은 가장 가까운 2의 승수에 맞추어 확대된다는 것을 의미한다.
D3DXCreateTextureFromFileEx()을 사용해서 이미지를 읽을때, D3DXIMAGE_INFO 구조체 변수의 포인터를 넘겨준다. (여기에는 함수실행후 원본 이미지의 정보가 담기게 된다.) 이 구조체 값과 IDirect3DTexture::GetLevelDesc() 함수를 사용해서 택스쳐의 크기를 얻어낸 후, 1:1 랜더링의 원하는 확대비율을 산출할 수 있다. 이 비율을 가지고 ID3DXSprite::Draw()에 적용하면 된다.
LPDIRECT3DTEXTURE8 pText; D3DXIMAGE_INFO info; D3DXCreateTextureFromFileEx(....,&info,....,&pText); D3DSURFACE_DESC desc; pText->GetLevelDesc(0,&desc); D3DXVECTOR2 vScaling; vScaling.x=info.Width/desc.Width; vScaling.y=info.Height/desc.Height;
14 Why does my programmable vertex shader fail during creation on some hardware? #
This may be because the device created by your application is using hardware vertex processing, but the video hardware or driver does not support the programmable vertex shader execution in hardware, or does not implement the version of vertex shader code required by your shader. To prevent this, you should check for vertex shader support when evaluating devices that use hardware vertex processing. For example, if you are implementing a vertex shader that requires Version 1.0 support, you would add the following to the ConfirmDevice() code (assuming you are using the D3DApp framework):
if( (dwBehavior & D3DCREATE_HARDWARE_VERTEXPROCESSING ) ||
(dwBehavior & D3DCREATE_MIXED_VERTEXPROCESSING ) )
{
if( pCaps->VertexShaderVersion < D3DVS_VERSION(1,0) )
return E_FAIL;
}
You do not need to perform this check on devices using software vertex processing, as shader support is guaranteed through emulation.








