PDA

View Full Version : i'm in a desperate need for VERY SIMPLE game/demo example



therealremi
12-12-2006, 04:07 PM
I just need to take a look at some basic texture managment in a game/demo - loading material files, sharing texture objects between meshes, maybe integrating it with shaders etc. I tries to take a look at Ogre source but that is far too complicated to me. Simple shader demos are also useless cause they have only a few hardcoded textures, with no material files. Can somebody help me get started?

hseb
12-13-2006, 12:10 AM
get a look to www.humus.ca (http://www.humus.ca) for example. However, there is a lot of other really good web site that you could find with google...

Try to visite other this other forum member's web pages.

PS : there's also my web site sebastien.hillaire.free.fr (but it's in french)

k_szczech
12-13-2006, 12:48 AM
texture managment (...) material files (...) sharing texture objects (...) integrating it with shaders (...) take a look at Ogre source but that is far too complicatedWell, if you want such functionality, then it won't be that simple.
There is also a free engine called "Crystal space" - perhaps that would be easier.

therealremi
12-13-2006, 01:02 AM
I'm a complete beginner and I'm having a hard time debugging my opengl/sdl demo. I somehow managed to integrate cgfx files, but when I try to add textures in opengl - strange things happen. I create a texture object for every unique texture and store it in a global array. Since some meshes use the same texture - each mesh has an index into this array of texture objects. But when I call:
glBindTexture(GL_TEXTURE_2D,texture_objects[mesh_texture_index]);
before drawing the geometry, then only the first geometry that has this texture assigned shows up. Which is strange, cause I know that they all have the same mesh_texture_index.

sqrt[-1]
12-13-2006, 02:20 AM
Perhaps you need some debugging tools?
Try http://glintercept.nutty.org/ and capture a few XML frames to see what is happening with your textures/meshes. (and also see if there is any GL errors)

therealremi
12-13-2006, 02:38 AM
thanks, I'll check that. gDEBugger crashed at the very beginning of my app:D besides, I could make head nor tail of it;)

k_szczech
12-13-2006, 06:23 AM
I'm a complete beginnerOk, OpenGL beginner or C/C++ beginner? (or maybe you use different language?)
I could describe what I'm using in my framework, but I'm not sure if you're interested in it. It would require some C++ knowledge:
-virtual methods
-templates
-a bit of STL
-XML

Korval
12-13-2006, 10:28 AM
I'm a complete beginnerAnd therein lies your problem. Anyone who can reasonably describe themselves as "a complete beginner" should not be trying to deal in issues of resource management.

therealremi
12-13-2006, 12:52 PM
Korval: why?
k_szczech: I have some C++ knowledge - after all I managed to write 3ds max exporter that gets me meshes with smoothing groups and texture coordinates, and load this into my app.

k_szczech
12-13-2006, 02:58 PM
I have some C++ knowledgeI specified exactly what kind of knowledge will be required, so assuming you can handle this - here goes:

First of all create a ResourceTree class.
This class will map a resource name, given as string (like file name and path) to a pointer to resource. It doesn't have to be a tree - it could be just list.
You don't have to implement this yourself - I'm sure there are a lot of implementatoins that map a string to a pointer, so feel free to use them.

Next thing would be to create base resource classes:

class ResourceData;
template <typename T> class Resource;ResourceData is a very simple class that does nothing, but has one integer in it - a reference counter.
Resource is a class that has a pointer to ResourceData and a static pointer to resource tree. It has to be static.
It has a constructor (or factory method) that takes a string with resource name. When you create object of this class it will search for given name in a tree - if such name is found it will then take pointer to ResourceData found in ResourceTree and increase reference count in that ResourceData. If not, then it will create new ResourceData, add it's pointer to a ResourceTree and set it's reference counter to 1.
Resource class also have a destructor that only decreases reference count in ResourceData, but if that counter goes dwn to 0 it can delete ResourceData and remove it's pointer from ResourceTree.

Now you can use ResorceData and Resource as your base classes for all resources. An example:

class TextureData : public ResourceData;
class Texture : public Resource<TextureData>;

class MaterialData : public ResourceData;
class Material : public Resource<MaterialData>;You use textures in your application by using Texture class - this class manages TextureData and provides access to it. An example:

void TextureData::Use(void) { glBindTexture(...); }
void Texture::Use(void) { data->Use(); }In your application you can create textures like this:

Texture* tex = new Texture("textures/abc.jpg");
(...)
tex->Use();
(...)
delete tex;So, your application creates Texture objects and these rediect everything to TextureData objects that they found in a ResourceTree by given name. If you create many Texture objects in various places of your application that have the same file name, then they will redirect all actions to the same TextureData.

As for XML I mentioned before - you could use it to store such resources like materials in files. You wouldn't need any special editor - you could edit these files manually.

Ok, It's getting late. I'm outta here.

Korval
12-13-2006, 03:46 PM
Korval: why?Because resource management is a very complicated subject. It's the reason why "simple" demos completely ignore it in favor of hardcoding. In general, your resource manager will need to be able to handle multiple kinds of resources, as well as interdependencies between them, etc. Even what k_szczech described is just the tip of the iceberg with regard of how much resource management entails.

therealremi
12-13-2006, 05:34 PM
k_szczech - dzięki. gdzie się uczyłeś programowania gier?

k_szczech
12-14-2006, 02:07 AM
:)
If you want to have a chat in polish, then use private messages or send me an email. Let's just stick to english in this forum, ok?
It's true what Korval wrote - implementing proper resource management requires experience, but sometimes you can get away with something simplier. What I described is a convenient way of identifying and sharing resources. Once you have these classes you can very easily add new type of resource to your application.
Design is the key. KISS as they say. If you have proper design then you'll have only half of the programming to do and chance that you'll have bug in your code is much smaller.

therealremi
12-14-2006, 02:26 AM
I'm ok with english. I understand you are self-taught? Or do they teach opengl on some polish university? I wonder whether I missed something in not studying at Poznań University of Technology.

k_szczech
12-14-2006, 07:27 AM
I've graduated at PUT 2 years ago. Software engineering M.Sc. to be precise. We had some classes related to DirectX / OpenGL but because most students had no knowledge in computer graphics, it was pretty basic.
So as for OpenGL and game programming I'm a self-taught. Remember that practice makes perfect.