Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 May 2013
Offline Last Active Jun 16 2013 02:05 AM

Posts I've Made

In Topic: Move glVertex Position

15 June 2013 - 01:42 PM

Ah, perfect, that did the trick! I really can't thank you enough, I've spent far too long trying to figure all of this out. Let me know if you have a bitcoin address and I'll be sure to send a few mbtc your way, thanks again! smile.png

In Topic: Move glVertex Position

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];
        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?  

In Topic: Move glVertex Position

14 June 2013 - 03:26 PM

Thanks Marc, great tips there, I really appreciate it. I'll have a 'lil look into GLEssentials and see what I can do.  


As for the code, I didn't explain myself very well, sorry. My problem doesn't lie in positioning the vertex as such but instead being able to reposition it after it's initially displayed, e.g// Everytime a number increments, or the mouse moves in a certain direction, the glVertex changes position and is re-rendered on the screen. The positioning I can handle, but I don't know how to constantly keep the triangle strip updating to adjust to the new coordinates- at the moment I can render the image, but for example, if I then altered moveVertex, it'd have no effect on the image's position. Any ideas how to fix this and keep the strip+texture updating?


In the mean time, I plan to go look through the example code from GLEssentials, thanks again for the help

In Topic: Move glVertex Position

14 June 2013 - 11:19 AM

Thanks for the link Marc, I've had a little browse through some of their OpenGL projects and they seem to rely quite heavily on using GLKit for a lot of their code. Not a bad thing, just I'm not too familiar with it. I'll perhaps play around with it later on today, in the meantime if anyone is able to chip in, it'd be much appreciated. My problem isn't really language specific, I'm just trying to figure out a way to move the vertexes whilst the programs running, be that in c, c++ or obj-c.

In Topic: Problem with texture mapping

30 May 2013 - 01:10 PM

Ah, that might be the problem, thanks, I'll give it a go. Will update in a few mins! Also, thanks for the tips Dave, much appreciated.


Edit: Yup, that did the trick, I can't thank you enough BornToCode! The funny thing is that I already had that line in my code, I'd just commented it out at some point- I'm an idiot. Thanks again!