Fully transparent windows in Pygame?

On Windows, you can create a solid background color then set the window’s transparency color with the Win32 API function SetLayeredWindowAttributes(). (Called with pywin32) Code: import pygame import win32api import win32con import win32gui pygame.init() screen = pygame.display.set_mode((800, 600)) # For borderless, use pygame.NOFRAME done = False fuchsia = (255, 0, 128) # Transparency color dark_red … Read more

OpenGL Scale Single Pixel Line

There is no “320×240 glOrtho canvas”. There is only the window’s actual resolution: 960×720. All you are doing is scaling up the coordinates of the primitives you render. So, your code says to render a line from, for example, (20, 20) to (40, 40). And OpenGL (eventually) scales those coordinates by 3 in each dimension: … Read more

How to use SDL2 and SDL_image with cmake

I think that the following will work, as it finds the libraries on my ubuntu system and the example function you provided can link: project(shooter-cmake2) cmake_minimum_required(VERSION 2.8) set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++0x”) add_executable(${PROJECT_NAME} src/test.cpp) INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES}) If cmake is executed with –debug-output it outputs: — Found PkgConfig: … Read more

Cannot infer an appropriate lifetime for autoref due to conflicting requirements

Here’s a smaller example that reproduces the problem: struct FontLoader(String); struct Font<‘a>(&’a str); impl FontLoader { fn load(&self) -> Font { Font(&self.0) } } struct Window; struct Phi<‘window> { window: &’window Window, loader: FontLoader, font: Option<Font<‘window>>, } impl<‘window> Phi<‘window> { fn do_the_thing(&mut self) { let font = self.loader.load(); self.font = Some(font); } } fn main() … Read more

Why SDL defines main macro?

Per the SDL Windows FAQ: You should be using main() instead of WinMain() even though you are creating a Windows application, because SDL provides a version of WinMain() which performs some SDL initialization before calling your main code. If for some reason you need to use WinMain(), take a look at the SDL source code … Read more

How do I use SDL2 in my programs correctly?

This answer is about MinGW / GCC, and not Visual Studio. This answer only applies to Windows. Common errors The common errors are: SDL.h: No such file or directory (when compiling) undefined reference to various functions (when linking) ??.dll was not found (when running your program) procedure entry point … could not be located in … Read more