Compy
Compy

Reputation: 25

glutGetWindow - Expression must have class type

Good Afternoon,

So I'm working with C++ (Visual Studios C++ 2010 to be exact) and am working on a seemingly easy task;

Draw a picture onto the middle of the window. If you readjust the window size, the picture/bitmap will be redrawn into the middle of the newly sized window.

I figure to get the middle of the window, I should find its rightmost and bottommost bits, then divide each by 2, but I don't know how to get the window length and height.

I currently have

centrewidth = glutGetWindow().Size.Width;
centreheight = glutGetWindow().Size.Height;

Yet for both I'm getting errors on glutGetWindow, saying "Error: Expression must have class type". I'm certain once I get this, it will be no problem, but this is causing a lot of trouble for me. Any advice is greatly appreciated. Thanks!

Upvotes: 0

Views: 694

Answers (1)

Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361352

glutGetWindow doesn't return object of any class type. It's signature is this:

int glutGetWindow(void);

And you need is this (see doc):

int glutGet(GLenum eWhat);

Example,

int width = glutGet(GLUT_WINDOW_WIDTH); //Width in pixels of the current window.
int height = glutGet(GLUT_WINDOW_HEIGHT); //Height in pixels of the current window.

Have a look at the doc to know what states you can get using this function.

Upvotes: 2

Related Questions