I've been at this for a long time, and I cannot get my OpenGL ES game to display properly in landscape mode. My game runs exclusively in landscape mode, so I don't need to rotate when it changes. I noticed that if I run my game in portrait mode and swap some of the dimensions, it works, but causes message boxes and screenshots to be forced in portrait mode. That is bad. I altered my code to change this, but so far, it either just runs in portrait mode, or it just refuses to be in the right orientation!
Some of you might tell me to rotate the OpenGL matrix and be done with it, but due to my game's internal mechanics, matrix handling, etc. that is going to be irritatingly hard to implement and therefore not feasible.
Let me show you the code that appears to look correct in portrait mode:
And this is it in landscape mode (or at least my latest attempt to get it to work...)
If you need a screenshot of what's happening, this is my problem in a nutshell:
I've tweaked and tweaked this stupid thing until I ran out of ideas. Even asked on another forum, not a single answer. Any ideas? Thanks.
Shogun.
Some of you might tell me to rotate the OpenGL matrix and be done with it, but due to my game's internal mechanics, matrix handling, etc. that is going to be irritatingly hard to implement and therefore not feasible.
Let me show you the code that appears to look correct in portrait mode:
Code:
int view_width, view_height;
get_dimensions( &view_height, &view_width );
self.view.transform = CGAffineTransformMakeRotation(3.14 * (90) / 180.0);
self.view.bounds = CGRectMake(0.0f, 0.0f, view_width, view_height);
self.view.center = CGPointMake(view_height/2.0f, view_width/2.0f);
self.glView = [[GLView alloc] initWithFrame:CGRectMake(0, 0, view_width, view_height)];
if( supports_retina_display() || !is_ipad() )
{
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.glView.layer;
eaglLayer.contentsScale = 2;
}
[self.view addSubview:self.glView];
// 4. Create a Renderbuffer
glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
[self.context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.glView.layer];
// 5. Create a Framebuffer
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB5_A1, view_width, view_height );
//glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_RGBA8_OES, view_width, view_height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer);
And this is it in landscape mode (or at least my latest attempt to get it to work...)
Code:
int view_width, view_height;
get_dimensions( &view_height, &view_width );
self.view.transform = CGAffineTransformMakeRotation(3.14 * (90) / 180.0);
self.view.bounds = CGRectMake(0.0f, 0.0f, view_height, view_width);
self.view.center = CGPointMake(view_width, view_height/2.0f);
self.glView = [[GLView alloc] initWithFrame:CGRectMake(0, 0, view_width, view_height)];
if( supports_retina_display() || !is_ipad() )
{
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.glView.layer;
eaglLayer.contentsScale = 2;
}
[self.view addSubview:self.glView];
// 4. Create a Renderbuffer
glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
[self.context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.glView.layer];
// 5. Create a Framebuffer
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB5_A1, view_height, view_width );
//glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_RGBA8_OES, view_width, view_height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer);
If you need a screenshot of what's happening, this is my problem in a nutshell:

I've tweaked and tweaked this stupid thing until I ran out of ideas. Even asked on another forum, not a single answer. Any ideas? Thanks.
Shogun.