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

PAndersson

Members
  • Content count

    67
  • Joined

  • Last visited

Community Reputation

394 Neutral

About PAndersson

  • Rank
    Member
  1. I went with this solution as it minimizes locking and ironically, the risk of deadlocks. The source of my issue is that openGL requires every task for a given openGL context to be performed in the same thread, this leads to tasks depending on other tasks for completion. Sometimes these tasks may end up in the same task queue and in the wrong order. The solution I have now simply finds out if a task waits for another in the same queue, and lets the one that is being waited for skip ahead.   Had the requirement to do certain tasks in a given thread not been there, task inter-dependencies would have disappeared and this problem would not be there.
  2. I have finalized the intiial threading model for a program I'm working on, and due to the nature of its enviroment I have to allow deadlocks to occur or loose much of the benift from multithreading. Fortunatly, it also enables easy detection and resolution of deadlocks without rolling anything back; except for one special case though the programmer has to go out of his way to make that one possible and those can still easily be detected though not resolved.   Anyway, I do not think there are any more cases where deadlocking can occur but I'm not 100% certain either. So I'm wondering if there are any good tools or methods for proving that deadlocking is impossible (other than that onbe case I mentioned) in a system of unknown size? The only method I'm aware of is petri nets, though I do not know if that method can be adapted to work with a model of unknown size or not.
  3.   Wont really work well at all for the game I'm designing. As it is a space-strategy game with a fair bit of ground action, and as the gameplay is planned showing loading screens at any time except game startup would very much interupt the flow of the game. The planets themselves need a fair bit of detail due to the zoom allowed, enough that I cannot fit all of them inte video memory except on high-end vide cards. Fitting them all into system RAM is both trivial and required, as they affect gameplay as well as their apperance.   Having low-resolution versions of them, for display purposes, makes it possible to view them all at a high level of zoom. Selectily loading them into VRAM as the player zooms in on a region is fairly straighforward and any latency from that can be hidden. It is rather the sudden unanticipated need for new data (ie, some event suddenly creates a new planet somewhere and it's height and terrainmap needs to be generated with an algorithm) that would prompt the "Loading" text, and given that there will be very few instances where the game cannot predict what data it will need ahead of time the player will only very rarely see the "Loading" text at all.   The regular textures that represent plain images will be few in number and most fairly low in resolution.
  4. I should add that a lot of the data is algorithimcally generated at runtime, in some cases the parameters used by the fairly time-consuming algorithm is not known until the last moment.
  5. So I'm working on my first hobby game where I have to implement a proper asset loading system, in my previous projects I have had no problem fitting everything in memory at once. In this, I have estimated that VRAM will most likely be a limiting factor that makes that approach impossible. Though fitting it all in system RAM should not be an issue.   Now, I do not need every art asset loaded at once of course, and determining and limiting what needs to be loaded and what does not is not really what I wonder here. Instead I'm unsure on how to go about designing a proper asset loading system.   While I try to eliminate loading screens, beyond an initial, altogether by being smart about what is loaded and what is not the game still nicely needs to handle the sudden need for an unloaded art asset. Perhaps an object that requires it is suddenly spawned by an in-game event. The way I would like to handle this from the users perspective is to simply pause the game until it is loaded and pop up a "Loading" text on the screen.   I have two possible implementations in mind for this:   1. Finish executing the current frame, render the game state with the "Loading" text and do not do another update until the asset(s) are done loading asynchoniously. This does pose the limitation that any assets cannot be used in the frame they are requested as they may not have loaded yet, which can be an issue as the heaviest of them are both used for graphical and gameplay data.   2. Have the game-loop execute in a seperate thread, and pause that thread whenever an unloaded asset is used. The seperate rendering thread needs to handle this correctly (note that I already have a seperate rendering thread). This should pose few issues, but feels overly complicated for such a task.   So how do games usually do this?   Finally, I'm wondering if it is a good idea to have each State (ie startup menu, game running and the like) provide a seperate "loading state" that they enter when they want to show the user that they are loading something? It feels like it should not be their concern, but each state may need to show different loading screens and at least one of the different "loading screens" will need graphical information for the current game state.  
  6. Always go for clear and readable code first, and only do micro-optimizations when you know for certain you need it, preferibly when your profiler tells you that it is indeed a performance bottleneck.
  7. [quote name='game of thought' timestamp='1355611428' post='5011063'] Also, how do i motivate myself to program every day? [/quote] Work on something that intrests you would be my suggestion, it has worked well for me at least.
  8. OpenGL

    Finally got some more time to look into the issue and managed to find and solve the problem. The setTexture method should look like this: [source lang="cpp"] void ShaderProgram::setTexture(String variableName, int samplerNo, ICubeMap* texture) { assert(this->programId == this->activeProgram); assert(samplerNo >= 0); //Prepere texture glCheckedCall( glActiveTexture(GL_TEXTURE0 + samplerNo) ); glCheckedCall( glEnable(GL_TEXTURE_CUBE_MAP) ); glCheckedCall( glBindTexture(GL_TEXTURE_CUBE_MAP, texture->getOpenGLId()) ); GLint loc = glCheckedCall( glGetUniformLocation(this->programId, variableName.getStringUtf8()) ); if (loc < 0) syslog.Error(String("Failed to find uniform cubemap name \"") + variableName + "\" in program " + this->getProgramID()); glCheckedCall( glUniform1i(loc, samplerNo) ); }[/source] As in my previous post, I bound the texture before activating it thus effectivly messing with other texture units. Simply swapping the order in which the function calls are made solved everything. Thank you for your help, and this just cements my sentiment that state-based interfaces are evil
  9. OpenGL

    [quote name='Brother Bob' timestamp='1353757833' post='5003718'] So if you use that exact code and just comment out one of the two texture samplers, then it stops working? Reduce your application to an absolute minimum and show the complete code. [/quote] All right, have not had any more success with this (to be fair, not a lot of time to work on it either) so I will see what I can do. The application currently uses A LOT of infrastructure and getting rid of that will be a major effort...
  10. OpenGL

    If I write this shader: [source lang="cpp"]uniform samplerCube cubeTest; uniform samplerCube terrainNoiseTexture; void main(void) { fragmentColour.rbg = texture(terrainNoiseTexture, vec3(rawNormal.xyz)).rrr; fragmentColour.rbg += texture(cubeTest, vec3(rawNormal.xyz)).rrr; fragmentColour.a = 1; }[/source] I can suddenly read from the black cubemap as expected.... Maybe I just should update my drivers... Still nothing. So what could cause a cubemap to be all blick until I sample another cubemap first?
  11. OpenGL

    [quote name='Brother Bob' timestamp='1353709872' post='5003594'] I don't see anything obvious other than what I mentioned. Check for errors codes to see if anything is wrong. Keep in mind that some functions indicate errors by return value instead of an error state from glGetError, such as querying a uniform location, so make sure you check return values for functions as well. [/quote] I should have done it from the beginning, especially as I usually program fairly defensivly. But I went and added error checking to all OpenGL calls and it seems that the shader program is unable to find the cubemap sampler. Strange, it is used so it should not be optimized away and I double checked the name after discovering this. No trouble there, are there any known causes for this issue? Edit: Nevermind, was reporting for a different shader program. It finds it just fine for this, but still black an no clear errors...
  12. OpenGL

    [quote name='Brother Bob' timestamp='1353707858' post='5003587'] I am not sure about this, but I believe gluBuild2DMipmaps does not accept cube map faces as texture targets and thus cannot build cube map faces. If this is the case, then your call to gluBuild2DMipmaps will fail and thus leave the texture object in an incomplete, and therefore invalid, state since you have specified the minification filtering as a mipmap filter but only provided the base level texture. Either don't use mipmap filtering, or generate your mipmaps with the current glGenerateMipmap function instead. [/quote] Looking at the documentation, you seem to be correct. Though removing any reference to mipmaps (the function and the filtering methods set to just GL_LINEAR instead) does not seem to correct the issue though. All samples are still pure black.
  13. Hey all, I'm having a bit of trouble trying to get a cubemap to work with OpenGL and GLSL. It seems to upload it just fine, at least GlIntercept outputs the cubemap texture in the way I would expect it too. However, when I try to sample the texture all I seem to get is just plain black no matter which coordinates I use to sample. The source texture has essentially no black at all. I have been tearing my hair over this for the past few days and I'm wondering if any of you could spot the likely stupid mistake I've made? Texture loading code: [source lang="cpp"]namespace { SDL_Surface* createCubeMapFace(SDL_Surface* in, int faceStartX, int faceStartY, int width, int height) { #if SDL_BYTEORDER == SDL_LIL_ENDIAN SDL_Surface* bufferSurface = SDL_CreateRGBSurface(0, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); #else SDL_Surface* bufferSurface = SDL_CreateRGBSurface(0, width, height, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); #endif SDL_Rect rect; rect.w = width; rect.h = height; rect.x = faceStartX; rect.y = faceStartY; SDL_Rect dest; dest.x = 0; dest.y = 0; SDL_FillRect(bufferSurface, &dest, SDL_MapRGBA(bufferSurface->format, 0, 0xFF, 0, 0xFF)); SDL_BlitSurface(in, &rect, bufferSurface, &dest); return bufferSurface; } void uploadCubeMapFace(GLenum cubeMapFace, SDL_Surface* face, bool generateMipMaps) { glTexImage2D(cubeMapFace, 0, GL_RGBA, face->w, face->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, face->pixels ); tryLogError(); if (generateMipMaps) gluBuild2DMipmaps(cubeMapFace, GL_RGBA, face->w , face->h, GL_RGBA,GL_UNSIGNED_BYTE, face->pixels); tryLogError(); } GLuint uploadFaceSet(SDL_Surface*left, SDL_Surface* front, SDL_Surface* right, SDL_Surface* far, SDL_Surface* top, SDL_Surface* bottom, bool mipmapped) { GLuint id; glGenTextures(1, &id); glEnable(GL_TEXTURE_CUBE_MAP); glBindTexture(GL_TEXTURE_CUBE_MAP, id); tryLogError(); // Upload texture glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); //Create cube map uploadCubeMapFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, left, mipmapped); uploadCubeMapFace(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, front, mipmapped); uploadCubeMapFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X, right, mipmapped); uploadCubeMapFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, far, mipmapped); uploadCubeMapFace(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, top, mipmapped); uploadCubeMapFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, bottom, mipmapped); glBindTexture(GL_TEXTURE_CUBE_MAP, 0); return id; } // Loads a Texture into VideoRAM and returns a texture id GLuint loadCubeMapTextureIntoVRAM(Image* image, bool generateMipMaps) { assert(image->getWidth() % 4 == 0); assert(image->getHeight() % 3 == 0); assert(image->getWidth()/4 == image->getHeight()/3); int sideWidth = image->getWidth()/4; int sideHeight = image->getHeight()/3; auto left = createCubeMapFace(image->getInternalSurface(), sideWidth*0, sideHeight*1, sideWidth, sideHeight); auto front = createCubeMapFace(image->getInternalSurface(), sideWidth*1, sideHeight*1, sideWidth, sideHeight); auto right = createCubeMapFace(image->getInternalSurface(), sideWidth*2, sideHeight*1, sideWidth, sideHeight); auto far = createCubeMapFace(image->getInternalSurface(), sideWidth*3, sideHeight*1, sideWidth, sideHeight); auto top = createCubeMapFace(image->getInternalSurface(), sideWidth*1, sideHeight*0, sideWidth, sideHeight); auto bottom = createCubeMapFace(image->getInternalSurface(), sideWidth*1, sideHeight*2, sideWidth, sideHeight); auto retVal = uploadFaceSet(left, front, right, far, top, bottom, generateMipMaps); SDL_FreeSurface(left); SDL_FreeSurface(front); SDL_FreeSurface(right); SDL_FreeSurface(far); SDL_FreeSurface(top); SDL_FreeSurface(bottom); return retVal; } }[/source] Code used to sent the cubemap id to the shader program, I have checked that the id is correct and that the part of the of the code is executed as it should as well as having a unique sampler number. [source lang="cpp"]void ShaderProgram::setTexture(String variableName, int samplerNo, ICubeMap* texture) { assert(this->programId == activeProgram); assert(samplerNo >= 0); glEnable(GL_TEXTURE_CUBE_MAP); glBindTexture(GL_TEXTURE_CUBE_MAP, texture->getOpenGLId()); glActiveTexture(GL_TEXTURE0 + samplerNo); GLuint loc = glGetUniformLocation(this->programId, variableName.getStringUtf8()); glUniform1i(loc, samplerNo); }[/source] Finally, the minimimalistic test fragment shader: [source lang="cpp"]#version 330 uniform samplerCube cubeMapTexture; in vec4 rawNormal; out vec4 fragmentColour; void main(void) { fragmentColour = texture(cubeMapTexture, vec3(rawNormal.xyz)); }[/source] The vertex shader works as it should, if I hard set the colour in the fragment shader the object appears as expected. I would be thankful for any help.
  14. What does your glVertexAttribPointer calls look like? Anyway, you should still set your w-component to 1.
  15. Do you somehow set your homogenus coordinate beforehand? To me, it seems like you do not.