OpenGL: assume GL_TEXTURE_ENV_MODE GL_MODULATE is the default state.
This commit is contained in:
@@ -486,7 +486,7 @@ void BLF_rotation_default(float angle)
|
||||
}
|
||||
}
|
||||
|
||||
static void blf_draw_gl__start(FontBLF *font, GLint *mode, GLint *param)
|
||||
static void blf_draw_gl__start(FontBLF *font, GLint *mode)
|
||||
{
|
||||
/*
|
||||
* The pixmap alignment hack is handle
|
||||
@@ -523,19 +523,10 @@ static void blf_draw_gl__start(FontBLF *font, GLint *mode, GLint *param)
|
||||
|
||||
/* always bind the texture for the first glyph */
|
||||
font->tex_bind_state = -1;
|
||||
|
||||
/* Save the current parameter to restore it later. */
|
||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
||||
if (*param != GL_MODULATE)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
|
||||
static void blf_draw_gl__end(GLint mode, GLint param)
|
||||
static void blf_draw_gl__end(GLint mode)
|
||||
{
|
||||
/* and restore the original value. */
|
||||
if (param != GL_MODULATE)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glPopMatrix();
|
||||
|
||||
@@ -554,19 +545,19 @@ void BLF_draw_ex(
|
||||
struct ResultBLF *r_info)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
GLint mode, param;
|
||||
GLint mode;
|
||||
|
||||
BLF_RESULT_CHECK_INIT(r_info);
|
||||
|
||||
if (font && font->glyph_cache) {
|
||||
blf_draw_gl__start(font, &mode, ¶m);
|
||||
blf_draw_gl__start(font, &mode);
|
||||
if (font->flags & BLF_WORD_WRAP) {
|
||||
blf_font_draw__wrap(font, str, len, r_info);
|
||||
}
|
||||
else {
|
||||
blf_font_draw(font, str, len, r_info);
|
||||
}
|
||||
blf_draw_gl__end(mode, param);
|
||||
blf_draw_gl__end(mode);
|
||||
}
|
||||
}
|
||||
void BLF_draw(int fontid, const char *str, size_t len)
|
||||
@@ -579,12 +570,12 @@ void BLF_draw_ascii_ex(
|
||||
struct ResultBLF *r_info)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
GLint mode, param;
|
||||
GLint mode;
|
||||
|
||||
BLF_RESULT_CHECK_INIT(r_info);
|
||||
|
||||
if (font && font->glyph_cache) {
|
||||
blf_draw_gl__start(font, &mode, ¶m);
|
||||
blf_draw_gl__start(font, &mode);
|
||||
if (font->flags & BLF_WORD_WRAP) {
|
||||
/* use non-ascii draw function for word-wrap */
|
||||
blf_font_draw__wrap(font, str, len, r_info);
|
||||
@@ -592,7 +583,7 @@ void BLF_draw_ascii_ex(
|
||||
else {
|
||||
blf_font_draw_ascii(font, str, len, r_info);
|
||||
}
|
||||
blf_draw_gl__end(mode, param);
|
||||
blf_draw_gl__end(mode);
|
||||
}
|
||||
}
|
||||
void BLF_draw_ascii(int fontid, const char *str, size_t len)
|
||||
@@ -603,13 +594,13 @@ void BLF_draw_ascii(int fontid, const char *str, size_t len)
|
||||
int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
GLint mode, param;
|
||||
GLint mode;
|
||||
int columns = 0;
|
||||
|
||||
if (font && font->glyph_cache) {
|
||||
blf_draw_gl__start(font, &mode, ¶m);
|
||||
blf_draw_gl__start(font, &mode);
|
||||
columns = blf_font_draw_mono(font, str, len, cwidth);
|
||||
blf_draw_gl__end(mode, param);
|
||||
blf_draw_gl__end(mode);
|
||||
}
|
||||
|
||||
return columns;
|
||||
|
||||
@@ -511,7 +511,6 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
|
||||
/* Specify the color outside this function, and tex will modulate it.
|
||||
* This is useful for changing alpha without using glPixelTransferf()
|
||||
*/
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, img_w);
|
||||
glBindTexture(GL_TEXTURE_2D, texid);
|
||||
|
||||
@@ -620,7 +619,6 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ltexid);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, lrowlength);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* workaround for os x 10.5/10.6 driver bug (above) */
|
||||
@@ -1096,7 +1094,6 @@ void glaDrawImBuf_glsl(ImBuf *ibuf, float x, float y, int zoomfilter,
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
if (ibuf->rect_float) {
|
||||
|
||||
@@ -336,7 +336,6 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
@@ -460,7 +459,6 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
@@ -1083,7 +1083,6 @@ static void draw_plane_marker_image(Scene *scene,
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glColor4f(1.0, 1.0, 1.0, plane_track->image_opacity);
|
||||
|
||||
last_texid = glaGetOneInteger(GL_TEXTURE_2D);
|
||||
|
||||
@@ -1289,7 +1289,6 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
|
||||
}
|
||||
}
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
last_texid = glaGetOneInteger(GL_TEXTURE_2D);
|
||||
|
||||
@@ -805,8 +805,6 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *rect, float *frect, int
|
||||
|
||||
if (GLEW_EXT_texture_filter_anisotropic)
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
|
||||
/* set to modulate with vertex color */
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
if (ibuf)
|
||||
IMB_freeImBuf(ibuf);
|
||||
@@ -848,8 +846,6 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
if (GLEW_EXT_texture_filter_anisotropic)
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
|
||||
|
||||
@@ -2044,11 +2040,15 @@ static void gpu_multisample(bool enable)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Default OpenGL State */
|
||||
/* Default OpenGL State
|
||||
*
|
||||
* This is called on startup, for opengl offscreen render and to restore state
|
||||
* for the game engine. Generally we should always return to this state when
|
||||
* temporarily modifying the state for drawing, though that are (undocumented)
|
||||
* exceptions that we should try to get rid of. */
|
||||
|
||||
void GPU_state_init(void)
|
||||
{
|
||||
/* also called when doing opengl rendering and in the game engine */
|
||||
float mat_ambient[] = { 0.0, 0.0, 0.0, 0.0 };
|
||||
float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 };
|
||||
int a, x, y;
|
||||
|
||||
@@ -249,7 +249,6 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)mag);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
error = glGetError();
|
||||
|
||||
|
||||
@@ -486,8 +486,6 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
|
||||
glTexImage2D(triple->target, 0, GL_RGB8, triple->x[x], triple->y[y], 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(triple->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(triple->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
/* The current color is ignored if the GL_REPLACE texture environment is used. */
|
||||
// glTexEnvi(triple->target, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glBindTexture(triple->target, 0);
|
||||
|
||||
/* not sure if this works everywhere .. */
|
||||
|
||||
Reference in New Issue
Block a user