Skip to main content
gamedev.net
🔒 Locked

Refreshing (updating) problem

Started by pkiskool Jul 9, 2008 at 2:47 PM 0 replies 450+ views
Original Post
pkiskool
pkiskool
Hi, It's kind of hard to explain exactly what the problem of my code is, but I'll try my best. My scope is to simulate a cavity mould where the liquid resin comes in and fills the cavity. I've managed to almost get this simulation to work, except I'm having weird problem with the openGL. I've set 3 types of keyboard input available for this program: 1. key 't' to advance the time, thus the flow progresses 2. key '+' to zoom in on the whole picture 3. key '-' to zoom out of the whole picture Now, once I press 't' once to advance the time (and the flow), it tends to do this particular action no matter what I press afterwards, ie) spacebar, any other letter, number etc, and most ridiculously a mouse click! Another weird symptom is that if I press zoom in a few times before I press 't' to progress the flow, it zooms in again everytime I press 't'. In summary, whatever the input I press at first, it tends to do this again and again no matter what I press afterwards. Really annoying, and unacceptable. I'll try to paste on some of the code, but the volume of it is quite something so I'll try to put the essentials. void RenderScene(void) { if (GeometryFlag==true) front(); //This function is the MATH behind the flow . . . } void SetupRC(void) { // Black background glClearColor(0.0f, 0.0f, 0.0f, 1.0f ); } void ChangeSize(int w, int h){ . . . } void OtherKeys(unsigned char key, int z, int a) { if(key == 't') { if (GeometryFlag==false) GeometryFlag=true; else if (GeometryFlag==true) GeometryFlag=false; } //Pressing 't' enables the flow . . . } void SpecialKeys(int key, int x, int y) { if(key == GLUT_KEY_UP) scale += 0.1; if(key == GLUT_KEY_DOWN) scale -= 0.1; //Zoom in and out glutPostRedisplay(); } int main (int argc, char **argv) { matcalc2(); //Another math function . . glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800,600); glutCreateWindow("Flow Simulation"); glutReshapeFunc(ChangeSize); glutSpecialFunc(SpecialKeys); glutDisplayFunc(RenderScene); glutKeyboardFunc(OtherKeys); SetupRC(); glutMainLoop(); } I'll also briefly show the math functions a little bit, although it probably has nothing to do with the problem. 'front' function: //HEADER FILES #include #include #include #include #include #include #include #include using namespace std; double t=0.05; void front() { . . . } 'matcalc2' function //HEADER FILES #include #include #include #include #include #include #include #include using namespace std; double *pres; double **eqn; double *posi; double *b; double *type; double **a; double *xsegment; double *ysegment; int xcount = 0; int n, m, dim; void matcalc2 () { . . . } There you have it. I wish I could post the entire code, but it might be pointless to do that. If someone could get rid of this bug for me, I'll appriciate it very much. Thank you!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.