Hello,
my problem is of that kind beginners use to have. After following some glut tutorials I've decided it's time to do something small generally on my own. An obstacle appeared at the very beginning.

At the moment I got stuck, all my code was supposed to do was drawing a primitive using an ortagonal transformation to display it. Apperently, I failed at coding the latter.

void reshape (int w, int h)
{
     if (h==0)
     {
              h=1;
     }
     
     glViewport(0,0,w,h);	
     glMatrixMode (GL_PROJECTION);
     glLoadIdentity();
     
     glOrtho(0.0f,w,h,0.0f,-1.0f,1.0f);	
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
}

and the drawing func("bobby's" variables x and y are holding float values, tried with various bare numbers too):

void DrawScene(void)
{ 
     glPushMatrix();
     glTranslatef(bobby.x, bobby.y, 0.0f);
     
     glColor3f(1.0f, 0.0f, 0.0f);
     glBegin(GL_TRIANGLES);
     
     glVertex2d(-0.2, -0.2);
     glVertex2d(0.2, 0.2);
     glVertex2d(0.2, -0.2);
     
     glEnd();
     glPopMatrix();
     glutSwapBuffers();
}

Guess I could solve this with a little help of an example code, but I'd like to understand what I'm doing. Thanks.

I don't know what other calls you have there...

but first make sure everything is off:

glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glDisable(GL_ALPHA);

Then...

Also it looks from there that Ortho Call is too vast scaled. Ortho sets a cordinte system. Your cordinate system goes from 0 to w (or h), thus scale is 1024 on both sides. If you draw then a Triangle with 0.2, guess where it is? Probably in the vast space of the opengl universe...

Either change glOrtho

double itsUnit=1.0f;
double itsRatio=1024.0f/768.0f;

glOrtho(0.0, itsUnit*itsRatio, 0.0, itsUnit, 0, 10);

or Change the size of your trinagle..

glVertex2d(-400, -400);

Could be other things as well, but for that I would need to see the whole code.

&Cheers,

poliet

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.