]> git.lizzy.rs Git - shadowclad.git/blob - debugutil.c
Start refactoring naming convention
[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* getGlInfoString() {
8         const char* glVersion = (const char*) glGetString(GL_VERSION);
9         const char* glslVersion = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
10         const char* glRenderer = (const char*) glGetString(GL_RENDERER);
11         
12         size_t glInfoLength = strlen("OpenGL  - GLSL  - ")
13                               + strlen(glVersion)
14                               + strlen(glslVersion)
15                               + strlen(glRenderer);
16         
17         char* glInfoString = malloc(glInfoLength + sizeof(char));
18         sprintf(glInfoString,
19                     "OpenGL %s - GLSL %s - %s",
20                         glVersion,
21                         glslVersion,
22                         glRenderer);
23         
24         return glInfoString;
25 }
26
27 void dumpScene(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 dumpNode(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 }