Newbe trying to plot points

  • Follow


Hello,
Im trying to plot some points but all i get is a small rectangle at
the top of the window.
The coordinates returned are in the range q=~350 to 0.
The Code:
#include <windows.h>
#include <glut.h>
#include <stdlib.h>
#include <stdio.h>

void display(void)
{
  unsigned q;
       //char h;
       int i;
       FILE *fopen(),*f, *g;

  glClear (GL_COLOR_BUFFER_BIT);



       f=fopen("d3.dat","r+b");
       g=fopen("out.dat","w");
       if(f!= NULL)
       {


glPointSize(20.0);
   glBegin(GL_POINTS);
   glColor3f (1.0, 1.0, 1.0);

  for(i=0;i!=1000;++i){
                       fread(&q,sizeof(q),1,f);
                       q=q/10000000;
                       printf("%u\n,%d\n",q,i);

      glVertex2f(q, i);
      //glVertex3f (0, .25, 0.0);
      //glVertex3f (.75, 1.0, 0.0);
      //glVertex3f (1.0, .75, 0.0);

   glEnd();
  }
   }
   glFlush ();
}

void init (void)
{
/* select clearing color 	*/
   glClearColor (0.7, 0.3, 0.6, 0.2);

/* initialize viewing values  */
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluOrtho2D(0.0,1000.0,1000.0,0.0);
}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   glutInitWindowSize (250, 250);
   glutInitWindowPosition (100, 100);
   glutCreateWindow ("hello");
   init ();
   glutDisplayFunc(display);
   glutMainLoop();
   return 0;   /* ANSI C requires main to return int. */
}


Thanks
Mike
0
Reply mpeloso 4/5/2004 5:04:26 PM

Mike p wrote:

> Hello,
> Im trying to plot some points but all i get is a small rectangle at
> the top of the window.

.....

> The coordinates returned are in the range q=~350 to 0.
> 


....


>    gluOrtho2D(0.0,1000.0,1000.0,0.0);
> }
> 

You set up your view system to only show things
in the range 0 to 1000....


-- 
<\___/>          "To err is human, to moo bovine."
/ O O \
\_____/  FTB.    For email, remove my socks.


0
Reply fungus 4/5/2004 7:44:23 PM


Hello,
The range of my x coordinates run from 429 to 0 to 429  and my y from 1 to
1000. (a sine wave)shouldnt they display?
Help and Thanks
Mike
"fungus" <openglMY@SOCKSartlum.com> wrote in message
news:rGicc.4389386$uj6.14258283@telenews.teleline.es...
> Mike p wrote:
>
> > Hello,
> > Im trying to plot some points but all i get is a small rectangle at
> > the top of the window.
>
> ....
>
> > The coordinates returned are in the range q=~350 to 0.
> >
>
>
> ...
>
>
> >    gluOrtho2D(0.0,1000.0,1000.0,0.0);
> > }
> >
>
> You set up your view system to only show things
> in the range 0 to 1000....
>
>
> --
> <\___/>          "To err is human, to moo bovine."
> / O O \
> \_____/  FTB.    For email, remove my socks.
>
>


0
Reply mike 4/5/2004 11:36:31 PM

Im also only getting one point to plot
"Mike p" <mpeloso@princeton.edu> wrote in message
news:5f6f0a73.0404050904.5b8d1f92@posting.google.com...
> Hello,
> Im trying to plot some points but all i get is a small rectangle at
> the top of the window.
> The coordinates returned are in the range q=~350 to 0.
> The Code:
> #include <windows.h>
> #include <glut.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> void display(void)
> {
>   unsigned q;
>        //char h;
>        int i;
>        FILE *fopen(),*f, *g;
>
>   glClear (GL_COLOR_BUFFER_BIT);
>
>
>
>        f=fopen("d3.dat","r+b");
>        g=fopen("out.dat","w");
>        if(f!= NULL)
>        {
>
>
> glPointSize(20.0);
>    glBegin(GL_POINTS);
>    glColor3f (1.0, 1.0, 1.0);
>
>   for(i=0;i!=1000;++i){
>                        fread(&q,sizeof(q),1,f);
>                        q=q/10000000;
>                        printf("%u\n,%d\n",q,i);
>
>       glVertex2f(q, i);
>       //glVertex3f (0, .25, 0.0);
>       //glVertex3f (.75, 1.0, 0.0);
>       //glVertex3f (1.0, .75, 0.0);
>
>    glEnd();
>   }
>    }
>    glFlush ();
> }
>
> void init (void)
> {
> /* select clearing color */
>    glClearColor (0.7, 0.3, 0.6, 0.2);
>
> /* initialize viewing values  */
>    glMatrixMode(GL_PROJECTION);
>    glLoadIdentity();
>    gluOrtho2D(0.0,1000.0,1000.0,0.0);
> }
>
> int main(int argc, char** argv)
> {
>    glutInit(&argc, argv);
>    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
>    glutInitWindowSize (250, 250);
>    glutInitWindowPosition (100, 100);
>    glutCreateWindow ("hello");
>    init ();
>    glutDisplayFunc(display);
>    glutMainLoop();
>    return 0;   /* ANSI C requires main to return int. */
> }
>
>
> Thanks
> Mike


0
Reply mike 4/6/2004 1:07:39 AM

On Mon, 05 Apr 2004 10:04:26 -0700, Mike p wrote:

> Hello,
> Im trying to plot some points but all i get is a small rectangle at
> the top of the window.
> The coordinates returned are in the range q=~350 to 0.
> The Code:
> #include <windows.h>
> #include <glut.h>
> #include <stdlib.h>
> #include <stdio.h>
> 
> void display(void)
> {
>   unsigned q;
>        //char h;
>        int i;
>        FILE *fopen(),*f, *g;
> 
>   glClear (GL_COLOR_BUFFER_BIT);
> 
> 
> 
>        f=fopen("d3.dat","r+b");
>        g=fopen("out.dat","w");
>        if(f!= NULL)
>        {
> 
> 
> glPointSize(20.0);
>    glBegin(GL_POINTS);
>    glColor3f (1.0, 1.0, 1.0);
> 
>   for(i=0;i!=1000;++i){
>                        fread(&q,sizeof(q),1,f);
>                        q=q/10000000;
>                        printf("%u\n,%d\n",q,i);
> 
>       glVertex2f(q, i);
>       //glVertex3f (0, .25, 0.0);
>       //glVertex3f (.75, 1.0, 0.0);
>       //glVertex3f (1.0, .75, 0.0);
> 
>    glEnd();
>   }
>    }
>    glFlush ();
> }
> 
> void init (void)
> {
> /* select clearing color 	*/
>    glClearColor (0.7, 0.3, 0.6, 0.2);
> 
> /* initialize viewing values  */
>    glMatrixMode(GL_PROJECTION);
>    glLoadIdentity();
>    gluOrtho2D(0.0,1000.0,1000.0,0.0);
> }

Shouldn't you set the matrix to 
GL_MODELVIEW now ?

-- 
Nils Olav Sel�sdal
System Engineer
w w w . u t e l s y s t e m s . c o m


0
Reply iso 4/6/2004 7:03:09 AM

4 Replies
125 Views

(page loaded in 2.501 seconds)

Similiar Articles:













7/26/2012 11:09:25 AM


Reply: