The World Wide Screen

Is it possible to create a proper 16:9 widescreen mode in opengl with two black borders at the top and bottom? Would I need to change the screen resolution or the viewport? How about changing the viewing angle. Currently I have my perspective projection set to 45 degrees but I think this might have to increase to accomodate the wider screen. The main goal is to be able to output the video through a TV-Out to a proper wide screen television and see it in glorious 16:9 movie style. Has anyone given this a go using OpenGL??


Hi !

You can set it up any way you want with glViewport, just remember that the field of view you use in gluPerspective is in the Y direction, so the fov in the horizontal plane is based on the fov and the aspect ratio.



I worked on it last night and achieved a real excellent looking display. If anyone would like to achieve this cool effect you can check out my widescreen source code below. One thing I noticed after checking out a lot of DVD movies was that a lot of them say they use 1.85:1 ratio. After a bit of head scratching I found out that they actually use 1.78:1 as correctly stated on the back of Finding Nemo DVD. Also what is the difference between 2.35:1 mode and 1.85:1 mode? Is there a big difference when viewed on a widescreen tv? I don’t have a widescreen tv by the way. :stuck_out_tongue:

GLboolean ResizeViewport(GLsizei width, GLsizei height)
	GLfloat	aspect_ratio = 0.0f;
	GLint	display_pos = 0;

	// Prevent the aspect ratio from dividing by zero
	if(height == 0){ height = 1; }

	// Call this function to change the display to a 16:9 Widescreen
	SetupWidescreen(&width, &height, &display_pos);

	glViewport(0, display_pos, width, height);

	// Find the aspect ratio for the window
	aspect_ratio = (GLfloat)width / (GLfloat)height;

	// Calculate a realistic perspective projection with a viewing distance of 15000
	gluPerspective(45.0f, aspect_ratio, 0.1f, 15000.0f);
	// Tell OpenGL that the current matrix is now the Modelview Matrix
	return TRUE;

GLboolean SetupWidescreen(GLsizei *width, GLsizei *height, GLint *display_pos)
	GLfloat wide_width = (GLfloat)*width;
	GLfloat wide_height = (wide_width / 16.0f) * 9.0f;

	// Below are some different widescreen aspect ratios (1.78:1) (1.85:1) (2.35:1)
	//wide_height = (wide_width / 1.78f);			// Finding Nemo
	//wide_height = (wide_width / 1.85f);			// Robin Hood: Prince of Thieves
	//wide_height = (wide_width / 2.35f);			// Lord of the Rings

	// Calculate the starting Y position of the viewport
	*display_pos = (*height - (GLint)wide_height) / 2;

	// Calculate the new height for the widescreen viewport
	*height = (GLint)wide_height;
	return TRUE;