sdl-2

SDL2 double buffer not working, still tearing

这一生的挚爱 提交于 2019-12-10 21:02:57
问题 I need a double buffer because i'm starting to notice tearing when I want to move my texture made tile map around the screen via mouse click. I'm using SDL2 and this is a SDL2 specific question, check out my code that produces tearing, whats wrong? //set up buffer and display bufferTexture = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_STREAMING,800,600); displayTexture = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_TARGET,800,600); while

SDL2 Raising a window without giving it focus

强颜欢笑 提交于 2019-12-10 20:28:39
问题 I need to display a tooltip over a window. I'm creating a second window with the tool tip and using SDL_RaiseWindow() to bring it to the top. However, doing that causes the tooltip to steal focus which is not what I want. Is there a way to bring a window to the top without changing focus? Also, is there a way to set focus (mouse and/or keyboard) without changing the Z order of the windows? 回答1: The answer offered by Neil will only work under X11 as SDL_SetWindowInputFocus() is only

Redirecting output in SDL 2

一曲冷凌霜 提交于 2019-12-10 15:17:43
问题 I'm using the SDL library in my project and I'm working on a Windows platform. When I'd decided to move my project to SDL 2, I encountered a problem: There was an option in SDL 1.2 to print output from stdout/stderr into the console window, rather than to files by defining a NO_STDIO_REDIRECT macro. However, I haven't found that macro in SDL 2. Is there a way to print SDL 2 output to the console instead of the standard files? 回答1: I suspect that NO_STDIO_REDIRECT is no longer part of SDL2.

How do I print to the console while an SDL 2 program is running?

你。 提交于 2019-12-10 14:57:43
问题 I'd like to print some debugging stuff to the console while running my SDL 2 program, but it seems impossible. printf("Hi!\n") and SDL_Log("Hi!\n") both won't do me any good. I even tried printing before initializing SDL (and after quitting it, too), but to no avail. It seems like merely importing the SDL library makes it impossible to print anything to the console. Here are the parameters I'm compiling with, since it's possible that might have something to do with it: g++ hello.cc -IC:\mingw

Why do I get an sRGB framebuffer only when I'm setting a non-zero alpha size in SDL2?

匆匆过客 提交于 2019-12-10 14:26:25
问题 I'm trying to render the typical OpenGL color triangle in a gamma correct way by following this guide and consulting the SDL2 documentation on how to enable SRGB support on the default framebuffer. This is the code I've written, which draws the triangle: #include <SDL.h> // Header file generated with glLoadGen #include "gl_core_3_3.h" #include <cstdlib> void sdl_loop(SDL_Window* window); static const char* const vertexSource = R"( #version 330 in vec2 position; in vec3 color; out vec3 vs

Sample SDL program gives an empty window

给你一囗甜甜゛ 提交于 2019-12-09 19:12:16
问题 config: archlinux with awesome desktop environment I just installed sdl2, and tried to run this sample code: https://github.com/xyproto/hello_sdl2/blob/master/c%2B%2B/main.cpp The result is an empty window (I can see my console through it) in the middle of the screen. Even when I hit mod4+Enter, it doesn't tile up nicely with the others. Why is that? (I updated my system, reinstalled sdl2. I also couldn't find any relevant hit browsing google.) 回答1: All windowing systems require you to handle

Debugging load time error in C++ SDL2 program compiled with VS2015 on Win10

自作多情 提交于 2019-12-09 02:49:18
问题 I'm writing a project in C++ with SDL2 on 64-bit Windows 10 using Visual Studio 2015. I recently purchased a new Windows 10 laptop and cloned my project from github. My project compiles correctly, but I get the following error when I run it: The application was unable to start correctly (0xc000007b). Click OK to close the application. Based on my research so far, this error is usually caused by loading an incompatible DLL, e.g. a 64-bit version instead of 32-bit. Suggestions I've found so far

How to render text in SDL2?

℡╲_俬逩灬. 提交于 2019-12-08 22:49:02
问题 I was wondering how to render text with SDL2. I found an API called SDL_TTF and some tutorials, however they do not work with my situation. I'm using an SDL_Window and SDL_Renderer , whereas the tutorials are specific to SDL_Surface . Is it possible to use SDL_TTF with SDL_Render/SDL_Window ? If so, how? 回答1: Yep, it is possible, given that you have a renderer and a window plus you don't really have any thoughts on dabbling with surfaces then you might want to mind on creating texture, here

SDL_SetWindowSize resizes window, but SDL_GetWindowSize reports old size — in Unix

耗尽温柔 提交于 2019-12-08 21:20:25
问题 I can't use SDL_GetWindowSize cross-platform, because in Unix it doesn't know that the window size changed (though I can see it did). Visual Studio and MinGW have no problem. (I keep running into cases where Unix is an outlier, but it's always been that I was doing something wrong and the other 2 platforms didn't notice.) I was running SDL2's version 2.0.8+dfsg1-4ubuntu on 64-bit Ubuntu 4.18.0 on VirtualBox; have since upgraded to SDL2 2.0.9+dfsg1-1ubuntu1 on Ubuntu 5.0.0, but behavior is the

C++/SDL2 — Rendering A Circle [closed]

北城余情 提交于 2019-12-08 16:47:49
Closed . This question is opinion-based . It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed last year . Am I on the right track here, drawing a filled circle with SDL2? I figured using parametric equations and a radius tending to zero would work, but it seems really inefficient in terms of processor use. Any other ideas are much appreciated Thanks in advance. //Circle test int circle_x = WINDOW_WIDTH/2; int circle_y = WINDOW_HEIGHT/2; int circle_radius = 100; SDL