diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source/blender/gpu/intern/gpu_extensions.c | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/gpu/intern/gpu_extensions.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index e1d6f64f661..846ee2850be 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -99,7 +99,7 @@ void GPU_extensions_init(void) const char *vendor, *renderer; /* can't avoid calling this multiple times, see wm_window_add_ghostwindow */ - if(gpu_extensions_init) return; + if (gpu_extensions_init) return; gpu_extensions_init= 1; glewInit(); @@ -123,38 +123,38 @@ void GPU_extensions_init(void) vendor = (const char*)glGetString(GL_VENDOR); renderer = (const char*)glGetString(GL_RENDERER); - if(strstr(vendor, "ATI")) { + if (strstr(vendor, "ATI")) { GG.device = GPU_DEVICE_ATI; GG.driver = GPU_DRIVER_OFFICIAL; } - else if(strstr(vendor, "NVIDIA")) { + else if (strstr(vendor, "NVIDIA")) { GG.device = GPU_DEVICE_NVIDIA; GG.driver = GPU_DRIVER_OFFICIAL; } - else if(strstr(vendor, "Intel") || + else if (strstr(vendor, "Intel") || /* src/mesa/drivers/dri/intel/intel_context.c */ strstr(renderer, "Mesa DRI Intel") || strstr(renderer, "Mesa DRI Mobile Intel")) { GG.device = GPU_DEVICE_INTEL; GG.driver = GPU_DRIVER_OFFICIAL; } - else if(strstr(renderer, "Mesa DRI R") || (strstr(renderer, "Gallium ") && strstr(renderer, " on ATI "))) { + else if (strstr(renderer, "Mesa DRI R") || (strstr(renderer, "Gallium ") && strstr(renderer, " on ATI "))) { GG.device = GPU_DEVICE_ATI; GG.driver = GPU_DRIVER_OPENSOURCE; } - else if(strstr(renderer, "Nouveau") || strstr(vendor, "nouveau")) { + else if (strstr(renderer, "Nouveau") || strstr(vendor, "nouveau")) { GG.device = GPU_DEVICE_NVIDIA; GG.driver = GPU_DRIVER_OPENSOURCE; } - else if(strstr(vendor, "Mesa")) { + else if (strstr(vendor, "Mesa")) { GG.device = GPU_DEVICE_SOFTWARE; GG.driver = GPU_DRIVER_SOFTWARE; } - else if(strstr(vendor, "Microsoft")) { + else if (strstr(vendor, "Microsoft")) { GG.device = GPU_DEVICE_SOFTWARE; GG.driver = GPU_DRIVER_SOFTWARE; } - else if(strstr(renderer, "Apple Software Renderer")) { + else if (strstr(renderer, "Apple Software Renderer")) { GG.device = GPU_DEVICE_SOFTWARE; GG.driver = GPU_DRIVER_SOFTWARE; } @@ -163,12 +163,12 @@ void GPU_extensions_init(void) GG.driver = GPU_DRIVER_ANY; } - if(GG.device == GPU_DEVICE_ATI) { + if (GG.device == GPU_DEVICE_ATI) { /* ATI 9500 to X2300 cards support NPoT textures poorly * Incomplete list http://dri.freedesktop.org/wiki/ATIRadeon * New IDs from MESA's src/gallium/drivers/r300/r300_screen.c */ - if(strstr(renderer, "R3") || strstr(renderer, "RV3") || + if (strstr(renderer, "R3") || strstr(renderer, "RV3") || strstr(renderer, "R4") || strstr(renderer, "RV4") || strstr(renderer, "RS4") || strstr(renderer, "RC4") || strstr(renderer, "R5") || strstr(renderer, "RV5") || @@ -205,7 +205,7 @@ int GPU_glsl_support(void) int GPU_non_power_of_two_support(void) { - if(GG.npotdisabled) + if (GG.npotdisabled) return 0; return GLEW_ARB_texture_non_power_of_two; @@ -260,7 +260,7 @@ static void GPU_print_framebuffer_error(GLenum status, char err_out[256]) break; } - if(err_out) { + if (err_out) { BLI_snprintf(err_out, 256, "GPUFrameBuffer: framebuffer incomplete error %d '%s'", (int)status, err); } @@ -318,7 +318,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in GLenum type, format, internalformat; void *pixels = NULL; - if(depth && !GLEW_ARB_depth_texture) + if (depth && !GLEW_ARB_depth_texture) return NULL; tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture"); @@ -332,7 +332,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in glGenTextures(1, &tex->bindcode); if (!tex->bindcode) { - if(err_out) { + if (err_out) { BLI_snprintf(err_out, 256, "GPUTexture: texture create failed: %d", (int)glGetError()); } @@ -352,7 +352,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in tex->number = 0; glBindTexture(tex->target, tex->bindcode); - if(depth) { + if (depth) { type = GL_UNSIGNED_BYTE; format = GL_DEPTH_COMPONENT; internalformat = GL_DEPTH_COMPONENT; @@ -396,7 +396,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in if (pixels) MEM_freeN(pixels); - if(depth) { + if (depth) { glTexParameteri(tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(tex->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(tex->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE); @@ -433,7 +433,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels) void *pixels = NULL; float vfBorderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - if(!GLEW_VERSION_1_2) + if (!GLEW_VERSION_1_2) return NULL; tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture"); @@ -476,7 +476,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels) GPU_print_error("3D glTexImage3D"); if (fpixels) { - if(!GPU_non_power_of_two_support() && (w != tex->w || h != tex->h || depth != tex->depth)) { + if (!GPU_non_power_of_two_support() && (w != tex->w || h != tex->h || depth != tex->depth)) { /* clear first to avoid unitialized pixels */ float *zero= MEM_callocN(sizeof(float)*tex->w*tex->h*tex->depth, "zero"); glTexSubImage3D(tex->target, 0, 0, 0, 0, tex->w, tex->h, tex->depth, format, type, zero); @@ -516,13 +516,13 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time, GPU_update_image_time(ima, time); bindcode = GPU_verify_image(ima, iuser, 0, 0, mipmap); - if(ima->gputexture) { + if (ima->gputexture) { ima->gputexture->bindcode = bindcode; glBindTexture(GL_TEXTURE_2D, lastbindcode); return ima->gputexture; } - if(!bindcode) { + if (!bindcode) { glBindTexture(GL_TEXTURE_2D, lastbindcode); return NULL; } @@ -593,7 +593,7 @@ void GPU_texture_bind(GPUTexture *tex, int number) return; } - if(number == -1) + if (number == -1) return; GPU_print_error("Pre Texture Bind"); @@ -618,7 +618,7 @@ void GPU_texture_unbind(GPUTexture *tex) return; } - if(tex->number == -1) + if (tex->number == -1) return; GPU_print_error("Pre Texture Unbind"); @@ -714,7 +714,7 @@ int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, char err GLenum status; GLenum attachment; - if(tex->depth) + if (tex->depth) attachment = GL_DEPTH_ATTACHMENT_EXT; else attachment = GL_COLOR_ATTACHMENT0_EXT; @@ -725,7 +725,7 @@ int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, char err glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, tex->target, tex->bindcode, 0); - if(tex->depth) { + if (tex->depth) { glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); } @@ -742,7 +742,7 @@ int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, char err return 0; } - if(tex->depth) + if (tex->depth) fb->depthtex = tex; else fb->colortex = tex; @@ -756,15 +756,15 @@ void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, GPUTexture *tex) { GLenum attachment; - if(!tex->fb) + if (!tex->fb) return; - if(GG.currentfb != tex->fb->object) { + if (GG.currentfb != tex->fb->object) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, tex->fb->object); GG.currentfb = tex->fb->object; } - if(tex->depth) { + if (tex->depth) { fb->depthtex = NULL; attachment = GL_DEPTH_ATTACHMENT_EXT; } @@ -817,12 +817,12 @@ void GPU_framebuffer_texture_unbind(GPUFrameBuffer *UNUSED(fb), GPUTexture *UNUS void GPU_framebuffer_free(GPUFrameBuffer *fb) { - if(fb->depthtex) + if (fb->depthtex) GPU_framebuffer_texture_detach(fb, fb->depthtex); - if(fb->colortex) + if (fb->colortex) GPU_framebuffer_texture_detach(fb, fb->colortex); - if(fb->object) { + if (fb->object) { glDeleteFramebuffersEXT(1, &fb->object); if (GG.currentfb == fb->object) { @@ -863,29 +863,29 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, char err_out[256]) ofs->h= height; ofs->fb = GPU_framebuffer_create(); - if(!ofs->fb) { + if (!ofs->fb) { GPU_offscreen_free(ofs); return NULL; } ofs->depth = GPU_texture_create_depth(width, height, err_out); - if(!ofs->depth) { + if (!ofs->depth) { GPU_offscreen_free(ofs); return NULL; } - if(!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth, err_out)) { + if (!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth, err_out)) { GPU_offscreen_free(ofs); return NULL; } ofs->color = GPU_texture_create_2D(width, height, NULL, err_out); - if(!ofs->color) { + if (!ofs->color) { GPU_offscreen_free(ofs); return NULL; } - if(!GPU_framebuffer_texture_attach(ofs->fb, ofs->color, err_out)) { + if (!GPU_framebuffer_texture_attach(ofs->fb, ofs->color, err_out)) { GPU_offscreen_free(ofs); return NULL; } @@ -897,11 +897,11 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, char err_out[256]) void GPU_offscreen_free(GPUOffScreen *ofs) { - if(ofs->fb) + if (ofs->fb) GPU_framebuffer_free(ofs->fb); - if(ofs->color) + if (ofs->color) GPU_texture_free(ofs->color); - if(ofs->depth) + if (ofs->depth) GPU_texture_free(ofs->depth); MEM_freeN(ofs); @@ -942,7 +942,7 @@ static void shader_print_errors(const char *task, char *log, const char *code) fprintf(stderr, "GPUShader: %s error:\n", task); - if(G.f & G_DEBUG) { + if (G.f & G_DEBUG) { c = code; while ((c < end) && (pos = strchr(c, '\n'))) { fprintf(stderr, "%2d ", line); @@ -971,9 +971,9 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU shader = MEM_callocN(sizeof(GPUShader), "GPUShader"); - if(vertexcode) + if (vertexcode) shader->vertex = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); - if(fragcode) + if (fragcode) shader->fragment = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); shader->object = glCreateProgramObjectARB(); @@ -985,7 +985,7 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU return NULL; } - if(vertexcode) { + if (vertexcode) { glAttachObjectARB(shader->object, shader->vertex); glShaderSourceARB(shader->vertex, 1, (const char**)&vertexcode, NULL); @@ -1001,10 +1001,10 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU } } - if(fragcode) { + if (fragcode) { count = 0; - if(libcode) fragsource[count++] = libcode; - if(fragcode) fragsource[count++] = fragcode; + if (libcode) fragsource[count++] = libcode; + if (fragcode) fragsource[count++] = fragcode; glAttachObjectARB(shader->object, shader->fragment); glShaderSourceARB(shader->fragment, count, fragsource, NULL); @@ -1022,7 +1022,7 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU } #if 0 - if(lib && lib->lib) + if (lib && lib->lib) glAttachObjectARB(shader->object, lib->lib); #endif @@ -1113,7 +1113,7 @@ int GPU_shader_get_uniform(GPUShader *shader, const char *name) void GPU_shader_uniform_vector(GPUShader *UNUSED(shader), int location, int length, int arraysize, float *value) { - if(location == -1) + if (location == -1) return; GPU_print_error("Pre Uniform Vector"); @@ -1137,10 +1137,10 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText return; } - if(tex->number == -1) + if (tex->number == -1) return; - if(location == -1) + if (location == -1) return; GPU_print_error("Pre Uniform Texture"); |