rifter1818 Posted July 5, 2004 Posted July 5, 2004 Transparancys not working hence i cant see clearly ha ha ok bad joke. Heres my problem. Ive loaded a set of textures from a Bitmap and i want all of the Black to be transparant so currently (d3d.dev is my Direct3d device) my settings are as follows (but it doesnt work theres black squares everywhere). [CS] d3d.Dev.RenderState.Lighting = false; d3d.Dev.RenderState.Ambient = Color.White;//redundant but when/if i enable lighting.... d3d.Dev.RenderState.CullMode = Cull.None; d3d.Dev.RenderState.AlphaBlendEnable = true; d3d.Dev.RenderState.AlphaTestEnable = true; d3d.Dev.RenderState.ReferenceAlpha = Color.Black.ToArgb(); d3d.Dev.RenderState.AlphaFunction = Compare.NotEqual; [/CS] Quote
ThePentiumGuy Posted July 6, 2004 Posted July 6, 2004 here's what i do while loading the texture: SpriteImage = TextureLoader.FromFile(dxDevice, ImageName, width,height, D3DX.Default, 0, Format.Unknown, Pool.Default, Filter.Point, Filter.Point, TheTransparentColor.ToArgb) and before rendering: dxDevice.RenderState.SourceBlend = Blend.SourceAlpha dxDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha dxDevice.RenderState.AlphaBlendEnable = True and after rendering (for performance reasons) dxDevice.RenderState.AlphaBlendEnable = False Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
rifter1818 Posted July 6, 2004 Author Posted July 6, 2004 here's what i do while loading the texture: SpriteImage = TextureLoader.FromFile(dxDevice, ImageName, width,height, D3DX.Default, 0, Format.Unknown, Pool.Default, Filter.Point, Filter.Point, TheTransparentColor.ToArgb) and before rendering: dxDevice.RenderState.SourceBlend = Blend.SourceAlpha dxDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha dxDevice.RenderState.AlphaBlendEnable = True and after rendering (for performance reasons) dxDevice.RenderState.AlphaBlendEnable = False Thats how i normally do it too, but in this case im using from bitmap and i cant find an overload that allows a colorkey. Quote
ThePentiumGuy Posted July 6, 2004 Posted July 6, 2004 oh, so you've loaded multiple textures from one bitmap.. the only way that i see to get around it is to take the bitmap and save it.. mybitmap.save("sometempfile.bmp") and then use FromFile, and then delete the bitmap.... horrible memory handling though ;) pent Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
rifter1818 Posted July 7, 2004 Author Posted July 7, 2004 That is what im gonna do But man oh man is that inefficiant, i hope someone can find a more efficiant way.... Quote
createdbyx Posted July 18, 2004 Posted July 18, 2004 But man oh man is that inefficiant' date=' i hope someone can find a more efficiant way....[/quote'] Have you tryied not fiddling with all the D3D flags and simply tried to use a image format that supports transparency like TGA or PNG. If I can avoid working with color keys and transparency flags I uses paint shop pro to create a png image and simply draw out what parts of the image I want to be trans parent. Then when I load my png image into D3D it automatically makes use of the images transparency. No fuss no mess. Just a suggestion... Possibly even more efficient for you to do it that way also. ;) Quote Created by: X createdbyx@gmail.com www.createdbyx.com
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.