Re: copy texture to another texture

Tech-Archive recommends: Speed Up your PC by fixing your registry




Richard [Microsoft Direct3D MVP] wrote:
[Please do not mail me a copy of your followup]

"brekehan" <cpisz@xxxxxxxxxxxxx> spake the secret code
<1169145972.126173.239100@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> thusly:

I have a class that has a LPDIRECT3DTEXTURE9 member. The need has
arisen for me to write a copy constructor. How can I copy one texture
to another without reloading it from file?

Do you need to create a new texture resource whose contents are
identical to the first resource or can you share the same texture
between the two C++ objects?

If the latter, then simply AddRef() the texture interface in the copy
constructor.

If the former, you'll have to create a new resource and StretchRect all
the levels from the source resource to the destination resource.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>

I was thinking about the latter, not realizing the first was an option.
I think sharing the resource is viable. Where is the resource contained
and managed? What will happen when I release a texture object and
texture object is still in use?

I'll try and find what I can in the msdn, but in the meantime, wanted
to post my reply anyway.

Here is my scenario:

A dialog parser reads though a .txt file of a bunch of 2d graphics
descriptions.
It comes across a font which is an art image of glyphs.
It creates a font object which in turn splits an image and calculates
texture coordinates.
The font object then creates the texture and holds a pointer to it
as a member
I then have a text area object which has a font as a member
To create the text area a font object is passed as an argument and
"copy constructed" to its member
Thus why I wanted to copy the texture

The idea is that the dialog parser can create a bunch of fonts and pass
in whatever font is needed for any text area it comes across. There may
be several text areas that use the same font. Since, the font contains
the texture, I wanted to copy it over in the text areas constructor.

.



Relevant Pages

  • Re: copy texture to another texture
    ... I think sharing the resource is viable. ... texture object is still in use? ... A COM object remains "live" as long as someone else holds a reference ... in whatever font is needed for any text area it comes across. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: copy texture to another texture
    ... I think sharing the resource is viable. ... texture object is still in use? ... A COM object remains "live" as long as someone else holds a reference ... in whatever font is needed for any text area it comes across. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Outline font rendering
    ... characters are anti-aliased, and this leads to artefacts inside ... also consider to render the text with a font rendering library - ... Freetype2 comes to mind - and upload the result as a texture. ... Especially if you want to render Unicode text this is the only ...
    (comp.graphics.api.opengl)
  • Re: copy texture to another texture
    ... [Please do not mail me a copy of your followup] ... arisen for me to write a copy constructor. ... Do you need to create a new texture resource whose contents are ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Rendered fonts dont look as they should
    ... the bitmap in GDI directly, the font is clear and sharp, white on ... When converting the bitmap to a texture and then drawing with ... OpenGL, the font looks shaded, some letters are much brighter than ... after rendering the font in GDI ...
    (comp.graphics.api.opengl)