• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IMG_Init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: init

bool init() {
	bool success = true;
	if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0) {
		printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
		success = false;
	}
	else
	{
		if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) )
		{
			printf( "Warning: Linear texture filtering not enabled!" );
		}
		gWindow = SDL_CreateWindow( "Mahjong", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
		if( gWindow == NULL )
		{
			printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
			success = false;
		}
		else
		{
			gRenderer = SDL_CreateRenderer( gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
			if( gRenderer == NULL )
			{
				printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
				success = false;
			}
			else
			{
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
				int imgFlags = IMG_INIT_PNG;
				if( !( IMG_Init( imgFlags ) & imgFlags ) )
				{
					printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
					success = false;
				}
				if( TTF_Init() == -1 )
				{
					printf( "SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError() );
					success = false;
				}
				if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 )
				{
					printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() );
					success = false;
				}
			}
		}
	}
	return success;
}
开发者ID:rosen90,项目名称:GitHub,代码行数:50,代码来源:main.cpp


示例2: printf

// Create window and renderer.
//Return -1 if it fails.
int Renderer::SDLinit(){
    sdlwindow = NULL;

    screensurface = NULL;

    int window_width = 1280;
    int window_height = 720;

    //Initialize SDL
    if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
        return -1;
    } else {
        //Create window
        sdlwindow = SDL_CreateWindow( "SDL Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width, window_height, SDL_WINDOW_SHOWN );

        if( sdlwindow == NULL )
        {
            printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
            return -1;
        } else {
            //Get window surface
            screensurface = SDL_GetWindowSurface( sdlwindow );

            //Create renderer for window
            gRenderer = SDL_CreateRenderer( sdlwindow, -1, SDL_RENDERER_ACCELERATED );
            if( gRenderer == NULL )
            {
                printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
                return -1;
            } else {
                //Initialize renderer color
                SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );

                //Initialize PNG loading
                int imgFlags = IMG_INIT_PNG;
                if( !( IMG_Init( imgFlags ) & imgFlags ) )
                {
                    printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
                    return -1;
                }
            }
        }
    }

    return 0;

}
开发者ID:JYGroman,项目名称:engine_eindproduct,代码行数:51,代码来源:renderer.cpp


示例3: init_sdl

int
init_sdl(void)
{
	int flags;

	/* initialize SDL */
	if (SDL_Init(SDL_INIT_VIDEO) == -1) {
		fprintf(stderr, "SDL could not initialize! SDL Error: %s\n",
			SDL_GetError());
		return -1;
	}

	/* set texture filtering to linear */
	if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"))
		fprintf(stderr,
			"Warning: Linear texture filtering not enabled!\n");

	/* create window */
	gWindow = SDL_CreateWindow("SDL Tutorial",
			SDL_WINDOWPOS_UNDEFINED,
			SDL_WINDOWPOS_UNDEFINED,
			SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
	if (gWindow == NULL) {
		fprintf(stderr, "window could not be created! SDL Error: %s\n",
			SDL_GetError());
		return -1;
	}

	/* create renderer for window */
	gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED);
	if (gRenderer == NULL) {
		fprintf(stderr, "Renderer could not be created! "
			"SDL Error: %s\n", SDL_GetError());
		return -1;
	} else {
		/* initialize renderer color */
		SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);

		/* initialize PNG loading */
		flags = IMG_INIT_PNG;
		if ((IMG_Init(flags) & flags) == 0) {
			fprintf(stderr, "SDL_image could not initialize! "
				"SDL_image Error: %s\n", IMG_GetError());
			return -1;
		}
	}

	return 0;
}
开发者ID:LXiong,项目名称:blog_tmp,代码行数:49,代码来源:color_modulation.cpp


示例4: init

