Jump to content
  • Advertisement

Archived

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

SikCiv

A guide and code for Reset() and D3DXSprite

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

Due to the numerous posts regarding the usage of D3D8Device->Reset() and D3DXSprite, I have created a guide (includes the source code) on how to get them working properly. The guide describes how to handle ALT-Tab and other similar problems using TestCooperativeLevel() and Reset(), and describes how the D3DXSprite functions. Follow the D3D8Sprite Wrapper link at:

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Thanks!
Been trying to get Reset working for ages.

Share this post


Link to post
Share on other sites
If you know how to load textures from your own fileformat that would be a gret thing to add.

(access to surfaces just like in DirectDraw).

Share this post


Link to post
Share on other sites
I am at work right now so I haven't looked much at your code but it does not support alpha masks does it ?

Do you know how to do this ? I don´t want all the pixels in my sprites to be blended by the same factor..

Note: I have made a 2D engine using DX6.1 with my own fileformat which includes alphamasks (for alphablending). I want to port it to DX8 using those sprite wrappers...But I want to be able to do the same stuff.

Oh another question. In yot initialize function you supply BPP and BitsPerTexel..Why must you specify 2 ColorDepths ?





Edited by - granat on September 7, 2001 12:49:11 PM

Share this post


Link to post
Share on other sites
quote:

I am at work right now so I haven''t looked much at your code but it does not support alpha masks does it ?

Do you know how to do this ? I don´t want all the pixels in my sprites to be blended by the same factor..

Note: I have made a 2D engine using DX6.1 with my own fileformat which includes alphamasks (for alphablending). I want to port it to DX8 using those sprite wrappers...But I want to be able to do the same stuff.

Oh another question. In yot initialize function you supply BPP and BitsPerTexel..Why must you specify 2 ColorDepths ?



The Wrapper doesnt support alpha masks (yet), its really only ment to help people convert their existing code from DDraw to D3D, though if u could modify the code to use alpha masks (which is definetely supported) and sent it to me so I can upload it, it would be appreciated.

As for your own fileformat, this isnt necessary since D3DX8 can load fileformats such as TGA that already contain masks.

I added BitsPerTexel just in case someone for example required 16Bit textures and 24/32Bit output for a specific task. Setting the BPT to 0 will use the same format as the BPP given.



  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
quote:
Original post by SikCiv
As for your own fileformat, this isnt necessary since D3DX8 can load fileformats such as TGA that already contain masks.



Oh yeas it IS necessary because I like my own fileformat where I can store all frames of a specific animation in a single file.. I know this is also possible in Tga by placing several frames next to each other. But the size of each of those frames cannot be stored in tga which means that you must hardcode these values in your source...Not pretty.

Besides I don´t like having the graphics exposed in "standard" formats.

Anyway..I just want to say that your article and sourcecode really made me want to port the code to DX8. Something I had previously discarded because I thought it would be too difficult.

I had hoped that you would know about the alphamask thing. I hate research. I like the actual gameplay coding.

If I ever finish my game and use parts of your wrapper I will remember to put you in the credits. *noting the name SikCiv in his notepad document*

Keep up the good work !!

(if you ever find out how to do the alphamask thing then please post it here or mail me).






Share this post


Link to post
Share on other sites
Alphamasking actually works if you include a mask with the texture being loaded.

I created a tga with half the mask filled with 255 values and the other half with 120 values.

All I need now is to find out how I can gain access to the texture so I can set the alpaha mask values individually.





Edited by - granat on September 8, 2001 5:25:31 PM

Share this post


Link to post
Share on other sites
quote:

All I need now is to find out how I can gain access to the texture so I can set the alpaha mask values individually.



To my understanding, a texture is basically a container for a
set of mipmapped surfaces, there is a way to get a pointer to
one of the surfaces by specifying its mipmap level then locking
it, though I havent actually tried it. Im planning on adding
this to the wrapper when I get some spare time.

quote:

Oh yeas it IS necessary because I like my own fileformat where I can store all frames of a specific animation in a single file.. I know this is also possible in Tga by placing several frames next to each other. But the size of each of those frames cannot be stored in tga which means that you must hardcode these values in your source...Not pretty.



U can load your own fileformat by creating an empty texture,
locking its surface, then tranferring the pixels across from
your file.
I personally prefer to let Direct3D handle the file loading
since it supports all the pixel formats, doing this
manually would be a major hassle. Each sprite has its own image
file, either as a BMP or JPEG. The frames/animations are on the
one surface and the game keeps the offsets and size info, though
this is fine because the sprites are dedicated to the game and
dont change much. The BMP and JPEG files are stored in my own
Data file format (similar to a ZIP file) so the data cannot be
ripped off. If u are going to convert to D3D maybe u should use
this technique, though its up to u.



  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
quote:
Original post by SikCiv
To my understanding, a texture is basically a container for a
set of mipmapped surfaces, there is a way to get a pointer to
one of the surfaces by specifying its mipmap level then locking
it, though I havent actually tried it. Im planning on adding
this to the wrapper when I get some spare time.



Yes I know. I found the functions but have not tried them yet.
Too bad GDI is useless in D3D. It could have done all the pixelformat conversion for me


quote:
Original post by SikCiv
The BMP and JPEG files are stored in my own
Data file format (similar to a ZIP file) so the data cannot be
ripped off. If u are going to convert to D3D maybe u should use
this technique, though its up to u.



But if you store the images in your own resourcefileformat how do you let D3D load the files for you ??





Edited by - granat on September 10, 2001 1:25:40 AM

Share this post


Link to post
Share on other sites
quote:

But if you store the images in your own resourcefileformat how do you let D3D load the files for you ??



I have a routine that extracts the whole image file from the data file into a malloced memory pointer. A D3DX function called D3DXLoadImageFromMemory takes the memory pointer and loads it like a normal disk based file.

  Downloads:  ZeroOne Realm

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!