hi, sorry for bothering, I am new here, please don’t get mad
this is my code for initialization:
void initializeGLFW()
{
glfwInit();
if (glfwInit() != GL_TRUE)
Shut_Down(1);
if (glfwOpenWindow(WindowWidth, WindowHeight, 5, 6, 5,
0, 0, 0, GLFW_WINDOW) != GL_TRUE)
Shut_Down(1);
glfwSetWindowTitle("Air Hockey");
}
and this is the code for Draw
void Draw()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(CurrentState == GameState::MainMenu)
{
Setup2DOrthoSpace(WindowWidth, WindowHeight);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Textures[4]);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glVertex3f(-10.0f, 10.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); // Top left
glVertex3f(10.0f, 10.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); // Top right
glVertex3f(10.0f, -10.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); // Bottom right
glVertex3f(-10.0f, -10.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); // Bottom left
glEnd();
glDisable(GL_TEXTURE_2D);
}
else if(CurrentState == GameState::InGame)
{
Setup2DOrthoSpace(WindowWidth, WindowHeight);
DrawScoreboard();
----draw game interface-------
----set up camera-------------
----draw hockey table, bat and puck-----
}
and this is the code for Setup2DOrthoSpace
void Setup2DOrthoSpace(int w, int h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, 0.0f, zFarDist);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glfwSwapBuffers();
}
I am not drawing GL and CV in one window, they are in different window actually. GL is for the game and CV is just to display the image detected by webcam.