void init(){
    SDL_Init(SDL_INIT_VIDEO);
    SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
    
    gWindow = SDL_CreateWindow("batman 1", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
    
    gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    
    batman = new Batman(gRenderer);
    
    SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
    
    IMG_Init(IMG_INIT_PNG);
    
}
开发者ID:xysun,项目名称:batman1,代码行数:15,代码来源:main.cpp


示例5: init_sdl_img

void GraphicsSDL::init_sdl_img()
{
    // init SDL_image
    int img_flags = IMG_INIT_JPG | IMG_INIT_PNG;
    if ((IMG_Init(img_flags) & img_flags) != img_flags) {
        printf("[gfx] SDL_image error: %s\n", IMG_GetError());
        throw E_INIT_SDL_IMG;
    }

    // TODO: Remove guards when IMG gets properly supported by Emscripten
#ifndef __EMSCRIPTEN__
    atexit(IMG_Quit);
    print_sdl_img_version();
#endif
}
开发者ID:Ronoh55,项目名称:supermariowar,代码行数:15,代码来源:gfxSDL.cpp


示例6: LOG

bool ModuleTextures::init() {
	LOG("init Image library");
	bool ret = true;

	// load support for the PNG image format
	int flags = IMG_INIT_PNG;
	int init = IMG_Init(flags);

	if ((init & flags) != flags) {
		LOG("Could not initialize Image lib. IMG_init: %s", IMG_GetError());
		ret = false;
	}

	return ret;
}
开发者ID:DorianHawkmoon,项目名称:Caveman-Ninja,代码行数:15,代码来源:ModuleTextures.cpp


示例7: assert

//create SDL window and allow for png loading
void Game::Start()
{
    assert( SDL_Init( SDL_INIT_EVERYTHING ) >= 0 );
    mWindow = SDL_CreateWindow( "Shmup", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH,
				SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
    assert( mWindow );

    mRenderer = SDL_CreateRenderer( mWindow, -1, SDL_RENDERER_ACCELERATED );
    assert( mRenderer );

    int imgFlags = IMG_INIT_PNG;
    assert( IMG_Init( imgFlags ) & imgFlags );

    SDL_SetRenderDrawColor( mRenderer, 0x00, 0x00, 0x00, 0xFF );
}
开发者ID:samgoodrick,项目名称:Shmup,代码行数:16,代码来源:game.cpp


示例8: Init

void Init() {
	bool success = true;

	SDL_Init(SDL_INIT_VIDEO);
	window = SDL_CreateWindow("Tamagochi", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
		SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
	renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
	//Initialize PNG loading
	int imgFlags = IMG_INIT_PNG;
	if (!(IMG_Init(imgFlags) & imgFlags))
	{
		printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
		success = false;
	}
}
开发者ID:KleoG,项目名称:SDLEngine,代码行数:15,代码来源:main.cpp


示例9: SDL_CreateWindow

GraphicsSystem::GraphicsSystem(EntityManager *em, int window_width, int window_height)
{
	_window = SDL_CreateWindow("Objectless", SDL_WINDOWPOS_UNDEFINED,
		SDL_WINDOWPOS_UNDEFINED, window_width, window_height, SDL_WINDOW_SHOWN);
	_renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_ACCELERATED |
		SDL_RENDERER_PRESENTVSYNC);

	_entitymanager = em;

	// Initialize the flags for image lib
	if (!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)) {
		assert2(false, "IMG_Init failed!! %s", SDL_GetError());
		exit(0);
	}
}
开发者ID:ivarboms,项目名称:Objectless,代码行数:15,代码来源:GraphicsSystem.cpp


示例10: StartUp

void CResourceManager::StartUp(void)
{
	//SDL_Image
	if ( !IMG_Init(IMG_INIT_PNG) )
	{
		CCoreEngine::Instance().GetLogManager().LogOutput( LOG_INFO, LOGSUB_RESOURCES,"Starting Up! (FAILED LOADING SDL_Image)");
	}
	else
	{
		CCoreEngine::Instance().GetLogManager().LogOutput( LOG_INFO, LOGSUB_RESOURCES,"Starting Up! SDL_Image Loaded!");
	}

	LoadTextures();
	LoadAudio();
}
开发者ID:roig,项目名称:Endavant,代码行数:15,代码来源:CResourceManager.cpp


示例11: logSDLError

int Saloon::init(const char* title, int width, int height, bool windowed, int x, int y) {
	if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
		logSDLError(std::cout, "SDL_Init");
		return 1;
	}

	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_BUFFER_SIZE, 32);

	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	// Slight optimization to prepare the PNG loader prior to loading any images
	if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) != IMG_INIT_PNG){
		logSDLError(std::cout, "IMG_Init");
		return 1;
	}

	if (TTF_Init() != 0){
		logSDLError(std::cout, "TTF_Init");
		return 1;
	}

	if(windowed) {
		_window = SDL_CreateWindow(title, x, y, width, height,
				SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
	}
	else {
		_window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
				width, height,
				SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
	}

	if (_window == nullptr){
		logSDLError(std::cout, "CreateWindow");
		return 2;
	}

	_displayWidth = width;
	_displayHeight = height;

	_halfDisplayWidth = width/2.0f;
	_halfDisplayHeight = height/2.0f;

	return 0;
}
开发者ID:jimhub,项目名称:saloon-engine,代码行数:48,代码来源:Saloon.cpp


