forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with simple handle menu in OpneGL classic window

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
leszpol



Joined: 25 Apr 2008
Posts: 29
Location: Gdynia-TriCity

PostPosted: Wed May 28, 2008 7:30 am    Post subject: Problem with simple handle menu in OpneGL classic window Reply with quote

Thank you for any help. I have source code in C as below:
Code:

#include <GL/glut.h>
#include <stdlib.h>
void Display ()
{
    glClearColor (1.0,1.0,1.0,1.0);
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0,0.0,0.0);
    glBegin (GL_POLYGON);
    glVertex3f (0.0, 0.0, 0.0);
    glVertex3f (0.0, 1.0, 0.0);
    glVertex3f (1.0, 1.0, 0.0);
    glVertex3f (1.0, 0.0, 0.0);
    glEnd ();
    glFlush ();
    glutSwapBuffers();
}
void Reshape (int width, int height)
{
    Display ();
}
enum
{
    EXIT
};
void Menu (int value)
{
    switch (value)
    {
        case EXIT:
        exit (0);
    }
}
int main (int argc, char *argv[])
{
    glutInit (&argc,argv);
    glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize (400,400);
    glutCreateWindow ("SQUARE 1");
    glutDisplayFunc (Display);
    glutReshapeFunc (Reshape);
    glutCreateMenu (Menu);
    glutAddMenuEntry ("END OF PROGRAM",EXIT);
    glutAttachMenu (GLUT_RIGHT_BUTTON);
    glutMainLoop ();
    return 0;
}

It makes simple read square in the classic OpenGL window. The part in main program:
Code:

    glutCreateMenu (Menu);
    glutAddMenuEntry ("END OF PROGRAM",EXIT);
    glutAttachMenu (GLUT_RIGHT_BUTTON);                     

and the parat in the subroutine part of the program
Code:

enum
{
    EXIT
};
void Menu (int value)
{
    switch (value)
    {
        case EXIT:
        exit (0);
    }
}

realise simple handle menu. When I am pushing a right mouse button I can see "EXIT" word in the region of my window. After choosing it I can exit, stop the program. I tried to rewrite it in FORTRAN and done evrything apart simple handle menu. It seems to be very simply but I am familiar with fortran 77 standard and I don't understand meaning of EXTERNAL variable. I done tha part of the program responsible for drawing red square and commented code it is what should be add to make handle menu and I can't menage with it.
My working part looks like this:
Code:

        subroutine display
        include 'GL/fgl.h'
        include 'GL/fglut.h'
        call fglClear(GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT)
        call fglColor3f(1.0, 0.0, 0.0)
        call fglBegin (GL_POLYGON)
        call fglVertex3f (0.0, 0.0, 0.0)
        call fglVertex3f (0.0, 1.0, 0.0)
        call fglVertex3f (1.0, 1.0, 0.0)
        call fglVertex3f (1.0, 0.0, 0.0)
        call fglEnd ()
        call fglFlush ()
        call fglutSwapBuffers()
        return
        end
Cenum
C{
C    EXIT
C};
Cvoid Menu (int value)
C{
C    switch (value)
C    {
C        case EXIT:
C        exit (0);
C    }
C}
      PROGRAM OpenGL01
        include 'GL/fglut.h'
        integer  okno1,menu1,menu
        external display
        call fglutInit
        call fglutInitDisplayMode(GLUT_DOUBLE+GLUT_RGB)
        call fglutInitWindowSize(400, 400)
        okno1 = fglutCreateWindow('SQUARE 1')
        call fglutDisplayFunc(display)
        menu1=fglutCreateMenu (Menu)
C      call fglutAddMenuEntry ("END OF PROGRAM",EXIT)
        call fglutAttachMenu (GLUT_RIGHT_BUTTON)
        call fglutMainLoop
      end

I have to write in quot
Back to top
View user's profile Send private message Send e-mail
leszpol



Joined: 25 Apr 2008
Posts: 29
Location: Gdynia-TriCity

PostPosted: Wed May 28, 2008 8:25 am    Post subject: Re: Problem with simple handle menu in OpneGL classic window Reply with quote

I have to write in reply because there is limited prost - sorry. The question is how to improve my example to obtain simple handle exit menu. You can notice that my example is written in Fortran 77 fixed standard and I use F7 BCC compilator. There are a lot of working examples. When I understand OpenGL I implemented it in FTN95 free format. The help can be to corect my example or simple exampel in FTN95. I generally don't understand using call fglutAddMenuEntry ("END OF PROGRAM",EXIT) in EXTERNAL context witch is connected to EXIT variable. Thank you for help.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group