• 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.

Astado89

Members
  • Content count

    9
  • Joined

  • Last visited

Community Reputation

135 Neutral

About Astado89

  • Rank
    Newbie
  1. Hi COlumbo,   great thanks thats exactly what I was looking for :)   Maybe I'll post my Interface solution when I finished it.
  2. Hi everyone,   i am currently facing some issues drawing a text in my interface. The drawing itself is working so far with the following code: NSRect backingBounds = [self convertRectToBacking:[self bounds]]; GLsizei backingPixelWidth = (GLsizei)(backingBounds.size.width), backingPixelHeight = (GLsizei)(backingBounds.size.height); glViewport(0, 0, backingPixelWidth, backingPixelHeight); //set viewport to complete screen glClearColor(1, 1, 1, 1); glClear(GL_COLOR_BUFFER_BIT); glColor3f(0, 0, 1); glBegin(GL_QUADS); //draw simple quad half the size of the screen glVertex2d(-0.5, 0.5); glVertex2d(0.5, 0.5); glVertex2d(0.5, -0.5); glVertex2d(-0.5, -0.5); glEnd(); glPushMatrix(); glLoadIdentity(); glViewport(0, 0, 100, 100); //set viewport to small part of the screen glColor3f(0, 1, 0); glBegin(GL_QUADS); //draw next rect glVertex2d(-1, 1); //just for indication of the next viewport glVertex2d(1, 1); // to see where the text is drawn glVertex2d(1, -1); glVertex2d(-1, -1); glEnd(); glColor3f(1, 0, 0); glOrtho(0, 100, 0, 100, -1.0, 1.0); //set the ortho for the viewport glRasterPos2d(10, 10); const char *_string = "das ist ein Test"; void* _fonttype = GLUT_BITMAP_TIMES_ROMAN_24; if (*_string && strlen(_string)) { while (*_string) { glutBitmapCharacter(_fonttype, *_string); //draw character _string++; } } glPopMatrix(); but the text is drawn when it reaches the viewports end.   I want the text to be clipped when it reaches the end of the viewport or what ever possibility. The main reason is I want to make a tableview that shows content of my game. Some of the content is too big (like texts) and each column will be resized to fit. But then the tableview might be too big for my interfacewindow. So I want to implement scrolling. So each column as it enters the window when scrolling should show its text but the text should cut of at the end of the window and when scrolled out of the window. For example the text is "Hallo World" and it is scrolled in the H is to be shown and the rest clipped. When is is scrolled out of the screen the H disappears. I hope that I described it so you can understand my issue   Does anyone have any ideas of how i would do that?     Thanks a lot for reading my post.      
  3. Hi everyone,   my question is a c++ based topic, but I'm using Cocoa and Xcode.   I'm allocating sone buffers to send files over the network. When i read the network-input into the buffer i process it in another object called Controller. after that i want to release(free) the buffer in order not to get any memory leaks. But here's my problem the program crashes and says:   but why? Here's the code:   So this is the code of my Network-Controller which gets the input as follows: int n = 0;     char *buffer = malloc(2049*sizeof(char));     while ( (n = (int)read( sockfd, buffer, 2048)) ) {         buffer[n] = '0';         [cont networkinput:buffer length:n];         free(buffer); Error!!!     }     connected = NO; [cont networkinput:buffer length:n]; sends the buffer to the Controller and the class processes it.     but why not allocated? I used malloc.   Can anyone help me? If I take out the freeing my memory must be increased to 1000GB    Thanks a lot
  4. Many thanks for your answers Dave and patrrr,   It was a result of many thinks that are different from cocoa and glut.   First I had to call the makeCurrentContext for the NSOpenglContext which set up the Context. I somehow had to call it explicitly.   And another reason was that glut get(GLUT_WINDOW_WIDTH) and the corresponding GLUT_WINDOW_HEIGHT didn't work under cocoa. they both returned 0. I set up my interface using the width and height of the window to make it more smooth. And cause they both returned 0 my glviewport for the interface was set to 0,0,0,0. :(   Terrible mistake sorry for wasting you time :)   But thanks to your replies i figured it out Tanks!! :)
  5. Thanks for your answer.   The code for loading textures is as follows: -(BOOL)loadTexture:(NSString *)_name { if ([_name isEqualToString:@""]) { return NO; } NSString *substring = [_name substringFromIndex:_name.length-4]; if ([substring isNotEqualTo:@".JPG"] && [substring isNotEqualTo:@".jpg"] && [substring isNotEqualTo:@".png"]) { return NO; } NSBundle *bundle = [NSBundle mainBundle]; NSString *path = bundle.bundlePath; path = [NSString stringWithFormat:@"%@/Contents/Resources/%@",path,_name]; NSImage *image = [[NSImage alloc] initWithContentsOfFile:path]; if (image == nil) { return NO; } NSRect bigRect; bigRect.origin = NSZeroPoint; bigRect.size = [image size]; [image lockFocus]; NSBitmapImageRep *upsideDown = [[NSBitmapImageRep alloc] initWithFocusedViewRect: bigRect]; [image unlockFocus]; // since OpenGL draws images upside down, we need to flip this image along // the y axis. I know a cool trick for doing this when texture mapping, // but I want something a little more general for now NSInteger bytesPerRow = [upsideDown bytesPerRow]; NSInteger bitsPerPixel = [upsideDown bitsPerPixel]; BOOL hasAlpha = [upsideDown hasAlpha]; NSInteger height = (int)bigRect.size.height; NSBitmapImageRep *_imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:(int)bigRect.size.width pixelsHigh:height bitsPerSample:[upsideDown bitsPerSample] samplesPerPixel:[upsideDown samplesPerPixel] hasAlpha:hasAlpha isPlanar:[upsideDown isPlanar] colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:bytesPerRow bitsPerPixel:bitsPerPixel]; unsigned char *from = [upsideDown bitmapData]; unsigned char *to = [_imageRep bitmapData]; for (int i = 0; i < height; i++) { bcopy((from + bytesPerRow + i), (to + bytesPerRow + (height - i - 1)), bytesPerRow); } GLenum format; format = hasAlpha ? GL_RGBA : GL_RGB; GLuint _tex; glGenTextures(1, &_tex); glBindTexture(GL_TEXTURE_2D, _tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)bytesPerRow / (bitsPerPixel >> 3)); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bigRect.size.width, bigRect.size.height, 0, format, GL_UNSIGNED_BYTE, from); [image release]; [upsideDown release]; [_imageRep release]; texturename[texturecount] = _name; [texturename[texturecount] retain]; int *temp = malloc((texturecount*sizeof(int))+1*sizeof(int)); for (int count = 0; count<texturecount; count++) { temp[count] = textureid[count]; } free(textureid); textureid = temp; textureid[texturecount] = _tex; texturecount ++; return YES; }   It's a whole lot of Code I copied it from another thread. It worked fine for my old app.   I have a class called TextureLoader which keeps all the information like texture name and the corresponding opengl name as an int. When a texture is asked for it will beloaded by the TextureLoader -(GLuint)textureidforTexturename:(NSString *)_name { for (int x = 0; x < texturecount; x++) { if ([texturename[x] isEqualToString:_name]) { return textureid[x]; } } if ([self loadTexture:_name]) { return textureid[texturecount-1]; } else { printf("not found\n"); return 0; } }   So what I do at the start of my app is create a window and inside a NSOpenGLView. when I just clear the buffer and draw on the right side of my screen it comes up yellow and red for example. So this works.   Tanks a lot :)
  6. Hi together,   I am currently facing an issue running my OpenGL App.   First i startet to use the GLUT functions to create my rendering Context (Window). Inside the App I initialized textures using glGenTexture and glTexImage2D and so on.   Now I switched to NSOpenGLView and NSOpenGLPixelFormat. I copied the whole Code that worked fine for me in my GLUT App but I am getting a white window.   When I take out my rendering and just clear the Color_Buffer to yellow I get a yellow window (as expected).   Even if I only draw on the right half of the screen it comes up white on the whole screen.   Now to my implementation :)   Inside the NSOpenglView drawrect function i call:   [[self openGLContext] clearDrawable]; [[self openGLContext] setView:self]; [[self openGLContext] makeCurrentContext]; NSRect backingBounds = [self convertRectToBacking:[self bounds]]; GLsizei backingPixelWidth = (GLsizei)(backingBounds.size.width), backingPixelHeight = (GLsizei)(backingBounds.size.height); glViewport(0, 0, backingPixelWidth, backingPixelHeight); glEnable(GL_TEXTURE_2D); glClearColor(1, 1, 0, 0); glClear(GL_COLOR_BUFFER_BIT); [interface draw]; [[self openGLContext] flushBuffer]; [NSOpenGLContext clearCurrentContext];   I create a normal window with an OpenGLContext. Do I have to initiate my OpenGL Stuff anywhere special? Stuff like glEnable(GL_Texture_2D) ? I hope someone of you already had this issue.   I appreciate any help :)
  7. Ok now I got it fixed!   after glutwarppointer is called the mouse is suppressed for a short amount of time. This also occurred using the CGWarpMouseCursorPosition function.   So these are not to be used in a game.   Instead use CGEventRef event = CGEventCreateMouseEvent(Nil, kCGEventMouseMoved, CGPointMake(windowwidth/2, windowheight/2), kCGMouseButtonLeft); CGEventPost(kCGHIDEventTap, event);   This moves the mouse to the middle without creating any interference.
  8. Hi Danicco,   thanks a lot for your reply.   Trying to keep the mouse in the center of the screen seemed to be the best solution to me. But the camera wont move fluently anymore because the function glutwarppointer is called every time the mouse is moved.   But I got another idea after 3 months of thinking   Now the mouse jumps back to the center of the screen every time it reaches the edges.   My solution is as follows:   I got a class that controls the OpenGL device functions. The class is called inside the glut function and given the parameters. Heres the function prototype. -(void)mousepassivenotion:(int)_x y:(int)_y;     Inside the class I save the old point of the mouse within 2 int variables. When I move the mouse the old and new values are given to my camera class. -(void)movetomousemotionx:(int)_x y:(int)_y xold:(int)_xold yold:(int)_yold { if (_xold-_x < 500) { NSLog(@"%d %d : %d %d",_x, _x, _xold, _yold); if (_xold > _x) { [self performSelectorOnMainThread:@selector(surroundviewpoint:) withObject:[NSNumber numberWithInt:(_xold-_x) /mousesensivity] waitUntilDone:YES]; } else if (_x > _xold) { [self performSelectorOnMainThread:@selector(surroundviewpoint:) withObject:[NSNumber numberWithInt:(_xold-_x) /mousesensivity] waitUntilDone:YES]; } if (_yold > _y) { [self performSelectorOnMainThread:@selector(overviewviewpoint:) withObject:[NSNumber numberWithInt:(_y-_yold) /mousesensivity] waitUntilDone:YES]; } else if (_yold < _y) { [self performSelectorOnMainThread:@selector(overviewviewpoint:) withObject:[NSNumber numberWithInt:(_y-_yold) /mousesensivity] waitUntilDone:YES]; } } }      In the first line i check if the difference between old and new is bigger than 500 in the horizontal(x) axis. I may add the y-axis too. This is because after glutwarppointer the function glutpassivemotion is called and the difference is bigger than 500 and is ignored. Then I call my surroungviewpoint function with the rotation radius. Heres my surroundviewpoint function. -(void)surroundviewpoint:(NSNumber *)_rotation { glPushMatrix(); glLoadMatrixd(Systemmatrix); glTranslated(0, 0, -distance); glRotated(-topdown, 1, 0, 0); glRotated(_rotation.floatValue, 0, 1, 0); glRotated(topdown, 1, 0, 0); glTranslated(0, 0, distance); glGetDoublev(GL_MODELVIEW_MATRIX, Systemmatrix); glPopMatrix(); }     So now the mouse is pointing at the center of the screen. There is only one more point. When you turn the camera around and reach the edge you can notice for a second that the mouse is not moving. So I tried calling my camera function manually after calling glutwarppointer and parameterize as the new point the center and as the old point the center minus the original difference. int dif[2]; dif[0] = _x-x; //x is the old value dif[1] = _y-y; //y is the old value x = windowwidth/2-dif[0]; y = windowheight/2-dif[1]; glutWarpPointer(windowwidth, windowheight); [camera movetomousemotionx:x+dif[0] y:y+dif[1] xold:x yold:y]; But still you can notice it.   Sorry for that much code but I wanted others to be able to solve the problem reading the post.
  9. Hi together,   sorry if I made the topic wrong, but I'm new to this forum.   I'm currently writing on a little game which is supposed to be a third person game. So I created a camera to rotate around the character. So good so far. My issue is that the mouse reaches the corners of my display and the camera stops rotating.   I tried working with glutwarppointer to warp my pointer back to the center of the screen. But it triggers my camera to rotate back, because the glutpassivemousefunc is called.   I tried using a BOOL to keed the camera moving just when its false and tried   mouselock = true; glutwarppointer(windowwidth/2, window height/2); mouselock = false;   but it still triggers the camera.  does anyone got any ideas?   Just so you know I'm working with Mac OS X Mountainlion and Xcode.   Any help is very much appreceated.