hey guys,
i have a weird question
i really want to write a small framework class for my demos (which obviously are only tutorial examples right now)…i was thinking of a class taht handles creating the window (main thing), and it would also contain pointers to different functions such as a drawing function, a resizing function…things like that…the class would have an internal wndproc (i’ve done this already in another porject) which would execute the common code such as saving the state of the application (active?), but that same wndproc would also call a user-defined proc before it returned, so taht you could handle your own messages (although i dont think opengl apps really need a lot of message processing)… (Almost done lol …Also there would be a function similar to the wiundow proc, but which is essentially the message loop in winmain…again there owuld be a call to a user-defined function that could do more stuff…
i was wondering if you guys thought it was a good idea…the way i see it is that it would be a nice way of having code organized and clean; all your code wuold be linked under one object…i just dont wan to write something that would later turn out to be useles…so if you guys could give me some feedback, it would give me an idea of what to do…
thanks in advance

PS: of course this would be for projects to be run on windows…i’d rather write somethign like taht, than use glut, since glut hides most of the underlying code from you (althought its the main point)…however i thinks its nice to know how to work with the current platform’s API at least a bit even if its not so important…

Definately the best way to go about it. All my game programming work uses a ‘COpenGL’ class to handle window creation, scene drawing, etc.)

nice, thanks dummstah…i’ll start mine then…since you already have your own class, i just have one question…say you want to draw you scene using your class…i suppose you call COpenGL: rawingFunction (…)…but do you change that function whenever you wanna draw something? or do you use some kind of pointer to a drawing fnuciton?..what i mean is do you edit your class’s fucntions to your needs?

My DrawScene class renders a pre-loaded list of objects. It’s something along the lines of this:

int COpenGL::GL_DrawScene(GLvoid)
//Clear Screen/Depth Buffer

//Setup the rotation/position for 3D data

//Start the object loop
for (y = 0; y <MAX_MODEL; y++)

  x = worldModels[y].model_ref;

  //Store the current matrix

  //Translate and rotate this object to its correct position						
  glTranslatef(worldModels[y].position.x, worldModels[y].position.y, worldModels[y].position.z);
  glRotatef(worldModels[y].rotation.x, 1.0f, 0.0f, 0.0f);
  glRotatef(worldModels[y].rotation.y, 0.0f, 1.0f, 0.0f);
  glRotatef(worldModels[y].rotation.z, 0.0f, 0.0f, 1.0f);

  //Bind its texture
  glBindTexture(GL_TEXTURE_2D, texture[worldModels[y].matref]);

  for (l = 0; l < worldModel[x].facecount; l++)

  	glBegin(GL_TRIANGLES);						// Drawing Using Triangles
  		glNormal3f	(worldModel[x].normal[l].vertexnormals[0].x,			worldModel[x].normal[l].vertexnormals[0].y,				worldModel[x].normal[l].vertexnormals[0].z);
  		glTexCoord3f(worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].a)].x,	worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].a)].y,		worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].a)].z);
  		glVertex3f	(worldModel[x].vertexlist[worldModel[x].facelist[l].a-1].x,	worldModel[x].vertexlist[worldModel[x].facelist[l].a-1].y,		worldModel[x].vertexlist[worldModel[x].facelist[l].a-1].z);

  		glNormal3f	(worldModel[x].normal[l].vertexnormals[1].x,			worldModel[x].normal[l].vertexnormals[1].y,				worldModel[x].normal[l].vertexnormals[1].z);
  		glTexCoord3f(worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].b)].x,	worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].b)].y,		worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].c)].z);
  		glVertex3f	(worldModel[x].vertexlist[worldModel[x].facelist[l].b-1].x,	worldModel[x].vertexlist[worldModel[x].facelist[l].b-1].y,		worldModel[x].vertexlist[worldModel[x].facelist[l].b-1].z);

  		glNormal3f	(worldModel[x].normal[l].vertexnormals[2].x,			worldModel[x].normal[l].vertexnormals[2].y,				worldModel[x].normal[l].vertexnormals[2].z);
  		glTexCoord3f(worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].c)].x,	worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].c)].y,		worldModel[x].uvvertexlist[(worldModel[x].uvfacelist[l].c)].z);
  		glVertex3f	(worldModel[x].vertexlist[worldModel[x].facelist[l].c-1].x,	worldModel[x].vertexlist[worldModel[x].facelist[l].c-1].y,		worldModel[x].vertexlist[worldModel[x].facelist[l].c-1].z);


  //Restore previous matrix


That way its pretty much consistant, as all my game engine needs just load my 3d model format and display it like that. The code is obviously a bit longer than that (as it has lighting/blending features too), and I was just showing the basics of how it works.

[This message has been edited by dummstah (edited 04-04-2003).]