Jump to content
  • Advertisement

Archived

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

iwaskia

using D3DSprite, plot pixel?

This topic is 6174 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

Advertisement
You can:
1) Create a single pixeled texture and blit it using D3DXSprite.
This is suprisingly quite fast in D3D.

2) Grab the backbuffer and write a pixel yourself, though
you will need to account for all the common D3D Pixel Formats.

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
Well, what you can do is create a new, blank texture using the D3DXCreateTextureFunction(). Then you can use the Direct3DTexture8::LockRect() function to set a pixel on that texture and then draw the texture.

Pseudo Code:
    
LPDIRECT3DTEXTURE8 m_Texture;

D3DXCreateTexture( m_Device, width, height, 0,0, format,D3DPOOL_MANAGED, &m_Texture);

D3DLOCKED_RECT d3dlr;
m_Texture->LockRect(0, &d3dlr, 0, 0);

DWORD* imageData = (DWORD*)d3dlr.pBits
imageData[0] = 0xFF00FF00; //Set First Pixel to Green

m_Texture->UnlockRect(0);



Then just use your D3DXSPRITE::Draw() function to draw your texture.

-------
Andrew



Edited by - acraig on September 20, 2001 2:30:25 AM

Share this post


Link to post
Share on other sites
quote:
Original post by iwaskia
what about IDirect3DDevice8::Clear ?



I think that this would be overkill for plotting pixels. Plus I''m not sure that you can specify an individual pixel. You can use it to clear the screen or use it to draw rectangles. Unfortunately, I don''t think that it supports alpha blending though.


-------
Andrew

Share this post


Link to post
Share on other sites
if i want to change color, do i need to change the texture?
or set several textures?

when i draw, do i set src rect to 0,0,0,0 and dest rect to x,y,x,y?

actually i plot pixel for font (chinese, at least 5k characters),
it is not possible to put all fonts to texture,
i need to read the bit pattern and plot.

Share this post


Link to post
Share on other sites
I''m wondering - could you store the characters as sets of vertices that define the shape of the character. It might be faster than plotting pixels. For instance, the letter X could be represented as many pixels or 4 points (more for serifs, etc). Such a scheme would make for good scaling, rotating, etc.

Then again, it would be alot of up front work to define the shapes...

Share this post


Link to post
Share on other sites
quote:
Original post by iwaskia
as i mentioned, there are at least 5000 chinese characters !


Try looking at the CD3DFont class. It should be a sample in the SDK. What they do is create a texture and create a bitmap of the font and blt that to the texture. It show how they change the colour as well. You could do something similar. With so many characters you''d need to have several textures and then figure out what texture that the character is on.

So you could just use a graphics program to create several bitmaps with characters and then have a Font class that would handle the loading,storing, and drawing.

  
fontClass->Load()
{
load in all your bitmaps into an array of textures.
}

fontClass->Draw(int character, int x, int y)
{
if character is less then 100 set texture 1
if the character > 100 and < then 500 set texture 2
...

set the source rectangle for that character
draw the character at the x,y position.
}


-------
Andrew

Share this post


Link to post
Share on other sites
I considered this, but one question to ask is - how big do you need the font? I think any decent side would require ALOT of texture memory.

One other idea about glyphs... Can you use a truetype font? If so, can you use something like GetGlyphOutline to write a truetype glyph -> DX shape (vertices) converter. Again, some up front work, but an extremely flexible solution once you get it working.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!