• Create Account

### #ActualaGuyWhoSucksAtOpenGL

Posted 15 June 2013 - 11:32 AM

Ah, I see your point, however in the above, defining x and y is just resetting the image dimensions, so that being called again shouldn't be a problem. As for the initPos variables, I'm redefining positionX beforehand in order to move the position of the object, so that being called again is needed in order to redraw the shape in the appropriate position, right? And to answer your question, I'm coding it for Mac at the moment- no real reason for it, just fancied doing it on such- I'll probably end up porting it to the iPhone eventually anyway.

I've been playing around with my code for the past few hours and I've somewhat solved my problem, well, kind of.

I was originally going to write a big explanation about what's wrong and what's working but I've recorded a video instead (linked here and below). Basically the NSRect function only gets called once initially, and every time the window size is repositioned thereafter. Placing the following code in the NSRect function works fine when resizing the window, but it's not exactly the way I want to move the image! haha

if (myInt < 1){
self.player = [[GLSprite alloc] initWithFile:@"tmp" fileFormat:@"png"];
[self.player render];
myInt++;
}
else{
self.player.positionX += 10;
[self.player render];
}


Alas, thinking I was close to figuring it out, I put the code into a separate function and called it at set intervals with an NSTimer. It didn't work. What instead happens is the image is drawn and drawn whilst being continuously repositioned- it's what happens in the second part of the video. Any ideas why it's doing that? Thanks again for the help though

Video: http://www.youtube.com/watch?v=9720on8GX68 (computer was lagging hard from quicktime, sorry for the slow recording)

Edit: Here's another example of the problem from using an NSTimer to call the above code (I've added mousetracking rather than an increasing integer): http://www.youtube.com/watch?v=eOgRvW7hON4

Edit 2: A timer probably isn't the best way to invoke the image re-position, but I can't think of a better solution. Any ideas?

### #5aGuyWhoSucksAtOpenGL

Posted 15 June 2013 - 11:29 AM

Ah, I see your point, however in the above, defining x and y is just resetting the image dimensions, so that being called again shouldn't be a problem. As for the initPos variables, I'm redefining positionX beforehand in order to move the position of the object, so that being called again is needed in order to redraw the shape in the appropriate position, right? And to answer your question, I'm coding it for Mac at the moment- no real reason for it, just fancied doing it on such- I'll probably end up porting it to the iPhone eventually anyway.

I've been playing around with my code for the past few hours and I've somewhat solved my problem, well, kind of.

I was originally going to write a big explanation about what's wrong and what's working but I've recorded a video instead (linked here and below). Basically the NSRect function only gets called once initially, and every time the window size is repositioned thereafter. Placing the following code in the NSRect function works fine when resizing the window, but it's not exactly the way I want to move the image! haha

if (myInt < 1){
self.player = [[GLSprite alloc] initWithFile:@"tmp" fileFormat:@"png"];
[self.player render];
myInt++;
}
else{
self.player.positionX += 10;
[self.player render];
}


Alas, thinking I was close to figuring it out, I put the code into a separate function and called it at set intervals with an NSTimer. It didn't work. What instead happens is the image is drawn and drawn whilst being continuously repositioned- it's what happens in the second part of the video. Any ideas why it's doing that? Thanks again for the help though

Video: http://www.youtube.com/watch?v=9720on8GX68 (computer was lagging hard from quicktime, sorry for the slow recording)

Edit: Here's another example of the problem from using an NSTimer to call the above code (I've added mousetracking rather than an increasing integer): http://www.youtube.com/watch?v=eOgRvW7hON4

### #4aGuyWhoSucksAtOpenGL

Posted 15 June 2013 - 11:27 AM

Ah, I see your point, however in the above, defining x and y is just resetting the image dimensions, so that being called again shouldn't be a problem. As for the initPos variables, I'm redefining positionX beforehand in order to move the position of the object, so that being called again is needed in order to redraw the shape in the appropriate position, right? And to answer your question, I'm coding it for Mac at the moment- no real reason for it, just fancied doing it on such- I'll probably end up porting it to the iPhone eventually anyway.

I've been playing around with my code for the past few hours and I've somewhat solved my problem, well, kind of.

I was originally going to write a big explanation about what's wrong and what's working but I've recorded a video instead (linked here and below). Basically the NSRect function only gets called once initially, and every time the window size is repositioned thereafter. Placing the following code in the NSRect function works fine when resizing the window, but it's not exactly the way I want to move the image! haha

if (myInt < 1){
self.player = [[GLSprite alloc] initWithFile:@"tmp" fileFormat:@"png"];
[self.player render];
myInt++;
}
else{
self.player.positionX += 10;
[self.player render];
}


Alas, thinking I was close to figuring it out, I put the code into a separate function and called it at set intervals with an NSTimer. It didn't work. What instead happens is the image is drawn and drawn whilst being continuously repositioned- it's what happens in the second part of the video. Any ideas why it's doing that? Thanks again for the help though

