Hey there, was wondering if anyone else has this issue.
I've checked to see if it was my drivers, but no.

the GL window wont move, it won't accept any inputs at all.
but it shows everything else.

I've tried everything in my memory bank.. and still nothing.
this is including rewriting the program, and implementing SDL as an input handler.


this is my cleaned out code (still wont accept anything) but still runs.

HALP!

#include <GL/glew.h>
#include <GL/glut.h> 
#include <iostream>

using namespace std;

bool* keyStates = new bool[256]; 

GLuint LoadTexture(char *TexName);



void keyOperations (void) {
	if (keyStates['w']) { 
		cout << "RAWR W WAS PRESSED" << endl;
	}
	if (keyStates['s']) {
		cout << "RAWR S WAS PRESSED" << endl;
	}
}

void display (void) {
	keyOperations();
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

	glLoadIdentity(); 

	glTranslatef(0.0f, 0.0f, -5.0f);

	glFlush();
}

void reshape (int width, int height) {
	glViewport(0, 0, (GLsizei)width, (GLsizei)height); 
	glMatrixMode(GL_PROJECTION); 
	glLoadIdentity(); 

	gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0, 100.0);

	glMatrixMode(GL_MODELVIEW);
}

void keyPressed (unsigned char key, int x, int y) {
	keyStates[key] = true; 
	cout << key;
}

void keyUp (unsigned char key, int x, int y) {
	keyStates[key] = false; 
}

int main (int argc, char **argv) {
	glutInit(&argc, argv);
	glutInitDisplayMode (GLUT_SINGLE);
	glutInitWindowSize (500, 500); 
	glutInitWindowPosition (100, 100); 
	glutCreateWindow ("OGL");
	glutDisplayFunc(display);

	glutIdleFunc(display); 

	glutReshapeFunc(reshape);

	glutKeyboardFunc(keyPressed); 
	glutKeyboardUpFunc(keyUp);
	
	glEnable (GL_DEPTH_TEST);
	
	for (int i = 0; i < 256; i++)
	keyStates[i] = false;

	glutMainLoop();
}

hmm, if you're using Windows have you tried running the application in administrator mode? Just making sure that wasn't overlooked.

Yea, all permissions are enabled for it. not sure why that would stop input.

Try checking your GLUT install then.

Also, I think you're leaking your key states array. (need to delete the memory)

Edited 5 Years Ago by pseudorandom21: n/a

It is because of this:

glutIdleFunc(display);

display() is being called continuously, since you have registered it as the idle callback. The window does move. The problem is there are too many idle calls. Give some delay, that will work.

PS: Its not a good idea to register the display as the idle callback itself. In your case, this could be a better approach:

void idleCallback(void)
{
    glutPostRedisplay();
    // delay would be required.
}

or you can perhaps you can have look at THIS as well.

Comments
fixed by adding a sleep <3

It is because of this:

glutIdleFunc(display);

display() is being called continuously, since you have registered it as the idle callback. The window does move. The problem is there are too many idle calls. Give some delay, that will work.

PS: Its not a good idea to register the display as the idle callback itself. In your case, this could be a better approach:

void idleCallback(void)
{
    glutPostRedisplay();
    // delay would be required.
}

or you can perhaps you can have look at THIS as well.

This was it, add a sleep/delay there. cant believe it was that simple, thanks.

This question has already been answered. Start a new discussion instead.