#include #include #include #include #include #include /* Yeah, in a perfect world it'd be time based, but it's not that big of a deal; this is only a demo of OMA, after all. */ #define MAGIC_ROTATION_RATE 0.06f OMAsizei ModelChunkCount; OMAuint Model, *ModelChunks, ObjectChunk = 123456; void DisplayFunc(void) { static float r=0.0f; glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f,0.0f,-5.0f); glRotatef(r += MAGIC_ROTATION_RATE,0.31f,0.54f,0.78f); { omaBindChunk(ObjectChunk); omautGLDrawObject(); } glutSwapBuffers(); } void ReshapeFunc(int Width, int Height) { glViewport(0,0,Width,Height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (float)Width/(float)Height, 1.0f, 5000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void KeyboardFunc(unsigned char Key, int X, int Y) { switch(Key) { case 27: /* Escape */ case 'q': case 'Q': exit(0); break; default: break; } } int LoadModel(void) { static const OMAubyte buffer[] = "\n" "\n" " \n" " 1-1-1\n" " 1-11\n" " -1-11\n" " -1-1-1\n" " 11-1\n" " -11-1\n" " -111\n" " 111\n" " 1-1-1\n" " 11-1\n" " 111\n" " 1-11\n" " 1-11\n" " 111\n" " -111\n" " -1-11\n" " -1-11\n" " -111\n" " -11-1\n" " -1-1-1\n" " 11-1\n" " 1-1-1\n" " -1-1-1\n" " -11-1\n" " \n" " \n" " 0132\n" " 4576\n" " 0154\n" " 2376\n" " 0264\n" " 1375\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" "\n"; unsigned int a; omaGenChunks(1, &Model); omaBindChunk(Model); /* sizeof-1 to avoid including NULL terminator */ omaLoadBuffer(OMA_OMX, buffer, sizeof(buffer)-1); ModelChunkCount = omaGetChunkParameteri(OMA_CHUNK_ELEM_COUNT); ModelChunks = omaMapChunk(OMA_READ_ONLY); /* Find the first object chunk */ for(a=0; a