Results 1 to 7 of 7

Thread: API for finding screen size

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2008
    Posts
    4

    API for finding screen size

    Hi all,,

    is there any function in opengl, which can determine the screen size when an application is called.
    as becoz setting parameters based on different screen sizes is quite a cumbersome task.

    do let me know..

    thanks in advance

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: API for finding screen size

    Windows:
    width = GetSystemMetrics(SM_CXSCREEN);
    height= GetSystemMetrics(SM_CYSCREEN);

  3. #3
    Member Contributor
    Join Date
    Jul 2006
    Location
    UK
    Posts
    86

    Re: API for finding screen size

    or, just for your primary monitor...

    RECT r;
    GetClientRect( GetDesktopWindow() ,&r );

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2008
    Posts
    4

    Re: API for finding screen size

    so can these functions be put in the opengl code..will it work fine..

  5. #5
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: API for finding screen size

    There is no reason why they should not work with an application that uses OpenGL. If you know one, please tell.

  6. #6
    Junior Member Newbie
    Join Date
    Jun 2008
    Posts
    4

    Re: API for finding screen size

    When i m using the Rect r;.. at that instant its not of any help for my glutInitWindowSize() method as it accepts 2 parameters i.e XSIZE and the YSIZE.

    Using the other declaration as
    int width = GetSystemMetrics(SM_CXSCREEN);
    int height= GetSystemMetrics(SM_CYSCREEN); in the main()

    its working fine, but my application window is starting minimized at the beginning, and i m maximizing it using the mouse..which is not intended as how itz to work..

    Plz let me know on this...

  7. #7

    Re: API for finding screen size

    Using the RECT method: use r.right and r.bottom. Gotta check if you have to add 1 or not (dunno if it specifies the bottom-rightmost pixel or the size, I always use the other method). Anyways, it should be obvious if you try it and very easy to fix if it is wrong (just add or remove the "+ 1").

    And about it starting minimized, no idea. Check if by any chance the program is set to start minimized (right click on the EXE and select "Properties"). If you're running it from an IDE, check if it isn't the IDE's fault (run the EXE directly instead from the IDE and see what happens).

Similar Threads

  1. Finding screen width and height dynamically in OpenGL GLUT program
    By kindergartenbaby in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-23-2012, 06:31 PM
  2. Finding screen dimensions
    By t3jem in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 09-08-2005, 06:42 PM
  3. Finding depth from a 2d screen point
    By disarm72 in forum OpenGL: General
    Replies: 11
    Last Post: 01-26-2005, 10:09 PM
  4. Finding the edges of the screen
    By Ping-Pong in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 03-28-2003, 06:33 PM
  5. Finding the screen coords of a 3D point?
    By lwenke in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-07-2000, 01:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean