sdl

OpenGL 3.x context creation using SDL2 on OSX (Macbook Air 2012)

会有一股神秘感。 提交于 2020-01-20 17:28:11
问题 As far as I'm aware, the Macbook Air 2012 supports OpenGL 3.2. When using SDL 2.0 to create the OpenGL context, however, the context is only opengl version 2.1. Is it possible for SDL 2.0 to create a GL 3.2 context? 回答1: For everyone who still has this problem as of Wednesday, Oct 10th, SDL2 allows you to create an OpenGL 3.2 context on Macs running Mac OS X 10.7 (Lion) and up. You just need to add this code: SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL

c++ executable runs from command line, but not from eclipse

半世苍凉 提交于 2020-01-17 14:46:12
问题 I'm trying to follow a tutorial using the SDL2 library. I've followed the instructions here verbatim. The program compiles fine, but when I try to run it within eclipse I get the following error when calling SDL_Init(SDL_INIT_VIDEO) : No available video device After some research I decided this was because SDL2 had not been correctly linked to any display drivers so wasted several hours installing it from source, and trying various fixes suggested on various forums. After following another

Text in OpenGL using SDL_TTF

我们两清 提交于 2020-01-17 05:58:19
问题 I'm a beginner in OpenGL and I've created a function to write text in OpenGL using SDL_TTF. Here is the code for my function: #define WINDOW_WIDTH 832 #define WINDOW_HEIGHT 487 #define glVertex2px(x,y) glVertex2d((double)(x) * 2.0 / (double)WINDOW_WIDTH - 1.0, 1.0 - (double)(y) * 2.0 / (double)WINDOW_HEIGHT); void glWriteText2d(TTF_Font *font,const char *text,SDL_Color color,const int x,const int y){ GLuint texture; SDL_Surface *surface; surface = TTF_RenderText_Blended(font,text,color);

undefined reference to 'WinMain' with SDL compiling in a native enviroment

拟墨画扇 提交于 2020-01-16 00:43:12
问题 I'm struggeling with my first steps in SDL. I wanted to compile a simple test class, just including the SDL2 header, nothing special for startup: main.cpp: #include <SDL.h> int main() { return 0; } main.cpp itself compiles fine: g++ -c main.cpp -ISDL/include but as soon as i want to link it with the SDL2.dll either with the machinecode main.o or directly, i'm getting this error: g++ main.cpp -o sdl_test -I SDL/include -L SDL/lib/x64 -l SDL2 -mwindows g++ -o test main.o -L SDL/lib/x64 -l SDL2

SDL OpenGL in C++, Texture Shader missing the texture

坚强是说给别人听的谎言 提交于 2020-01-16 00:42:38
问题 I am trying to create my first OpenGL Shader but are experiencing difficulties when trying to add a texture to a Cube object. Is anyone sharp eyed enough to spot the error? The code might have lots of errors, and I am grateful if anyone points them out, but I am most interested in why my rotating cube is gray and not colorful. (I have skipped all error handling to keep source code size low, sorry about that) * *EDIT Found out I missed some UV settings, still gray cube though ... #include

SDL library error: cannot find -lSDL_ttf cannot find -lSDL_image

Deadly 提交于 2020-01-15 10:50:08
问题 I'm running a C++ program using sdl, my ubuntu version is 16.04. After I sudo apt-get install libsdl1.2-dev and run the following displays : g++ sdl-config --cflags -g -W -Wall -Weffc++ -Wextra -pedantic -O0 main.cpp -o run generateFrames.o sdl-config --libs -lSDL_ttf -lSDL_image /usr/bin/ld: cannot find -lSDL_ttf /usr/bin/ld: cannot find -lSDL_image collect2: error: ld returned 1 exit status Makefile:10: recipe for target 'run' failed make: *** [run] Error 1 How to get rid of this error ?

Using SDL2 RenderDraw functions with Emscripten

China☆狼群 提交于 2020-01-15 08:11:40
问题 I've been struggling to port a simple C program that uses SDL2 for graphics to the web using emscripten. I scanned through example programs but was unable to find one that draws to the screen using SDL_RenderDrawPoint, SDL_RenderDrawLine, or SDL_RenderDrawRect. These functions work on the windows/ubuntu versions of my program, but not on the emscripten version. I simply see the screen painted with the cleared color, but nothing drawn to it. Here's sample code that showcases the issue.

SDL2 empty transparent window in Linux

只谈情不闲聊 提交于 2020-01-15 05:54:26
问题 Here is some sample SDL2 code I tried to run on my Linux computer running Ubuntu 18.04 with KDE Plasma Desktop Environment (I have multiple desktop environments installed in case it is relevant): #include<iostream> #include<SDL2/SDL.h> int main(int argc, char** argv) { if(SDL_Init(SDL_INIT_VIDEO) != 0){ std::cerr << "SDL_Init() Error: " << SDL_GetError() << std::endl; return 1; } SDL_Window* win = SDL_CreateWindow( "Hello world", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640,480, 0 );

SDL2 empty transparent window in Linux

独自空忆成欢 提交于 2020-01-15 05:54:02
问题 Here is some sample SDL2 code I tried to run on my Linux computer running Ubuntu 18.04 with KDE Plasma Desktop Environment (I have multiple desktop environments installed in case it is relevant): #include<iostream> #include<SDL2/SDL.h> int main(int argc, char** argv) { if(SDL_Init(SDL_INIT_VIDEO) != 0){ std::cerr << "SDL_Init() Error: " << SDL_GetError() << std::endl; return 1; } SDL_Window* win = SDL_CreateWindow( "Hello world", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640,480, 0 );

SDL-Mixer audio stops upon starting Reactive-Banana input loop

我们两清 提交于 2020-01-14 22:52:43
问题 I've been working on a game that uses multiple audio tracks whose volumes are adjusted in realtime based on mouse motion. I'm using SDl-Mixer for audio, and Reactive-Banana for the game in general. The problem is that the tracks, which have all been started at the beginning, stop playing when the input-loop starts. The cause may be something else, but I wonder if there's some strange interaction between SDL and Reactive-Banana that I don't understand. I've been trying to puzzle this out for a