"Happy Year2000" For All Software Developers

Environment: VC6.0, Win95/98, NT4.0

Keywords: Greeting Card/Screen Saver, OpenGL, Texture Map, MCI(MultiMedia), MIDI

To All developers:

I contribute this special gift to all developers around the world to the new millenium. I send all of you my best wishes for a sucessful and wonderful new century I thank you for your willing to share my exciting feeling about this work and the new century I will be very pleased if the knowledge and skill in this work can help you.

Good Luck, Everybody!

The Special Points in the code

1.The texture map

1.1 Process arbitrary size texture image

Instead of glTexImage2D, function gluBuild2DMipmaps can process the texture image which width and heigth are arbitrary

The sample code is:

glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, m_TexWidth, m_TexHeight, 
                  GL_BGR_EXT, GL_UNSIGNED_BYTE, m_glTexture);

The parameters in gluBuild2DMipmaps are similar to those in glTexImage2D

.

1.2 Animation with texture image

In the scene of this program, the animation of the object "Ball" is realized by "sliding" the texture image. The "Ball" "rotates" by changing its texture coordinates. The details of implementation can be found in

glEllipsoid::SetTexCoord
glEllipsoid::DrawObject
CGLControl::OnTimer

2. MIDI music play

In this program, class CMCIPlayer encapsulates the MCI functions to play MIDI/Wave format file. To play MIDI music, set the parameter "lpstrDeviceType" of MCI_OPEN_PARMS data to "sequencer"

3. Put resource in executable file

For easy to deploy the program, I put the texture image and MIDI data into .rc file and compile them. The texture image can be found in the section of "DIB" and MIDI data in the section of "MIDI" in the "greet.rc" file.

When the program need to get the texture image or MIDI data, the program can load these data from resource, then save them as temprary disk files so that other functions can read texture image or MIDI data correctly from the temprary disk files. When the program is over, the temprary disk files will be delete automatically.

The implementations are in

CMCIPlayer::LoadMIDIFile
CMCIPlayer::MoveMIDIFile
glEllipsoid::BuildBMPTexture
glCube::BuildBMPTexture

Downloads

Download demo project - 762 Kb
Download source - 675 Kb


Comments

  • A little incorrect?

    Posted by Legacy on 12/15/2003 12:00am

    Originally posted by: Anthony

    I think this line is a little incorrect ::

    gluBuild2DMipmaps(GL_TEXTURE_2D, 4, m_TexWidth, m_TexHeight,
    GL_BGR_EXT, GL_UNSIGNED_BYTE, m_glTexture);


    The second parameter should be 3 if you have only three color components (GL_BGR_EXT).

    Reply
  • Welldone!

    Posted by Legacy on 12/15/2000 12:00am

    Originally posted by: Pavel Gorbunov

    Thanx. I attach your sources to my xperience :)
    www.developers.f2s.com

    Reply
  • Add GIF Animation

    Posted by Legacy on 01/27/2000 12:00am

    Originally posted by: Pham Le Cuong

    It would be better if you supported animated GIF. Just utilize some ActiveX control posted on this site and you will make it more impressive.
    Happy new lunar year to all wonder creators: computer programmers!

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • 10 Rules that Make or Break Enterprise App Development Projects In today's app-driven world, application development is a top priority. Even so, 68% of enterprise application delivery projects fail. Designing and building applications that pay for themselves and adapt to future needs is incredibly difficult. Executing one successful project is lucky, but making it a repeatable process and strategic advantage? That's where the money is. With help from our most experienced project leads and software engineers, …

  • Live Event Date: August 19, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT You deployed your app with the Bluemix PaaS and it's gaining some serious traction, so it's time to make some tweaks. Did you design your application in a way that it can scale in the cloud? Were you even thinking about the cloud when you built the app? If not, chances are your app is going to break. Check out this upcoming webcast to learn various techniques for designing applications that will scale successfully in Bluemix, for the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds