Jump to content
  • Advertisement
Sign in to follow this  
pkiskool

OpenGL Refreshing (updating) problem

This topic is 3755 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 <iostream> #include <iomanip> #include <math.h> #include <cmath> #include <fstream> #include <string> #include <stdlib.h> #include <cstdlib> using namespace std; double t=0.05; void front() { . . . } 'matcalc2' function //HEADER FILES #include <iostream> #include <iomanip> #include <math.h> #include <cmath> #include <fstream> #include <string> #include <stdlib.h> #include <cstdlib> 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!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!