Skip to main content
GameDev.net gamedev.net
🔒 Locked

Implementing a DirectX style surface

Started by confuzled Oct 28, 2005 at 11:28 AM 1 replies 300+ views
Original Post
confuzled
confuzled
I am looking to implement some sort of DirectX style surface class that I can then inherit from to create variations such as texture or z buffer classes. Ok, now I want the resulting texture class to be able to store ANY type of image data, by this I mean any bit depth or format. E.g it would be able to store the image as a series of bytes for the r,g and b componants or as floating point values in order to accomodate hight dynamic range data (should it be required). Now I have implementted a generic buffer in C using an array of bytes to store the data which can then be accessed as whatever you want it to be. This works well (so far). But I was wondering if this was the best/ only way to do this in c++ or I should somehow make use of templates? Finally as an extension, in my c implementation I use a lock function which takes a void** and sets it to point at the data stored in the buffer. A matching unlock function also takes a void** which it then makes invalid. This is a bit clumsy I know so I was wondering how DirectX allows you to simply call an unlock function without passing in the pointer to the locked buffer? Any ideas? Any thoughts appreciated. Thank you all.
Stevieboy
Stevieboy
Are you using the directx sdk by any chance? If you are you can create textures or sufaces in any format you want (D3DX does the work for you), and you can as you mentioned also lock the surfaces, also you can copy one surface to another as a block as well, pluse you can specify a colour key see -D3DXLoadSurfaceFromSurface(..).

edit. oops sorry didn't quite answer your question, I think it might happen (if it needs to), behind the scenes, remember you use that particular surface to lock and unlock it, so directx probably already knows which pointer you are using. - lock and unlock are methods of that surface.
confuzled
confuzled
No I am not using directX. I mean as if you were going to write your own software in the style of directX.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.