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

Chaosenemy

Members
  • Content count

    39
  • Joined

  • Last visited

Community Reputation

152 Neutral

About Chaosenemy

  • Rank
    Member
  1. Hey guys, I would greatly appreciate any help you can offer me. I'm writing a big Entity/Sprite/Model/Rendering system and I am having the hardest time understanding how to use matrices properly. I guess my main questions is: how can I use only a single matrix per object to define where it is located, how it is rotated, and how it is scaled? Since matrix multiplication is cumulative, I have come to the conclusion that I have no choice but to store a (Vector3D) position, (Quaternion) rotation, and (Vector3D) scale, and then re-calculate the matrix (for rendering) each frame from these values. This seems.... cumbersome and ugly. Is there some way to simply have a Matrix for each object and modify it directly when I call SetPosition(), RotateX(), etc.? I'm not that great with Matrix manipulation, so maybe this is no-brainer, but I can't seem to find any direct answer to this no matter where I search.   Side note: This isn't meant to sound rude at all, but please don't suggest that I use SDL or some matrix library. I get that a lot, but I want to make this myself. I just need some help in the right direction. Believe me, I've tried learning this myself, but I learn by example, so reading books explaining matrices just doesn't make it click for me.   Thanks in advance!
  2. I'm trying to get a very simple vertex shader running but nothing seems to be happening. The shader loads, compiles, and links successfully - no errors. When I try to use it however, nothing renders. Here is my shader code: [CODE] void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } [/CODE] As far as I know, the above code should just render the vertex like usual, correct? Here is my drawing code in the application itself: [CODE] glUseProgram(programObject); glBegin(GL_QUADS); glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(0.0f, -1.0f, -1.0f); glVertex3f(0.0f, -1.0f, 1.0f); glVertex3f(0.0f, 1.0f, 1.0f); glVertex3f(0.0f, 1.0f, -1.0f); glEnd(); glUseProgram(0); [/CODE] If I comment out 'glUseProgram(programObject)' the quad renders just fine. Otherwise, nothing is rendered at all from what I can see anyways. I know this is simple but I swear I've Googled the hell out of it and can't figure out what I'm doing wrong. Any help would be much appreciated. Thanks. EDIT: Figured it out. Apparently if you don't specify a color in the shader source, it draws the vertex black. So I wasn't seeing it on my black background. D'oh!
  3. [quote name='Seaßourne' timestamp='1295356923' post='4760692'] [quote name='Chaosenemy' timestamp='1295236564' post='4759921'] [font="Arial,"]For the Windows version of my game engine, I'm using WM_INPUT and registering the mouse device directly to get the most precise movements. Anyone know how I would go about doing this in X11 (for Linux)? I've searched Google about as thoroughly as I can, but finding good documentation for X11 is next to impossible.[/font] [/quote] Well in general, no one ever accesses pure X11 for handling this stuff as there are gui libraries out there for this. Have you thought about using a cross OS gui library rather than rolling your own and just wasting time doing that? [/quote] I've always wanted to make a game engine from scratch (well as close to scratch as possible), so I'd rather not mess with anything but the required APIs/libraries. And anyways, I'm getting very close to being done with the X11 stuff, so I've already come too far at this point to switch to something else. [quote name='Bregma' timestamp='1295361682' post='4760714'] [quote name='Chaosenemy' timestamp='1295330174' post='4760571'] Thanks, that pointed me in the right direction I think, and I've found a few samples. There is one issue though: [url="http://www.spinics.net/lists/xorg/msg50675.html"]Link[/url]. That guy's post is the only thing I can find on the internet about this issue, and it hasn't been resolved =\ Can you think of any way to get around that? I was thinking something like sending a certain X event before calling XWarpPointer() and then in my event handler, when I get to the event I sent, ignore the next event, which would be the one sent by XWarpPointer(). Not sure if I'm explaining that right, but does it sound plausible?[/quote] It sounds like you're jumping through hoops to reinvent pointer grabbing. You may dislike SDL, but if you're keen on reinventing what it does you might want to look at how it does it. I think what you really want to do is read up on XGrabPointer() and it's wife/sister XUngrabPointer(). They're the preferred way to do X11 active pointer grabbing. [/quote] My big issue with grabbing the pointer is that it breaks external keyboard shortcuts like Alt+Tab. Also if I'm not careful enough about error checking and a fatal bug occurs, the user could end up trapped and have to restart their machine. I dunno, XGrabPointer just bothers me. Anyways though, the solution I proposed in my last post seems to have worked, so I think I've got it all figured out. Thanks again for pointing me to the XInput extension.
  4. [quote name='Bregma' timestamp='1295271055' post='4760077'] Input under x.org (the most common X11 implementation on Linux) is performed through the XInput module, or preferably the XInput2 module. You can google for that: it's documented on freedesktop.org and in the header files. If you want the "raw" input, you need to bypass the X11 stack and connect to the appropriate /dev/input/event pseudofile directly. That's certainly not recommended.[/quote] Thanks, that pointed me in the right direction I think, and I've found a few samples. There is one issue though: [url="http://www.spinics.net/lists/xorg/msg50675.html"]Link[/url]. That guy's post is the only thing I can find on the internet about this issue, and it hasn't been resolved =\ Can you think of any way to get around that? I was thinking something like sending a certain X event before calling XWarpPointer() and then in my event handler, when I get to the event I sent, ignore the next event, which would be the one sent by XWarpPointer(). Not sure if I'm explaining that right, but does it sound plausible? [quote]Any reason why you want to talk X11 directly instead of using a portable wrapper like SDL (or equivalent)?[/quote] SDL murdered my parents.
  5. [font="Arial,"]For the Windows version of my game engine, I'm using WM_INPUT and registering the mouse device directly to get the most precise movements. Anyone know how I would go about doing this in X11 (for Linux)? I've searched Google about as thoroughly as I can, but finding good documentation for X11 is next to impossible.[/font]
  6. Hey guys, sorry it has been a few days. Been a little busy and I've been rewriting some of my code. I think I've got it all sorted out now. The Texture constructor and destructor no longer depend on the existence of the Texture* vector in the Graphics class, so the problem shouldn't happen anymore. I also modified my audio component to follow this specification, to avoid any future problems with this design. Thanks for all the help everyone.
  7. Quote:There are two usual causes -- one is double-freeing. The other is writing to a pointer after freeing. You are almost certainly doing one or the other; 99 times out of 100 that's what's doing this. I can 100% assure you it's not being double-free'd. As for writing to a pointer after freeing... read below. Quote:Install valgrind, run your program through valgrind. (You just go "valgrind ./myprogram.exe"). Valgrind will hook into your program and generate better debugging info. CAUTION: Valgrind will reduce performance, so if you can shrink this to a small test case that's better. Valgrind will (for example) find you not only the duplicated free operation but also the one it's duplicated, or both parts of the free/write pair and then tell you about them. Valgrind seemed to point to the issue being in the destruction of a certain vector. This vector held a list of IDs for textures that should be (possibly) deleted in the next Update(). During Texture's destructor, a function is called to queue the Texture's OpenGL textureId for deletion (in the event that textureId is not being used in another Texture object). Valgrind tells me that the problem lies in where I assign the textureId to the "deletion" vector. Apparently the vector has been destroyed already at that point? I've "fixed" the problem by making sure no Textures can be constructed or destructed before Graphics::Initialize() or after Graphics::CleanUp(). Yeah, this fixed it, but I still don't really understand why it didn't work in the first place. AFAIK, objects in C++ are destroyed in the opposite order that they are created, so if I am able to call on a function/variable during Texture construction, shouldn't I be able to call on it during destruction as well? :confused:
  8. Okay, I downloaded the Eclipse IDE for debugging purposes. I've got some new info. First of all, stepping through my last Texture object's destructor, I see that the original line of code causing the problem actually executes just fine, as well as the rest of the code in my destructor. Once I get to the end of the destructor, the debugger goes into "exit.c" which it can't find the source code for apparently. I have no choice here but to resume execution. Once I do, the debugger haults at "__kernel_vsyscall()" which it also has no source for. So what exactly do I need to do here?... I'm guessing I need to get the source code for these files/functions that get called at the exit so I can step through them, but how/where do I get them? Also I enabled the Glibc debugs you mentioned above but I'm not sure it made a difference. I'm assuming the source code I'm missing is the reason why?
  9. Oops, sorry about the confusion there. Don't know what I was thinking heh. Quote:Is _id a valid *index* in to the textures vector? In other words, put assert(_id < textures.size()) at the start of the function. Yes, it is valid. When a Texture object is constructed, it is given an available ID from the Graphics::textures vector. The function that does this, keeps within the bounds of textures.size() and at the moment the size of the vector is constant (just for now). Also the blatant check you suggested above does indeed confirm that the index is valid. Quote:I'm not sure what you mean by a "valid" pointer, anyway (Not null? Not dangling? not previously deleted? Pointing to an object on the heap? ...). So specifically, does your class have a copy constructor, assignment operator and destructor defined appropriately? Or have you made sure it's not copyable (as per boost::noncopyable, for example)? By valid I mean the pointer has a value. My definition of invalid would be NULL or undeclared. When the ID is assigned to a Texture object, the Graphics class searches through the Texture* vector to find a NULL element. That element is the ID for the newly declared Texture. And yes, the copy constructor, assignment operator, and destructor should be written correctly... I based this whole design on how I did my audio class with OpenAL, managing buffer IDs the same way I do with texture IDs. The Sound objects have very very similar constructors/destructors/etc to the Texture class and don't seem to cause any trouble. Quote:To get you started, run gdb. Do "help load", "help break", "help step", "help start" and "help backtrace". That should get you quite far. My suggestions for _GLIBCXX_DEBUG and _GLIBCXX_DEBUG_PEDANTIC will help you validate your STL usage (out-of-bounds errors for example). Will do. Thank you. Quote:As your object is in static storage, am I to assume that you do *not* in fact have a valid GL context? If so, this may be causing problems (though in truth I suspect something else). Well the thing is, the ID I'm working with here is actually unrelated to OpenGL. My Texture class has a textureId and a graphicsId member. The textureId refers to the OpenGL texture IDs, the graphicsId refers to the Texture class's ID in my Graphics class (this is the one causing the issue). So basically, whether or not OpenGL still has a context, this particular ID should be unaffected. This ID's only purpose is to tell my Graphics class that the Texture object exists. Again sorry about the confusion; it's been a long day =\
  10. Quick update: I can set texture[_id] equal to some other pointer and it works. Only setting it to NULL gives me the error. I can also set it to NULL and then set it to something else and not error. But if I set it to NULL last, it errors. Wtf?! It's like my game engine has grown sentient and doesn't want to work O.o
  11. Quote:Original post by Palidine It looks like, most likely, the instance of your Graphics class has been destructed before this method is invoked or the variable that's pointing to it has been set to NULL. Make sure that you are calling DeleteTexture before you delete your Graphics instance, and otherwise make sure that the pointer to Graphics is valid. Also what language are you using. Just setting a pointer to NULL does not free up memory (unless these are smart pointers of some kind?) -me I'm not setting it to NULL to free it; it is to make the pointer available for for a different texture. Basically my Graphics class checks each initialized Texture object against each OpenGL texture ID every once in a while to see if there is an unused OpenGL texture floating around, and if so, calls glDeleteTextures(). Also, this portion of the Graphics class is independent of OpenGL and is a static class, so it is not instanced. And as I said, I have tried checking the validity of the pointer before setting it to NULL and it checks out fine. Quote:Original post by the_edd Have you checked that you aren't deleting something twice? Perhaps you've neglected to follow the rule of three somewhere? Do you assert that _id is valid (within range)? Have you tried running the code with all debugging features enabled e.g. _GLIBCXX_DEBUG and _GLIBCXX_DEBUG_PEDANTIC? Can you confirm that you aren't calling a virtual function in a destructor? Do you still have a valid GL context when the function is being called? And is that really the entire function? As Palidine says, you need to call glDeleteTextures to really release the associated texture object. Have you tried running the code in a debugger? What is the first point where the program's behaviour diverges from that which is expected? 1. As I said in my OP, I can check the verify the validity of the pointer right before NULLifying it. Still errors at the NULL assignment. 2. No I haven't... erm, I am actually programming with Gedit and G++ in a Terminal window... don't really know much about runtime debugging in Linux (and of course glibc does not exist in Windows). I will look into it though. 3. Yes, it is not virtual. 4. Read above. Thanks for the suggestions so far guys. I will check into runtime debugging under Linux and check back for any further suggestions.
  12. Getting a weird crash here. My game engine compiles fine and runs fine, until I exit, where I get a segmentation fault, or more specifically, this: *** glibc detected *** ./bin/engine: corrupted double-linked list: 0x092f8df8 *** *** glibc detected *** ./bin/engine: corrupted double-linked list: 0x092f9eb8 *** Segmentation fault This only happens on Linux. Windows doesn't seem to complain about any of this. The piece of code where it happens is here: void Graphics::DeleteTexture(GLuint _id) { textures[_id] = NULL; // <------- } This is a function that gets called in my Texture class's destructor. "textures" is a vector of Texture pointers in my Graphics class that keeps track of all Texture objects declared, for purposes of freeing up memory when texture data goes unused and falls into limbo. This function always succeeds during normal execution, but fails when the program is closing and is destructing all of my remaining Texture objects. I know the first thing you will ask is that I post more code, but seriously, nothing else affects this line of code. My game engine is not multi-threaded (yet) and if I comment out this piece of code, everything works fine (except of course unused texture data remains in memory!). I have tried multiple things with this one line of code, including checking that the pointer is valid before setting it to NULL, and using "cout" to show the value of the pointer before and after the operation (first value always shows as valid, followed by a 0 as expected, but then the error shows afterwards). Also, the above error only occurs when one Texture object is being destroyed at exit. If there is more than one, I get this instead: *** glibc detected *** ./bin/engine: free(): corrupted unsorted chunks: 0x09151000 *** Segmentation fault Anyone have a clue what's happening here?
  13. Thanks for the quick answer. I suppose I understand somewhat, but for the time being I guess I'm going to stick with my method. As it is, my current project only takes about 10 seconds to compile anyways.
  14. In pretty much any source package I've downloaded, there is a Makefile. I've looked at a few and they're big, bloated, and ugly to look at. I couldn't imagine writing one. Is there some advantage to them over compiling straight from the command line? The way I do it is this: My project directory has a "bin" and "src" folder and a compile script for each operating system the source code supports. The compile script for Linux, for instance, would be something like this: g++ -o ./bin/executable -lLibrary1 -lLibrary2 `ls ./src/*.cpp` That simple 1-line script will compile every .cpp in the src folder with the specified libraries and spit out the executable into the bin folder. I don't really understand how a Makefile would be needed. Any insight?
  15. Quote:Original post by bubu LV Just create new project, drag the source files, add needed preprocessor defines/includes. And press compile. This should be not very difficult to do. I dragged the source files from the IL-src folder into a new project (C++ Dynamic Library) and when I tried to compile I got 1,905 errors. The first few complained about 'il.h' missing, so I looked for that and added it to the project as well, but its still telling me it can't find it. Also what preprocessor defines am I supposed to add? Sorry to be a noob, but I really don't know what I'm doing here. I'm new to Mac and Xcode and also I typically compile from the command line and use lightweight text editors to write code, so I don't know much about IDEs in general.