• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

aGuyWhoSucksAtOpenGL

Members
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

116 Neutral

About aGuyWhoSucksAtOpenGL

  • Rank
    Newbie
  1. 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!
  2. 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?  
  3. 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
  4. 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.
  5. Hi,   I usually only turn to forums when I'm completely and utterly stuck on a problem, and guess what? I'm completely and utterly stuck! Each time I think I've figured out a way for my code to work, I rush to my keyboard and my ideas are quickly shot down.   My question is, how do I actively re-position a trianglestrip as the program is running?     I'll be honest, I have pretty much no clue as to how to do this without reloading both the image and texture. The code I was previously using, used a timer that refreshed the screen every 0.05s and each time it did so, it was re-allocating and re-drawing my texture. Not the most efficient way to move an image.    This is the code I'm currently using in order to display the image and set it's position (coding in Obj-C): -(void)addSprite{ // This code works btw, image is drawn on screen and positioned accordingly self.player = [[GLSprite alloc] initWithFile:@"logo2" fileFormat:@"png"]; self.player.positionX = 100; [self.player render]; }   This is the code I'm trying to use to loop the render function in order to redraw it (am I even correct in doing this?). This code doesn't work at all (image doesn't show up) but it's a rough attempt at what I'm trying to do. [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval) 0.05 target:self selector:@selector(update) userInfo:nil repeats:YES]; -(void)update{ myInt += 1; if (myInt < 2) { // Calls alloc once self.player = [[GLSprite alloc] initWithFile:@"logo2" fileFormat:@"png"]; NSLog(@"ALLOC"); } // Render, render, render that image self.player.positionX += 10; // Increments x coordinate every 0.05s (will eventually revert xPos to be dependant on mouse) [self.player render]; NSLog(@"RENDER"); }   And finally, here's the implementation of the functions from the above code:  -(id)initWithFile:(NSString *)imageName fileFormat: (NSString *) format{ if ((self = [super init])) { [GLSprite getWindowSize]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:  [NSNumber numberWithBool:YES],  GLKTextureLoaderOriginBottomLeft,  nil]; NSString *imageURL, *dirImage; imageURL = [NSString stringWithFormat:@"images/%@", imageName]; dirImage = [[NSBundle mainBundle] pathForResource:imageURL ofType:format]; NSError *error; self.texture = [GLKTextureLoader textureWithContentsOfFile:dirImage options:options error:&error]; if (error) { NSLog(@"Error loading texture from image: %@",error); } } return self; }  -(void)render{ x = (self.texture.width / window.x); y = (self.texture.height / window.y); self.initPositionX = (self.positionX / window.x) * 2; self.initPositionY = (self.positionY / window.y) * 2; xCoord[0] = 0 - x; yCoord[0] = 0 - y; xCoord[1] = 0 + x; yCoord[1] = 0 - y; xCoord[2] = 0 - x; yCoord[2] = 0 + y; xCoord[3] = 0 + x; yCoord[3] = 0 + y; NSLog(@"Render: %f", self.initPositionX); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_TRIANGLE_STRIP); glTexCoord2d(0.0, 0.0); glVertex2d(xCoord[0] + self.initPositionX, yCoord[0] + self.initPositionY); glTexCoord2d(1.0, 0.0); glVertex2d(xCoord[1] + self.initPositionX, yCoord[1] + self.initPositionY); glTexCoord2d(0.0, 1.0); glVertex2d(xCoord[2] + self.initPositionX, yCoord[2] + self.initPositionY); glTexCoord2d(1.0, 1.0); glVertex2d(xCoord[3] + self.initPositionX, yCoord[3] + self.initPositionY); glEnd(); }   I'm most likely completely wrong in what I'm trying to achieve so any help would be great, thanks!
  6. OpenGL

    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!
  7. OpenGL

    Hi all,    Today was my first step into the mighty land of OpenGL and so the first task I set myself- after playing around with shapes and colours- was to display an image on screen. So far, I've been attempting to texturise a quad for the past 5/6 hours with not much luck, well, none at all really. The rest of the code seems to work fine, I just can't get the texture to show. As a side note, my eyes are beginning to glaze over right now, so if anything I say doesn't make sense, just skip a few lines and see if that does the trick.   What choo doing? I'm using SOIL in my code, so the problem may lie with that if the rest of the code seems fine. If you lovely people could check my code for mistakes, I'd greatly appreciate it, thanks! As I said, I'm still a noob and so I can't figure out where I've gone wrong. As for my code, I'm writing this on a mac, so some functions are written in obj-c.   Where yo' code at? -(void) loadTextures{ GLuint textures[1]; glGenTextures( 1, textures ); int width, height; width = 128; height = 256; unsigned char *image; glBindTexture( GL_TEXTURE_2D, textures[0] ); image = SOIL_load_image( "logo.png", &width, &height, 0, SOIL_LOAD_RGB ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image ); SOIL_free_image_data( image ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glBegin(GL_QUADS); glTexCoord2d(0.0, 0.0); glVertex2d(-0.5, -0.5); glTexCoord2d(1.0, 0.0); glVertex2d(-0.5, 0.5); glTexCoord2d(1.0, 1.0); glVertex2d(0.5, 0.5); glTexCoord2d(0.0, 1.0); glVertex2d(0.5, -0.5); glEnd(); } - (void)drawRect:(NSRect)dirtyRect { glClearColor(0, 104.0/255.0, 55.0/255.0, 1.0); // rgba ; Red, Green, Blue, Alpha (transparency) glClear(GL_COLOR_BUFFER_BIT); // if no buffer is present, glclear has no effect. glclear clears buffers to preset values. MyOpenGLView *GLView = [[MyOpenGLView alloc] init]; [GLView loadTextures]; glFlush(); // forces execution of GL commands. }     I'm off to sleep now, this code -albeit small- has worn me out. Any responses would be fantastic, I've looked over and over my code, checked with what seems like a million other pieces of source code and yet I still can't figure out the issue, obviously there is, as the texture isn't loading! If I don't respond within a couple of minutes, odds are I'm asleep, but any responses would be much appreciated and I'll be sure to reply back in around 6 hours time.   Thanks!   Edit: Here's what I'm getting at the moment: http://i.imgur.com/JOFaYG6.png