]> git.lizzy.rs Git - shadowclad.git/blob - debugutil.c
Return aiScene* from import, move prints to debugutil
[shadowclad.git] / debugutil.c
1 #include <GL/gl.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <assimp/scene.h>
6
7 char * get_gl_info() {
8         const char * gl_version = (const char *) glGetString(GL_VERSION);
9         const char * gl_sl_version = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
10         const char * gl_renderer = (const char *) glGetString(GL_RENDERER);
11         
12         size_t gl_info_length = strlen("OpenGL  - GLSL  - ")
13                                 + strlen(gl_version)
14                                 + strlen(gl_sl_version)
15                                 + strlen(gl_renderer);
16         
17         char * gl_info = malloc(gl_info_length + sizeof(char));
18         sprintf(gl_info,
19                     "OpenGL %s - GLSL %s - %s",
20                         gl_version,
21                         gl_sl_version,
22                         gl_renderer);
23         
24         return gl_info;
25 }
26
27 void print_struct_aiScene(FILE* stream, const struct aiScene* scene) {
28         if (scene == NULL) {
29                 fprintf(stream, "NULL");
30                 return;
31         }
32         fprintf(stream, "{ mFlags = %u, mRootNode = %p, mNumMeshes = %u, mMeshes = %p, mNumMaterials = %u, mMaterials = %p, mNumAnimations = %u, mAnimations = %p, mNumTextures = %u, mTextures = %p, mNumLights = %u, mLights = %p }",
33                         (*scene).mFlags,
34                         (void*) (*scene).mRootNode,
35                         (*scene).mNumMeshes,
36                         (void*) (*scene).mMeshes,
37                         (*scene).mNumMaterials,
38                         (void*) (*scene).mMaterials,
39                         (*scene).mNumAnimations,
40                         (void*) (*scene).mAnimations,
41                         (*scene).mNumTextures,
42                         (void*) (*scene).mTextures,
43                         (*scene).mNumLights,
44                         (void*) (*scene).mLights);
45 }
46
47 void print_struct_aiNode(FILE* stream, const struct aiNode* node) {
48         if (node == NULL) {
49                 fprintf(stream, "NULL");
50                 return;
51         }
52         fprintf(stream, "{ mName = %s, mNumMeshes = %u, mMeshes = %p }",
53                         (*node).mName.data,
54                         (*node).mNumMeshes,
55                         (void*) (*node).mMeshes);
56 }