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


  • Content count

  • Joined

  • Last visited

Community Reputation

288 Neutral

About Tallkotten

  • Rank
  1. Ok, thanks!   I'm going to look at how some other people do it and ultimately decide on a way to go. But yours sound solid.
  2. Ok, so you are saying: "Store a static VBO in the memory with some coordinates and texture data and then use glTranslate to move it on the screen"?
  3. I might be talking in my sleep since i know very little on the VBO topic. This is my current code for drawing something to the screen:   float texLeft = (float)clip.x / width; float texRight = (float)( clip.x + clip.w ) / width; float texTop = (float)clip.y / height; float texBottom = (float)( clip.y + clip.h ) / height; glPushMatrix(); glTranslatef(0, 0, 0); glScalef(scale,scale,1); //set color glColor4f(R, G, B, A); glBegin( GL_QUADS ); glTexCoord2f( texLeft, texTop ); glVertex2f( x, y ); glTexCoord2f( texRight, texTop ); glVertex2f( x+w, y ); glTexCoord2f( texRight, texBottom ); glVertex2f( x+w, y+h ); glTexCoord2f( texLeft, texBottom ); glVertex2f( x, y+h ); glEnd(); glPopMatrix(); Each call i update the position and the texture-coords.   From the tutorials i've read on VBO's you have to do the same: (a straight copy-paste from the tutorials) GLfloat vertices_position[8] = { x, y, x+w, y, x+w, y+h, x, y+h, }; GLfloat texture_coord[8] = { texLeft, texTop, texRight, texTop, texRight, texBottom, texLeft, texBottom, }; // Allocate space for vertex positions and texture coordinates glBindBuffer(GL_ARRAY_BUFFER , vbo); glBufferData(GL_ARRAY_BUFFER , sizeof(vertices_position) + sizeof(texture_coord), NULL, GL_STATIC_DRAW); // Transfer the vertex positions: glBufferSubData(GL_ARRAY_BUFFER , 0, sizeof(vertices_position), vertices_position); // Transfer the texture coordinates: glBufferSubData(GL_ARRAY_BUFFER , sizeof(vertices_position), sizeof(texture_coord), texture_coord); This wouldn't in any way decrease the performance? If it will, how else do i define position and texture-coords when using a VBO?   Thank you for taking your time, i really appreciate it!
  4. So you are suggesting that i check if the entity has changed location and if it has i'll update the vertices for location? And same goes with the texture. That's all i ever need to update, drawing location and texture-coords.   How much performance are we talking about? Lower than using immediate mode?
  5.   But each enemy hold it's own copy of it? Right?     I understanding right now is that i create a VBO when a (lets say) enemy is created. I then store this with the enemy until it's destroyed (how do i unload a VBO?).   You're saying that i should't update the data, is it ok to update the texture and vertex buffer? That shouldn't be a problem right? Because i need to be able to do that every frame.
  6. Hi,   I've spent the day trying to understand the use of VBO since i want to boost the FPS in my game.   However i'm having some trouble understanding the life-scope of the VBO and how to properly use it. Every sample code and tutorial i've found has shown a single static scene to render and I've got a pretty complex file architecture in my game.    --Revelation?--   So this literally just occurred to me. If a VBO behaves kind of like a texture (you generate and bind it) would i be correct to say that each entity in the game should hold it's own VBO?   For example; my player character would create a VBO at runtime and then call a render-function which fills it with data and renders it?    The render code would take the VBO, texture and some placement information. Then my normal code would run (bind the texture, create a clip for the 2D image) then I create a new vertex buffer and a new texture buffer and bind them. Lastly the VBO should be bound and rendered.   A NPC would have it's own VBO just like the player does. --   Am i thinking right? And even if i am, could you be so kind to explain the scope and use of a VBO? Like i said, all the examples just handled a static scene to render so i'm having trouble understanding how to update it.   My game is in 2D and currently renders everything as quads or circles (all collision is done with rectangles). The size of an object is never changed after creation. When an object animates it'll change the location of the clip within it's loaded imagesheet. So the image itself will rarely change.   I'm kind of tired at the moment so i hope i made myself clear enough for you to understand.   Looking forward to some answer, thanks in advance!
  7.   Hi and thanks for the help man!   I actually have a pretty sophisticated image loader that i've written myself but i only takes SDL_Surface's so i only have to make it work with the GL texture instead.   I plan to:  1.open a image in SDL 2.convert it to a texture and save the proportions 3.maybe make a class that keeps track of if the image is in use (like a smart pointer) and if it isnt dispose of it 4.release the SDL_Surface and save all of the other stuff for later use
  8. Every image loading library provides a means to query the width and height of an image. And if you decide one day to implement your own loader, all of the commonly used image formats store width/height data in the file header (as should you if you ever create your own image file format).   I'm thinking of saving the image size from the SDL_Surface when i load an image. Then i link the size to a texture or something,    Thanks for the tip, i'll have to look into that when i get home!
  9. Thank you both for the answers. I suspected that was the FPS theif but like i said i am only trying out this new way atm.     I use SDL for other stuff like keyboard detection as well, so i might stick around with it.    ---   Thanks very much you both! I'll try altering my code a bit when i get home and see if i see any performance boost
  10. Hi!   I took it upon myself to finally start migrating from SDL to OpenGl in my project today. So far I've managed to (in isolated code) translate an SDL_Surface to an OpenGl texture which i then use to apply on polygons.   In my previous rendering method i used a lot of clips. Meaning I've got one image with maybe 3-5 images on it which i then clip before i render to get the desired image to show. I've managed to translate this over to OpenGl as well but it takes a bit of work and i need to know the loaded image dimensions before i do.   Just to clarify how the rendering process works now, so you get a better scope of my problem:   1. Loads image to an SDL_Surface 2. Saves it to an array 3. Something fetches the image memory location from the array 4. Converts the SDL_Surface to a OpenGl texture 5. Clips the texture 6. Renders it to QUADS 7. Destroys the texture   My Convert code is basically the same as this one here: http://content.gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL   Question time:    1. I've noticed a sudden drop of FPS since the tryout change (only the tiles are being rendered at the moment since haven't made it global yet). The drop if from 400+ FPS to around 60 FPS after i use glDeleteTextures(); on the texture I've just drawn. Why is this? I suspect it's the conversion that drains the fps.   2. If it is the conversion that drains the FPS, then it is smarter to convert the image once just as it loads and save the texture in the array instead of the surface? Sounds like it...   3. Is there any reason for me to save the image as a SDL_Surface instead of loading it from OpenGL directly? Can i do that?   4. If there is no reason at all for me to involve SDL in the rendering process then how to i keep track of the loaded image width and height? Right now i use surface->w/surface->h. Is there similar ways in OpenGl?   I think that's all! Thanks for your time, i really appreciate answers!   // Tallkotten    
  11. [quote name='SiCrane' timestamp='1352487659' post='4999386'] No, it requires a [i]const[/i] char *, which you can from a std::string with the .c_str() member function. [/quote] Well... f*ck me... I've used that to some extent but now i just feel silly... Is it even worth going back and using that instead of my newly implemented system?
  12. [quote name='Karsten_' timestamp='1352477385' post='4999333'] [quote name='Tallkotten' timestamp='1352366168' post='4998799'] How do i know if i have to do that or not? And what difference does it make? [/quote] If you get a compiler error stating that std::tr1::shared_ptr does not exist, then you will need to include the tr1 versions of the header. If you are using the CodeBlocks IDE, that probably means you are using GCC/G++ as your compiler, so it is quite likely you will need to include them. [/quote] Ok thanks! Yes i am using GCC/G++ [quote name='Álvaro' timestamp='1352486514' post='4999377'] So why are you using `new' and `delete' for things like a "char * array"? You probably should be using std::vector or std::string instead of using new to allocate arrays. It's much harder to have a memory leak if you don't use `new'. [/quote] Well that is old code and when i looked up how to do it that was one of the only ways. Also TTF_RenderText_Solid requires a char*. http://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf_43.html
  13. I just found out where one of the leaks were located... In one of my functions where i turn a string to a char* array i never used delete after new... Thanks everyone! Hopefully i wont get stuck on the rest of the code (that i have yet to check for leaks ).
  14. [quote name='Karsten_' timestamp='1352315450' post='4998532'] Hi, if you are using C++, perhaps you can use a smart pointer for this (These two lines looks ugly as sin, but provides memory safety I have yet to see with any other language / platform)... [code] std::tr1::shared_ptr<SDL_Surface> surface; surface.reset(SDL_LoadImage(imageFileName.c_str()), std::tr1::bind(SDL_FreeSurface, std::tr1::placeholders::_1)); // Now you can do whatever and RAII will take care of the memory management. [/code] Remember: You must set the deleter to be SDL_FreeSurface, because otherwise (and in std::auto_ptr) the c++ [b]delete[/b] will just be called, which will cause undefined behaviour with things not created via [b]new[/b]. I generally do this with OpenGL textures but there is no reason this wont work for SDL textures. [/quote] Yes that is one option i might go with later on when i add the manager system. Like i described earlier i dont really have to unload images at the moment since i have so few loaded. But i'll definitely consider it! [quote name='Karsten_' timestamp='1352315450' post='4998532'] If you are not using the very latest compiler you will need to include the technical report 1 versions of memory and functional. #include <tr1/functional> #include <tr1/memory> [/quote] How do i know if i have to do that or not? And what difference does it make? I am running codeblocks
  15. [quote name='ultramailman' timestamp='1352247935' post='4998277'] There aren't any references in your code, only pointers D: [/quote] Yeah, my mind were some place else. [quote name='ultramailman' timestamp='1352247935' post='4998277'] I think freeing surfaces should only be done when you are absolutely sure it will never be used again. Are you really going to use this example_image.png once? If you are sure, then the correct way to do it is to use the complement of imageLoader.loadImg [/quote] This is true and i plan on adding this function. But i am planning on writing a system which takes care of what is in use and what's not so i am waiting with this. There really aren't many images now to load either so the unload functions isn't needed at the moment. Thanks for your reply!