PlotWidget::PlotWidget(QWidget * parent) : KPlotWidget(parent) , mKpoBCWP(NULL) , mKpoBCWS(NULL) , mKpoACWP(NULL) { kDebug() << "------------> ChartWidget :: Constructor"<<endl; // UI Parameters setBackgroundColor(Qt::white); setForegroundColor(Qt::black); setGridColor(Qt::black); setAntialiasing(false); // // creating a plot object whose points are connected by red lines // mKpoBCWP = new KPlotObject( Qt::black, KPlotObject::Lines ); // mKpoBCWS = new KPlotObject( Qt::green, KPlotObject::Lines ); // mKpoACWP = new KPlotObject( Qt::red, KPlotObject::Lines ); // // // ... and adding the object to the plot widget // addPlotObject(mKpoBCWP); // addPlotObject(mKpoBCWS); // addPlotObject(mKpoACWP); kDebug() << "ChartWidget :: Constructor Ended"<<endl; }
MyGraphicsView::MyGraphicsView(QObject * /*parent*/) : QGraphicsView(), m_rotation(0.0) { setDragMode(QGraphicsView::RubberBandDrag); setAntialiasing(g_settings->antialiasing); setViewportUpdateMode(QGraphicsView::FullViewportUpdate); }
ChartsTimeGraph::ChartsTimeGraph( QQuickItem* parent ) : QQuickItem( parent ) { setFlag( ItemHasContents, true ); setSmooth( true ); setAntialiasing( true ); }
DemoQPItem::DemoQPItem(QQuickItem *parent) : QQuickPaintedItem(parent) , m_animationTime(0.0) , m_enabledTests(0) , m_testCount(1) , m_qpAntialiasing(true) , m_qpRenderTargetFBO(false) { // Setup colors m_colorWhite = QColor(255,255,255,255); m_colorGray = QColor(180,180,180,255); m_colorBlack = QColor(0,0,0,255); m_color1 = QColor(180,190,40,20); m_color2 = QColor(255,255,255,150); m_color3 = QColor(255,255,255,80); m_circleImage = QImage(":/qml/images/circle.png"); // Load custom font int id = QFontDatabase::addApplicationFont(":/qml/fonts/Roboto-Regular.ttf"); QStringList s = QFontDatabase::applicationFontFamilies(id); m_testFont = QFont(s.at(0)); // Set antialiasing and render target setAntialiasing(m_qpAntialiasing); setRenderTarget(m_qpRenderTargetFBO ? QQuickPaintedItem::FramebufferObject : QQuickPaintedItem::Image); // Enable this to try FastFBOResizing //setPerformanceHint(QQuickPaintedItem::FastFBOResizing, true); }
void QQuickContext2DTexture::canvasChanged(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing) { QSize ts = tileSize; if (ts.width() > canvasSize.width()) ts.setWidth(canvasSize.width()); if (ts.height() > canvasSize.height()) ts.setHeight(canvasSize.height()); setCanvasSize(canvasSize); setTileSize(ts); setCanvasWindow(canvasWindow); if (canvasSize == canvasWindow.size()) { m_tiledCanvas = false; } else { m_tiledCanvas = true; } if (dirtyRect.isValid()) setDirtyRect(dirtyRect); setSmooth(smooth); setAntialiasing(antialiasing); }
QmlMitkSliderLevelWindowItem::QmlMitkSliderLevelWindowItem( QQuickPaintedItem * parent ) : QQuickPaintedItem(parent) { m_Manager = mitk::LevelWindowManager::New(); m_Manager->SetDataStorage(QmlMitkSliderLevelWindowItem::storage); itk::ReceptorMemberCommand<QmlMitkSliderLevelWindowItem>::Pointer command = itk::ReceptorMemberCommand<QmlMitkSliderLevelWindowItem>::New(); command->SetCallbackFunction(this, &QmlMitkSliderLevelWindowItem::OnPropertyModified); m_ObserverTag = m_Manager->AddObserver(itk::ModifiedEvent(), command); m_IsObserverTagSet = true; setAcceptedMouseButtons(Qt::AllButtons); setAcceptHoverEvents(true); setAntialiasing(true); m_Resize = false; m_Bottom = false; m_CtrlPressed = false; m_MouseDown = false; m_ScaleVisible = true; this->setEnabled(false); update(); }
GraphConnection::GraphConnection(QQuickItem *parent) : QQuickItem(parent), m_source(), m_sink() { setFlag(ItemHasContents, true); setAntialiasing(true); }
MachinePage::MachinePage(QObject *parent) : PagePlugin(parent) { m_componentUrl.setUrl("qrc:/machineparameters/main.qml"); m_model = Datahandling::createParameterModel(); connect(this, SIGNAL(engineChanged()), this, SLOT(setModel()), Qt::DirectConnection); connect(this, SIGNAL(componentCreated()), this, SLOT(setAntialiasing()), Qt::DirectConnection); }
PolygonItem::PolygonItem(QQuickItem *parent) : QQuickPaintedItem(parent), _color(QColor(255, 255, 255)) { setAntialiasing(true); connect(this, SIGNAL(widthChanged()), SLOT(onAppearanceChanged())); connect(this, SIGNAL(heightChanged()), SLOT(onAppearanceChanged())); connect(this, SIGNAL(colorChanged()), SLOT(onAppearanceChanged())); }
AVTPlotWidget::AVTPlotWidget( QWidget *parent ) : KPlotWidget( parent ) { setAntialiasing(true); //Default SunRise/SunSet values SunRise = 0.25; SunSet = 0.75; MousePoint = QPoint( -1, -1 ); }
QMLProfile::QMLProfile(QQuickItem *parent) : QQuickPaintedItem(parent), m_devicePixelRatio(1.0), m_margin(0) { setAntialiasing(true); m_profileWidget = new ProfileWidget2(0); m_profileWidget->setProfileState(); m_profileWidget->setPrintMode(true); m_profileWidget->setFontPrintScale(0.8); //m_profileWidget->setGeometry(this->geometry()); }
QMLProfile::QMLProfile(QQuickItem *parent) : QQuickPaintedItem(parent), m_devicePixelRatio(1.0), m_margin(0) { setAntialiasing(true); m_profileWidget = new ProfileWidget2(0); m_profileWidget->setProfileState(); m_profileWidget->setPrintMode(true); m_profileWidget->setFontPrintScale(0.8); connect(QMLManager::instance(), &QMLManager::sendScreenChanged, this, &QMLProfile::screenChanged); setDevicePixelRatio(QMLManager::instance()->lastDevicePixelRatio()); }
FeatureListModelHighlight::FeatureListModelHighlight( QQuickItem* parent ) : QQuickItem( parent ) , mModel( nullptr ) , mSelection( nullptr ) , mDirty( false ) , mMapSettings( nullptr ) { setFlags( QQuickItem::ItemHasContents ); setAntialiasing( true ); connect( this, &FeatureListModelHighlight::modelChanged, this, &FeatureListModelHighlight::onDataChanged ); connect( this, &FeatureListModelHighlight::selectionChanged, this, &FeatureListModelHighlight::onDataChanged ); }
ParameterPlotter::ParameterPlotter(QWidget *parent) : KPlotWidget(parent) { setAntialiasing(true); setLeftPadding(20); setRightPadding(10); setTopPadding(10); setBottomPadding(20); m_movepoint = NULL; m_colors << Qt::white << Qt::red << Qt::green << Qt::blue << Qt::magenta << Qt::gray << Qt::cyan; m_moveX = false; m_moveY = true; m_moveTimeline = true; m_newPoints = false; m_activeIndexPlot = -1; m_max_y = 0; m_min_y = 0; }
void JSonIO::reset(){ parserState = 0; setOutputFile("empty"); setTopFace("empty"); setBottomFace("empty"); setLeftFace("empty"); setRightFace("empty"); setFrontFace("empty"); setBackFace("empty"); setFrameStart(0); setFrameStop(0); setOutputWidth(0); setAntialiasing(0); setAaPattern("grid"); frames.clear(); }
ArcStyle::ArcStyle(QQuickItem *parent) : QQuickPaintedItem(parent), m_value(0), m_minValue(0), m_maxValue(100), m_stepSize(0.1), m_readOnly(false), m_color(QColor(135,206,235)), m_factor(57.6), m_scale(16 / m_factor), m_startAngle(-1680), m_spanAngle(480), m_offset((1440) + ( m_spanAngle / 2 )), m_anim(NULL) { setAntialiasing(true); #if defined Q_OS_LINUX || defined Q_OS_MAC setRenderTarget(QQuickPaintedItem::FramebufferObject); #endif }
void JSonIO::loadJSon(QString filePath){ parserState = 0; QJson::Parser parser; QFile jsonFile(filePath); if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)){ parserState = 1; return; } QTextStream in(&jsonFile); QString json = in.readAll(); jsonFile.close(); bool ok; QVariantMap result = parser.parse(json.toAscii(), &ok).toMap(); if (!ok) { parserState = 2; } setOutputFile(result["outputFile"].toString()); setTopFace(result["topFace"].toString()); setBottomFace(result["bottomFace"].toString()); setLeftFace(result["leftFace"].toString()); setRightFace(result["rightFace"].toString()); setFrontFace(result["frontFace"].toString()); setBackFace(result["backFace"].toString()); setFrameStart(result["frameStart"].toInt()); setFrameStop(result["frameStop"].toInt()); setOutputWidth(result["outputWidth"].toInt()); setAntialiasing(result["antialiasing"].toInt()); setAaPattern(result["aaPattern"].toString()); frames = result["frames"].toList(); }
Graphics::PixelBuffer SurfaceSdlGraphicsManager::setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d) { uint32 sdlflags; int bpp; closeOverlay(); #ifdef USE_OPENGL _opengl = accel3d; _antialiasing = 0; #endif _fullscreen = fullscreen; #ifdef USE_OPENGL if (_opengl) { if (ConfMan.hasKey("antialiasing")) _antialiasing = ConfMan.getInt("antialiasing"); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); setAntialiasing(true); sdlflags = SDL_OPENGL; bpp = 24; } else #endif { bpp = 16; sdlflags = SDL_HWSURFACE; } if (_fullscreen) sdlflags |= SDL_FULLSCREEN; _screen = SDL_SetVideoMode(screenW, screenH, bpp, sdlflags); #ifdef USE_OPENGL // If 32-bit with antialiasing failed, try 32-bit without antialiasing if (!_screen && _opengl && _antialiasing) { warning("Couldn't create 32-bit visual with AA, trying 32-bit without AA"); setAntialiasing(false); _screen = SDL_SetVideoMode(screenW, screenH, bpp, sdlflags); } // If 32-bit failed, try 16-bit if (!_screen && _opengl) { warning("Couldn't create 32-bit visual, trying 16-bit"); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 1); setAntialiasing(true); _screen = SDL_SetVideoMode(screenW, screenH, 0, sdlflags); } // If 16-bit with antialiasing failed, try 16-bit without antialiasing if (!_screen && _opengl && _antialiasing) { warning("Couldn't create 16-bit visual with AA, trying 16-bit without AA"); setAntialiasing(false); _screen = SDL_SetVideoMode(screenW, screenH, 0, sdlflags); } #endif if (!_screen) error("Could not initialize video: %s", SDL_GetError()); #ifdef USE_OPENGL if (_opengl) { int glflag; // apply atribute again for sure based on SDL docs SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &glflag); warning("INFO: GL RED bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &glflag); warning("INFO: GL GREEN bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &glflag); warning("INFO: GL BLUE bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &glflag); warning("INFO: GL APLHA bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &glflag); warning("INFO: GL Z buffer depth bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &glflag); warning("INFO: GL Double Buffer: %d", glflag); SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &glflag); warning("INFO: GL Stencil buffer bits: %d", glflag); } #endif _overlayWidth = screenW; _overlayHeight = screenH; #ifdef USE_OPENGL if (_opengl) { uint32 rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0x00001f00; gmask = 0x000007e0; bmask = 0x000000f8; amask = 0x00000000; #else rmask = 0x0000f800; gmask = 0x000007e0; bmask = 0x0000001f; amask = 0x00000000; #endif _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, rmask, gmask, bmask, amask); } else #endif { _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, _screen->format->Rmask, _screen->format->Gmask, _screen->format->Bmask, _screen->format->Amask); } if (!_overlayscreen) error("allocating _overlayscreen failed"); /*_overlayFormat.bytesPerPixel = _overlayscreen->format->BytesPerPixel; // For some reason the values below aren't right, at least on my system _overlayFormat.rLoss = _overlayscreen->format->Rloss; _overlayFormat.gLoss = _overlayscreen->format->Gloss; _overlayFormat.bLoss = _overlayscreen->format->Bloss; _overlayFormat.aLoss = _overlayscreen->format->Aloss; _overlayFormat.rShift = _overlayscreen->format->Rshift; _overlayFormat.gShift = _overlayscreen->format->Gshift; _overlayFormat.bShift = _overlayscreen->format->Bshift; _overlayFormat.aShift = _overlayscreen->format->Ashift;*/ _overlayFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); _screenChangeCount++; SDL_PixelFormat *f = _screen->format; _screenFormat = Graphics::PixelFormat(f->BytesPerPixel, 8 - f->Rloss, 8 - f->Gloss, 8 - f->Bloss, 0, f->Rshift, f->Gshift, f->Bshift, f->Ashift); return Graphics::PixelBuffer(_screenFormat, (byte *)_screen->pixels); }
GraphView::GraphView( QQuickItem* parent ) : qan::Navigable{ parent } { setAntialiasing( true ); setSmooth( true ); }
InteractiveConnectionItem::InteractiveConnectionItem(QQuickItem* parent /*= 0*/) : QQuickItem(parent) { setFlag(QQuickItem::ItemHasContents); setAntialiasing(true); }
Graphics::PixelBuffer SurfaceSdlGraphicsManager::setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d) { uint32 sdlflags; int bpp; closeOverlay(); #ifdef USE_OPENGL _opengl = accel3d; _antialiasing = 0; #endif _fullscreen = fullscreen; ConfMan.registerDefault("fullscreen_res", "desktop"); const Common::String &fsres = ConfMan.get("fullscreen_res"); if (fsres != "desktop") { uint newW, newH; int converted = sscanf(fsres.c_str(), "%ux%u", &newW, &newH); if (converted == 2) { _desktopW = newW; _desktopH = newH; } else { warning("Could not parse 'fullscreen_res' option: expected WWWxHHH, got %s", fsres.c_str()); } } ConfMan.registerDefault("aspect_ratio", true); _lockAspectRatio = ConfMan.getBool("aspect_ratio"); uint fbW = screenW; uint fbH = screenH; _gameRect = Math::Rect2d(Math::Vector2d(0, 0), Math::Vector2d(1, 1)); #ifdef USE_OPENGL bool framebufferSupported = false; // Use the desktop resolution for fullscreen when possible if (_fullscreen) { if (g_engine->hasFeature(Engine::kSupportsArbitraryResolutions)) { // If the game supports arbitrary resolutions, use the desktop mode as the game mode screenW = _desktopW; screenH = _desktopH; } else if (_opengl) { // If available, draw to a framebuffer and scale it to the desktop resolution #ifndef AMIGAOS // Spawn a 32x32 window off-screen SDL_putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=9000,9000")); SDL_SetVideoMode(32, 32, 0, SDL_OPENGL); SDL_putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=centered")); Graphics::initExtensions(); framebufferSupported = Graphics::isExtensionSupported("GL_EXT_framebuffer_object"); if (_fullscreen && framebufferSupported) { screenW = _desktopW; screenH = _desktopH; if (_lockAspectRatio) { float scale = MIN(_desktopH / float(fbH), _desktopW / float(fbW)); float scaledW = scale * (fbW / float(_desktopW)); float scaledH = scale * (fbH / float(_desktopH)); _gameRect = Math::Rect2d( Math::Vector2d(0.5 - (0.5 * scaledW), 0.5 - (0.5 * scaledH)), Math::Vector2d(0.5 + (0.5 * scaledW), 0.5 + (0.5 * scaledH)) ); } } #endif } } if (_opengl) { if (ConfMan.hasKey("antialiasing")) _antialiasing = ConfMan.getInt("antialiasing"); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); setAntialiasing(true); sdlflags = SDL_OPENGL; bpp = 24; } else #endif { bpp = 16; sdlflags = SDL_SWSURFACE; } if (_fullscreen && !accel3d && _lockAspectRatio) { screenW = _desktopW; screenH = _desktopH; _gameRect = Math::Rect2d( Math::Vector2d((_desktopW - fbW) / 2, (_desktopH - fbH) / 2), Math::Vector2d((_desktopW + fbW) / 2, (_desktopH + fbH) / 2) ); } if (_fullscreen) sdlflags |= SDL_FULLSCREEN; _screen = SDL_SetVideoMode(screenW, screenH, bpp, sdlflags); #ifdef USE_OPENGL // If 32-bit with antialiasing failed, try 32-bit without antialiasing if (!_screen && _opengl && _antialiasing) { warning("Couldn't create 32-bit visual with AA, trying 32-bit without AA"); setAntialiasing(false); _screen = SDL_SetVideoMode(screenW, screenH, bpp, sdlflags); } // If 32-bit failed, try 16-bit if (!_screen && _opengl) { warning("Couldn't create 32-bit visual, trying 16-bit"); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 1); setAntialiasing(true); _screen = SDL_SetVideoMode(screenW, screenH, 0, sdlflags); } // If 16-bit with antialiasing failed, try 16-bit without antialiasing if (!_screen && _opengl && _antialiasing) { warning("Couldn't create 16-bit visual with AA, trying 16-bit without AA"); setAntialiasing(false); _screen = SDL_SetVideoMode(screenW, screenH, 0, sdlflags); } // If 16-bit with alpha failed, try 16-bit without alpha if (!_screen && _opengl) { warning("Couldn't create 16-bit visual with alpha, trying without alpha"); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); setAntialiasing(true); _screen = SDL_SetVideoMode(screenW, screenH, 0, sdlflags); } // If 16-bit without alpha and with antialiasing didn't work, try without antialiasing if (!_screen && _opengl && _antialiasing) { warning("Couldn't create 16-bit visual with AA, trying 16-bit without AA"); setAntialiasing(false); _screen = SDL_SetVideoMode(screenW, screenH, 0, sdlflags); } #endif if (!_screen) { warning("Error: %s", SDL_GetError()); g_system->quit(); } #ifdef USE_OPENGL if (_opengl) { int glflag; const GLubyte *str; // apply atribute again for sure based on SDL docs SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); str = glGetString(GL_VENDOR); debug("INFO: OpenGL Vendor: %s", str); str = glGetString(GL_RENDERER); debug("INFO: OpenGL Renderer: %s", str); str = glGetString(GL_VERSION); debug("INFO: OpenGL Version: %s", str); SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &glflag); debug("INFO: OpenGL Red bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &glflag); debug("INFO: OpenGL Green bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &glflag); debug("INFO: OpenGL Blue bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &glflag); debug("INFO: OpenGL Alpha bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &glflag); debug("INFO: OpenGL Z buffer depth bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &glflag); debug("INFO: OpenGL Double Buffer: %d", glflag); SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &glflag); debug("INFO: OpenGL Stencil buffer bits: %d", glflag); #ifdef USE_GLEW debug("INFO: GLEW Version: %s", glewGetString(GLEW_VERSION)); GLenum err = glewInit(); if (err != GLEW_OK) { warning("Error: %s", glewGetErrorString(err)); g_system->quit(); } #endif #ifdef USE_OPENGL_SHADERS debug("INFO: GLSL version: %s", glGetString(GL_SHADING_LANGUAGE_VERSION)); const GLfloat vertices[] = { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, }; // Setup the box shader used to render the overlay const char* attributes[] = { "position", "texcoord", NULL }; _boxShader = Graphics::Shader::fromStrings("box", Graphics::BuiltinShaders::boxVertex, Graphics::BuiltinShaders::boxFragment, attributes); _boxVerticesVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(vertices), vertices); _boxShader->enableVertexAttribute("position", _boxVerticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); _boxShader->enableVertexAttribute("texcoord", _boxVerticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); #endif Graphics::initExtensions(); } #endif _overlayWidth = screenW; _overlayHeight = screenH; #ifdef USE_OPENGL if (_opengl) { uint32 rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0x00001f00; gmask = 0x000007e0; bmask = 0x000000f8; amask = 0x00000000; #else rmask = 0x0000f800; gmask = 0x000007e0; bmask = 0x0000001f; amask = 0x00000000; #endif _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, rmask, gmask, bmask, amask); _overlayScreenGLFormat = GL_UNSIGNED_SHORT_5_6_5; } else #endif { _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, _screen->format->Rmask, _screen->format->Gmask, _screen->format->Bmask, _screen->format->Amask); } if (!_overlayscreen) { warning("Error: %s", SDL_GetError()); g_system->quit(); } /*_overlayFormat.bytesPerPixel = _overlayscreen->format->BytesPerPixel; // For some reason the values below aren't right, at least on my system _overlayFormat.rLoss = _overlayscreen->format->Rloss; _overlayFormat.gLoss = _overlayscreen->format->Gloss; _overlayFormat.bLoss = _overlayscreen->format->Bloss; _overlayFormat.aLoss = _overlayscreen->format->Aloss; _overlayFormat.rShift = _overlayscreen->format->Rshift; _overlayFormat.gShift = _overlayscreen->format->Gshift; _overlayFormat.bShift = _overlayscreen->format->Bshift; _overlayFormat.aShift = _overlayscreen->format->Ashift;*/ _overlayFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); _screenChangeCount++; SDL_PixelFormat *f = _screen->format; _screenFormat = Graphics::PixelFormat(f->BytesPerPixel, 8 - f->Rloss, 8 - f->Gloss, 8 - f->Bloss, 0, f->Rshift, f->Gshift, f->Bshift, f->Ashift); #if defined(USE_OPENGL) && !defined(AMIGAOS) if (_opengl && _fullscreen && !g_engine->hasFeature(Engine::kSupportsArbitraryResolutions) && framebufferSupported) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); _frameBuffer = new Graphics::FrameBuffer(fbW, fbH); _frameBuffer->attach(); } #endif if (_fullscreen && !accel3d) { _subScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, fbW, fbH, bpp, _screen->format->Rmask, _screen->format->Gmask, _screen->format->Bmask, _screen->format->Amask); return Graphics::PixelBuffer(_screenFormat, (byte *)_subScreen->pixels); } return Graphics::PixelBuffer(_screenFormat, (byte *)_screen->pixels); }
Graphics::PixelBuffer SurfaceSdlGraphicsManager::setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d) { uint32 sdlflags; int bpp; closeOverlay(); #ifdef USE_OPENGL _opengl = accel3d; _antialiasing = 0; #endif _fullscreen = fullscreen; #ifdef USE_OPENGL if (_opengl) { if (ConfMan.hasKey("antialiasing")) _antialiasing = ConfMan.getInt("antialiasing"); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); setAntialiasing(true); sdlflags = SDL_OPENGL; bpp = 24; } else #endif { bpp = 16; sdlflags = SDL_SWSURFACE; } if (_fullscreen) sdlflags |= SDL_FULLSCREEN; _screen = SDL_SetVideoMode(screenW, screenH, bpp, sdlflags); #ifdef USE_OPENGL // If 32-bit with antialiasing failed, try 32-bit without antialiasing if (!_screen && _opengl && _antialiasing) { warning("Couldn't create 32-bit visual with AA, trying 32-bit without AA"); setAntialiasing(false); _screen = SDL_SetVideoMode(screenW, screenH, bpp, sdlflags); } // If 32-bit failed, try 16-bit if (!_screen && _opengl) { warning("Couldn't create 32-bit visual, trying 16-bit"); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 1); setAntialiasing(true); _screen = SDL_SetVideoMode(screenW, screenH, 0, sdlflags); } // If 16-bit with antialiasing failed, try 16-bit without antialiasing if (!_screen && _opengl && _antialiasing) { warning("Couldn't create 16-bit visual with AA, trying 16-bit without AA"); setAntialiasing(false); _screen = SDL_SetVideoMode(screenW, screenH, 0, sdlflags); } #endif if (!_screen) { warning("Error: %s", SDL_GetError()); g_system->quit(); } #ifdef USE_OPENGL if (_opengl) { int glflag; const GLubyte *str; // apply atribute again for sure based on SDL docs SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); str = glGetString(GL_VENDOR); debug("INFO: OpenGL Vendor: %s", str); str = glGetString(GL_RENDERER); debug("INFO: OpenGL Renderer: %s", str); str = glGetString(GL_VERSION); debug("INFO: OpenGL Version: %s", str); SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &glflag); debug("INFO: OpenGL Red bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &glflag); debug("INFO: OpenGL Green bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &glflag); debug("INFO: OpenGL Blue bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &glflag); debug("INFO: OpenGL Alpha bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &glflag); debug("INFO: OpenGL Z buffer depth bits: %d", glflag); SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &glflag); debug("INFO: OpenGL Double Buffer: %d", glflag); SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &glflag); debug("INFO: OpenGL Stencil buffer bits: %d", glflag); #ifdef USE_OPENGL_SHADERS debug("INFO: GLSL version: %s", glGetString(GL_SHADING_LANGUAGE_VERSION)); debug("INFO: GLEW Version: %s", glewGetString(GLEW_VERSION)); // GLEW needs to be initialized to use shaders GLenum err = glewInit(); if (err != GLEW_OK) { warning("Error: %s", glewGetErrorString(err)); g_system->quit(); } const GLfloat vertices[] = { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, }; // Setup the box shader used to render the overlay const char* attributes[] = { "position", "texcoord", NULL }; _boxShader = Graphics::Shader::fromStrings("box", Graphics::BuiltinShaders::boxVertex, Graphics::BuiltinShaders::boxFragment, attributes); _boxVerticesVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(vertices), vertices); _boxShader->enableVertexAttribute("position", _boxVerticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); _boxShader->enableVertexAttribute("texcoord", _boxVerticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); #endif } #endif _overlayWidth = screenW; _overlayHeight = screenH; #ifdef USE_OPENGL if (_opengl) { uint32 rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0x00001f00; gmask = 0x000007e0; bmask = 0x000000f8; amask = 0x00000000; #else rmask = 0x0000f800; gmask = 0x000007e0; bmask = 0x0000001f; amask = 0x00000000; #endif _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, rmask, gmask, bmask, amask); _overlayScreenGLFormat = GL_UNSIGNED_SHORT_5_6_5; } else #endif { _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, _screen->format->Rmask, _screen->format->Gmask, _screen->format->Bmask, _screen->format->Amask); } if (!_overlayscreen) { warning("Error: %s", SDL_GetError()); g_system->quit(); } /*_overlayFormat.bytesPerPixel = _overlayscreen->format->BytesPerPixel; // For some reason the values below aren't right, at least on my system _overlayFormat.rLoss = _overlayscreen->format->Rloss; _overlayFormat.gLoss = _overlayscreen->format->Gloss; _overlayFormat.bLoss = _overlayscreen->format->Bloss; _overlayFormat.aLoss = _overlayscreen->format->Aloss; _overlayFormat.rShift = _overlayscreen->format->Rshift; _overlayFormat.gShift = _overlayscreen->format->Gshift; _overlayFormat.bShift = _overlayscreen->format->Bshift; _overlayFormat.aShift = _overlayscreen->format->Ashift;*/ _overlayFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); _screenChangeCount++; SDL_PixelFormat *f = _screen->format; _screenFormat = Graphics::PixelFormat(f->BytesPerPixel, 8 - f->Rloss, 8 - f->Gloss, 8 - f->Bloss, 0, f->Rshift, f->Gshift, f->Bshift, f->Ashift); return Graphics::PixelBuffer(_screenFormat, (byte *)_screen->pixels); }