当前位置: 首页>>代码示例>>C++>>正文


C++ createSurface函数代码示例

本文整理汇总了C++中createSurface函数的典型用法代码示例。如果您正苦于以下问题:C++ createSurface函数的具体用法?C++ createSurface怎么用?C++ createSurface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createSurface函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateGL

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;
}
开发者ID:amineas,项目名称:libGK,代码行数:32,代码来源:gkPlatformAndroid.c

示例2: createSurface

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;
}
开发者ID:pelya,项目名称:Commander-Genius,代码行数:56,代码来源:COpenGL.cpp

示例3: createSurface

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
}
开发者ID:hoodwolf,项目名称:Infraelly,代码行数:52,代码来源:MapperGui.cpp

示例4: defined

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);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:60,代码来源:tst_qopengl.cpp

示例5: drawTextBox

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;
}
开发者ID:Lonnifer,项目名称:Blockenspiel,代码行数:25,代码来源:sdl_wrapper.cpp

示例6: createSurface

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;
}
开发者ID:Lonnifer,项目名称:Blockenspiel,代码行数:7,代码来源:sdl_wrapper.cpp

示例7: switch

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(&params, 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);
    }
}
开发者ID:10x-Amin,项目名称:frameworks_base,代码行数:28,代码来源:ISurfaceComposerClient.cpp

示例8: createSurface

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;
}
开发者ID:keqiaox,项目名称:libyami,代码行数:25,代码来源:vaapiencoder_base.cpp

示例9: createSurface

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
}
开发者ID:86400,项目名称:scummvm,代码行数:32,代码来源:opengl-graphics.cpp

示例10: main

//---------------------------------------------------------------------
//---------------------------------------------------------------------
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;
}
开发者ID:dibanezalegria,项目名称:Cplusplus,代码行数:9,代码来源:Main.cpp

示例11: createSurface

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;
}
开发者ID:01org,项目名称:libyami,代码行数:34,代码来源:vaapiencoder_h264.cpp

示例12: _glfwPlatformCreateWindow

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;
}
开发者ID:Delwin9999,项目名称:glfw,代码行数:26,代码来源:wl_window.c

示例13: owfNativeStreamCreateImageStream

/*!---------------------------------------------------------------------------
 *  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;
        }
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:41,代码来源:owfnativestreamstub.cpp

示例14: QFETCH

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;
}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:33,代码来源:tst_qopengl.cpp

示例15: ASSERT

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;

}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:30,代码来源:Canvas2DLayerBridge.cpp


注:本文中的createSurface函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。