本文整理汇总了C++中SDL_SetHint函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_SetHint函数的具体用法?C++ SDL_SetHint怎么用?C++ SDL_SetHint使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_SetHint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: SDL_GL_SetAttribute
bool game::init(const char* title, int xPos, int yPos, int width, int height, bool fullscreen)
{
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
if (SDL_Init(SDL_INIT_EVERYTHING) >= 0)
{
_window = SDL_CreateWindow(title, xPos, yPos, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
_context = SDL_GL_CreateContext(_window);
if (_context)
{
glewExperimental = GL_TRUE;
GLenum glewError = glewInit();
if (glewError != GLEW_OK)
{
printf("Error initializing GLEW! %s\n", glewGetErrorString(glewError));
}
}
}
SDL_GL_SetSwapInterval(1);
std::cout << "SDL init success \n";
_timer = std::shared_ptr<GameTick>(new GameTick);
int currentWindowWidth = 0;
int currentWindowHeight = 0;
SDL_GetWindowSize(_window, ¤tWindowWidth, ¤tWindowHeight);
gameData::instance().setData(_renderer, _window, xPos, yPos, currentWindowWidth, currentWindowHeight, fullscreen);
_stateHandler = std::shared_ptr<stateHandlerGen>(new stateHandlerGen);
_input.reset(new inputSystem);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2");
_running = true;
return true;
}
示例3: main
int main(int argc, char *argv[])
{
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
qDebug() << "SDL_Init failed: " << QString::fromStdString(SDL_GetError());
return 0;
}
QApplication app(argc, argv);
// Now we make sure the current dir is set to application path
QDir dir(QCoreApplication::applicationDirPath());
#ifdef Q_OS_MAC
if (dir.dirName() == "MacOS") {
dir.cdUp();
dir.cdUp();
dir.cdUp();
}
// force Qt to load only LOCAL plugins, don't touch system Qt installation
QDir pluginsPath(QCoreApplication::applicationDirPath());
pluginsPath.cdUp();
pluginsPath.cd("Plugins");
QStringList libraryPaths;
libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath();
app.setLibraryPaths(libraryPaths);
#endif
QDir::setCurrent(dir.absolutePath());
// Support non-latin characters
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
MainDialog mainWin;
if (mainWin.setup()) {
mainWin.show();
} else {
return 0;
}
int returnValue = app.exec();
SDL_Quit();
return returnValue;
}
示例4: SDL_SetHint
//--------------------------------------------------------------------------------
// @ WindowManager::init()
//--------------------------------------------------------------------------------
// General constructor
//--------------------------------------------------------------------------------
void WindowManager::init(uint32 w, uint32 h, bool _fullScreen, std::string _title)
{
//Set title
title = _title;
//Set flags
fullScreen = _fullScreen;
//Set up the screen
if (fullScreen)
{
// make the scaled rendering look smoother.
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
sdlScreen = SDL_CreateWindow(title.c_str(),
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
w, h,
SDL_WINDOW_FULLSCREEN_DESKTOP);
}
else
sdlScreen = SDL_CreateWindow(title.c_str(),
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
w, h,
SDL_WINDOW_OPENGL);
//If there was an error in setting up the screen
if( sdlScreen == NULL )
{
std::cerr << "@WindowManager::WindowManager(...) -> Could not create screen" << std::endl;
}
sdlRenderer = SDL_CreateRenderer(sdlScreen, -1, 0);
sdlTexture = SDL_CreateTexture(sdlRenderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
w, h);
//Letterbox full screenf
SDL_RenderSetLogicalSize(sdlRenderer, w, h);
//Set data
ww = w;
wh = h;
} //End: WindowManager::init()
示例5: video_setup_yuv_overlay
int video_setup_yuv_overlay(const yuv_video_mode *mode)
{
stored_yuv_mode = *mode;
yuv_mode = 1;
if(opengl) return video_gl_setup_yuv_overlay(mode);
SDL_DestroyTexture(texture);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
texture = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_YV12,
SDL_TEXTUREACCESS_STREAMING,
mode->width, mode->height);
if(!stretch)
SDL_RenderSetLogicalSize(renderer, mode->display_width, mode->display_height);
return texture ? 1 : 0;
}
示例6: deinit
void InputManager::init()
{
if(initialized())
deinit();
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
Settings::getInstance()->getBool("BackgroundJoystickInput") ? "1" : "0");
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
SDL_JoystickEventState(SDL_ENABLE);
// first, open all currently present joysticks
this->addAllJoysticks();
mKeyboardInputConfig = new InputConfig(DEVICE_KEYBOARD, -1, "Keyboard", KEYBOARD_GUID_STRING, 0);
loadInputConfig(mKeyboardInputConfig);
}
示例7: SCREEN_WIDTH
SDL_Setup::SDL_Setup(const int width, const int height)
: SCREEN_WIDTH(width), SCREEN_HEIGHT(height)
{
e = new SDL_Event();
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
std::printf("\nUnable to initialize SDL: %s\n", SDL_GetError());
}
else
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"))
{
std::printf("Warning: Linear texture filtering not enabled!");
}
//Create Window
gWindow = SDL_CreateWindow("Game Prototype", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (gWindow == NULL)
{
std::printf("Window failed to initialize! SDL Error: %s\n", SDL_GetError());
}
else
{
//Create renderer
gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED);
if (gRenderer == NULL)
{
printf("Renderer failed to initialize! SDL Error: %s\n", SDL_GetError());
}
else
{
//Sets resolution for all platforms (letter boxing)
SDL_RenderGetLogicalSize(gRenderer, &resWidth, &resHeight);
//Intitialize render 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());
}
}
}
}
示例8: printf
bool GameApplication::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!");
}
window = SDL_CreateWindow("Mahjong", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (window == NULL) {
printf("Window could not be created! SDL Error: %s\n",
SDL_GetError());
success = false;
} else {
renderer = SDL_CreateRenderer(window, -1,
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (renderer == NULL) {
printf("Renderer could not be created! SDL Error: %s\n",
SDL_GetError());
success = false;
} else {
SDL_SetRenderDrawColor(renderer, 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;
}
示例9: init
bool init() {
//Initialization flag
bool success = true;
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
success = false;
} else {
//Set texture filtering to linear
if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) ) {
printf( "Warning: Linear texture filtering not enabled!" );
}
//Create window
gWindow = SDL_CreateWindow( "SDL Tutorial", 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 {
//Create vsynced renderer for window
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 {
//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() );
success = false;
}
//Initialize SDL_ttf
if( TTF_Init() == -1 ) {
printf( "SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError() );
success = false;
}
}
}
}
return success;
}
示例10: Hints_s_aset
/*
* Set the value of a hint.
*
* @overload []=(hint, value)
* Set a hint with normal priority.
*
* @param hint [String] the name of the hint to query
* @param value [String] the value of the hint varaible
*
* @overload []=(hint, priority: , value)
* Set a hint with given priority.
*
* @param hint [String] the name of the hint to query
* @param priority [Integer] the priority, one of the
* {DEFAULT}, {NORMAL}, or {OVERRIDE}.
* @param value [String] the value of the hint varaible
*
* @return [Boolean] return true if the hint was set
*
* @example
* SDL2::Hints["SDL_HINT_XINPUT_ENABLED", priority: SDL2::Hints::OVERRIDE] = "0"
*
*/
static VALUE Hints_s_aset(int argc, VALUE* argv, VALUE self)
{
VALUE name, pri, value;
rb_scan_args(argc, argv, "21", &name, &pri, &value);
if (argc == 2) {
value = pri;
return INT2BOOL(SDL_SetHint(StringValueCStr(name), StringValueCStr(value)));
} else {
Check_Type(pri, T_HASH);
return INT2BOOL(SDL_SetHintWithPriority(StringValueCStr(name),
StringValueCStr(value),
NUM2INT(rb_hash_aref(pri, sym_priority))));
}
return Qnil;
}
示例11: graphics_initialize
void graphics_initialize(char *windowName, int viewWidth, int viewHeight, int renderWidth, int renderHeight, int fullscreen)
{
Uint32 flags = 0;
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
slog("Unable to initilaize SDL system: %s",SDL_GetError());
return;
}
atexit(SDL_Quit);
if (fullscreen)
{
if (renderWidth == 0)
{
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
else
{
flags |= SDL_WINDOW_FULLSCREEN;
}
}
graphicsMainWindow = SDL_CreateWindow(windowName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, renderWidth, renderHeight, flags);
if (!graphicsMainWindow)
{
slog("failed to create main window: %s",SDL_GetError());
graphics_close();
return;
}
graphicsRenderer = SDL_CreateRenderer(graphicsMainWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
if (!graphicsRenderer)
{
slog("failed to create renderer: %s",SDL_GetError());
graphics_close();
return;
}
SDL_RenderClear(graphicsRenderer);
SDL_RenderPresent(graphicsRenderer);
//sets a hint with normal priority, this specifically sets the scaling quality to be linear, this is supported by OpenGL and Direct3D
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
//sets a device independent resolution for rendering
SDL_RenderSetLogicalSize(graphicsRenderer, renderWidth, renderHeight);
atexit(graphics_close);
slog("graphics initialized\n");
}
示例12: fprintf
ScreenGlobalInit::ScreenGlobalInit()
{
Uint32 flags = SDL_INIT_VIDEO;
if (!IsKobo())
flags |= SDL_INIT_AUDIO;
if (::SDL_Init(flags) != 0) {
fprintf(stderr, "SDL_Init() has failed: %s\n", ::SDL_GetError());
exit(EXIT_FAILURE);
}
#if defined(HAVE_GLES) && SDL_MAJOR_VERSION >= 2
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
#ifdef HAVE_GLES2
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
#endif
#endif
#if SDL_MAJOR_VERSION >= 2
// Keep screen on (works on iOS, and maybe for other platforms)
SDL_SetHint(SDL_HINT_IDLE_TIMER_DISABLED, "1");
#endif
if (HasTouchScreen())
SDL_ShowCursor (SDL_FALSE);
#if SDL_MAJOR_VERSION < 2
::SDL_EnableKeyRepeat(250, 50);
::SDL_EnableUNICODE(true);
#endif
#if defined(ENABLE_OPENGL)
::SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
::SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
OpenGL::Initialise();
#endif
Font::Initialise();
event_queue = new EventQueue();
ScreenInitialized();
}
示例13: printf
bool Game::Start(const char* title, int argc, char** argv)
{
// Init SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("Could not init SDL: %s\n", SDL_GetError());
return false;
}
// TODO read arguments and config file
// Enable VSync
/*
if (!SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1"))
{
printf("VSync not enabled!\n");
}
*/
// Set texture filtering to linear
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"))
{
printf("Linear texture filtering not enabled!\n");
}
// Create window
window_ = SDL_CreateWindow(
title,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
WINDOW_WIDTH,
WINDOW_HEIGHT,
SDL_WINDOW_SHOWN
);
if (window_ == NULL)
{
printf("Could not create window: %s\n", SDL_GetError());
return false;
}
renderer_ = new Renderer(window_, SDL_RENDERER_ACCELERATED);
this->init_ = true;
return true;
}
示例14: input_joysticks_detect
void input_joysticks_detect() {
// Initialize any joysticks
printf("%i joystick(s) found:\n", SDL_NumJoysticks());
int i;
for (i = 0; i < SDL_NumJoysticks(); i++) {
joystick = SDL_JoystickOpen(i);
printf("%s\n", SDL_JoystickName(joystick));
}
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
turbostate.p1a = turbotoggle.p1a = 0;
turbostate.p1b = turbotoggle.p1b = 0;
turbostate.p2a = turbotoggle.p2a = 0;
turbostate.p2b = turbotoggle.p2b = 0;
}
示例15: VidExt_Init
/* video extension functions to be called by the video plugin */
EXPORT m64p_error CALL VidExt_Init(void)
{
/* call video extension override if necessary */
if (l_VideoExtensionActive)
return (*l_ExternalVideoFuncTable.VidExtFuncInit)();
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
#endif
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
{
DebugMessage(M64MSG_ERROR, "SDL video subsystem init failed: %s", SDL_GetError());
return M64ERR_SYSTEM_FAIL;
}
return M64ERR_SUCCESS;
}