What im currently doing is drawing multiple textures on a single IDirect3DTexture9 and then scale it to make a nice animation using ID3DXSprite.
Im searching a way to draw text on that final IDirect3DTexture9, however ID3DXFont does not apparently support it.
TextOut requires the DC of the texture and in consequence requires the texture to be in format D3DFMT_X8R8G8B8, which will make me lose my opacity support.
Is there anyway to do this without coding my own font engine?
DirectX9 and C++
Thanks.
Related
I have a directX11 texture which is of ARGB format. (different pixels has different alpha value, like the one below)
I need to render that texture on a transparent Window which means the desktop should appear behind the texture.
I am using SetLayeredWindowAttributes which could make the window transparent but it's boolean, i.e. a pixel appears either fully transparent or doesn't appear. I need to achieve per-pixel transparency level - where darkness is defined by the alpha value of the pixel (Something like AlphaBlend). How to achieve it?
Use UpdateLayeredWindow instead. Select a 32-bit ARGB bitmap into the source HDC.
A more fancy solution is WS_EX_NOREDIRECTIONBITMAP and ICompositorDesktopInterop but this is probably overkill in this case unless you need to do updates often. MSDN magazine did have a few articles about this. DirectComposition is intended to interop with Direct2D etc. where as UpdateLayeredWindow is much older and predates the DWM and any kind of visual tree rendering.
How to change background color of sprites to transparent by changing alpha after loading it to a SDL_Surface. Are there any functions in SDL which use a floodfill kind of algorithm and change all pixel with a given color to transparent on the outside. I don't want it to happen inside the border of the sprite if the same color is used.
Sample Image:
I would like to make the background blue here transparent before I blit it on the window surface using SDL_BlitSurface.
Only a color key (SDL_SetColorKey()) or a full alpha channel are going to help you here.
Note, that you can provide an alpha channel in your source graphics if you use a format such as PNG. If you only sometimes need/want an alpha, then provide the alpha channel in your source graphics and use SDL_SetSurfaceBlendMode() with SDL_BLENDMODE_NONE to blend without the alpha and SDL_BLENDMODE_BLEND to blend with it.
Both SDL_Surface and SDL_Texture support SDL_BlendMode.
Even if SDL provided another method, such as the fill you mentioned. You wouldn't want to use that. It is more difficult, expensive, and unnecessary overhead. You should stick with best practices here.
You may want to look into SDL_Texture and SDL_Renderer and switch to using a "texture atlas" instead of individual surfaces/textures for each image to maximize performance.
I learn OpenGL under Linux platform. Recently, I try to use texts created by glutBitmapCharacter() as the texture of some quadrics objects provided by glu or glut. However, glutBitmapCharacter() does not return a pointer so that I can't feed it to the glTexImage2D(). I had google it for quite a while, but all I found is some topic related to Android SDK which I have no experience to it.
All I can think of is to render texts and read it form buffer using glReadPixels(), then save it to a file. Next, read the pixels back from the file and refer it to a pointer. Finally, draw 3D objects with these texts as the texture (i.e. feed the pointer to the glTexImage2D()).
However, it's kind of silly. What I want to ask is: Are there some other alternative way to this?
Applying text on top of a 3D surface is not trivial with pure OpenGL. GLUT does not provide any tools for that. One possible option would be for you to implement your own text rendering methods, possibly loading glyphs using Freetype then create a texture with the glyphs and apply that texture to the polygons. Freetype-GL is a tiny helper library that would facilitate a lot if you were to do that.
Another option would be to again load the text glyphs into a texture and then apply them as decals over the geometry. That way you could still simulate a 2D text drawing in a flat surface (the decal) and then apply that on top of a 3D object.
I'm writting a simple software renderer,
load 3d model, process vertex, rasterization, texture, lighting,
all that things, all done.
I used SDL(not using OpenGL mode) to draw pixel on its SDL_Surface,
and call SDL_Flip, so one frame appears.
for some reason now I don't want to use SDL,
I just need a double-buffer to draw pixel.
I know there're someway to do this,
OpenGL, Direct3D, gdi,
maybe they're too "advanced" for this project,
what is the direct(or fastest) way to draw pixels to back-buffer on win32 ?
I'd recommend using a graphics API for this (OpenGL or Direct3D), but GDI would be the easiest option. You can create a DIB (Device Independent Bitmap) using the CreateDIBSection function which returns a pointer to the bitmap's memory. You can then modify the pixels of the bitmap however you please and draw it to your window's client area. See chapter 15 of Programming Windows (5th) by Charles Petzold for source code and explanation of this technique.
I've been playing with LWJGL a little, as a bit of a step up from Pygame. I'm trying to render a sprite and I was wondering if LWJGL has a function similar to Pygame's colorkey that lets you define a color in an image that will be rendered as transparent. Do you have to use an alpha channel in OpenGL?
OpenGL doesn't have any built in color keying support. You'll need to either manually swap your key for alpha on the CPU, or use a custom shader that replaces it on the fly.