bool wxGLCanvasBase::SetColour(const wxString& colour) { wxColour col = wxTheColourDatabase->Find(colour); if ( !col.Ok() ) return false; GLboolean isRGBA; glGetBooleanv(GL_RGBA_MODE, &isRGBA); if ( isRGBA ) { glColor3f(col.Red() / 256., col.Green() / 256., col.Blue() / 256.); } else // indexed colour { GLint pix = GetColourIndex(col); if ( pix == -1 ) { wxLogError(_("Failed to allocate colour for OpenGL")); return false; } glIndexi(pix); } return true; }
bool wxGLCanvasBase::SetColour(const wxString& colour) { wxColour col = wxTheColourDatabase->Find(colour); if ( !col.IsOk() ) return false; #ifdef wxHAS_OPENGL_ES wxGLAPI::glColor3f((GLfloat) (col.Red() / 256.), (GLfloat) (col.Green() / 256.), (GLfloat) (col.Blue() / 256.)); #else GLboolean isRGBA; glGetBooleanv(GL_RGBA_MODE, &isRGBA); if ( isRGBA ) { glColor3f((GLfloat) (col.Red() / 256.), (GLfloat) (col.Green() / 256.), (GLfloat) (col.Blue() / 256.)); } else // indexed colour { GLint pix = GetColourIndex(col); if ( pix == -1 ) { wxLogError(_("Failed to allocate colour for OpenGL")); return false; } glIndexi(pix); } #endif return true; }