void VBoxDDRAWFrameBuffer::resizeEvent (VBoxResizeEvent *re) { LOGDDRAW (("DDRAW: resizeEvent %d, %p, %d %d %dx%d\n", re->pixelFormat(), re->VRAM(), re->bitsPerPixel(), re->bytesPerLine(), re->width(), re->height())); VBoxFrameBuffer::resizeEvent (re); bool ok = createSurface (re->pixelFormat(), re->VRAM (), re->bitsPerPixel(), re->bytesPerLine (), re->width(), re->height()); if (!ok && re->pixelFormat() != FramebufferPixelFormat_Opaque) { /* try to create a fallback surface with indirect buffer * (only if haven't done so already) */ ok = createSurface (FramebufferPixelFormat_Opaque, NULL, 0, 0, re->width(), re->height()); } Assert (ok); getWindowPosition(); //#warning: port me // mView->setBackgroundMode (Qt::NoBackground); }
static int updateGL(struct engine* engine) { GK_BOOL init = engine->context == EGL_NO_CONTEXT; EGLint w, h; if (init) { initDisplay(engine); createSurface(engine); engine->context = eglCreateContext(engine->display, engine->config, NULL, NULL); }else { createSurface(engine); } if (!bindContext(engine, GK_TRUE)) return -1; GLEE_EXT_framebuffer_object = (strstr((const char*)glGetString(GL_EXTENSIONS), "OES_framebuffer_object")?GK_TRUE:GK_FALSE); eglQuerySurface(engine->display, engine->surface, EGL_WIDTH, &w); eglQuerySurface(engine->display, engine->surface, EGL_HEIGHT, &h); if (init) { gkScreenSize.width = w; gkScreenSize.height = h; } else { onWindowSizeChanged(GK_SIZE(w, h)); } engine->initialized = GK_TRUE; engine->animating = GK_TRUE; return 0; }
bool COpenGL::createSurfaces() { // This function creates the surfaces which are needed for the game. const CRect<Uint16> gamerect = m_VidConfig.m_GameRect; ScrollSurface = createSurface( "ScrollSurface", true, 512, 512, RES_BPP, m_Mode, screen->format ); g_pLogFile->textOut("Blitsurface = creatergbsurface<br>"); BlitSurface = createSurface( "BlitSurface", true, getPowerOfTwo(gamerect.w), getPowerOfTwo(gamerect.h), RES_BPP, m_Mode, screen->format ); g_pLogFile->textOut("FilteredSurface = creatergbsurface<br>"); FilteredSurface = createSurface( "FilteredSurface", true, BlitSurface->w*m_VidConfig.m_ScaleXFilter, BlitSurface->h*m_VidConfig.m_ScaleXFilter, RES_BPP, m_Mode, screen->format ); m_dst_slice = FilteredSurface->w*screen->format->BytesPerPixel; if(m_VidConfig.m_ScaleXFilter == 1) { FXSurface = createSurface( "FXSurface", true, getPowerOfTwo(gamerect.w), getPowerOfTwo(gamerect.h), RES_BPP, m_Mode, screen->format ); } else { FXSurface = createSurface( "FXSurface", false, gamerect.w, gamerect.h, RES_BPP, m_Mode, screen->format ); //Set surface alpha } g_pGfxEngine->Palette.setFXSurface( FXSurface ); Scaler.setFilterFactor(m_VidConfig.m_ScaleXFilter); Scaler.setFilterType(m_VidConfig.m_normal_scale); Scaler.setDynamicFactor( float(FilteredSurface->w)/float(screen->w), float(FilteredSurface->h)/float(screen->h)); return true; }
void MapperGui::prepareWorldImage(){ /************************************** Make sure the Cache exists and is still relevent ***************************************/ // check if the map has been edited since last drawn // if so, regen layer images if( mapTouched ){ // check if there a no world if( world != NULL ){ // check if layers are initialised if( !world->empty() ){ Layer& workingLayer = world->getLayer(layerToggleBox->getWorkingLayer()); // check if the worldImage exists and is coherrent if( worldImage == NULL ){ // there is no world image, create one worldImage = createSurface( workingLayer.getWidth()* workingLayer.getTileWidth(), workingLayer.getHeight()* workingLayer.getTileHeight(), graphics->getTarget()->format->BitsPerPixel, SDL_SWSURFACE ); } else // a world image exists, but it is the wrong dimensions if ( ( worldImage->w != workingLayer.getWidth()* workingLayer.getTileWidth() ) || ( worldImage->h != workingLayer.getHeight()* workingLayer.getTileHeight() ) ) { //free old image SDL_FreeSurface(worldImage); //creaet new one of correct dimensions worldImage = createSurface( workingLayer.getWidth()* workingLayer.getTileWidth(), workingLayer.getHeight()* workingLayer.getTileHeight(), graphics->getTarget()->format->BitsPerPixel, SDL_SWSURFACE ); } //match the dimensions of the world image and the PlaceHolder worldImagePlaceHolder->setWidth( worldImage->w ); worldImagePlaceHolder->setHeight( worldImage->h ); //now that worldImage is properly initialised, draw the world onto it drawWorld(); } // end layers exists }// end if world exists mapTouched = 0; }// end if touched }
void tst_QOpenGL::openGLPaintDevice() { #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__) QSKIP("QTBUG-22617"); #endif QFETCH(int, surfaceClass); QScopedPointer<QSurface> surface(createSurface(surfaceClass)); QOpenGLContext ctx; QVERIFY(ctx.create()); QSurfaceFormat format = ctx.format(); if (format.majorVersion() < 2) QSKIP("This test requires at least OpenGL 2.0"); QVERIFY(ctx.makeCurrent(surface.data())); const QSize size(128, 128); QImage image(size, QImage::Format_RGB32); QPainter p(&image); p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red); p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green); p.fillRect(image.width() / 2, image.height() / 2, image.width() / 2, image.height() / 2, Qt::blue); p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white); p.end(); QOpenGLFramebufferObject fbo(size); QVERIFY(fbo.bind()); QOpenGLPaintDevice device(size); QVERIFY(p.begin(&device)); p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red); p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green); p.fillRect(image.width() / 2, image.height() / 2, image.width() / 2, image.height() / 2, Qt::blue); p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white); p.end(); QImage actual = fbo.toImage().convertToFormat(QImage::Format_RGB32); QCOMPARE(image.size(), actual.size()); QCOMPARE(image, actual); QVERIFY(p.begin(&device)); p.fillRect(0, 0, image.width(), image.height(), Qt::black); p.drawImage(0, 0, image); p.end(); actual = fbo.toImage().convertToFormat(QImage::Format_RGB32); QCOMPARE(image.size(), actual.size()); QCOMPARE(image, actual); QVERIFY(p.begin(&device)); p.fillRect(0, 0, image.width(), image.height(), Qt::black); p.fillRect(0, 0, image.width(), image.height(), QBrush(image)); p.end(); actual = fbo.toImage().convertToFormat(QImage::Format_RGB32); QCOMPARE(image.size(), actual.size()); QCOMPARE(image, actual); }
void drawTextBox(SDL_Surface *dst, const string s[], int numLines, TTF_Font *font, int x, int y){ SDL_Color col = {0xDD, 0xDD, 0xDD, 0xDD}; int max_w = 0, pos = y, w, h; SDL_Surface **textImgs = new SDL_Surface *[numLines]; for(int i=0; i<numLines; i++){ TTF_SizeText(font, s[i].c_str(), &w, &h); textImgs[i] = TTF_RenderText_Blended(font, s[i].c_str(), col); if(w > max_w) max_w = w; } SDL_Surface *bg = createSurface(max_w + 8, h*numLines); SDL_FillRect(bg, NULL, 0); SDL_SetAlpha(bg, SDL_SRCALPHA, 128); x -= bg->w/2; blitSurface(bg, dst, x, y); SDL_FreeSurface(bg); for(int i=0; i<numLines; i++){ if(textImgs[i]){ blitSurface(textImgs[i], dst, x+4 ,y+h*i); SDL_FreeSurface(textImgs[i]); } } delete [] textImgs; }
SDL_Surface *getImageFromTexMap(SDL_Surface *tm, int x, int y, int w, int h){ SDL_Surface *dst = createSurface(w,h); SDL_SetColorKey( dst, SDL_RLEACCEL | SDL_SRCCOLORKEY, 0 ); blitClippedSurface(tm, x, y, w, h, dst, 0, 0); return dst; }
status_t BnSurfaceComposerClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case CREATE_SURFACE: { CHECK_INTERFACE(ISurfaceComposerClient, data, reply); surface_data_t params; String8 name = data.readString8(); DisplayID display = data.readInt32(); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); PixelFormat format = data.readInt32(); uint32_t flags = data.readInt32(); sp<ISurface> s = createSurface(¶ms, name, display, w, h, format, flags); params.writeToParcel(reply); reply->writeStrongBinder(s->asBinder()); return NO_ERROR; } break; case DESTROY_SURFACE: { CHECK_INTERFACE(ISurfaceComposerClient, data, reply); reply->writeInt32( destroySurface( data.readInt32() ) ); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
SurfacePtr VaapiEncoderBase::createSurface(VideoFrameRawData* frame) { SurfacePtr surface = createSurface(frame->fourcc); SurfacePtr nil; if (!surface) return nil; ImagePtr image = VaapiImage::derive(surface); if (!image) { ERROR("VaapiImage::derive() failed"); return nil; } ImageRawPtr raw = mapVaapiImage(image); if (!raw) { ERROR("image->map() failed"); return nil; } uint8_t* src = reinterpret_cast<uint8_t*>(frame->handle); if (!raw->copyFrom(src, frame->offset, frame->pitch)) { ERROR("copyfrom in buffer failed"); return nil; } return surface; }
void OpenGLGraphicsManager::displayActivityIconOnOSD(const Graphics::Surface *icon) { #ifdef USE_OSD if (_osdIconSurface) { delete _osdIconSurface; _osdIconSurface = nullptr; // Make sure the icon is cleared on the next update _forceRedraw = true; } if (icon) { Graphics::Surface *converted = icon->convertTo(_defaultFormatAlpha); _osdIconSurface = createSurface(_defaultFormatAlpha); assert(_osdIconSurface); // We always filter the osd with GL_LINEAR. This assures it's // readable in case it needs to be scaled and does not affect it // otherwise. _osdIconSurface->enableLinearFiltering(true); _osdIconSurface->allocate(converted->w, converted->h); Graphics::Surface *dst = _osdIconSurface->getSurface(); // Copy the icon to the texture dst->copyRectToSurface(*converted, 0, 0, Common::Rect(0, 0, converted->w, converted->h)); converted->free(); delete converted; } #endif }
//--------------------------------------------------------------------- //--------------------------------------------------------------------- int main(int argc, char* argv[]) { createSurface(); game.changeSize((int)game.mW, (int)game.mH); glClearColor(0.0f, 0.0f, 0.2f, 1.0f); mainLoop(); return 0; }
Encode_Status VaapiEncoderH264::encodePicture(const PicturePtr& picture) { Encode_Status ret = ENCODE_FAIL; SurfacePtr reconstruct = createSurface(); if (!reconstruct) return ret; { AutoLock locker(m_paramLock); #ifdef __BUILD_GET_MV__ uint32_t size; void *buffer = NULL; getMVBufferSize(&size); if (!picture->editMVBuffer(buffer, &size)) return ret; #endif if (!ensureSequence (picture)) return ret; if (!ensureMiscParams (picture.get())) return ret; if (!ensurePicture(picture, reconstruct)) return ret; if (!ensureSlices (picture)) return ret; } if (!picture->encode()) return ret; if (!referenceListUpdate (picture, reconstruct)) return ret; return ENCODE_SUCCESS; }
int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { if (!_glfwCreateContext(window, ctxconfig, fbconfig)) return GL_FALSE; if (!createSurface(window, wndconfig)) return GL_FALSE; if (wndconfig->monitor) { wl_shell_surface_set_fullscreen( window->wl.shell_surface, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, wndconfig->monitor->wl.output); } else { wl_shell_surface_set_toplevel(window->wl.shell_surface); } return GL_TRUE; }
/*!--------------------------------------------------------------------------- * Create new off-screen image stream. * * \param width Stream image buffer width * \param height Stream image buffer height * \param imageFormat Stream image buffer format * \param nbufs Number of image buffers to allocate * * \param Handle to newly created stream or OWF_INVALID_HANDLe if no * stream could be created. *----------------------------------------------------------------------------*/ OWF_API_CALL OWFNativeStreamType owfNativeStreamCreateImageStream(OWFint width, OWFint height, const OWF_IMAGE_FORMAT* format, OWFint nbufs) { RSurfaceManager surface_manager; TInt err=surface_manager.Open(); if (err<KErrNone) { return WFC_INVALID_HANDLE; } TSurfaceId surface; surface = createSurface(surface_manager, width, height, format, nbufs); if (surface.IsNull()) { return WFC_INVALID_HANDLE; } SymbianStreamType ns=WFC_INVALID_HANDLE; //No more error checking required... SymbianStreamAcquire(&surface,&ns); surface_manager.CloseSurface(surface); if (ns) { WipeWriteBuffer(ns); } surface_manager.Close(); return (OWFNativeStreamType)ns; }
void tst_QOpenGL::fboSimpleRendering() { QFETCH(int, surfaceClass); QScopedPointer<QSurface> surface(createSurface(surfaceClass)); QOpenGLContext ctx; ctx.create(); ctx.makeCurrent(surface.data()); if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) QSKIP("QOpenGLFramebufferObject not supported on this platform"); // No multisample with combined depth/stencil attachment: QOpenGLFramebufferObjectFormat fboFormat; fboFormat.setAttachment(QOpenGLFramebufferObject::NoAttachment); QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(200, 100, fboFormat); fbo->bind(); glClearColor(1.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glFinish(); QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32); QImage reference(fb.size(), QImage::Format_RGB32); reference.fill(0xffff0000); QFUZZY_COMPARE_IMAGES(fb, reference); delete fbo; }
bool Canvas2DLayerBridge::isValid() { ASSERT(m_layer); if (m_context->webContext()->isContextLost() || !m_surfaceIsValid) { // Attempt to recover. m_layer->clearTexture(); m_mailboxes.clear(); RefPtr<GraphicsContext3D> sharedContext = SharedGraphicsContext3D::get(); if (!sharedContext || sharedContext->webContext()->isContextLost()) { m_surfaceIsValid = false; } else { m_context = sharedContext; IntSize size(m_canvas->getTopDevice()->width(), m_canvas->getTopDevice()->height()); SkAutoTUnref<SkSurface> surface(createSurface(m_context.get(), size)); if (surface.get()) { m_canvas->setSurface(surface.get()); m_surfaceIsValid = true; // FIXME: draw sad canvas picture into new buffer crbug.com/243842 } else { // Surface allocation failed. Set m_surfaceIsValid to false to // trigger subsequent retry. m_surfaceIsValid = false; } } } if (!m_surfaceIsValid) setRateLimitingEnabled(false); return m_surfaceIsValid; }
EglContext::EglContext(EglContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) : m_display (EGL_NO_DISPLAY), m_context (EGL_NO_CONTEXT), m_surface (EGL_NO_SURFACE), m_config (NULL) { #ifdef SFML_SYSTEM_ANDROID // On Android, we must save the created context ActivityStates* states = getActivity(NULL); Lock lock(states->mutex); states->context = this; #endif // Get the initialized EGL display m_display = getInitializedDisplay(); // Get the best EGL config matching the requested video settings m_config = getBestConfig(m_display, bitsPerPixel, settings); updateSettings(); // Create EGL context createContext(shared); #if !defined(SFML_SYSTEM_ANDROID) // Create EGL surface (except on Android because the window is created // asynchronously, its activity manager will call it for us) createSurface((EGLNativeWindowType)owner->getSystemHandle()); #endif }
int main(int argc, char *argv[]) { // Init SDL video subsystem if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); // Set GL context attributes initAttributes (); // Create GL context createSurface(0); // Get GL context attributes printAttributes(); // Init GL state initGL(); // Draw, get events... mainLoop(); // Cleanup SDL_Quit(); return 0; }
bool CSDLVideo::initOverlaySurface( const bool useAlpha, const Uint16 width, const Uint16 height ) { SDL_Surface *overlay = createSurface( "OverlaySurface", useAlpha, width, height, RES_BPP, m_Mode ); mpOverlaySurface.reset( overlay ); if(!mpOverlaySurface) return false; #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_SetSurfaceBlendMode( overlay, SDL_BLENDMODE_BLEND); SDL_SetSurfaceAlphaMod( overlay, 0); #else SDL_SetAlpha( overlay, SDL_SRCALPHA, 0); #endif return true; }
void tst_QOpenGL::sharedResourceCleanup() { QFETCH(int, surfaceClass); QScopedPointer<QSurface> surface(createSurface(surfaceClass)); QOpenGLContext *ctx = new QOpenGLContext; ctx->create(); ctx->makeCurrent(surface.data()); SharedResourceTracker tracker; SharedResource *resource = new SharedResource(&tracker); resource->free(); QCOMPARE(tracker.invalidateResourceCalls, 0); QCOMPARE(tracker.freeResourceCalls, 1); QCOMPARE(tracker.destructorCalls, 1); tracker.reset(); resource = new SharedResource(&tracker); QOpenGLContext *ctx2 = new QOpenGLContext; ctx2->setShareContext(ctx); ctx2->create(); delete ctx; resource->free(); // no current context, freeResource() delayed QCOMPARE(tracker.invalidateResourceCalls, 0); QCOMPARE(tracker.freeResourceCalls, 0); QCOMPARE(tracker.destructorCalls, 0); ctx2->makeCurrent(surface.data()); // freeResource() should now have been called QCOMPARE(tracker.invalidateResourceCalls, 0); QCOMPARE(tracker.freeResourceCalls, 1); QCOMPARE(tracker.destructorCalls, 1); tracker.reset(); resource = new SharedResource(&tracker); // this should cause invalidateResource() to be called delete ctx2; QCOMPARE(tracker.invalidateResourceCalls, 1); QCOMPARE(tracker.freeResourceCalls, 0); QCOMPARE(tracker.destructorCalls, 0); // should have no effect other than destroying the resource, // as it has already been invalidated resource->free(); QCOMPARE(tracker.invalidateResourceCalls, 1); QCOMPARE(tracker.freeResourceCalls, 0); QCOMPARE(tracker.destructorCalls, 1); }
void rot_bitmap_layer_update_func (Layer* l,GContext* ctx) { ROT_BITMAP_GET; GPoint topOffset=getTopOffset (); setTopOffset(GPoint(0,0)); GRect rect=GRect(0,0,l->frame.size.w,l->frame.size.h); SDL_Surface* sur=createSurface(rotbitmap->bitmap->bounds.size.w,rotbitmap->bitmap->bounds.size.h); SDL_FillRect(sur,0,0); graphics_context_set_compositing_mode (ctx,GCompOpAssign); graphics_draw_bitmap_in_rect_to (ctx,rotbitmap->bitmap,rect,sur); double angle=(double)rotbitmap->rotation/TRIG_MAX_ANGLE*360.0; SDL_Surface* rotated=rotozoomSurface(sur,-angle,1.0,SMOOTHING_OFF); SDL_FreeSurface(sur); GPoint offset=getPivotRotationOffset(rotbitmap->bitmap->bounds.size,GSize(rotated->w,rotated->h),rotbitmap->src_ic,angle); rotbitmap->dest_ic.x=l->frame.size.w/2; //TODO: Verify this rotbitmap->dest_ic.y=l->frame.size.h/2; setTopOffset(topOffset); if (rotbitmap->corner_clip_color!=GColorClear) { graphics_context_set_fill_color(ctx,rotbitmap->corner_clip_color); graphics_fill_rect(ctx,GRect(0,0,l->frame.size.w,l->frame.size.h),0,0); } graphics_context_set_compositing_mode (ctx,rotbitmap->compositing_mode); graphics_draw_surface_in_rect (ctx,rotated,GRect(rotbitmap->dest_ic.x-offset.x,rotbitmap->dest_ic.y-offset.y,rotated->w,rotated->h)); SDL_FreeSurface(rotated); }
/** * Rendering a wordy tooltip (TTF to raster) can be expensive. * Instead of doing this each frame, do it once and cache the result. */ void WidgetTooltip::createBuffer(TooltipData &tip) { // concat multi-line tooltip, used in determining total display size string fulltext; fulltext = tip.lines[0]; for (int i=1; i<tip.num_lines; i++) { fulltext = fulltext + "\n" + tip.lines[i]; } // calculate the full size to display a multi-line tooltip Point size = font->calc_size(fulltext, width); size.x += margin + margin; size.y += margin + margin; // this SDL_Surface memory is freed when the TooltipData leaves scope // or when a clear() is called. tip.tip_buffer = createSurface(size.x, size.y); // Currently tooltips are always opaque SDL_SetAlpha(tip.tip_buffer, 0, 0); // style the tooltip background // currently this is plain black SDL_FillRect(tip.tip_buffer, NULL, 0); int cursor_y = margin; for (int i=0; i<tip.num_lines; i++) { font->render(tip.lines[i], margin, cursor_y, JUSTIFY_LEFT, tip.tip_buffer, size.x, tip.colors[i]); cursor_y = font->cursor_y; } }
AsScene2402TV::AsScene2402TV(NeverhoodEngine *vm, Klaymen *klaymen) : AnimatedSprite(vm, 1100), _klaymen(klaymen), _countdown1(0), _countdown2(0) { _x = 260; _y = 210; createSurface(100, 127, 90); setDoDeltaX(1); SetMessageHandler(&Sprite::handleMessage); if (!getGlobalVar(V_TV_JOKE_TOLD)) { loadSound(0, 0x58208810); _countdown1 = 48; startAnimation(0x4919397A, 0, -1); _newStickFrameIndex = 0; SetUpdateHandler(&AsScene2402TV::upWait); } else { int16 frameIndex; if (_klaymen->getX() > 320) _currFrameIndex = 29; frameIndex = CLIP<int16>((_klaymen->getX() - _x + 150) / 10, 0, 29); startAnimation(0x050A0103, frameIndex, -1); _newStickFrameIndex = frameIndex; _countdown1 = 0; SetUpdateHandler(&AsScene2402TV::upFocusKlaymen); } }
void initVulkan() { createInstance(); setupDebugCallback(); createSurface(); pickPhysicalDevice(); createLogicalDevice(); createSwapChain(); }
AsScene2101HitByDoorEffect::AsScene2101HitByDoorEffect(NeverhoodEngine *vm, Sprite *klaymen) : AnimatedSprite(vm, 1400), _klaymen(klaymen) { SetUpdateHandler(&AnimatedSprite::update); SetMessageHandler(&AsScene2101HitByDoorEffect::handleMessage); createSurface(1200, 88, 165); setVisible(false); }
Background::Background(NeverhoodEngine *vm, uint32 fileHash, int objectPriority, int surfacePriority) : Entity(vm, objectPriority), _surface(NULL), _spriteResource(vm) { _spriteResource.load(fileHash); createSurface(surfacePriority, _spriteResource.getDimensions().width, _spriteResource.getDimensions().height); _surface->drawSpriteResource(_spriteResource); }
/** * Create a font from the panel pixel data. * * @param pixels Panel pixel data * @param big Whether to use the small or the big font */ Font::Font (unsigned char* pixels, bool big) { unsigned char* chrPixels; int count, y; if (big) lineHeight = 8; else lineHeight = 7; chrPixels = new unsigned char[8 * lineHeight]; for (count = 0; count < 40; count++) { for (y = 0; y < lineHeight; y++) memcpy(chrPixels + (y * 8), pixels + (count * 8) + (y * SW), 8); characters[count] = createSurface(chrPixels, 8, lineHeight); if (big) SDL_SetColorKey(characters[count], SDL_SRCCOLORKEY, 31); } nCharacters= 40; delete[] chrPixels; // Create ASCII->font map if (big) { // Goes " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-:." for (count = 0; count < 45; count++) map[count] = 0; map[count++] = 37; map[count++] = 39; for (; count < 48; count++) map[count] = 0; for (; count < 58; count++) map[count] = count - 47; // Numbers map[count++] = 38; for (; count < 65; count++) map[count] = 0; for (; count < 91; count++) map[count] = count - 54; // Upper-case letters for (; count < 97; count++) map[count] = 0; for (; count < 123; count++) map[count] = count - 86; // Lower-case letters for (; count < 128; count++) map[count] = 0; } else { // Goes " 0123456789oo" (where oo = infinity) // Use :; to represent the infinity symbol for (count = 0; count < 48; count++) map[count] = 0; for (; count < 60; count++) map[count] = count - 47; // Numbers and :; for (; count < 128; count++) map[count] = 0; } return; }
SsScene1105SymbolDie::SsScene1105SymbolDie(NeverhoodEngine *vm, uint dieIndex, int16 x, int16 y) : StaticSprite(vm, 1100), _dieIndex(dieIndex) { _x = x; _y = y; createSurface(200, 50, 50); loadSymbolSprite(); SetMessageHandler(&SsScene1105SymbolDie::handleMessage); }
//Returns -1 on failure, 0 on success, sets up the module int setupGraphicModule(int fd, GraphicModule * module){ //Zero the buffered array memset(buffered,0,sizeof(buffered)); module->memShareAddr = mmap(NULL, MEMSHARESIZE, PROT_READ, MAP_SHARED, fd, 0); if(module->memShareAddr == MAP_FAILED){ perror("memsharegraphic"); puts("Failed to map memory share to network module"); return -1; } module->memShareFD = fd; msync(module->memShareAddr,sizeof(int),MS_SYNC|MS_INVALIDATE); //Set up the graphics if (SDL_Init(SDL_INIT_VIDEO) < 0 ){ puts("Failed to initalize video"); return -1; } module->screen = SDL_SetVideoMode(SCREENWIDTH, SCREENHEIGHT, SCREENDEPTH, SDL_HWSURFACE); if(module->screen == NULL){ puts("Failed to set video mode"); SDL_Quit(); return -1; } //Create the drawing and document surfaces module->drawing = createSurface(SDL_SWSURFACE, SCREENWIDTH,SCREENHEIGHT,module->screen); if(module->drawing == NULL){ puts("failed to create drawing surface"); SDL_Quit(); return -1; } //Load the bitmap engine within the module module->font = malloc(sizeof(BitFont*)); if(setupBitFont(module->font) < 0){ puts("Failed to create the bitmap engine"); SDL_Quit(); return -1; } if(loadUI(module) < 0){ puts("Failed to load User Interface"); SDL_Quit(); return -1; } //Set the stop flag module->stopFlag = 0; SDL_WM_SetCaption( "Smart Desk | Interactive Learning Software", NULL); return 0; }
void OpenGLGraphicsManager::setActualScreenSize(uint width, uint height) { _outputScreenWidth = width; _outputScreenHeight = height; // Setup backbuffer size. _backBuffer.setDimensions(width, height); uint overlayWidth = width; uint overlayHeight = height; // WORKAROUND: We can only support surfaces up to the maximum supported // texture size. Thus, in case we encounter a physical size bigger than // this maximum texture size we will simply use an overlay as big as // possible and then scale it to the physical display size. This sounds // bad but actually all recent chips should support full HD resolution // anyway. Thus, it should not be a real issue for modern hardware. if ( overlayWidth > (uint)g_context.maxTextureSize || overlayHeight > (uint)g_context.maxTextureSize) { const frac_t outputAspect = intToFrac(_outputScreenWidth) / _outputScreenHeight; if (outputAspect > (frac_t)FRAC_ONE) { overlayWidth = g_context.maxTextureSize; overlayHeight = intToFrac(overlayWidth) / outputAspect; } else { overlayHeight = g_context.maxTextureSize; overlayWidth = fracToInt(overlayHeight * outputAspect); } } // HACK: We limit the minimal overlay size to 256x200, which is the // minimum of the dimensions of the two resolutions 256x240 (NES) and // 320x200 (many DOS games use this). This hopefully assure that our // GUI has working layouts. overlayWidth = MAX<uint>(overlayWidth, 256); overlayHeight = MAX<uint>(overlayHeight, 200); if (!_overlay || _overlay->getFormat() != _defaultFormatAlpha) { delete _overlay; _overlay = nullptr; _overlay = createSurface(_defaultFormatAlpha); assert(_overlay); // We always filter the overlay with GL_LINEAR. This assures it's // readable in case it needs to be scaled and does not affect it // otherwise. _overlay->enableLinearFiltering(true); } _overlay->allocate(overlayWidth, overlayHeight); _overlay->fill(0); // Re-setup the scaling for the screen and cursor recalculateDisplayArea(); recalculateCursorScaling(); // Something changed, so update the screen change ID. ++_screenChangeID; }