A Texture Browser In Win32 (C++)

Started by
4 comments, last by jwezorek 14 years, 2 months ago
Hello, I'm creating a 3D / 2D Application I'm writing using C++, OpenGL and Win32. So far so good I have everything I want working and know how to get things going, but just a little problem I don't know where to look. I created a child window with nothing in it except a drop down menu for importing textures or excluding textures selected. I have a Targa loader from NeHe's tutorial and I want to create a texture list in that child window that will display the textures in little preview squares. Can this be done using Win32 only? Then having to create another OpenGL viewport? I'm not asking for anything fancy like applying the textures on a sphere or something, but can I at least get something simple like these examples just using the Targa loader and Win32? Examples: Maya Hypershade Unreal Editor Texture Browser Thanks, Andrew.
Check out my open source code projects/libraries! My Homepage You may learn something.
Advertisement
There's lots of ways of doing stuff like that in Win32. The question is what exactly do you want and how much work do you want to put into custom GUI controls?

How big do you want the texture samples to be? Because if you want to go the no custom controls route I think the easiest way to do it would be to put your texture samples in a ListView control in the large icon mode, or whatever it's called. I'm just not sure if there is a limit to how big Win32 will let you make the images in a ListView, however. The nice thing about that is you can set the "double buffered" ListView extended style.

If you want to make a custom control make your own scrollable pane class that has a scroll bar control and a child pane in which you put your sample textures as static controls or something and then MoveWindow the child pane on scroll bar messages.

[Edited by - jwezorek on February 15, 2010 7:16:28 PM]
I'm going to do it the hard way, may sound crazy, but I think the hard way may be easier for me and have much more flexibility when you make it yourself. I think I already know how to do it. :)


Steps:
x = Number of images loaded
1. Load images and get x.
2. Create child window and enable vertical scroll.
3. Create x amount of static controls with bitmap displays.
4. Change the static controls to have a certain color border and change the backgrounds to the windows. Then selected change to a lighter color of gray around the image.
5. Create x amount of buttons over each static that hold a image.
6. Hide the buttons and if I can then maybe make them inviable except for the text.

But if anyone was curious I hope this helps them get ideas.


Then what ever is clicked, highlight that static control and use a integer to assign a id to of which button was clicked or image I should say.

Ok, well I think I can do it, if I run into any problems with the controls I'll ask on here then. :)
Check out my open source code projects/libraries! My Homepage You may learn something.
Do you load all the textures in advance? What happens if there are so much textures, that you run out of texture memory?
Or you compress the images while loading?
Or do you load a number of textures at a time, and reload others on demand (depending on scrolling)? Loading takes time, so you have to load asynchronously.

I think it's not so simple as you think. But if you compress, you can load a lot of them. (And I guess you want to make one atlas from all of them).
Quote:Original post by szecs
Do you load all the textures in advance? What happens if there are so much textures, that you run out of texture memory?
Or you compress the images while loading?
Or do you load a number of textures at a time, and reload others on demand (depending on scrolling)? Loading takes time, so you have to load asynchronously.

I think it's not so simple as you think. But if you compress, you can load a lot of them. (And I guess you want to make one atlas from all of them).


Yeah, I mean it depends on how big they are, but the orginal poster should probably load them in and then scale them down to a standard size for the GUI control to use, like 128x128 pixels or something.

If there are hundreds of them or something then he should load them in dynamically on scroll events, maybe caching the ones that are probably going to be needed next.
Quote:Original post by ajm113
Steps:
x = Number of images loaded
1. Load images and get x.
2. Create child window and enable vertical scroll.
3. Create x amount of static controls with bitmap displays.
4. Change the static controls to have a certain color border and change the backgrounds to the windows. Then selected change to a lighter color of gray around the image.
5. Create x amount of buttons over each static that hold a image.
6. Hide the buttons and if I can then maybe make them inviable except for the text.


Yeah, I don't have time to go into it in detail but basically what I would do is make a custom pane class that doesn't do anything but paint itself and is a child window. Make a call that calls CreateWindow for you and makes one of these custom panes.

Then for the scrollable pane use two of your custom panes, one that is a Win32 child of the other one. I'd use a separate a Win32 scrollbar control rather than setting the WS_VSCROLL style on the parent pane but you can do it either way.

This topic is closed to new replies.

Advertisement