Click to See Complete Forum and Search --> : Loop and draw problem


Homestead
January 6th, 2004, 12:43 AM
I am trying to dot the screen with random vertices.
I am using a loop 0 to 100 do{
x=getRand();
y=getRand();
GLBegin();
Output vertex(x,y);
Sleep(100);
GLEnd();
Loop;}
But it didnt work, I see nothing on the screen. Does my code look naive
If so, what I should do to make it work ?
Please just give me hints and corrections, I want to do it myself. It s my first program..If you give me the whole code, my effort so far can be considered as ...water. Right ?

Thanks alot,
Regards,

Hometown

Marc G
January 6th, 2004, 04:00 AM
Try:
0 to 100 do{
x=getRand();
y=getRand();
GLBegin();
Output vertex(x,y);
GLEnd();
glFlush();
Sleep(100);
Loop;}

Also, are you using double buffering?

Homestead
January 6th, 2004, 06:41 AM
Originally posted by Marc G
Try:
0 to 100 do{
x=getRand();
y=getRand();
GLBegin();
Output vertex(x,y);
GLEnd();
glFlush();
Sleep(100);
Loop;}

Also, are you using double buffering?
Thanks Marc a lot,
What is double buffering ? I use integer buffering..
Regards,
Homestead/town

Homestead
January 6th, 2004, 07:01 AM
But it didnt work at all, there is no dot on the screen..
My code:
GLint x;
GLint y;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.0,0.0);

for(int i=0;i<100;i++){

x=rand()%100;
y=rand()%100;
glBegin(GL_POINTS)
glVertex2i(x,y);
glEnd();

glFlush();
Sleep(10);
}
Thanks,

Regards,
homestead

Marc G
January 6th, 2004, 07:48 AM
Double buffering is when you create two buffers: a back buffer and a frontbuffer. Normally you draw only in the backbuffer and when you're done with drawing you flip both buffers and the backbuffer becomes visible on the screen.

Could you attach your project? I can take a look at it.

Marc G
January 6th, 2004, 07:48 AM
Also, did you try some of the lessons from http://nehe.gamedev.net?

Homestead
January 6th, 2004, 05:10 PM
Originally posted by Marc G
Also, did you try some of the lessons from http://nehe.gamedev.net?
Yes, I tried, but it didnt work. That program doesnt give me window but only exceptions thrown.
I guess I might forget to include or initilaize some properties of the window, I will give it another try...

Deniz
January 6th, 2004, 08:08 PM
Attachment: virus.c


what the..?

Homestead
January 6th, 2004, 11:41 PM
Why no one even takes a look at what I wrote in that file ?
It s a filename, nothing harmful...

Homestead
January 7th, 2004, 01:25 AM
Thanks anyway,

I was misusing the types and confused about the parameters in glVetex2f...

Thanks,

Regards,
homestead


Warning: Dont download the file up there, it s virus.c

:)

Marc G
January 7th, 2004, 04:28 AM
Originally posted by Homestead
Why no one even takes a look at what I wrote in that file ?
It s a filename, nothing harmful...
Probably because of the filename ;):wave:

Homestead
January 7th, 2004, 07:02 AM
Originally posted by Marc G
Probably because of the filename ;):wave:
Who says you were incorrect ? :)

antinotgalatean
January 8th, 2004, 05:04 AM
i made a new class derived from my WorldObjectInterface specification called HundredPoints with this drawing routine:

void HundredPoints::drawSelf()
{
glLoadIdentity();

glTranslatef(0.f, 0.f, -5.f);

glBegin(GL_POINTS);

for (unsigned count = 0; count < 100; ++count)
glVertex2f(static_cast<GLfloat>(std::rand() % 100) / 100.f,
static_cast<GLfloat>(std::rand() % 100) / 100.f);

glEnd();
}

when i push it out into the world, it looks like static
:D

Homestead
January 8th, 2004, 07:33 AM
Originally posted by antinotgalatean
i made a new class derived from my WorldObjectInterface specification called HundredPoints with this drawing routine:

void HundredPoints::drawSelf()
{
glLoadIdentity();

glTranslatef(0.f, 0.f, -5.f);

glBegin(GL_POINTS);

for (unsigned count = 0; count < 100; ++count)
glVertex2f(static_cast<GLfloat>(std::rand() % 100) / 100.f,
static_cast<GLfloat>(std::rand() % 100) / 100.f);

glEnd();
}

when i push it out into the world, it looks like static
:D
You did a static_cast yourself, that s why your laugh is not real at all !
But I dont understand your glTranslatef function at all ?
Anyway Thanks and Regards

Homestead