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

MrSimon

Members
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

123 Neutral

About MrSimon

  • Rank
    Member
  1. Hi, This is a purely hypothetical question. Suppose, I actually had a great idea for a game, and suppose, that were it to be produced, it would not only be hugely successful, it would be really big. Just suppose. How does someone like me (a little knowledge of c++ and a good idea of how to develop this game IF I had a big wad of cash) actually go about getting it done? I see thread after after thread (all over the net) advising not to bother/it'll never happen/do something else, but there are obviously people who have managed to make it happen. So what do they do that's so different? Essentially, what I am asking is this: Suppose I have a great enough idea for a game (an some idea as to how to execute the design), that you're convinced it will, if made, be a phenomenal success. What would you suggest I do with it? Send to Eidos? Approach the bank? Slog away in my own time for the next 12 years? Honestly, there must be some way of doing this.
  2. It all works now. I needed the correct order of assignments, in the correct place in regards to the object calls. It works now. Yay! I've only been using c++ for a few weeks, but I'm getting really really good at diagnosing errors!!!! It's a start!
  3. Hi there. Sorry for the late reply. I managed to get it working on my own, though essentially I have done what you describe in the second method. I am having another problem though. I have my gameengine class create pointers to the renderengine, the gamestates and now the eventengine. The gameengine constructor creates new instances of the renderengine, the gamestate and the event engine. The gameengine destructor deletes these instances. The gamestate class creates a pointer to renderengine, and is now able to access it to do rendering. The gamestate class also creates a pointer to the eventengine class and is able to access that. However, even though i create pointers in the event engine class (even copying and pasting the same declarations) the event engine is unable to access the functions of the other objects. It compiles, but I am getting bad access errors, which so far have usually been caused by empty pointers. In pseudo code, if it helps. [CODE] class cGameEngine { cGameEngine(); void Function(); cEventEngine* EventEngine; cRenderEngine* RenderEngine; cGameState* GameState; }; cGameEngine::cGameEngine() { EventEngine = new cEventEngine; RenderEngine = new cRenderEngine; GameState = new cGameState; }; cGameEngine::~cGameEngine() { delete EventEngine; delete RenderEngine; delete GameState; }; void cRenderEngine() { //Do Something... }; class cRenderEngine { void Function(); }; void cRenderEngine::Function() { //Render Something... }; class cGameState { void GetEvents(); void GetRendering(); cRenderEngine* RenderEngine; cEventEngine* EventEngine; }; void cGameState::GetEvents() { EventEngine->Function(); }; void cGameState::GetRendering() { RenderEngine->Function(); }; cGameEngine* Game = new GameEngine; int main() { while(running) { Game->GameState->GetRendering(); // ^ This works! Game->GameState->GetEvent(); // ^ This doesn't work! }; delete Game; }; [/CODE] If I change the event engine function to render (like the render engine function) it fails here too with the same error. I can follow the processes with the debugger, and it is following the references through the gameengine to the gamestate to the render engine, and it is following the process through the gameengine to the gamestate to the eventengine, but the pointers at the eventengine are coming up empty. Game engine > game state > render engine > to render engine function Game engine > game state > event engine > empty pointers. Sorry that I have basically tried to explain the same problem over and over. I want to make it clear. Thanks in advance for any help offered. Simon
  4. Edit: Sorry, I should have said, this is c++. Could someone please help me out with some code. I have a global class - cGameEngine. I have two other classes - cRenderEngine and cGameStates. cGameEngine manages the game, initialises the other two classes and manages the game states. cRenderEngine handles OpenGL, and cGameStates is an abstract base class from which I derive my game states - InitialState, PlayState and so on. So far cGameEngine initialises cRenderEngine on creation and has functions to Model 3D, 2D and to render - called through the renderengine object. cGameEngine also creates a game states stack, and initialises some game states. So far so good (although I have no idea if this is a wise way of doing things - it's as far as I've been able to work out). What I want to happen, is for the game states to handle the renderengine though the gamengine object. I can get the renderengine to function through the gameengine object, because the renderengine object is a member of the game engine object, but I can't get the game state objects to access the gameengine object, because the game states are object members of gameengine. I understand that I need to pass a pointer from gameengine to the game states, but I can't find how to do this with out upsetting something. I've managed to find a way to pass a gameengine pointer as far as the gamestates base class, but it isn't inherited by the derived game state objects, and gives me an error regarding explicit and default constructors. Could some body please provide the code I would need to add to the cGameStates abstract base class, and the derived gamestate classes. Also, is this a sensible way of doing things? It seems pretty tidy, but I'm a bit worried about memory leaks and so on, not really knowing how to look for them. Thanks to everyone looks and/or comments.
  5. And that did it. As promised, I will bugger off for a while. Thanks guys. You really are brilliant.
  6. OK. I have one more. After this, I promise, I'll leave you all alone. VBO works, colours work, IBO works. Texture doesn't work? Any ideas what's wrong? [CODE] struct float3 { float x, y, z; }; struct float2 { float x, y; }; struct sVertex { float3 Position, colours, normals; float2 Texture; }; struct sPolygons { int x, y, z; //float Normal; }; class cModel { private: GLuint TextureID; GLuint VBOID; GLuint IBOID; int nVertices, nPolygons; unsigned char* TextureData; public: cModel(int nVertices, sVertex Vertices[], int nPolygons, sPolygons Polygons[], const char * TextureFile, int TextureWidth, int TextureHeight); void Update(); void Render(); }; cModel::cModel(int numVertices, sVertex Vertices[], int numPolygons, sPolygons Polygons[], const char * TextureFile, int TextureWidth, int TextureHeight) { nVertices = numVertices; glGenBuffers(1, &VBOID); glGenBuffers(1, &IBOID); glBindBuffer(GL_ARRAY_BUFFER, VBOID); glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(sVertex), Vertices, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); nPolygons = numPolygons; glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, numPolygons*sizeof(sPolygons), Polygons, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); FILE * file = NULL; file = fopen(TextureFile, "rb"); TextureData = new unsigned char [TextureWidth * TextureHeight * 3]; fread(TextureData, TextureWidth * TextureHeight * 3, 1, file); fclose(file); glGenTextures(1, &TextureID); glBindTexture(GL_TEXTURE_2D, TextureID); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, TextureWidth, TextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureData); }; void cModel::Render() { glBindBuffer(GL_ARRAY_BUFFER, VBOID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOID); glBindTexture(GL_TEXTURE_2D, TextureID); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 11*sizeof(float), (char*)NULL+0); glColorPointer(3, GL_FLOAT, 11*sizeof(float), (char*)NULL+3*sizeof(float)); glTexCoordPointer(2, GL_FLOAT,11*sizeof(float), ((char*)NULL)+9*sizeof(float)); glDrawElements(GL_TRIANGLES, nPolygons*3, GL_UNSIGNED_INT, 0); //glDrawArrays(GL_TRIANGLES, 0, nVertices); glDisableClientState(GL_VERTEX_ARRAY); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); }; sVertex Vertices[3] = { {{0.0f, 5.0f, -1.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.5f, 1.0f}}, {{5.0f, -5.0f, -1.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f}}, {{-5.0f, -5.0f, -1.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}} }; sPolygons Array2[1] = { {0, 1, 2} }; [/CODE] I really promise, this will be the last thing for a while (a little while anyway).
  7. And now it works. Thank you guys. I should be quiet for a couple of days while I try to work out loading textures! Thanks again guys. You make a difficult process (for me anyway - it's only been a week, so far) a whole lot easier.
  8. Ok. I got this one too. Turns out I am an idiot, and got the colour values wrong. The values written as 0.1f should have been 1.0f. I do, however, have yet another difficulty. My IBO is not working. [CODE] struct float3 { float x, y, z; }; struct sVertex { float3 Position, colours, normals; float2 Texture; }; struct sPolygons { int x, y, z; //float Normal; }; sVertex Vertices[3] = { {{300.0f, 200.0f, -1.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, {{350.0f, 150.0f, -1.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, {{250.0f, 150.0f, -1.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}} }; sPolygons Array2 = { 2, 1, 0 }; cModel::cModel(int numVertices, sVertex Vertices[], int numPolygons, sPolygons Polygons[]) { nVertices = numVertices; nPolygons = numPolygons; glGenBuffers(1, &VBOID); glGenBuffers(1, &IBOID); glBindBuffer(GL_ARRAY_BUFFER, VBOID); glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(sVertex), Vertices, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, numPolygons*sizeof(sPolygons), Polygons, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); }; void cModel::Render() { glBindBuffer(GL_ARRAY_BUFFER, VBOID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOID); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(3, GL_FLOAT, 11*sizeof(float), (char*)NULL+0); glColorPointer(3, GL_FLOAT, 11*sizeof(float), (char*)NULL+3*sizeof(float)); glDrawElements(GL_TRIANGLES, nPolygons, GL_FLOAT, 0); //glDrawArrays(GL_TRIANGLES, 0, nVertices); glDisableClientState(GL_VERTEX_ARRAY); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); }; [/CODE] If I comment out the DrawElements line and uncomment the DrawArrays line, it works perfectly. Otherwise I get nothing. Anyone have any ideas? I promise I'll stop asking questions for a while if I get help with this
  9. So far so good. I'm expanding my structs now, and adding colours the vertices. But, naturally ([img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] ), I'm having some difficulties. This is the new struct form for sVertex: [CODE] struct sVertex { float3 Position, colours, normals; float2 Texture; }; [/CODE] And here is the data: [CODE] sVertex Vertices[3] = { {300.0f, 200.0f, -1.0f, 0.0f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, {350.0f, 150.0f, -1.0f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, {250.0f, 150.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f} }; [/CODE] The colorpointer is defined as: [CODE] glColorPointer(3, GL_FLOAT, 11*sizeof(float), (char*)NULL+3*sizeof(float)); [/CODE] What should(?) happen is that each vertices should be a different colour. What is happening, is that the whole triangle renders black. If I shift the stride and offset values I can get one corner blue or one corner yellow, or one corner red, or one corner green. Any ideas? I thought I was doing well!
  10. Wow. I fixed it. If I initialise the struct better: [CODE] sVertex Vertices[3] = { {300.0f, 200.0f, -1.0f}, {350.0f, 150.0f, -1.0f}, {250.0f, 150.0f, -1.0f} }; [/CODE] And change: [CODE] glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(sVertex), &Vertices, GL_STATIC_DRAW); [/CODE] to: [CODE] glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(sVertex), Vertices, GL_STATIC_DRAW); [/CODE] It works! Yay. But I'm sure there are about a million other things wrong. I', open to any and all advice regarding the better way of doing what I'm doing. Thanks everyone.
  11. Ok. Would anyone mind to give me a hand with my structs. I created the following structs: [CODE] struct float3 { float x, y, z; }; struct sVertex { float3 Position; }; [/CODE] I made the struct 'Vertices' and filled it in: [CODE] sVertex Vertices[3] = { 300.0f, 200.0f, -1.0f, 350.0f, 150.0f, -1.0f, 250.0f, 150.0f, -1.0f }; [/CODE] In my class cModels, I have the constructor as follows: [CODE] cModel::cModel(int numVertices, sVertex Vertices[], int numPolygons, sPolygons Polygons[]) { nVertices = numVertices; glGenBuffers(1, &VBOID); glBindBuffer(GL_ARRAY_BUFFER, VBOID); glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(sVertex), &Vertices, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); }; [/CODE] And the render function: [CODE] void cModel::Render() { glBindBuffer(GL_ARRAY_BUFFER, VBOID); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, 0); glDrawArrays(GL_TRIANGLES, 0, nVertices); glDisableClientState(GL_VERTEX_ARRAY); glBindBuffer(GL_ARRAY_BUFFER, 0); }; [/CODE] And nothing happens. If I remove the structs and enter the information as I did in the opening post, it works and I get a little grey triangle. I am assuming the problem is with the structs, or with my trying to get the information from the struct into the buffer. Would I have to take the vertex information out of the struct, and put it into an array within the class before putting it into the buffer? That seems a bit excessive, but I guess the glVertexArray may be having a problem with being given an array of structs, each of which contains another struct. Any ideas? All help is appreciated. Edit: OK. For a start, I think I'm initialising the array of structs wrong. I'll have a look and see what that does later.
  12. [quote name='mhagain' timestamp='1336134218' post='4937352'] One other problem. numVertices is probably 3 coming in here, as you have 3 verts (each of which is 3 floats), so you're not allocating enough buffer storage for them. The data parameter to glBufferData is a total size in bytes, so you need numVertices * 3 * sizeof (float) instead. It's probably better to use a struct for your vertex type rather than a raw array of floats as it can help catch this kind of thing. If numVertices is actually 9 then this is the wrong value to use for glDrawArrays - you need to be using 3 instead. Again, using a struct will make this clearer and easier. [/quote] It is the second case. I'm working on the structs, but I'm not so good with them. Hopefully a little more practice...
  13. That did it! Thank you so much. [quote name='Tsus' timestamp='1336132637' post='4937347'] You probably did it to shorten the code you show us, but in practice it’s better to create resources once at startup (glGenBuffers), not every draw call. [/quote] I do normally. It was all nicely arranged in a good long class, which I then had to butcher whilst trying to find what was wrong! Thank you again.
  14. Can someone please tell me why this piece of code is not working? I've been messing around with it for days. If I enter the vertex data in immediate mode (glBegin/glEnd) it renders with no problems. So what am I dong wrong? [CODE] float Vertices[9] = { 300.0f, 200.0f, -1.0f, 350.0f, 150.0f, -1.0f, 250.0f, 150.0f, -1.0f }; void DrawTriangle(int numVertices, float Vertices[]) { GLuint VBOID; glGenBuffers(1, &VBOID); glBindBuffer(GL_ARRAY_BUFFER, VBOID); glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(float), &Vertices[0], GL_STATIC_DRAW); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, 0); glDrawElements(GL_TRIANGLES, 9, GL_FLOAT, &Vertices[0]); glDisableClientState(GL_VERTEX_ARRAY); glDeleteBuffers(1, &VBOID); }; [/CODE] This is ultimately going to go back into the class it's failing to work in. It took me a day to wok out that the this bit of code is what is wrong with it. It was a long day. Thanks.
  15. Hi all, I'm new to this site and c++ programming and openGL and, well, all of this. But I have been making steady progress. I'm fairly confident with c++ (syntax not withstanding) and have gotten to the stage where I can create a window, create some objects and move them about. I'm now going over what I now and trying to make it as efficient and functional as possible. So far I have progressed from entering all object generation methods between glBegin and glEnd tags directly in may game loop, to creating object generation classes for much simpler object specification. I am now trying to creating a method that enables polygons and objects to share vertex references, minimising the number of necessary calls. This is the bit I need a little guidance on. What I am hoping to do is the following: Create an array of vertices for each object (the vertex array will also hold normal, texture, etc information). Create an array of vertex references. Construct objects using vertex references, enabling my polygons to share vertexes. Add simple functions for constructing and manipulating objects. I'm pretty comfortable with all of this, however I was wondering how sensible this approach is; whether it is the most efficient way of doing this, whether I have forgotten or overlooked something, or whether the openGL vertex array method would render this approach redundant. I've looked through the specification regarding the openGL vertex array method and am assuming it basically does what I am intending to do, though (I think) in a slightly less efficient way. I've also read somewhere suggesting that using glBegin/glEnd is to be avoided. The draw functions within my object generation class would use this method, though it would be specifying vertex data through references, rather than literals. Also using my own vertex and reference arrays, I am making my classes a bit more universal ( i.e. not so bound to openGL). In case that matters. Am I correct I'm this assumption? Does anyone have any suggest/advice/input? I'm eager to do as much of this myself as possible, but I certainly don't want to start getting myself into any bad habits.