diff options
Diffstat (limited to 'source/blender/editors/screen/glutil.c')
-rw-r--r-- | source/blender/editors/screen/glutil.c | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 495bfb9ba39..28fe8caf34b 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -150,7 +150,7 @@ void fdrawbezier(float vec[4][3]) glBegin(GL_LINE_STRIP); while (spline_step < 1.000001f) { #if 0 - if(do_shaded) + if (do_shaded) UI_ThemeColorBlend(th_col1, th_col2, spline_step); #endif glEvalCoord1f(spline_step); @@ -261,7 +261,7 @@ void sdrawbox(short x1, short y1, short x2, short y2) void setlinestyle(int nr) { - if(nr==0) { + if (nr==0) { glDisable(GL_LINE_STIPPLE); } else { @@ -284,7 +284,7 @@ void set_inverted_drawing(int enable) void sdrawXORline(int x0, int y0, int x1, int y1) { - if(x0==x1 && y0==y1) return; + if (x0==x1 && y0==y1) return; set_inverted_drawing(1); @@ -306,7 +306,7 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) set_inverted_drawing(1); glBegin(GL_LINES); - if(nr== -1) { /* flush */ + if (nr== -1) { /* flush */ for (nr=0; nr<4; nr++) { if (flags[nr]) { glVertex2sv(old[nr][0]); @@ -314,9 +314,10 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) flags[nr]= 0; } } - } else { - if(nr>=0 && nr<4) { - if(flags[nr]) { + } + else { + if (nr>=0 && nr<4) { + if (flags[nr]) { glVertex2sv(old[nr][0]); glVertex2sv(old[nr][1]); } @@ -339,7 +340,7 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) void fdrawXORellipse(float xofs, float yofs, float hw, float hh) { - if(hw==0) return; + if (hw==0) return; set_inverted_drawing(1); @@ -502,28 +503,28 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, float rast_y= y+subpart_y*offset_y*yzoom; /* check if we already got these because we always get 2 more when doing seamless*/ - if(subpart_w<=seamless || subpart_h<=seamless) + if (subpart_w<=seamless || subpart_h<=seamless) continue; - if(format==GL_FLOAT) { + if (format==GL_FLOAT) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y*offset_y*img_w*4 + subpart_x*offset_x*4]); /* add an extra border of pixels so linear looks ok at edges of full image. */ - if(subpart_w<tex_w) + if (subpart_w<tex_w) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y*offset_y*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); - if(subpart_h<tex_h) + if (subpart_h<tex_h) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + subpart_x*offset_x*4]); - if(subpart_w<tex_w && subpart_h<tex_h) + if (subpart_w<tex_w && subpart_h<tex_h) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); } else { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y*offset_y*img_w*4 + subpart_x*offset_x*4]); - if(subpart_w<tex_w) + if (subpart_w<tex_w) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y*offset_y*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); - if(subpart_h<tex_h) + if (subpart_h<tex_h) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + subpart_x*offset_x*4]); - if(subpart_w<tex_w && subpart_h<tex_h) + if (subpart_w<tex_w && subpart_h<tex_h) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); } @@ -608,27 +609,28 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo /* Don't use safe RasterPos (slower) if we can avoid it. */ if (rast_x>=0 && rast_y>=0) { glRasterPos2f(rast_x, rast_y); - } else { + } + else { glaRasterPosSafe2f(rast_x, rast_y, 0, 0); } glPixelStorei(GL_UNPACK_ROW_LENGTH, row_w); - if(format==GL_LUMINANCE || format==GL_RED) { - if(type==GL_FLOAT) { + if (format==GL_LUMINANCE || format==GL_RED) { + if (type==GL_FLOAT) { float *f_rect= (float *)rect; glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)); } - else if(type==GL_INT || type==GL_UNSIGNED_INT) { + else if (type==GL_INT || type==GL_UNSIGNED_INT) { int *i_rect= (int *)rect; glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y*row_w + off_x)); } } else { /* RGBA */ - if(type==GL_FLOAT) { + if (type==GL_FLOAT) { float *f_rect= (float *)rect; glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)*4); } - else if(type==GL_UNSIGNED_BYTE) { + else if (type==GL_UNSIGNED_BYTE) { unsigned char *uc_rect= (unsigned char *) rect; glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y*row_w + off_x)*4); } @@ -709,7 +711,8 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) di->screen_rect= *screen_rect; if (world_rect) { di->world_rect= *world_rect; - } else { + } + else { di->world_rect.xmin = di->screen_rect.xmin; di->world_rect.ymin = di->screen_rect.ymin; di->world_rect.xmax = di->screen_rect.xmax; @@ -765,13 +768,13 @@ void bglBegin(int mode) { curmode= mode; - if(mode==GL_POINTS) { + if (mode==GL_POINTS) { float value[4]; glGetFloatv(GL_POINT_SIZE_RANGE, value); - if(value[1] < 2.0f) { + if (value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); pointhack= floor(value[0] + 0.5f); - if(pointhack>4) pointhack= 4; + if (pointhack>4) pointhack= 4; } else glBegin(mode); } @@ -782,10 +785,10 @@ int bglPointHack(void) float value[4]; int pointhack_px; glGetFloatv(GL_POINT_SIZE_RANGE, value); - if(value[1] < 2.0f) { + if (value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); pointhack_px= floorf(value[0]+0.5f); - if(pointhack_px>4) pointhack_px= 4; + if (pointhack_px>4) pointhack_px= 4; return pointhack_px; } return 0; @@ -795,7 +798,7 @@ void bglVertex3fv(const float vec[3]) { switch(curmode) { case GL_POINTS: - if(pointhack) { + if (pointhack) { glRasterPos3fv(vec); glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); } @@ -808,7 +811,7 @@ void bglVertex3f(float x, float y, float z) { switch(curmode) { case GL_POINTS: - if(pointhack) { + if (pointhack) { glRasterPos3f(x, y, z); glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); } @@ -821,7 +824,7 @@ void bglVertex2fv(const float vec[2]) { switch(curmode) { case GL_POINTS: - if(pointhack) { + if (pointhack) { glRasterPos2fv(vec); glBitmap(pointhack, pointhack, (float)pointhack/2, pointhack/2, 0.0, 0.0, Squaredot); } @@ -833,7 +836,7 @@ void bglVertex2fv(const float vec[2]) void bglEnd(void) { - if(pointhack) pointhack= 0; + if (pointhack) pointhack= 0; else glEnd(); } @@ -849,10 +852,10 @@ void bgl_get_mats(bglMats *mats) /* Very strange code here - it seems that certain bad values in the * modelview matrix can cause gluUnProject to give bad results. */ - if(mats->modelview[0] < badvalue && + if (mats->modelview[0] < badvalue && mats->modelview[0] > -badvalue) mats->modelview[0]= 0; - if(mats->modelview[5] < badvalue && + if (mats->modelview[5] < badvalue && mats->modelview[5] > -badvalue) mats->modelview[5]= 0; @@ -868,7 +871,7 @@ void bglPolygonOffset(float viewdist, float dist) { static float winmat[16], offset=0.0; - if(dist != 0.0f) { + if (dist != 0.0f) { float offs; // glEnable(GL_POLYGON_OFFSET_FILL); @@ -880,7 +883,7 @@ void bglPolygonOffset(float viewdist, float dist) /* dist is from camera to center point */ - if(winmat[15]>0.5f) offs= 0.00001f*dist*viewdist; // ortho tweaking + if (winmat[15]>0.5f) offs= 0.00001f*dist*viewdist; // ortho tweaking else offs= 0.0005f*dist; // should be clipping value or so... winmat[14]-= offs; @@ -903,7 +906,7 @@ void bglFlush(void) { glFlush(); #ifdef __APPLE__ -// if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) +// if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) // XXX myswapbuffers(); //hack to get mac intel graphics to show frontbuffer #endif } |