示例12: LogSDLError

bool 
BackBuffer::Initialise(int width, int height)
{
	m_width = width;
	m_height = height;

	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
	{
		LogSDLError();
		return (false);
	}
	else
	{
		m_pWindow = SDL_CreateWindow("717130 Game Framework", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN);

		if (m_pWindow == 0)
		{
			LogSDLError();
			return (false);
		}
		else
		{
			m_pRenderer = SDL_CreateRenderer(m_pWindow, -1, SDL_RENDERER_ACCELERATED); 

			if (m_pRenderer == 0)
			{
				LogSDLError();
				return (false);
			}
			else
			{
				int imageResult = IMG_Init(IMG_INIT_PNG);

				if (imageResult == 0)
				{
					LogSDLError();
					return (false);
				}
			}
		}
	}

	m_pTextureManager = new TextureManager();
	assert(m_pTextureManager);
	m_pTextureManager->Initialise(m_pRenderer);

	return (true);
}
开发者ID:camzakii,项目名称:GP-VS-2015,代码行数:48,代码来源:backbuffer.cpp


示例13: init

bool init() {
  bool l_success = true;
  
  if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
    printf("SDL could not initialize! SDL Error: %s\n",
	   SDL_GetError());
    l_success = false;
  } else {
    if(!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1")) {
      printf("Warning: Linear texture filtering not enabled");
    }  
    //Create window
    g_window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, 
				SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH,
				SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
  
    if(g_window == NULL) {
      printf("Window could not be created! SDL Error: %s\n",
	     SDL_GetError());
      l_success = false;
    } else {
      //Creates vsynced renderer for window
      g_renderer = SDL_CreateRenderer(g_window, -1,
				      SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
      if(g_renderer == NULL) {
	printf("Renderer could not be created! SDL Error:%s\n",
	       SDL_GetError());
	l_success = false;
      } else {
	SDL_SetRenderDrawColor(g_renderer, 0xFF, 0xFF, 0xFF, 0xFF);

	//Initialize PNG loading
	int imgFlags = IMG_INIT_PNG;
	if(!(IMG_Init(imgFlags) & imgFlags)) {
	  printf("SDL_image could not initialize! SDL_image Error: %s\n",
		 IMG_GetError());
	  l_success = false;
	}
	
	//Initialize SDL_mixer
	if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) {
	  printf("SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError());
	}
      }
    }
  }
  return l_success;
}
开发者ID:wedemalm,项目名称:lazyfoo,代码行数:48,代码来源:camera.cpp


