Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: OPEN GL HELP PLZ

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    8

    OPEN GL HELP PLZ

    Hello everybody i have an problem that i dont know how to solve,
    i have to create a free hand drawing tool on OpenGl C++ can anybody of you tell me how to do this bcz i dont have any idea.

    Beast Regards

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325

    Re: OPEN GL HELP PLZ

    There are lots of ways to do that and lots of possible problems. You should be more specific with your question. Do you even know how to code in C++? Do you know OpenGL? Do you have decided on a OS and windowing toolkit?

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    8

    Re: OPEN GL HELP PLZ

    Dear now i have created program on c++ for making points, i can send you the code.
    Here is the code:
    #include<gl\glut.h>

    const int screenWidth=800;
    const int screenHeight=600;

    void Init()
    {
    glClearColor(0.0,0.0,0.0,0.0);
    glClear(GL_COLOR_BUFFER_BIT);
    gluOrtho2D(0.0,(GLdouble)screenWidth,0.0,(GLdouble )screenHeight);
    glViewport(0,0,screenWidth,screenHeight);
    }

    void Display()
    {
    glColor3f(0.0,0.0,1.0);
    glPointSize(6.0);
    glFlush();

    }

    //callback mouse function
    void mouse(int button, int state, int x, int y)
    {
    if(state==GLUT_DOWN)
    {
    if(button==GLUT_LEFT_BUTTON)
    {
    glBegin(GL_POINTS);
    glVertex2i(x,screenHeight-y);

    glEnd();
    }
    else if(button==GLUT_RIGHT_BUTTON)
    glClear(GL_COLOR_BUFFER_BIT);
    }
    }

    int main(int argc, char** argv)
    {
    glutInit(&amp;argc, argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(screenWidth,screenHeight);
    glutInitWindowPosition(100,100);
    glutCreateWindow("Katerkenedshi Dinamik");
    glutMouseFunc(mouse);
    glutDisplayFunc(Display);
    Init();
    glutMainLoop();
    return 0;
    }
    And from this code i want to make free hand draw tool, if i am clearly thats the point, so if you can tell me what to do to draw free lines.

    Best Regards

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117

    Re: OPEN GL HELP PLZ

    First, you need to save the mouse down x,y in some array in the mouse handler.

    Then in the Display handler, loop through this list and display the points.

    Something like this

    Code :
    glColor3f(0.0,0.0,1.0);
    glPointSize(6.0);
     
    glBegin(GL_POINTS);
    for (int i = 0; i < nbr_of_points; i++)
      glVertex2i(x[i],y[i]);
    glEnd();

    I also think there is a limit on the maximum value for glPointSize.

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    8

    Re: OPEN GL HELP PLZ

    i tried but it doesnt work, i dont know what is wront and i dont know if im clear but the point is that i want to free hand draw with this program, and if somebody can try this and then send me all the code, bcz im trying while 2 weeks or more.

    Best Regards

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    8

    Re: OPEN GL HELP PLZ

    anyone plz it is urgent

  7. #7
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,170

    Re: OPEN GL HELP PLZ

    generally speaking people here will not do home work assignments for you.

  8. #8
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    8

    Re: OPEN GL HELP PLZ

    i know but im not asking to you to do all my assignments thats a problem that i cannot fix, and that is a forum that can tell me how to do, if you cannot do it its not problem, then for what is this forum
    ???

  9. #9
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325

    Re: OPEN GL HELP PLZ

    This forum is for general discussion about OpenGL related topics and also about helping each other with specific OpenGL problems.

    We can point you in the right direction if you ask questions about GL, but we will not write full programs for you. tonyo_au told you how you could tackle the problem of drawing connected lines, telling us that it's not working (without showing how you tried it) and asking for someone to solve your homework is not the reaction that motivates any of us investing time on this...

    Also, you haven't answered my questions, we don't know how experienced you are with C/C++ or OpenGL (well we could derive that from your code, but still, you don't make anything to help us with helping you...)

  10. #10
    Junior Member Newbie
    Join Date
    Mar 2012
    Posts
    8

    Re: OPEN GL HELP PLZ

    i tried with this code:
    glBegin(GL_POINTS);
    for (int i = 0; i < 30; i++)

    glVertex2i(x[i],y[i]);

    glEnd();
    it shows up to me : expression must have pointer-to-object type.
    i have tried something else with

    glRecti(x,y,x+brush,y+brush); where brush is a GLint but it doesnt work, thats the problem my dear.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •