How hard would this be?

This is a discussion on How hard would this be? within the Game Programming forums, part of the General Programming Boards category; If I wanted to make an .exe that displayed a .jpg, .gif, or .bmp with every mouse click, where would ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    56

    How hard would this be?

    If I wanted to make an .exe that displayed a .jpg, .gif, or .bmp with every mouse click, where would I start?

    Anyone ever see a tutorial like this?

    Basically, it would be for a child to play with. Optimally it would allow for sounds with every click. But for a beginner, it would probably be best to keep it to just click the mouse to change the graphic displayed.

    Oh, and esc key would exit the program.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    Well Allegro is a graphics library that you can use to do something like you explained. Once you figured out how to install it, there are many tutorials on it you can find on the web. Good luck!
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    ACK!!!

    Setting up allegro with devc++ looks tricky,

    I'm still stuck in chapter 3 of most of my books.

    Perhaps this should be a back shelf project.

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    Isnt there something along the lines of:
    Code:
    if mouse clicks
    {
        cout << *.bmp;
    }
    
    if esc 
    {
    quit
    }


  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    There's no standard way to do graphics in C/C++. You have to use a 3rd-party library such as Allegro.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    What about GLUT?

    Can I use that?

    Perhaps I could apply my bmp or jpg as a texture to a single planar box shape which responds to a click of the mouse to cycle through the stored images.

    Would that work?

  7. #7
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    It could be done like you described with OpenGL or DirectX. If you do it with DirectX, you can use DirectX both to display the picture, and to detect the mouse clicks. I think in OpenGL you'd have to handle the windows message for the mouse click (I'm not sure).

    There is also Allegro.
    Away.

  8. #8
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by confuted
    It could be done like you described with OpenGL or DirectX. If you do it with DirectX, you can use DirectX both to display the picture, and to detect the mouse clicks. I think in OpenGL you'd have to handle the windows message for the mouse click (I'm not sure).
    The opengl utility library glut handles all kinds of stuff including mouseclicks =)

    Code:
    #include <gl/glut.h> 
    #include <gl/gl.h>
    
    void renderScene(void) {
    	glClear(GL_COLOR_BUFFER_BIT);
    	glBegin(GL_TRIANGLES);
    		glVertex3f(-0.5,-0.5,0.0);
    		glVertex3f(0.5,0.0,0.0);
    		glVertex3f(0.0,0.5,0.0);
    	glEnd();
    	glFlush();
    }
    
    void main(int argc, char **argv) {
    	glutInit(&argc, argv);
    	glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
    	glutInitWindowPosition(100,100);
    	glutInitWindowSize(320,320);
    	glutCreateWindow("3D Tech- GLUT Tutorial");
    	glutDisplayFunc(renderScene);
    	glutMainLoop();
    }
    lol, they use void main =) anyway, what I wanted to say is, you can use glutMouseFunc(processMouse);
    where processMouse is void processMouse(int button, int state, int x, int y).

    glut has function pointers for all kinds of stuff, like keyboard events, mouse events, window resize, move... bla..

    glu32 and glut are parts of a standard opengl installation.

    You can find a good glut tutorial here

  9. #9
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >> glu32 and glut are parts of a standard opengl installation.

    erm, GLUT is not a standard OpenGL library. It is however a very handy and commonly used one. OpenGL can be used without GLUT.

  10. #10
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by Perspective
    >> glu32 and glut are parts of a standard opengl installation.

    erm, GLUT is not a standard OpenGL library. It is however a very handy and commonly used one. OpenGL can be used without GLUT.
    I guess I was trying to say that glut isn't an additional download or something. I didn't want to say that you need to use glut if you want to use opengl. Did I? I hope I didn't because I don't use glut at all =)

  11. #11
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    UGH!!

    GLUT doesnt work with DevC++!

    I cant get allegro and mingw32 to compile correctly.

    And, The reading is making my head feel woozy...LOL!

    Time to go with another compiler...


  12. #12
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    I cant get allegro and mingw32 to compile correctly.
    If the problem is installing allegro with dev-cpp you might wanna hit this.
    Illusion and reality become impartiality and confidence.

  13. #13
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    Yup, followed that exact same page...

    gcc -v only worked in C:\Dev-Cpp\bin

    and C:\Dev-Cpp>make

    returned a bad command error....

    It was ugly...

    Hours of trying later I came here in search of some opinions on user friendly compilers.

  14. #14
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    user friendly compilers.
    MSVC
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  15. #15
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Can easily be done with some basic GDI knowledge in WIN32 API or MFC.

    In MFC you can load the bmp off the HD each time you get a WM_LBUTTONDOWN msg and set a picture frame control (a form of static control) to the HBITMAP. MFC will handle the rest, even if the images are different sizes.

    In WIN32 you will have to load the bmp, create a temp HDC, select the bmp into this temp hdc and draw this to the screen HDC, then select back the original bmp and delete the temp HDC.
    Only problem comes if the images are not the same size.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extracting data from a laptop hard drive
    By DavidP in forum Tech Board
    Replies: 6
    Last Post: 06-13-2009, 07:02 AM
  2. Hard drives - capacity and speed
    By ulillillia in forum Tech Board
    Replies: 5
    Last Post: 06-01-2007, 09:55 AM
  3. Detect SCSI Hard Drive Serial Number
    By mercury529 in forum Windows Programming
    Replies: 3
    Last Post: 10-17-2006, 06:23 PM
  4. Replies: 2
    Last Post: 07-06-2005, 07:11 PM
  5. Trinary Hard Drive
    By nickname_changed in forum Tech Board
    Replies: 14
    Last Post: 05-13-2005, 10:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21