Video: http://www.youtube.com/watch?v=9720on8GX68 (computer was lagging hard from quicktime, sorry for the slow recording)

Edit: Here's another example of the problem from using an NSTimer to call the above code: http://www.youtube.com/watch?v=eOgRvW7hON4

### #3aGuyWhoSucksAtOpenGL

Posted 15 June 2013 - 11:27 AM

Ah, I see your point, however in the above, defining x and y is just resetting the image dimensions, so that being called again shouldn't be a problem. As for the initPos variables, I'm redefining positionX beforehand in order to move the position of the object, so that being called again is needed in order to redraw the shape in the appropriate position, right? And to answer your question, I'm coding it for Mac at the moment- no real reason for it, just fancied doing it on such- I'll probably end up porting it to the iPhone eventually anyway.

I've been playing around with my code for the past few hours and I've somewhat solved my problem, well, kind of.

I was originally going to write a big explanation about what's wrong and what's working but I've recorded a video instead (linked here and below). Basically the NSRect function only gets called once initially, and every time the window size is repositioned thereafter. Placing the following code in the NSRect function works fine when resizing the window, but it's not exactly the way I want to move the image! haha

if (myInt < 1){
self.player = [[GLSprite alloc] initWithFile:@"tmp" fileFormat:@"png"];
[self.player render];
myInt++;
}
else{
self.player.positionX += 10;
[self.player render];
}


Alas, thinking I was close to figuring it out, I put the code into a separate function and called it at set intervals with an NSTimer. It didn't work. What instead happens is the image is drawn and drawn whilst being continuously repositioned- it's what happens in the second part of the video. Any ideas why it's doing that? Thanks again for the help though

Video: http://www.youtube.com/watch?v=9720on8GX68 (computer was lagging hard from quicktime, sorry for the slow recording)

Edit: Here's another example of the problem of using an NSTimer to call the above code: http://www.youtube.com/watch?v=eOgRvW7hON4

### #2aGuyWhoSucksAtOpenGL

Posted 15 June 2013 - 10:48 AM

Ah, I see your point, however in the above, defining x and y is just resetting the image dimensions, so that being called again shouldn't be a problem. As for the initPos variables, I'm redefining positionX beforehand in order to move the position of the object, so that being called again is needed in order to redraw the shape in the appropriate position, right? And to answer your question, I'm coding it for Mac at the moment- no real reason for it, just fancied doing it on such- I'll probably end up porting it to the iPhone eventually anyway.

I've been playing around with my code for the past few hours and I've somewhat solved my problem, well, kind of.

I was originally going to write a big explanation about what's wrong and what's working but I've recorded a video instead (linked here and below). Basically the NSRect function only gets called once initially, and every time the window size is repositioned thereafter. Placing the following code in the NSRect function works fine when resizing the window, but it's not exactly the way I want to move the image! haha

if (myInt < 1){
self.player = [[GLSprite alloc] initWithFile:@"tmp" fileFormat:@"png"];
[self.player render];
myInt++;
}
else{
self.player.positionX += 10;
[self.player render];
}


Alas, thinking I was close to figuring it out, I put the code into a separate function and called it at set intervals with an NSTimer. It didn't work. What instead happens is the image is drawn and drawn whilst being continuously repositioned- it's what happens in the second part of the video. Any ideas why it's doing that? Thanks again for the help though

Video: http://www.youtube.com/watch?v=9720on8GX68 (computer was lagging hard from quicktime, sorry for the slow recording)

### #1aGuyWhoSucksAtOpenGL

Posted 15 June 2013 - 10:32 AM

Ah, I see your point, however in the above, defining x and y is just resetting the image dimensions, so that being called again shouldn't be a problem. As for the initPos variables, I'm redefining positionX beforehand in order to move the position of the object, so that being called again is needed in order to redraw the shape in the appropriate position, right? And to answer your question, I'm coding it for Mac at the moment- no real reason for it, just fancied doing it on such- I'll probably end up porting it to the iPhone eventually anyway.

I've been playing around with my code for the past few hours and I've somewhat solved my problem, well, kind of.

I was originally going to write a big explanation about what's wrong and what's working but I've recorded a video instead (linked here and below). Basically the NSRect function only gets called once initially, and every time the window size is repositioned thereafter. Placing the following code in the NSRect function works fine when resizing the window, but it's not exactly the way I want to move the image! haha

if (myInt < 1){
self.player = [[GLSprite alloc] initWithFile:@"tmp" fileFormat:@"png"];
[self.player render];
myInt++;
}
else{
self.player.positionX += 10;
[self.player render];
}


Alas, thinking I was close to figuring it out, I put the code into a separate function and called it at set intervals with an NSTimer. It didn't work. What instead happens is the image is drawn and drawn whilst being continuously repositioned- it's what happens in the second part of the video. Any ideas why it's doing that? I mean, I have a rough idea, just no clue how to fix it.

Video: http://www.youtube.com/watch?v=9720on8GX68 (computer was lagging hard from quicktime, sorry for the slow recording)

PARTNERS