Jump to content
  • Advertisement
Sign in to follow this  
thyrgle

Why won't this display fullscreen or a square?

This topic is 2998 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am working on this game.
Here is part of the source source:

//Gun coordinates.
float gunType1[12] = {
1.0f, 1.0f, -10.0f,
1.0f, -1.0f, -10.0f,
-1.0f, -1.0f, -10.0f
-1.0f, 1.0f, -10.0f
};
float gunType2[12] = {
1.0f, 1.0f, -10.0f,
1.0f, -1.0f, -10.0f,
-1.0f, -1.0f, -10.0f
-1.0f, 1.0f, -10.0f
};
float gunType3[12] = {
1.0f, 1.0f, -10.0f,
1.0f, -1.0f, -10.0f,
-1.0f, -1.0f, -10.0f
-1.0f, 1.0f, -10.0f
};
float gunType4[12] = {
1.0f, 1.0f, -10.0f,
1.0f, -1.0f, -10.0f,
-1.0f, -1.0f, -10.0f
-1.0f, 1.0f, -10.0f
};
float gunType5[12] = {
1.0f, 1.0f, -10.0f,
1.0f, -1.0f, -10.0f,
-1.0f, -1.0f, -10.0f
-1.0f, 1.0f, -10.0f
};

void Players::initWithGun(int gunType)
{
if (gunType == 1)
{
//Draw gunType 1
glBegin(GL_QUADS);
int i;
for (i = 0; i < sizeof(gunType1)/sizeof(float); i = i + 3)
{
glVertex3fv(gunType1+i);
}
glEnd();
}
else if (gunType == 2)
{
//Draw gunType 2
glBegin(GL_QUADS);
int i;
for (i = 0; i < sizeof(gunType2)/sizeof(float); i = i + 3)
{
glVertex3fv(gunType2+i);
}
glEnd();
}
else if (gunType == 3)
{
//Draw gunType 3
glBegin(GL_QUADS);
int i;
for (i = 0; i < sizeof(gunType3)/sizeof(float); i = i + 3)
{
glVertex3fv(gunType3+i);
}
glEnd();
}
else if (gunType == 4)
{
//Draw gunType 4
glBegin(GL_QUADS);
int i;
for (i = 0; i < sizeof(gunType4)/sizeof(float); i = i + 3)
{
glVertex3fv(gunType4+i);
}
glEnd();
}
else if (gunType == 5)
{
//Draw gunType 5
glBegin(GL_QUADS);
int i;
for (i = 0; i < sizeof(gunType5)/sizeof(float);i = i + 3)
{
glVertex3fv(gunType5+i);
}
glEnd();
}
}

void drawScene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//Temporary way for getting the gun the user wants.
int i;
cout << "Gun choice sir: ";
cin >> i;

static int g = 0;
//Make a new user spawn at a random place.
if (g == 0) //We do not want to keep doing this over and over again.
{
Players newPlayer;
newPlayer.initWithGun(i);
newPlayer.spawnAtBase();
g = 1;
}

glutSwapBuffers(); //Send the 3D scene to the screen
}
int main(int argc, char** argv) {
//Initialize GLUT
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

glutFullScreen();

//Create the window
glutCreateWindow("Game");
initRendering(); //Initialize rendering

//Set handler functions for drawing, keypresses, and window resizes
glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);

glutMainLoop(); //Start the main loop. glutMainLoop doesn't return.
return 0; //This line is never reached
}



It only makes a small window with only black once I give it my gun choice. I don't know why it is not making a square or a fullscreen window. Any help would be greatly appreciated!

Share this post


Link to post
Share on other sites
Advertisement
the documentation say's that glutFullScreen will make the current window into a full screen. at the time of calling you have no window created. try putting the glutFullScreen after creating the window.

Share this post


Link to post
Share on other sites
@GregMicheal: Thanks, I will keep that in mind, but at the moment I really need the other thing to work.

@Carver413: Thanks, but it still doesn't work. When I put glutFullScreen() right after the window is created it does the following: It asks for input as usual, and I put 1. Then, it makes this small window which is completely white. Then, it asks for input again. I put in 1 again and it does what I thought it should do, with regards to glutFullScreen that is. But, there is still no square. Any suggestions as for that?

Share this post


Link to post
Share on other sites
I think you have some logic problems.

Your drawing code only gets called once and thats it. I dont know Glut but if its using double buffering that want work. If it clears the screen each draw then it wont work.

You need to take the choice thing away from being called every time. But instead draw the gun each time.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!