Quads doesn't appear

Started by
2 comments, last by cutovoi 17 years, 6 months ago
Hi fellows I want to put a very single 2D square in my app but I don't have sucess in this. Here is my code:

int __stdcall WinMain(HINSTANCE hCurrentInstance, HINSTANCE hPrevInstance, LPSTR lp, int iShow)
{
   ....window creation
   if(hwnd != NULL)
   {
      EnableGL(hwnd, &hdc, &hrc);
      InitializeGL();
      ShowWindow(hwnd, SW_SHOW);
      GetClientRect(hwnd, &tempRect);
      SetFieldOfView(tempRect.right,tempRect.bottom);
   }
   while(GetMessage(&msg, NULL, 0, 0))
   {
      if(msg.message == WM_QUIT)
      {
         break;             
      }
      else
      {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
	  GetClientRect(hwnd, &tempRect);
	  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	  SetFieldOfView(tempRect.right,tempRect.bottom);
	  glColor3f(0.0, 0.0, 1.0);
	  glBegin(GL_QUADS);
	     glVertex2f(100,100);
	     glVertex2f(200,100);
	     glVertex2f(200,200);
	     glVertex2f(100,200);
	  glEnd();
          SwapBuffers(hdc);
   }
   return msg.wParam;
}

My window remains black, what's going on? May I have forgot a matrix?
Advertisement
If you set up openGL correctly, then I think the problem might be your camera is inside the quad, so you can't see it.
Hi

check if :
- face culling is enabled
- your glOrtho() values (from -1.0f to 1.0f or some different value ?)

try something like that first :
  glDisable(GL_CULL_FACE);  glBegin(GL_QUADS);     glVertex2f(0.0f, 0.0f);     glVertex2f(1.0f, 0.0f);     glVertex2f(1.0f, 1.0f);     glVertex2f(0.0f, 1.0f);  glEnd();
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
I didn't insert the glOrthoMatrix. How can I put them?? I'm working in a 3D environment.
And I put this glOrthoMatrix and nothing occurs:
glOrtho(tempRect.left,tempRect.right, tempRect.right, tempRect.top, 0.1, 100);

This topic is closed to new replies.

Advertisement