Skip to main content
gamedev.net
🔒 Locked

glut prob

Started by JasonL220 4 replies 650+ views
Original Post
JasonL220
JasonL220
Hi i'm tring to enter gamemode but my app creates a window the is transparent. here's some of my code: void main(int argc, char **argv) { glutInit(&argc, argv); // Init glut glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); // Init diplay mode glutCreateWindow("Test"); // Create the window glutDisplayFunc(renderScene); // Callback to renderscene glutIdleFunc(renderScene); glutReshapeFunc(changeSize); // Here is our new entry in the main function InitIL(); // Init DevIL glutGameModeString("800x600:32"); // Set to fullscreen LoadBrick(); // Load Brick Texture glutMainLoop(); // Enter main loop }
BitBlt
BitBlt
What values are you using for glClearColor()?
BitBlt
BitBlt
Also, make sure you are calling glutSwapBuffers().
JasonL220
JasonL220
i tries what you siad it displays a window but not fullscreen:

[source=cpp]#include "Engine.h"									// Include EngineGLuint	Brick1;										// Brick1 texturenamevoid renderScene(void) {	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen to black	glLoadIdentity();								// Reset Matrix	glTranslatef(0.0f,0.0f,-3.0f);					// move 3 units into screen	glBindTexture(GL_TEXTURE_2D, Brick1);	glBegin(GL_QUADS);								// Draw A Quad		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 0.0f);	// Top Left		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 0.0f);	// Top Right		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,-1.0f, 0.0f);	// Bottom Right		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,-1.0f, 0.0f);	// Bottom Left	glEnd();										// finish drawing triangle	glFlush();										// Flush all command	glutSwapBuffers();								// Swap buffer}void changeSize(int w, int h) {	// Prevent a divide by zero, when window is too short	// (you cant make a window of zero width).	if(h == 0)		h = 1;	float ratio = 1.0* w / h;					// Calculate prespective ratio	// Reset the coordinate system before modifying	glMatrixMode(GL_PROJECTION);	glLoadIdentity();		// Set the viewport to be the entire window	glViewport(0, 0, w, h);	// Set the correct perspective.	gluPerspective(45,ratio,1,1000);	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();}bool LoadBrick(){	Image *image = new Image(IL_BMP, "brick.bmp");	// Create Image class	glGenTextures(1, &Brick1);						// GenTexture name	glBindTexture(GL_TEXTURE_2D, Brick1);			// Bind The Texture	glTexImage2D(GL_TEXTURE_2D,						// Generate Texture					0,					3,					image->width,					image->height,					0,					GL_BGR_EXT,					GL_UNSIGNED_BYTE,					image->data);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	// Linear Filtering	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	// Linear Filtering	if(ilGetError() != IL_NO_ERROR)	{		return false;	}	return true;}void main(int argc, char **argv) {	glutInit(&argc, argv);										// Init glut	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);	// Init diplay mode	glutCreateWindow("Test");									// Create the window	glutDisplayFunc(renderScene);								// Callback to renderscene	glutIdleFunc(renderScene);									// Ilde Callback to renderscene	glEnable(GL_DEPTH_TEST);									// Enable depth testing	glutReshapeFunc(changeSize);								// Here is our new entry in the main function	InitIL();													// Init DevIL	glutGameModeString("800x600:32");							// Set to fullscreen	LoadBrick();												// Load Brick Textur	glutMainLoop();												// Enter main loop}
BitBlt
BitBlt
How come you never call glutEnterGameMode()?
JasonL220
JasonL220
Opps, must have deleted it tring to get it working. anyway i get a black window for about 15seconds then the app closes.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.