示例14: LOG

// Called before render is available
bool Textures::awake(pugi::xml_node &node)
{
	LOG("Init Image library");
	bool ret = true;
	// load support for the PNG image format
	int flags = IMG_INIT_PNG;
	int init = IMG_Init(flags);

	if((init & flags) != flags)
	{
		LOG("Could not initialize Image lib. IMG_Init: %s", IMG_GetError());
		ret = false;
	}

	return ret;
}
开发者ID:crandino,项目名称:Pinball,代码行数:17,代码来源:Textures.cpp


示例15: sdl_init

void sdl_init(uint32_t sdl_flags, int img_flags)
{
    sp_logger = common::logging_get_logger("sdlwrap");

    sp_logger->info("Initializing SDL");
    auto result = SDL_Init(sdl_flags);
    if (result){
        sdl_throw_error("SDL_Init");
    }

    sp_logger->info("Initializing SDL image");
    result = IMG_Init(img_flags);
    if (result != img_flags){
        sdl_img_throw_error("IMG_Init");
    }
}
开发者ID:important-business,项目名称:engine,代码行数:16,代码来源:wrap.cpp


示例16: main

int main (int argc, char** argv)
{
	//init libraries at the top level to avoid game system dependencies and because I'm using SDL_main anyway
	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
	IMG_Init(IMG_INIT_PNG);

	Game game;
	game.run();
	game.destroy();

	//stop libraries
	IMG_Quit();
	SDL_Quit();

	return 0;
}
开发者ID:bbkane,项目名称:Nested_Rectangles,代码行数:16,代码来源:Source.cpp


示例17: SDL_Init

void Game::Init()
{
    int ret;
    ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO);
    assert(ret >= 0);
    window = SDL_CreateWindow("Chinese Chess", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Config::SCREEN_WIDTH, Config::SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
    assert(window != NULL);
    renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
    assert(renderer != NULL);
    SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
    int imgFlags = IMG_INIT_PNG;
    ret = IMG_Init(imgFlags) & imgFlags;
    assert(ret);
    ret = TTF_Init();
    assert(ret != -1);
}
开发者ID:yingwang,项目名称:chinese-chess,代码行数:16,代码来源:Game.cpp


示例18: LOG

// Called before render is available
bool j1Textures::Awake(j1IniReader* conf)
{
	LOG("Init Image library");
	bool ret = true;
	// load support for the PNG image format
	int flags = IMG_INIT_PNG;
	int init = IMG_Init(flags);

	if((init & flags) != flags)
	{
		LOG("Could not initialize Image lib. IMG_Init: %s", IMG_GetError());
		ret = false;
	}

	return ret;
}
开发者ID:PillosuCrew,项目名称:programacio_2,代码行数:17,代码来源:j1Textures.cpp


示例19: SGL_Init

int SGL_Init(void)
{
	int error = SDL_Init(SDL_INIT_EVERYTHING);
	if(error != 0)
	{
		SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, SDL_GetError());
		return error;
	}
	error = IMG_Init(IMG_INIT_PNG);
	if (error == 0)
	{
		SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, SDL_GetError());
		return error;
	}
	return 0;
}
开发者ID:uraani,项目名称:StercusEngine,代码行数:16,代码来源:SGL.c


示例20: init_SDL_all

int init_SDL_all()
{
    SDL_Init(SDL_INIT_VIDEO);              // Initialize SDL2

    //init image loader
    if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) != IMG_INIT_PNG){
	    logSDLError("IMG_Init");
	    return 1;
    }

    if (TTF_Init() != 0){
	    logSDLError("TTF_Init");
	    return 1;
    }
    return 0;
}
开发者ID:jake314159,项目名称:another-tetris-clone,代码行数:16,代码来源:SDL_functions.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IMG_Load函数代码示例发布时间:2022-05-30
下一篇:
C++ IMG_GetError函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap