sdl

SDL with g++ on OSX Lion

半腔热情 提交于 2019-12-05 18:59:57
Dose anyone know how to set up SDL (simple direct media layer) on OSX Lion so I can compile my code with g++ ? I have read the "readme" that comes with the package and I have placed the frameworks folder in the relevant directory, however, this does not seem to be enough. Can anyone help me ? (I do not want to use Xcode) If you're not using XCode, and are compiling SDL projects using gcc , you can run: gcc -o test SDLTest.c `sdl-config --cflags --libs` g++ -o test SDLText.c `sdl-config --cflags --libs` This works happily for me on my mac - sdl-config --version returns 1.2.14 , and I can run

Am I calculating my FPS correctly?

给你一囗甜甜゛ 提交于 2019-12-05 18:34:44
So I was wondering if I'm calculating my FPS correctly: Uint32 delayFrom(float startTime, float endTime){ return(endTime - startTime ); } int main(){ int numFrames = 0; Uint32 startTime = SDL_GetTicks(); while(!done){ frameTime = 0; float fps = ( numFrames/(float)(SDL_GetTicks() - startTime) )*1000; cout << fps << endl; SDL_Delay(delayFrom(frameTime, 1/60)); ++numFrames; } } int main() { int numFrames = 0; Uint32 startTime = SDL_GetTicks(); while (!done) { ++numFrames; Uint32 elapsedMS = SDL_GetTicks() - startTime; // Time since start of loop if (elapsedMS) { // Skip this the first frame

How to draw a rectangle outline in SDL 2.0

柔情痞子 提交于 2019-12-05 16:21:40
I'm trying to draw a rectangle outline in SDL 2.0 in order to use as a selection box. Does anyone know how to make one in SDL 2.0? You are looking for the SDL_RenderDrawRect : int SDL_RenderDrawRect(SDL_Renderer* renderer, const SDL_Rect* rect); Typical usage would be: SDL_Rect rectToDraw = {100,100,100,100} // Just some random rect //Set Color of Rect with SDL_SetRenderDrawColor if needed SDL_RenderDrawRect(renderer, &rectToDraw); To draw a filled rect it would then be with SDL_RenderFillRect 来源: https://stackoverflow.com/questions/20072639/how-to-draw-a-rectangle-outline-in-sdl-2-0

MonoGame application says SDL.dll is missing, even though it's there. Why?

試著忘記壹切 提交于 2019-12-05 14:31:27
I have a MonoGame application built using the Linux Game template in Visual Studio. It runs on Windows using either .NET or Mono, but it fails on Linux. The error is a DllNotFoundException concerning SDL.dll but the SDL.dll is always in the binary's directory. The file is not a CLR assembly, so it's not in the References. Instead, I have it copied during build from MonoGame's Assemblies/Linux directory (and all related CLR assemblies are copied from that folder as well). The error appears regardless of whether I've built the project under Windows in Visual Studio or Xamarin Studio or under

libSDL, CMake and Mac OS X Lion

ⅰ亾dé卋堺 提交于 2019-12-05 13:07:49
I'm trying to compile a cmake project on my mac, but it depends on the SDL framework. I installed this framework and after cmake then reported to me libSDL was not found I set following export variables myself (as suggested by cmake): export SDL_INCLUDE_DIR=/Library/Frameworks/SDL.framework/ export SDLIMAGE_LIBRARY=/Library/Frameworks/SDL_image.framework/ export SDLIMAGE_INCLUDE_DIR=/Library/Frameworks/SDL_image.framework/Headers Now cmake does it job, but when I run make, I get the following message: Mats-MBP:build mats$ make Linking CXX executable SDLExample Undefined symbols for

How to disable vsync on macOS

偶尔善良 提交于 2019-12-05 12:50:28
问题 With all my SDL/OpenGL programs, the framerate is stuck at 60fps, so looks like the vsync is enable, but not by me, nor in my code or my settings. so i would like to now if there is a way to disable it, maybe in some deep macOS settings? 回答1: This enabled me to get around ~700 frames per second on my MacBook Pro. Download Graphics Tools for Xcode - Late August 2014 Install or just mount Graphic Tools Open Quartz Debug Go to Tools -> Show Beam Sync Tools Select Disable Beam Synchronization It

Why does my unique_ptr think is has a null function pointer deleter? [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-05 08:18:10
This question already has an answer here: Cannot move std::unique_ptr with NULL deleter to std::shared_ptr? 2 answers I'm trying to learn SDL using C++. I've created a window.h header and a window.cpp source file for storing a Window class. In window.h it looks something like this: Class Window { public: Window(); . . . private: std::unique_ptr<SDL_Window, void (*)(SDL_Window*)> window; std::unique_ptr<SDL_Renderer, void (*)(SDL_Renderer*)> renderer; . . . } with some of the code in the class omitted. Then, in my source file, in the definition of the default constructor, I do this: Window:

Compiling SDL from source on a Mac running OS X 10.7 Lion

点点圈 提交于 2019-12-05 07:40:56
I've downloaded the SDL source SDL-1.2.14.zip from the libsdl website and gotten to the make step. When I ./configure , I have no issues. However, when I make , it gets what seems like a long way through the compilation process and dies with this output: /bin/sh ./libtool --mode=compile gcc -g -O2 -I./include -D_GNU_SOURCE=1 -DTARGET_API_MAC_CARBON -DTARGET_API_MAC_OSX -fvisibility=hidden -I/usr/X11R6/include -DXTHREADS -D_THREAD_SAFE -force_cpusubtype_ALL -fpascal-strings -c ./src/video/SDL_RLEaccel.c -o build/SDL_RLEaccel.lo libtool: compile: gcc -g -O2 -I./include -D_GNU_SOURCE=1 -DTARGET

C++ / SDL Debugging with console window

痴心易碎 提交于 2019-12-05 06:18:52
I am playing around with some OpenGL, using SDL to handle the window / input etc. Currently I am displaying any information I want to see to a HUD. Well, this is getting over-cumbersome, and I was wondering if there is a simple way to open up a separate console window to report this information to me. I am still new to C++ so go easy on me if this is an obvious one. In Linker -> System in your project's properties, check that the SubSystem is "Console (/SUBSYSTEM:CONSOLE)". That causes a separate console window to be brought up when you run your program. If your current entry point isn't main

How to compile an example SDL program written in C?

☆樱花仙子☆ 提交于 2019-12-05 05:59:03
I'm getting started with SDL and C programming. I have experience with other programming languages, but linking/compiling libraries in C is new to me. I am using Mac 10.8 and have installed latest stable 2.0 using the instructions in the read me ( ./configure; make; make install ). Here is the sample code that I am trying to compile: #include <stdlib.h> #include <stdio.h> #include "SDL.h" int main(void) { if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0) { fprintf(stderr, "\nUnable to initialize SDL: %s\n", SDL_GetError()); return 1; } atexit(SDL_Quit); return 0; } When I try to compile my