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


C++ SDL_GetWindowSize函数代码示例

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


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

示例1: display_canvas_text

void display_canvas_text(Menu* main_menu) {
    int win_width, win_height;
    int canvas_text_x, canvas_text_y, canvas_text_w, canvas_text_h;
    SDL_Texture* image = load_image("display/images/program_a_work_of_art.bmp", 
                                      &main_menu->window);

    SDL_GetWindowSize(main_menu->window.win, &win_width, &win_height);

    canvas_text_x = main_menu->canvas_button.rect.w + win_width / LEFT_MARGIN;
    canvas_text_y = main_menu->canvas_button.rect.y;
    canvas_text_w = MENU_POPUP_WIDTH;
    canvas_text_h = MENU_POPUP_HEIGHT;

    make_rect(&main_menu->window, &main_menu->canvas_text, 
                canvas_text_x, canvas_text_y, canvas_text_w, canvas_text_h, 
                  230, 230, 230);

    SDL_RenderCopy(main_menu->window.renderer, image, 
                     NULL, &main_menu->canvas_text.rect);
    SDL_DestroyTexture(image); 
}
开发者ID:ahaggan,项目名称:ArtC,代码行数:21,代码来源:display.c

示例2: _gut_updatePhysic

static inline void _gut_updatePhysic(SDL_Window *window) {
	int w, h;
	w = gut.core->window.physic.w;
	h = gut.core->window.physic.h;
	SDL_GetWindowSize(
		window,
		&gut.core->window.physic.w,
		&gut.core->window.physic.h
	);
	if (gut.reshape &&
		(w != gut.core->window.physic.w || h != gut.core->window.physic.h)) {
		gut.reshape(gut.core->window.physic.w, gut.core->window.physic.h);
	}
	if (!(gut.window.flags & GUT_NO_AUTO_VIEWPORT)) {
		glViewport(
			0, 0,
			gut.core->window.physic.w,
			gut.core->window.physic.h
		);
	}
}
开发者ID:FolkertVanVerseveld,项目名称:gut,代码行数:21,代码来源:gut.c

示例3: SDL_VERSION_ATLEAST

void SDLAppDisplay::resize(int width, int height) {

    int resized_width, resized_height;

#if SDL_VERSION_ATLEAST(1,3,0)
    SDL_GetWindowSize(sdl_window, &resized_width, &resized_height);
#else
    setVideoMode(width, height, fullscreen);
    
    const SDL_VideoInfo* display_info = SDL_GetVideoInfo();

    resized_width  = display_info->current_w;
    resized_height = display_info->current_h;
#endif

    //set viewport to match what we ended up on
    glViewport(0, 0, resized_width, resized_height);

    this->width  = resized_width;
    this->height = resized_height;
}
开发者ID:atondwal,项目名称:Core,代码行数:21,代码来源:display.cpp

示例4: SDL_RenderSetViewport

int
SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect)
{
    CHECK_RENDERER_MAGIC(renderer, -1);

    if (rect) {
        renderer->viewport = *rect;
    } else {
        renderer->viewport.x = 0;
        renderer->viewport.y = 0;
        if (renderer->window) {
            SDL_GetWindowSize(renderer->window,
                              &renderer->viewport.w, &renderer->viewport.h);
        } else {
            /* This will be filled in by UpdateViewport() */
            renderer->viewport.w = 0;
            renderer->viewport.h = 0;
        }
    }
    return renderer->UpdateViewport(renderer);
}
开发者ID:DarkWolk,项目名称:libsdl,代码行数:21,代码来源:SDL_render.c

示例5: display_expert_text

void display_expert_text(Menu* challenges) {
    int win_width, win_height;
    int expert_text_x, expert_text_y, expert_text_w, expert_text_h;
    SDL_Texture* image = load_image("display/images/expert_text.bmp", 
                                      &challenges->window);

    SDL_GetWindowSize(challenges->window.win, &win_width, &win_height);

    expert_text_x = challenges->expert.rect.w + win_width / LEFT_MARGIN;
    expert_text_y = challenges->expert.rect.y;
    expert_text_w = MENU_POPUP_WIDTH;
    expert_text_h = MENU_POPUP_HEIGHT;

    make_rect(&challenges->window, &challenges->expert_text, 
                expert_text_x, expert_text_y, expert_text_w, expert_text_h, 
                  230, 230, 230);

    SDL_RenderCopy(challenges->window.renderer, image, 
                     NULL, &challenges->expert_text.rect);
    SDL_DestroyTexture(image); 
}
开发者ID:ahaggan,项目名称:ArtC,代码行数:21,代码来源:display.c

示例6: setNavigationOffset

void setNavigationOffset(GraphicsData *graphicsData, int x, int y){
	int sx,sy;
	SDL_GetWindowSize(graphicsData->window,&sx,&sy);
	if(x + sx > X_SIZE_OF_WORLD){
		x = X_SIZE_OF_WORLD - sx;
	}
	else if(x < 0){
		x = 0;
	}
	if(y + sy > Y_SIZE_OF_WORLD){
		y = Y_SIZE_OF_WORLD - sy;
	}
	else if(y < 0){
		y = 0;
	}

	x = -x;
	y = -y;

	graphicsData->navigationOffset.x = x;
	graphicsData->navigationOffset.y = y;
}
开发者ID:Syreniac,项目名称:verdant-octo-spork,代码行数:22,代码来源:graphics.c

示例7: SDL_GetWindowSize

	void CSprite::SetFullScreen(const bool bFull)
	{
		//Invert bool
		this->m_bFullScreen = bFull;

		//Fullscreen
		if (this->m_bFullScreen)
		{
			//Resize (First)
			SDL_GetWindowSize(this->m_pWin, &this->m_tScreenSize.w, &this->m_tScreenSize.h);
			SDL_SetWindowSize(this->m_pWin, SCREEN_WIDTH, SCREEN_HEIGHT);
			//Goto Windowed/FullScreen
			SDL_SetWindowFullscreen(this->m_pWin, this->m_bFullScreen);
		}
		else// Windowed
		{
			//Goto Windowed/FullScreen
			SDL_SetWindowFullscreen(this->m_pWin, this->m_bFullScreen);
			//Resize
			SDL_SetWindowSize(this->m_pWin, this->m_tScreenSize.w, this->m_tScreenSize.h);
		}
	}
开发者ID:kingnobody8,项目名称:fs.armada,代码行数:22,代码来源:Sprite.cpp

示例8: ImGui_ImplSDL2_NewFrame

void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
{
    ImGuiIO& io = ImGui::GetIO();
    IM_ASSERT(io.Fonts->IsBuilt());     // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame() 

    // Setup display size (every frame to accommodate for window resizing)
    int w, h;
    int display_w, display_h;
    SDL_GetWindowSize(window, &w, &h);
    SDL_GL_GetDrawableSize(window, &display_w, &display_h);
    io.DisplaySize = ImVec2((float)w, (float)h);
    io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);

    // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
    static Uint64 frequency = SDL_GetPerformanceFrequency();
    Uint64 current_time = SDL_GetPerformanceCounter();
    io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
    g_Time = current_time;

    ImGui_ImplSDL2_UpdateMousePosAndButtons();
    ImGui_ImplSDL2_UpdateMouseCursor();
}
开发者ID:warrenm,项目名称:imgui,代码行数:22,代码来源:imgui_impl_sdl.cpp

示例9: SDL_GetWindowSize

    /// \brief Wrap the mouse to the viewport
    void InputWrapper::_wrapMousePointer(const SDL_MouseMotionEvent& evt)
    {
        //don't wrap if we don't want relative movements, support relative
        //movements natively, or aren't grabbing anyways
        if(!mMouseRelative || !mWrapPointer || !mGrabPointer)
            return;

        int width = 0;
        int height = 0;

        SDL_GetWindowSize(mSDLWindow, &width, &height);

        const int FUDGE_FACTOR_X = width/4;
        const int FUDGE_FACTOR_Y = height/4;

        //warp the mouse if it's about to go outside the window
        if(evt.x - FUDGE_FACTOR_X < 0  || evt.x + FUDGE_FACTOR_X > width
                || evt.y - FUDGE_FACTOR_Y < 0 || evt.y + FUDGE_FACTOR_Y > height)
        {
            warpMouse(width / 2, height / 2);
        }
    }
开发者ID:Allofich,项目名称:openmw,代码行数:23,代码来源:sdlinputwrapper.cpp

示例10: SDL_GetWindowSize

void SDLHardwareRenderDevice::windowResize() {
	int w,h;
	SDL_GetWindowSize(window, &w, &h);
	SCREEN_W = w;
	SCREEN_H = h;

	float scale = (float)VIEW_H / (float)SCREEN_H;
	VIEW_W = (int)((float)SCREEN_W * scale);

	// letterbox if too tall
	if (VIEW_W < MIN_SCREEN_W) {
		VIEW_W = MIN_SCREEN_W;
	}

	VIEW_W_HALF = VIEW_W/2;

	SDL_RenderSetLogicalSize(renderer, VIEW_W, VIEW_H);

	if (texture) SDL_DestroyTexture(texture);
	texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, VIEW_W, VIEW_H);
	SDL_SetRenderTarget(renderer, texture);
}
开发者ID:cllpyl,项目名称:flare-engine,代码行数:22,代码来源:SDLHardwareRenderDevice.cpp

示例11: GFraMe_screen_set_maximize_double

/**
 * Resize the screen filling the greatest area possible, but ignoring the
 *original aspect ratio. This shouldn't be used at all! Ò.Ó
 * @param	update_window	Whether the windows dimensions should be updated
 */
void GFraMe_screen_set_maximize_double(int update_window) {
	int w = 0, h = 0;
	// Get the actual window's dimension
	if (update_window) {
		SDL_GetWindowSize(GFraMe_window, &w, &h);
		GFraMe_window_w = w;
		GFraMe_window_h = h;
	}
	else {
		w = GFraMe_window_w;
		h = GFraMe_window_h;
	}
	// Letterbox the game
	GFraMe_buffer_x = 0;
	GFraMe_buffer_y = 0;
	GFraMe_buffer_w = w;
	GFraMe_buffer_h = h;
	GFraMe_screen_ratio_h = (double)w / GFraMe_screen_w;
	GFraMe_screen_ratio_v = (double)h / GFraMe_screen_h;
	GFraMe_screen_log_dimensions(0);
	GFraMe_screen_cache_dimensions();
}
开发者ID:rayyee,项目名称:GFraMe,代码行数:27,代码来源:gframe_screen.c

示例12: sdl_env

int				sdl_env(int **map)
{
	t_env	*e;

	if (map == NULL)
		return (0);
	e = init_env(map);
	menu_loop(e);
	while (1)
	{
		while (SDL_PollEvent(&e->event))
		{
			SDL_GetWindowSize(e->win_sdl, &e->w, &e->h);
			handle_event(e);
			draw(e);
		}
	}
	if (ft_free(e))
		return (1);
	else
		return (0);
}
开发者ID:Horsell,项目名称:42,代码行数:22,代码来源:sdl_env.c

示例13: D3D_ActivateRenderer

static int D3D_ActivateRenderer(SDL_Renderer * renderer)
{
	D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
	HRESULT result;

	if (data->updateSize) {
		SDL_Window *window = renderer->window;
		int w, h;

		SDL_GetWindowSize(window, &w, &h);
		data->pparams.BackBufferWidth = w;
		data->pparams.BackBufferHeight = h;
		if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
			data->pparams.BackBufferFormat =
				PixelFormatToD3DFMT(SDL_GetWindowPixelFormat(window));
		} else {
			data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
		}
		/* XXX if (D3D_Reset(renderer) < 0) {
		   return -1;
		   }*/

		data->updateSize = SDL_FALSE;
	}
	if (data->beginScene) {
		result = IDirect3DDevice9_BeginScene(data->device);
		if (result == D3DERR_DEVICELOST) {
			/* XXX if (D3D_Reset(renderer) < 0) {
			   return -1./include/GL/glext.h;
			   }*/
			result = IDirect3DDevice9_BeginScene(data->device);
		}
		if (FAILED(result)) {
			return SDL_SetError("SDL_Shader: D3D BeginScene() failed, errno %d\n", result);
		}
		data->beginScene = SDL_FALSE;
	}
	return 0;
}
开发者ID:powertomato,项目名称:SDL2_shader,代码行数:39,代码来源:SDL_D3D_SDL_internals.c

示例14: MoveSprites

void
MoveSprites(SDL_Window * window, SDL_Texture * sprite)
{
    int i, n;
    int window_w, window_h;
    int sprite_w, sprite_h;
    SDL_Rect *position, *velocity;

    SDL_SelectRenderer(window);

    /* Query the sizes */
    SDL_GetWindowSize(window, &window_w, &window_h);
    SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h);

    /* Move the sprite, bounce at the wall, and draw */
    n = 0;
    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
    SDL_RenderClear();
    for (i = 0; i < NUM_SPRITES; ++i) {
        position = &positions[i];
        velocity = &velocities[i];
        position->x += velocity->x;
        if ((position->x < 0) || (position->x >= (window_w - sprite_w))) {
            velocity->x = -velocity->x;
            position->x += velocity->x;
        }
        position->y += velocity->y;
        if ((position->y < 0) || (position->y >= (window_h - sprite_h))) {
            velocity->y = -velocity->y;
            position->y += velocity->y;
        }

        /* Blit the sprite onto the screen */
        SDL_RenderCopy(sprite, NULL, position);
    }

    /* Update the screen! */
    SDL_RenderPresent();
}
开发者ID:BarleyStudio,项目名称:CorsixTH-AndroidFrontend,代码行数:39,代码来源:testnative.c

示例15: SDL_GetWindowSize

void SDLHardwareRenderDevice::windowResize() {
	int w,h;
	SDL_GetWindowSize(window, &w, &h);
	SCREEN_W = static_cast<unsigned short>(w);
	SCREEN_H = static_cast<unsigned short>(h);

	float scale = static_cast<float>(VIEW_H) / static_cast<float>(SCREEN_H);
	VIEW_W = static_cast<unsigned short>(static_cast<float>(SCREEN_W) * scale);

	// letterbox if too tall
	if (VIEW_W < MIN_SCREEN_W) {
		VIEW_W = MIN_SCREEN_W;
	}

	VIEW_W_HALF = VIEW_W/2;

	SDL_RenderSetLogicalSize(renderer, VIEW_W, VIEW_H);

	if (texture) SDL_DestroyTexture(texture);
	texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, VIEW_W, VIEW_H);
	SDL_SetRenderTarget(renderer, texture);
}
开发者ID:SBasalaev,项目名称:flare-engine,代码行数:22,代码来源:SDLHardwareRenderDevice.cpp


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