Retrieves the specified texture surface level. (?!)

Started by
5 comments, last by ShadowP13 20 years, 3 months ago
?!?!? I''ve been having messing around with different ways to manually put alpha information into a texture that has been loaded from a standard bitmap file. I''ve gotten a lot of help on this. But, I was digging through a tutorial I found on line about how to do this and at somepoint they called the GetSurfaceLevel which is a memeber of IDirect3DTexture9 (of course). What the hell does this function do? I''m pretty sure if I had a brief explanation of this function I''d completly understand the program I''ve been looking at. Microsofts SDK (bless their heart) says the function "Retrieves the specified texture surface level" which is, strangely enough, what I would of written in a help file if I had NO IDEA what the function did (since it''s basicly only rephrasing the name of the function).
Believe it or not, the idiot is learning.
Advertisement
Textures can have MIP levels. They''re created automatically when you create the texture. Level 0 is the full resolution, 1 is half by half, 2 quarter by quarter, etc. If you only create one level, you can just get level 0 and that''s it. Otherwise, each MIP level is its own surface object, and you can play with each one by itself.

I like pie.
[sub]My spoon is too big.[/sub]
So, the purpose of the function "GetSurfaceLevel" is to have DirectX tell you how many miplevels a texture has? That doesn''t make sence. Infact, I''m asuming from "Retrieves the specified texture surface level" that you need to already know what miplevel you want when you make this call. But what does "retrieve" mean?

Maybe you answered my question, gosh I hope not though because I still don''t know what this function does.
Believe it or not, the idiot is learning.
No, the purpose of GetSurfaceLevel() is to get a pointer to the surface at that level. If you look at the method signature in the docs, it specifies a level and a pointer-to-address of a surface. You get access to the surface at level n by calling GetSurfaceLevel().

I like pie.
[sub]My spoon is too big.[/sub]
It gets the surface of level n, where you specify n. If your texture is 256x256 and has 9 levels (256x256, all the way down to down to 1x1) then GetSurfaceLevel with 1 would get the 128x128 version of the texture. If you said level 7 it would get the 2x2 version of the texture.

If you want to update the mipmaps after locking and modifying level 0, call D3DXFilterTexture. In some cases it''s just easier not to have mipmaps at all (render to surface comes to mind).
Oh, ok, see that makes since. Thanks Namethatnobodyelsetook and Rendertarget.

The point of this function is to get a pointer to a specified mipmap level of a texture for the purpose of locking it (using a LockRect I''m assuming, but that doesn''t seem right *shrugs*) and making changes... Is that right?

My trouble was "Retrieves the specified texture surface level" doesn''t tell you WHY you would retrieve it and what you can do with it once you''ve retrieved it. (ref: What the hell does this function do?) I''m fairly new to textures, though I''ve used DirectDraw quite a lot. I keep forgetting mipmapping even exist.
Believe it or not, the idiot is learning.
Using LockRect is indeed the correct way to do it, so don''t worry ''bout that. And as you''ve probably noticed, there''s a LockRect for both IDirect3DTexture9 and IDirect3DSurface9, the only difference being that with the first, you just specify which level you want, whereas with the second, you need to get a surface level from a texture, and then lock it, and then unlock and release it. Usually the first will be the easiest (since it sort of does the same as the second, but hides the extra details from you). And I suppose you''re only modifying textures with no mipmapping, so you''ll only need to ever lock surface level 0. However, I haven''t used it, but I''m pretty sure that if you''re editing textures with multiple mipmap levels, you can edit surface level 0, and then call IDirect3DTexture9::GenerateMipSubLevels(), and it should apply the filtering that you chose at the creation of the texture to the number of miplevels that you already have.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke

This topic is closed to new replies.

Advertisement