Click here to Skip to main content
12,953,479 members (52,878 online)
Rate this:
 
Please Sign up or sign in to vote.
I'm trying to setup an OpenGL window to have the the top-left corner 0,0 and the bottom-right corner the width and height of the window (pixels not percentage). And when resized nothing drawn is scaled, instead the window area is enlarged/shrunk. It's for drawing 2D images. I'm using the Windows API. How can I do this?
Posted 21-Sep-12 17:27pm
Updated 21-Sep-12 18:18pm
v2
Comments
Wes Aday 21-Sep-12 23:44pm
   
And?
Mohibur Rashid 21-Sep-12 23:53pm
   
go on, you are not done with the question yet.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

OnSize(UINT nType, int cx, int cy)
{
    // Set viewport widht as cx, and height as cy
    glViewport( 0, 0, cx, cy );
 
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glOrtho( 0, cx, cy, 0, 0, 1 );
 
    m_nWidth = cx;
    m_nHeight = cy;
}


You need to redraw all your frame related to new screen size.

onDrawFrame()
{
   // Draw frame relative to m_nWidth and m_nHeight.
   // Eg. glRect( 0,0, m_nWidth, m_nHeight )
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,429
CHill60 3,490
Maciej Los 3,103
ppolymorphe 2,020
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 22 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100