Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: OpenGL Drawing Grid (help)

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    4

    OpenGL Drawing Grid (help)

    Hi
    I have a header file like that. I'm willing to create a grid. By using OpenGl and C++. The problem is in there cpp file. I can't excatly draw. Hope you can help it.In the for loop i don't know how to fill inside the vertex blocks


    Code :
    #ifndef Grid_h
    #define Grid_h
    #include "Shape.h"
     
    class Grid :: public Shape
    {
     
    public:
     
    Grid();
     
    Grid(int numberOfLines,int distanceBetweenLines);
     
    void Draw();
     
    int distanceBetweenLines;
     
    int numberOfLines;
     
    };
     
    #endif

    Code :
    #include "Grid.h"
    #include <GL/freeglut.h>
     
    Grid :: Grid()
    {
    numberOfLines = 0.0f;
     
    distanceBetweenLines = 0.0f;
    }
    Grid:: Grid(int numberOfLines , int distanceBetweenLines )
    { 
    cizimSekli = GL_LINES; //drawing way
    numberOfLines= 50; //number of Lines
    renk = Renk(0.0f, 1.0f, 0.0f); //Colour
    distanceBetweenLines = 20;
     
    for(int x = 0; x < numberOfLines; x++){
     
    glBegin(GL_LINES);
    glVertex2f(x,0);
    glVertex2f(0,x);
    glEnd();
    };
    for(int y = 0; y < numberOfLines; y++){
    glBegin(GL_LINES);
    glVertex2f(y,0);
    glVertex2f(0,y);
    glEnd();
    }; 
    }
    Last edited by IntelliSense; 05-04-2013 at 12:15 PM.

Posting Permissions

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