Can't animate the exact object that I want in openGL & GLUT Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Initializing OpenGL without GLUTCenter an OpenGL window with GLUTLearning OpenGL without GLUT?How to pause an animation with OpenGL / glutOpenGL/GLUT - drawing on an objectsimple 2d animation in glutOPENGL GLUT compiler can't find functionsOpenGL glut animation of 8 puzzle solvingCan't display a PNG using Glut or OpenGLStopping animation with a key using GLUT?
preposition before coffee
How does the math work when buying airline miles?
Girl Hackers - Logic Puzzle
Significance of Cersei's obsession with elephants?
Do wooden building fires get hotter than 600°C?
Intuitive explanation of the rank-nullity theorem
How to compare two different files line by line in unix?
How to write capital alpha?
What does it mean that physics no longer uses mechanical models to describe phenomena?
Trademark violation for app?
Why do aircraft stall warning systems use angle-of-attack vanes rather than detecting airflow separation directly?
What does Turing mean by this statement?
One-one communication
Why can't I install Tomboy in Ubuntu Mate 19.04?
Deconstruction is ambiguous
Dynamic filling of a region of a polar plot
Google .dev domain strangely redirects to https
How long can equipment go unused before powering up runs the risk of damage?
How can I set the aperture on my DSLR when it's attached to a telescope instead of a lens?
How often does castling occur in grandmaster games?
What initially awakened the Balrog?
Crossing US/Canada Border for less than 24 hours
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
How did Fremen produce and carry enough thumpers to use Sandworms as de facto Ubers?
Can't animate the exact object that I want in openGL & GLUT
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Initializing OpenGL without GLUTCenter an OpenGL window with GLUTLearning OpenGL without GLUT?How to pause an animation with OpenGL / glutOpenGL/GLUT - drawing on an objectsimple 2d animation in glutOPENGL GLUT compiler can't find functionsOpenGL glut animation of 8 puzzle solvingCan't display a PNG using Glut or OpenGLStopping animation with a key using GLUT?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
When I clicked the right button on the particular object it gets started to animate. However, whether I click on the same object to stop it -the animating one- or any other object which is not animating, the animating object stops. But, I want animating object to be stopped only when I click on it.
How can I fix this problem? Here is my onClick and onTimer functions. Should I use the animating bool in structure? if so, how?
if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
for(i=0; i<MAX; i++)
if(mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 && my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation = !animation;
animationNumber = i;
printf("TRUEn");
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
if(animation)
arr[animationNumber].xB++;
if(arr[animationNumber].xB >= 640)
arr[animationNumber].xB -= 1410;
glutPostRedisplay() ; // display()
c++ animation opengl glut
add a comment |
When I clicked the right button on the particular object it gets started to animate. However, whether I click on the same object to stop it -the animating one- or any other object which is not animating, the animating object stops. But, I want animating object to be stopped only when I click on it.
How can I fix this problem? Here is my onClick and onTimer functions. Should I use the animating bool in structure? if so, how?
if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
for(i=0; i<MAX; i++)
if(mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 && my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation = !animation;
animationNumber = i;
printf("TRUEn");
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
if(animation)
arr[animationNumber].xB++;
if(arr[animationNumber].xB >= 640)
arr[animationNumber].xB -= 1410;
glutPostRedisplay() ; // display()
c++ animation opengl glut
The title is wrong. The problem is in the description. I don't want the animating object to be stopped when I click another object.
– baruj
Mar 8 at 22:09
How is this related to OpenGL?
– Rabbid76
Mar 8 at 22:18
I am drawing a rocket some other things by using OpenGL
– baruj
Mar 8 at 22:27
StoreanimationNumber
in an array. InonClick
check, ifi
in an array. If it is - remove it, otherwise add it. InonTimer
iterate thru the whole array.
– Michael Nastenko
Mar 9 at 0:48
still not working.
– baruj
Mar 9 at 9:35
add a comment |
When I clicked the right button on the particular object it gets started to animate. However, whether I click on the same object to stop it -the animating one- or any other object which is not animating, the animating object stops. But, I want animating object to be stopped only when I click on it.
How can I fix this problem? Here is my onClick and onTimer functions. Should I use the animating bool in structure? if so, how?
if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
for(i=0; i<MAX; i++)
if(mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 && my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation = !animation;
animationNumber = i;
printf("TRUEn");
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
if(animation)
arr[animationNumber].xB++;
if(arr[animationNumber].xB >= 640)
arr[animationNumber].xB -= 1410;
glutPostRedisplay() ; // display()
c++ animation opengl glut
When I clicked the right button on the particular object it gets started to animate. However, whether I click on the same object to stop it -the animating one- or any other object which is not animating, the animating object stops. But, I want animating object to be stopped only when I click on it.
How can I fix this problem? Here is my onClick and onTimer functions. Should I use the animating bool in structure? if so, how?
if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
for(i=0; i<MAX; i++)
if(mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 && my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation = !animation;
animationNumber = i;
printf("TRUEn");
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
if(animation)
arr[animationNumber].xB++;
if(arr[animationNumber].xB >= 640)
arr[animationNumber].xB -= 1410;
glutPostRedisplay() ; // display()
c++ animation opengl glut
c++ animation opengl glut
edited Mar 8 at 22:11
genpfault
42.7k954100
42.7k954100
asked Mar 8 at 22:08
barujbaruj
61
61
The title is wrong. The problem is in the description. I don't want the animating object to be stopped when I click another object.
– baruj
Mar 8 at 22:09
How is this related to OpenGL?
– Rabbid76
Mar 8 at 22:18
I am drawing a rocket some other things by using OpenGL
– baruj
Mar 8 at 22:27
StoreanimationNumber
in an array. InonClick
check, ifi
in an array. If it is - remove it, otherwise add it. InonTimer
iterate thru the whole array.
– Michael Nastenko
Mar 9 at 0:48
still not working.
– baruj
Mar 9 at 9:35
add a comment |
The title is wrong. The problem is in the description. I don't want the animating object to be stopped when I click another object.
– baruj
Mar 8 at 22:09
How is this related to OpenGL?
– Rabbid76
Mar 8 at 22:18
I am drawing a rocket some other things by using OpenGL
– baruj
Mar 8 at 22:27
StoreanimationNumber
in an array. InonClick
check, ifi
in an array. If it is - remove it, otherwise add it. InonTimer
iterate thru the whole array.
– Michael Nastenko
Mar 9 at 0:48
still not working.
– baruj
Mar 9 at 9:35
The title is wrong. The problem is in the description. I don't want the animating object to be stopped when I click another object.
– baruj
Mar 8 at 22:09
The title is wrong. The problem is in the description. I don't want the animating object to be stopped when I click another object.
– baruj
Mar 8 at 22:09
How is this related to OpenGL?
– Rabbid76
Mar 8 at 22:18
How is this related to OpenGL?
– Rabbid76
Mar 8 at 22:18
I am drawing a rocket some other things by using OpenGL
– baruj
Mar 8 at 22:27
I am drawing a rocket some other things by using OpenGL
– baruj
Mar 8 at 22:27
Store
animationNumber
in an array. In onClick
check, if i
in an array. If it is - remove it, otherwise add it. In onTimer
iterate thru the whole array.– Michael Nastenko
Mar 9 at 0:48
Store
animationNumber
in an array. In onClick
check, if i
in an array. If it is - remove it, otherwise add it. In onTimer
iterate thru the whole array.– Michael Nastenko
Mar 9 at 0:48
still not working.
– baruj
Mar 9 at 9:35
still not working.
– baruj
Mar 9 at 9:35
add a comment |
1 Answer
1
active
oldest
votes
Use an array bool animation[MAX]
instead of the single boolean variable animation
and the indexing variable animationNumber
.
With this solution each object has its own state which indicates if it is "animating" or stands still.
bool animation[MAX] = ;
Change the corresponding state of the object in the array, when the mouse button is pressed:
if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
for (i=0; i<MAX; i++)
if (mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 &&
my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation[i] = !animation[i];
printf("TRUEn");
Traverse all the objects in the timer function and update the positions of the objects:
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
for (i=0; i<MAX; i++)
if(animation[i])
arr[i].xB++;
if( arr[i].xB >= 640)
arr[i].xB -= 1410;
glutPostRedisplay();
thanks for sharing your idea. I solved the problem
– baruj
Mar 10 at 14:02
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071669%2fcant-animate-the-exact-object-that-i-want-in-opengl-glut%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use an array bool animation[MAX]
instead of the single boolean variable animation
and the indexing variable animationNumber
.
With this solution each object has its own state which indicates if it is "animating" or stands still.
bool animation[MAX] = ;
Change the corresponding state of the object in the array, when the mouse button is pressed:
if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
for (i=0; i<MAX; i++)
if (mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 &&
my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation[i] = !animation[i];
printf("TRUEn");
Traverse all the objects in the timer function and update the positions of the objects:
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
for (i=0; i<MAX; i++)
if(animation[i])
arr[i].xB++;
if( arr[i].xB >= 640)
arr[i].xB -= 1410;
glutPostRedisplay();
thanks for sharing your idea. I solved the problem
– baruj
Mar 10 at 14:02
add a comment |
Use an array bool animation[MAX]
instead of the single boolean variable animation
and the indexing variable animationNumber
.
With this solution each object has its own state which indicates if it is "animating" or stands still.
bool animation[MAX] = ;
Change the corresponding state of the object in the array, when the mouse button is pressed:
if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
for (i=0; i<MAX; i++)
if (mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 &&
my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation[i] = !animation[i];
printf("TRUEn");
Traverse all the objects in the timer function and update the positions of the objects:
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
for (i=0; i<MAX; i++)
if(animation[i])
arr[i].xB++;
if( arr[i].xB >= 640)
arr[i].xB -= 1410;
glutPostRedisplay();
thanks for sharing your idea. I solved the problem
– baruj
Mar 10 at 14:02
add a comment |
Use an array bool animation[MAX]
instead of the single boolean variable animation
and the indexing variable animationNumber
.
With this solution each object has its own state which indicates if it is "animating" or stands still.
bool animation[MAX] = ;
Change the corresponding state of the object in the array, when the mouse button is pressed:
if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
for (i=0; i<MAX; i++)
if (mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 &&
my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation[i] = !animation[i];
printf("TRUEn");
Traverse all the objects in the timer function and update the positions of the objects:
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
for (i=0; i<MAX; i++)
if(animation[i])
arr[i].xB++;
if( arr[i].xB >= 640)
arr[i].xB -= 1410;
glutPostRedisplay();
Use an array bool animation[MAX]
instead of the single boolean variable animation
and the indexing variable animationNumber
.
With this solution each object has its own state which indicates if it is "animating" or stands still.
bool animation[MAX] = ;
Change the corresponding state of the object in the array, when the mouse button is pressed:
if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
for (i=0; i<MAX; i++)
if (mx >= arr[i].xB + 0 && mx <= arr[i].xB + 130 &&
my <= arr[i].yB + 17 && my >= arr[i].yB + - 17)
animation[i] = !animation[i];
printf("TRUEn");
Traverse all the objects in the timer function and update the positions of the objects:
void onTimer( int v)
glutTimerFunc( TIMER_PERIOD, onTimer, 0) ;
for (i=0; i<MAX; i++)
if(animation[i])
arr[i].xB++;
if( arr[i].xB >= 640)
arr[i].xB -= 1410;
glutPostRedisplay();
answered Mar 9 at 13:29
Rabbid76Rabbid76
44.8k123354
44.8k123354
thanks for sharing your idea. I solved the problem
– baruj
Mar 10 at 14:02
add a comment |
thanks for sharing your idea. I solved the problem
– baruj
Mar 10 at 14:02
thanks for sharing your idea. I solved the problem
– baruj
Mar 10 at 14:02
thanks for sharing your idea. I solved the problem
– baruj
Mar 10 at 14:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071669%2fcant-animate-the-exact-object-that-i-want-in-opengl-glut%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The title is wrong. The problem is in the description. I don't want the animating object to be stopped when I click another object.
– baruj
Mar 8 at 22:09
How is this related to OpenGL?
– Rabbid76
Mar 8 at 22:18
I am drawing a rocket some other things by using OpenGL
– baruj
Mar 8 at 22:27
Store
animationNumber
in an array. InonClick
check, ifi
in an array. If it is - remove it, otherwise add it. InonTimer
iterate thru the whole array.– Michael Nastenko
Mar 9 at 0:48
still not working.
– baruj
Mar 9 at 9:35