this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added a couple of memory tests and fixed a reallocation that was not freed in glew.

+159 -3
+20 -3
src/externals/glew/glew.c
··· 225 225 return i; 226 226 } 227 227 228 + static GLubyte* _glewStrDup (const GLubyte* s) 229 + { 230 + GLuint length = _glewStrLen(s); 231 + GLubyte* result = (GLubyte*)malloc(length * sizeof(GLubyte)); 232 + GLuint i=0; 233 + while (s[i] != '\0') 234 + { 235 + result[i] = s[i]; 236 + ++i; 237 + } 238 + result[i] = '\0'; 239 + return result; 240 + } 241 + 228 242 static GLuint _glewStrCLen (const GLubyte* s, GLubyte c) 229 243 { 230 244 GLuint i=0; ··· 10324 10338 GLEW_VERSION_1_1 = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE; 10325 10339 } 10326 10340 10327 - /* query opengl extensions string */ 10328 - if(GLEW_VERSION_3_0) 10341 + /* query opengl extensions string */ 10342 + free(extStart); 10343 + if(major >= 3) 10329 10344 { 10330 10345 GLint n = 0; 10331 10346 GLint count = 1; ··· 10359 10374 extStart = NULL; 10360 10375 } 10361 10376 else 10362 - extStart = glGetString(GL_EXTENSIONS); 10377 + { 10378 + extStart = _glewStrDup(glGetString(GL_EXTENSIONS)); 10379 + } 10363 10380 10364 10381 extEnd = extStart + _glewStrLen(extStart); 10365 10382
+6
tests/CMakeLists.txt
··· 134 134 add_executable(anchor-test anchor/main.c) 135 135 target_link_libraries (anchor-test ${TEST_LIBS}) 136 136 137 + add_executable(memory-test memory/main.c) 138 + target_link_libraries (memory-test ${TEST_LIBS}) 139 + 140 + add_executable(reinit-test reinit/main.c) 141 + target_link_libraries (reinit-test ${TEST_LIBS}) 142 + 137 143 add_executable(video-test video/main.c) 138 144 target_link_libraries (video-test ${TEST_LIBS})
+46
tests/memory/main.c
··· 1 + #include "SDL.h" 2 + #include "SDL_gpu.h" 3 + 4 + int main(int argc, char* argv[]) 5 + { 6 + GPU_Target* screen = GPU_Init(800, 600, GPU_DEFAULT_INIT_FLAGS); 7 + 8 + SDL_Event event; 9 + Uint8 done = 0; 10 + while(!done) 11 + { 12 + while(SDL_PollEvent(&event)) 13 + { 14 + if(event.type == SDL_QUIT) 15 + done = 1; 16 + else if(event.type == SDL_KEYDOWN) 17 + { 18 + if(event.key.keysym.sym == SDLK_ESCAPE) 19 + done = 1; 20 + } 21 + } 22 + 23 + GPU_Clear(screen); 24 + 25 + GPU_Image* image = GPU_LoadImage("data/test.bmp"); 26 + GPU_Image* image2 = GPU_CopyImage(image); 27 + GPU_Target* target = GPU_LoadTarget(image2); 28 + 29 + GPU_Blit(image, NULL, screen, screen->w/4, screen->h/2); 30 + 31 + GPU_Blit(image2, NULL, screen, 3*screen->w/4, screen->h/2); 32 + 33 + GPU_FreeTarget(target); 34 + GPU_FreeImage(image2); 35 + GPU_FreeImage(image); 36 + 37 + GPU_Flip(screen); 38 + SDL_Delay(100); 39 + } 40 + 41 + GPU_Quit(); 42 + 43 + return 0; 44 + } 45 + 46 +
+87
tests/reinit/main.c
··· 1 + #include "SDL.h" 2 + #include "SDL_gpu.h" 3 + #include <math.h> 4 + #include "common.h" 5 + 6 + #define IMAGE_FILE "data/test.bmp" 7 + 8 + int main_loop() 9 + { 10 + int result = -1; 11 + GPU_Target* screen; 12 + 13 + printRenderers(); 14 + 15 + screen = GPU_Init(800, 600, GPU_DEFAULT_INIT_FLAGS); 16 + if(screen == NULL) 17 + { 18 + GPU_LogError("Failed to init SDL_gpu.\n"); 19 + return -1; 20 + } 21 + 22 + printCurrentRenderer(); 23 + 24 + { 25 + Uint8 done; 26 + SDL_Event event; 27 + GPU_Image* image; 28 + 29 + GPU_LogError("Loading image\n"); 30 + image = GPU_LoadImage(IMAGE_FILE); 31 + if(image == NULL) 32 + { 33 + GPU_LogError("Failed to load image.\n"); 34 + return -1; 35 + } 36 + 37 + done = 0; 38 + while(!done) 39 + { 40 + while(SDL_PollEvent(&event)) 41 + { 42 + if(event.type == SDL_QUIT) 43 + { 44 + done = 1; 45 + result = -1; 46 + } 47 + else if(event.type == SDL_KEYDOWN) 48 + { 49 + if(event.key.keysym.sym == SDLK_ESCAPE) 50 + { 51 + done = 1; 52 + result = -1; 53 + } 54 + else if(event.key.keysym.sym == SDLK_SPACE) 55 + { 56 + done = 1; 57 + result = 1; 58 + } 59 + } 60 + } 61 + 62 + GPU_Clear(screen); 63 + 64 + GPU_Blit(image, NULL, screen, 150, 150); 65 + 66 + GPU_Flip(screen); 67 + } 68 + 69 + GPU_FreeImage(image); 70 + } 71 + 72 + GPU_Quit(); 73 + 74 + return result; 75 + } 76 + 77 + 78 + int main(int argc, char* argv[]) 79 + { 80 + while(main_loop() > 0) 81 + { 82 + GPU_Log("\nReinitializing.\n\n"); 83 + } 84 + return 0; 85 + } 86 + 87 +