Jump to content
  • Advertisement

Archived

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

chup

Reading numbers of bitmap files as texture!!

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

Now i have thousands of bitmap files named from "1000.bmp" to "3000.bmp"!! CTexture m_Texture[3000]; m_Texture[0].ReadFile("1000.bmp"); m_Texture[1].ReadFile("1001.bmp"); m_Texture[2].ReadFile("1002.bmp"); m_Texture[3].ReadFile("1003.bmp"); . . . m_Texture[2999].ReadFile("2999.bmp"); How could i use "for loop" to simplify the process??

Share this post


Link to post
Share on other sites
Advertisement
Just use a string stream : a stream which writes to a string instead of sending it to a file, or the console.


  
#include <sstream>

using namespace std;

void LoadTextures( CTexture* tx, size_t offset, size_t count )
{
for( int i = 0; i < count; ++i )
{
stringstream ss; // constructed empty each iteration

ss << i+offset << ".bmp"; // Write <number>.bmp

tx[i].ReadFile( ss.str().c_str() ); // Assuming you''re taking a const char*

}
}

LoadTextures( m_Texture, 1000, 2000 ); // Loads textures 1000 to 2999




Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites
i got an error message as follow~~

"error C2664: ''ReadFile'' : cannot convert parameter 1 from ''const char *'' to ''char*'' "

What should i do??

Share this post


Link to post
Share on other sites
Just wondering...
After u have loaded the images into memory. how do u display them such that it render a 3D model?

please advice

Share this post


Link to post
Share on other sites
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);

if(m_Texture[pic_no].GetData() != NULL)
glTexImage2D(GL_TEXTURE_2D,0,3,
m_Texture[pic_no].GetWidth(),m_Texture[pic_no].GetHeight(),0,
GL_RGB,GL_UNSIGNED_BYTE,m_Texture[pic_no].GetData());

glBegin(GL_POLYGON); //Back (Green)

glTexCoord2f(0, 0);glVertex3d( -400, -300, 0);
glTexCoord2f(1, 0);glVertex3d( 400, -300, 0);
glTexCoord2f(1, 1);glVertex3d( 400, 300, 0);
glTexCoord2f(0, 1);glVertex3d( -400, 300, 0);
glEnd();

::glDisable(GL_TEXTURE_2D);
::glEndList();

Share this post


Link to post
Share on other sites
Are your images by any chance, a slice of a whole "picture"/model?
Meaning each image is a cross section of the object?
u have an email for discussion?
chup?

[edited by - Whitehair on December 3, 2002 12:05:49 AM]

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!