Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

steve_bagnall

black lines round transparent texture

This topic is 5421 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am very new to this, so forgive me if this is really simple. What I am trying to do is get an image on the screen with transparency. I have created a bitmap with a number of images in it (montage01.bmp). The size of the whole composition is 320 x 288 pixels. The image I am displaying is 128 x 192 pixels, and is the top left image. The problem I am experiencing is that a thin line all the way across the top of the image and some of the way down the left of the image is showing. When I examine the bitmap in my graphics program, the areas that are coloured are all, RGB(0,0,0) black , and my transparent colour is black. The rest of the image is fully transparent as expected, it''s just these lines, and I can''t figure out why. I have pasted some relevent code below. I have tried using values one less in the CUSTOMVERTEX structure (i.e. 491 instead of 492, and 427 instead of 428 etc.), but the same error occurs. Hope someone can help me with this. Cheers, Steve. g_hResult = D3DXCreateTextureFromFileEx(g_pDirect3DDevice, "montage01.bmp", D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000, NULL, NULL, &g_pTexture); CUSTOMVERTEX triangleVertices[] = { {300.0f, 492.0f, 0.0f, 1.0f, 0.0f, 0.6667f,}, {300.0f, 300.0f, 0.0f, 1.0f, 0.0f, 0.0f,}, {428.0f, 300.0f, 0.0f, 1.0f, 0.4f, 0.0f,}, {300.0f, 492.0f, 0.0f, 1.0f, 0.0f, 0.6667f,}, {428.0f, 300.0f, 0.0f, 1.0f, 0.4f, 0.0f,}, {428.0f, 492.0f, 0.0f, 1.0f, 0.4f, 0.6667f,}, }; HRESULT g_hResult = g_pDirect3DDevice->CreateVertexBuffer(6 * sizeof(CUSTOMVERTEX), 0, D3DFVF_XYZRHW | D3DFVF_TEX1, D3DPOOL_DEFAULT , &g_pVertexBuf); VOID* pVertices; g_hResult = g_pVertexBuf->Lock(0, 0, (BYTE**)&pVertices, 0); if (FAILED(g_hResult)) { strcpy(g_szErrorMsg, "Error locking vertex buffer."); PostQuitMessage(WM_QUIT); return g_hResult; } memcpy(pVertices, triangleVertices, sizeof(triangleVertices)); g_pVertexBuf->Unlock(); g_pDirect3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); g_pDirect3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); g_pDirect3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); g_pDirect3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); g_pDirect3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); g_pDirect3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); // extra line in texture app g_pDirect3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); g_pDirect3DDevice->SetVertexShader(D3DFVF_XYZRHW|D3DFVF_TEX1); g_pDirect3DDevice->SetStreamSource(0, g_pVertexBuf, sizeof(CUSTOMVERTEX)); g_pDirect3DDevice->SetTexture(0, g_pTexture); if (SUCCEEDED(g_pDirect3DDevice->BeginScene())) { g_pDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); g_pDirect3DDevice->EndScene(); g_pDirect3DDevice->Present(NULL, NULL, NULL, NULL); }

Share this post


Link to post
Share on other sites
Advertisement
quote:
The size of the whole composition is 320 x 288 pixels.


I''d say that is your problem. Make the texture width and height a power of two (ie 256x256) and adjust your texture coords. Feel free to email me a screen shot neighbour

- Matt

Share this post


Link to post
Share on other sites
quote:
Original post by matibee
quote:
The size of the whole composition is 320 x 288 pixels.


I''d say that is your problem. Make the texture width and height a power of two (ie 256x256) and adjust your texture coords. Feel free to email me a screen shot neighbour

- Matt

- D3DXCreateTextureFromFile* automatically scales the texture if the device requires power-of-two textures.

- Texture coordinates are independent of texture width/height (they start at 0, and end at 1. Values greater than 1 or less than 0 wrap according to the wrapping mode set)

- I''ve not looked at the code (BTW, remember to use the [ source ][ /source ] tags - without the space s- for source-code formatting next time), but maybe your issue is related to this: Directly mapping texels to pixels


Muhammad Haggag

Share this post


Link to post
Share on other sites
Matt, changing the image size to 512 x 512 worked! Next time I have a question, I''ll just open the window and shout loudly

Thanks to both of you for your replies.

Cheers,
Steve

Share this post


Link to post
Share on other sites
quote:
Original post by Coder
- D3DXCreateTextureFromFile* automatically scales the texture if the device requires power-of-two textures.



That probably is the problem. In order to scale the image properly, it will undoubtedly interpolate some of the colors, causing lines around the edge of the intended picture that are almost black (so the colorkeying system won''t make it transparent properly).

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!