rendering to surface / no transparancy?

Started by
3 comments, last by boebi 19 years, 8 months ago
Hi, Instead of using bitmaps for my text (pre rendered), I'd like to make my simple 2D text at startup by rendering it to a surface. It works pretty fine, I simply see a black 256x256 square with my message in Trebuchet. No problems there. But, I just cannot get the black background to be transparant, so that only the white text is visible. it's probably something simple, but I just cannot find the problem. Ofcourse I've tried the standard SrcBlend/DestBlend alpha blend operations. Making the render to texture: Set m_oTexture = objD3DX.CreateTexture(objDev, SURFACE_SIZE, SURFACE_SIZE, 1&, 0&, D3DFMT_R5G6B5, D3DPOOL_MANAGED) Render surface: Set oRTS = g_oD3DX.CreateRenderToSurface(g_oD3DDevice, SURFACE_SIZE, SURFACE_SIZE, _ DispMode.Format, 0&, D3DFMT_UNKNOWN) Clearing the render surface: g_oD3DDevice.Clear 0&, ByVal 0&, D3DCLEAR_TARGET, &HFF000000, 1!, 0& I hope someone knows the solution to this slightly annoying problem :) Thanks :)
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
Advertisement
This may or may not be the problem, but I noticed that you are using R5G6B5 format for your surface. This format does not have an alpha channel. You may be limited by your graphics card as to what formats you can use, but try using A8R8G8B8 (32bits) , A1R5G5B5 or A4R4G4B4 (both 16bits).

Hope this helps.
Unfortunatly, anything else than the R5G6B5 one will give errors.

I couldn't find anything on this at google, while I'm just sure that I'm not the only one trying to get something like this to work.. :)
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
Take a look at the Adapter Formats for your card in caps viewer, perhaps your card supports some other format. The card on my current this computer only supports using A8R8G8B8 and X8R8G8B8 as valid texture render targets ,in 'Fullscreen X8R8G8B8', and only R5G6B5 in 'Fullscreen R5G6B5.'

You might try looking for some combo of formats for your adapter/surface that allows you to write an alpha channel.

I just ran into this problem myself. I was rendering to an X8R8G8B8 texture, and I couldnt clear it to a transparent color. I changed this my making the texture A8R8G8B8. Unfortunately, it's totally up to your video card if you can do this. Check your device caps.

This topic is closed to new replies.

Advertisement