SDL
Rehashing the old perl SDL binding on cpan.org
Tobias Leich / SDL - search.cpan.org
If I want to move to C++ and SDL in the future, is Python and pygame a good way to learn SDL?
Source: (StackOverflow)
I was messing around with SDL and found out that you cannot rotate images with SDL. Everywhere the question was asked, people said to use OpenGL to do rotation. I always thought that SDL was completely separate from OpenGL, am I wrong in thinking this? I even found tutorials for using OpenGL within SDL, which confused me even further. What exactly is the relationship between SDL and OpenGL? Why not just use OpenGL if its more powerful and allows you to do more (this is from what I've read)?
Source: (StackOverflow)
I've just started experimenting with SDL in C++, and I thought checking for memory leaks regularly may be a good habit to form early on.
With this in mind, I've been running my 'Hello world' programs through Valgrind to catch any leaks, and although I've removed everything except the most basic SDL_Init()
and SDL_Quit()
statements, Valgrind still reports 120 bytes lost and 77k still reachable.
My question is: Is there an acceptable limit for memory leaks, or should I strive to make all my code completely leak-free?
Source: (StackOverflow)
What are the pros and cons to each? It seems they serve the same purpose. I have a few demos with each and they seem about the same. Performance or cross platform wise, is one better than the other?
The only thing I notice is that SDL seems to have more "helper" libraries (fonts, images, mixer, built in sound support, etc).
On its site, GLFW claims to be more "OpenGL" focused, but still have to use a GLEW to get any newer OpenGL features (same with SDL).
I guess I'm leaning towards using SDL now (more mature, more features, more community). Are there any reasons I've missed why GLFW stands out and I should use it instead of SDL?
Source: (StackOverflow)
I'm writing a 3D model viewer application as a hobby project, and also as a test platform to try out different rendering techniques. I'm using SDL to handle window management and events, and OpenGL for the 3D rendering. The first iteration of my program was single-threaded, and ran well enough. However, I noticed that the single-threaded program caused the system to become very sluggish/laggy. My solution was to move all of the rendering code into a different thread, thereby freeing the main thread to handle events and prevent the app from becoming unresponsive.
This solution worked intermittently, the program frequently crashed due to a changing (and to my mind bizarre) set of errors coming mainly from the X window system. This led me to question my initial assumption that as long as all of my OpenGL calls took place in the thread where the context was created, everything should still work out. After spending the better part of a day searching the internet for an answer, I am thoroughly stumped.
More succinctly: Is it possible to perform 3D rendering using OpenGL in a thread other than the main thread? Can I still use a cross-platform windowing library such as SDL or GLFW with this configuration? Is there a better way to do what I'm trying to do?
So far I've been developing on Linux (Ubuntu 11.04) using C++, although I am also comfortable with Java and Python if there is a solution that works better in those languages.
UPDATE: As requested, some clarifications:
- When I say "The system becomes sluggish" I mean interacting with the desktop (dragging windows, interacting with the panel, etc) becomes much slower than normal. Moving my application's window takes time on the order of seconds, and other interactions are just slow enough to be annoying.
- As for interference with a compositing window manager... I am using the GNOME shell that ships with Ubuntu 11.04 (staying away from Unity for now...) and I couldn't find any options to disable desktop effects such as there was in previous distributions. I assume this means I'm not using a compositing window manager...although I could be very wrong.
- I believe the "X errors" are server errors due to the error messages I'm getting at the terminal. More details below.
The errors I get with the multi-threaded version of my app:
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
after 73 requests (73 known processed) with 0 events remaining.
X Error of failed request: BadColor (invalid Colormap parameter)
Major opcode of failed request: 79 (X_FreeColormap)
Resource id in failed request: 0x4600001
Serial number of failed request: 72
Current serial number in output stream: 73
Game: ../../src/xcb_io.c:140: dequeue_pending_request: Assertion `req == dpy->xcb->pending_requests' failed.
Aborted
I always get one of the three errors above, which one I get varies, apparently at random, which (to my eyes) would appear to confirm that my issue does in fact stem from my use of threads. Keep in mind that I'm learning as I go along, so there is a very good chance that in my ignorance I've something rather stupid along the way.
SOLUTION: For anyone who is having a similar issue, I solved my problem by moving my call to SDL_Init(SDL_INIT_VIDEO)
to the rendering thread, and locking the context initialization using a mutex. This ensures that the context is created in the thread that will be using it, and it prevents the main loop from starting before initialization tasks have finished. A simplified outline of the startup procedure:
1) Main thread initializes struct
which will be shared between the two threads, and which contains a mutex.
2) Main thread spawns render thread and sleeps for a brief period (1-5ms), giving the render thread time to lock the mutex. After this pause, the main thread blocks while trying to lock the mutex.
3) Render thread locks mutex, initializes SDL's video subsystem and creates OpenGL context.
4) Render thread unlocks mutex and enters its "render loop".
5) The main thread is no longer blocked, so it locks and unlocks the mutex before finishing its initialization step.
Be sure and read the answers and comments, there is a lot of useful information there.
Source: (StackOverflow)
I'm learning a spot of 3d opengl, and it's going rather well, I've got a nice camera moving about and some simple cube objects, at the moment. Currently using vertex arrays, but I'm swapping to VBOs pretty quick here. I'm just trying to enable culling, however I'm not sure what order in which I ought to specify my vertices, right now this is what I'm doing:
void cube::update_verts(){
GLushort cur=0;
///back face
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z;
///right face
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z+sz;
///top face
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z+sz;
///front face
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z+sz;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z+sz;
///bottom face
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z+sz;
///left face
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z+sz;
}
///Drawing Code:
glVertexPointer(3,GL_FLOAT,0,object.verts);
glColorPointer(3,GL_UNSIGNED_BYTE,0,object.colors);
glDrawArrays(GL_QUADS,0,6*4);
However it's definitely quite wrong, because when I glEnable(GL_CULL_FACE);
my cubes don't show the correct faces (as seen below).
Normal
Problem Child
With both of these images culling is enabled.
In what order should I specify the vertices?
(EDIT) Updated Working Function:
void cube::update_verts(){
GLushort cur=0;
///top face
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z;
///bottom face
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z+sz;
///left face
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z+sz;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z;
///right face
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z+sz;
///front face
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z+sz;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z+sz;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z+sz;
///back face
verts[cur++]=x; verts[cur++]=y; verts[cur++]=z;
verts[cur++]=x; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y+sy; verts[cur++]=z;
verts[cur++]=x+sx; verts[cur++]=y; verts[cur++]=z;
}
Source: (StackOverflow)
I'm trying to load a PNG file using SDL but the program doesn't work and this error appears in the console
"libpng warning: iCCP: known incorrect sRGB profile"
Why this warning appears?
what should I do to solve this problem?
Source: (StackOverflow)
For a while I've been thinking of trying to do a port of one of my favorite classic PC games, The Ur-Quan Masters (aka Star Control 2) to the iPhone. UQM uses SDL for all its graphics, sound, input and other gamey stuff and there does seem to be a port of SDL to iPhone but it doesn't look very mature at this point.
Has anyone put the iPhone SDL port through its paces? How well does it work? What kinds of issues can I expect taking this project, which is already cross platform code to iPhone?
If SDL isn't an option can anyone reccomend an alternative framework to look at that will bridge the gap between SDL and the native libraries like OpenGL ES and Core Audio? Or is coding to those frameworks the best option?
Edit to add: Here's a link to a forum thread on the UQM forum about doing an iPhone port.
Source: (StackOverflow)
I am following along with the SDL2.0 tutorials by LazyFoo, using Code::Blocks 13.12. I have had no trouble getting SDL2 linked and running in VS2010 but have changed IDE and come across this error:
winapifamily.h: No such file or directory
I think everything is linked correctly. I have pointed the program to my SDL2 include and lib directories.
Buildlog: (error is occuring in file: ..\include\SDL2\SDL_platform.h)
=== Build: Debug in SDL2_Setup (compiler: GNU GCC Compiler) ===
fatal error: winapifamily.h: No such file or directory
=== Build fails: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===
This is my first time asking a question on here. I did Google for an answer and search the existing questions/answers on here but was unable to solve the issue. Here is my code also.
My Code:
// Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>
// Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main( int argc, char* args[] )
{
// The window we'll be rendering to
SDL_Window* window = NULL;
// The surface contained by the window
SDL_Surface* screenSurface = NULL;
// Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO) < 0 )
{
printf( "SDL could not initialize! SDL_GetError: %s\n", SDL_GetError() );
}
else
{
// Create window
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( window == NULL )
{
printf( "Window could not be created! SDL_GetError: %s\n", SDL_GetError() );
}
else
{
// Get window surface
screenSurface = SDL_GetWindowSurface( window );
// Fill the surface white
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF));
// Update the surface
SDL_UpdateWindowSurface( window );
// Wait two seconds
SDL_Delay( 2000 );
}
}
// Destroy window
SDL_DestroyWindow( window );
// Quit SDL subsystems
SDL_Quit();
return 0;
}
Source: (StackOverflow)
So I realize that there are various posts that cover pairs of these but I am having trouble understanding how they all fit together.
Explain what each of the following are used for and how they relate to each other:
glu
glew
glut
sdl
qt
openGL
webGL
Source: (StackOverflow)
I basically want to create a full screen window and draw text on it in different colors and sizes (and also update the screen). I've used pygame for this in python and I'm looking for a similar library (should be fairly easy to use).
+1 if it handles input too...
Source: (StackOverflow)
I tried to follow these two tutorials (or the applicable parts of them, due to version differences) to install SDL 2.0.2 to work with Xcode 5.1:
Tutorial 1
Tutorial 2
Running any program with the SDL 2 framework linked causes Xcode to crash with the following problem details:
Process: Xcode [1787]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 5.1 (5084)
Build Info: IDEFrameworks-5084000000000000~21
App Item ID: 497799835
App External ID: 444172641
Code Type: X86-64 (Native)
Parent Process: launchd [257]
Responsible: Xcode [1787]
User ID: 501
PlugIn Path: /Library/Frameworks/SDL2.framework/Versions/A/SDL2
PlugIn Identifier: org.libsdl.SDL2
PlugIn Version: 2.0.2 (2.0.2)
Date/Time: 2014-03-13 04:24:59.771 +0200
OS Version: Mac OS X 10.9.2 (13C64)
Report Version: 11
Anonymous UUID: EFECF2A0-A489-055E-0904-D3CD9E756EB0
Crashed Thread: 21 <lldb.process.internal-state(pid=1804)>
Exception Type: EXC_BAD_ACCESS (Code Signature Invalid)
Exception Codes: 0x0000000000000032, 0x0000000124718000
VM Regions Near 0x124718000:
Stack 0000000124696000-0000000124718000 [ 520K] rw-/rwx SM=COW thread 22
--> mapped file 0000000124718000-00000001247fd000 [ 916K] r--/rwx SM=COW /Library/Frameworks/SDL2.framework/Versions/A/SDL2
CG shared images 00000001c0003000-00000001c000b000 [ 32K] r--/r-- SM=SHM
Application Specific Information:
ProductBuildVersion: 5B130a
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8d1aca1a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8d1abd18 mach_msg + 64
2 com.apple.CoreFoundation 0x00007fff87ba8155 __CFRunLoopServiceMachPort + 181
3 com.apple.CoreFoundation 0x00007fff87ba7779 __CFRunLoopRun + 1161
4 com.apple.CoreFoundation 0x00007fff87ba70b5 CFRunLoopRunSpecific + 309
5 com.apple.HIToolbox 0x00007fff8e776a0d RunCurrentEventLoopInMode + 226
6 com.apple.HIToolbox 0x00007fff8e7767b7 ReceiveNextEventCommon + 479
7 com.apple.HIToolbox 0x00007fff8e7765bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
8 com.apple.AppKit 0x00007fff8145a3de _DPSNextEvent + 1434
9 com.apple.AppKit 0x00007fff81459a2b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
10 com.apple.dt.DVTKit 0x00000001067a3e31 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 84
11 com.apple.AppKit 0x00007fff8144db2c -[NSApplication run] + 553
12 com.apple.AppKit 0x00007fff81438913 NSApplicationMain + 940
13 libdyld.dylib 0x00007fff8dda55fd start + 1
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff8d1b1662 kevent64 + 10
1 libdispatch.dylib 0x00007fff88b8543d _dispatch_mgr_invoke + 239
2 libdispatch.dylib 0x00007fff88b85152 _dispatch_mgr_thread + 52
Thread 2:
0 libsystem_kernel.dylib 0x00007fff8d1b0e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ddccf08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff8ddcffb9 start_wqthread + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff8d1b0e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ddccf08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff8ddcffb9 start_wqthread + 13
Thread 4:: com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x00007fff8d1aca1a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8d1abd18 mach_msg + 64
2 com.apple.CoreFoundation 0x00007fff87ba8155 __CFRunLoopServiceMachPort + 181
3 com.apple.CoreFoundation 0x00007fff87ba7779 __CFRunLoopRun + 1161
4 com.apple.CoreFoundation 0x00007fff87ba70b5 CFRunLoopRunSpecific + 309
5 com.apple.Foundation 0x00007fff87db8967 +[NSURLConnection(Loader) _resourceLoadLoop:] + 348
6 com.apple.Foundation 0x00007fff87db876b __NSThread__main__ + 1318
7 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
8 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
9 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff8d1aca1a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8d1abd18 mach_msg + 64
2 com.apple.CoreFoundation 0x00007fff87ba8155 __CFRunLoopServiceMachPort + 181
3 com.apple.CoreFoundation 0x00007fff87ba7779 __CFRunLoopRun + 1161
4 com.apple.CoreFoundation 0x00007fff87ba70b5 CFRunLoopRunSpecific + 309
5 com.apple.DTDeviceKitBase 0x00000001109fb40e -[DTDKRemoteDeviceDataListener listenerThreadImplementation] + 162
6 com.apple.Foundation 0x00007fff87db876b __NSThread__main__ + 1318
7 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
8 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
9 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 6:: com.apple.CFSocket.private
0 libsystem_kernel.dylib 0x00007fff8d1b09aa __select + 10
1 com.apple.CoreFoundation 0x00007fff87bf3b83 __CFSocketManager + 867
2 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
3 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
4 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 7:: DYMobileDeviceManager
0 libsystem_kernel.dylib 0x00007fff8d1aca1a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8d1abd18 mach_msg + 64
2 com.apple.CoreFoundation 0x00007fff87ba8155 __CFRunLoopServiceMachPort + 181
3 com.apple.CoreFoundation 0x00007fff87ba7779 __CFRunLoopRun + 1161
4 com.apple.CoreFoundation 0x00007fff87ba70b5 CFRunLoopRunSpecific + 309
5 com.apple.Foundation 0x00007fff87dbaadc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 253
6 com.apple.Foundation 0x00007fff87ea34aa -[NSRunLoop(NSRunLoop) run] + 74
7 com.apple.GPUToolsMobileFoundation 0x0000000112ab0e0d -[DYMobileDeviceManager _deviceNotificationThread:] + 134
8 com.apple.Foundation 0x00007fff87db876b __NSThread__main__ + 1318
9 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
10 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
11 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 8:: CVDisplayLink
0 libsystem_kernel.dylib 0x00007fff8d1b0716 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ddcdc3b _pthread_cond_wait + 727
2 com.apple.CoreVideo 0x00007fff8d2d1a38 CVDisplayLink::runIOThread() + 656
3 com.apple.CoreVideo 0x00007fff8d2d178f startIOThread(void*) + 147
4 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
5 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
6 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 9:
0 libsystem_kernel.dylib 0x00007fff8d1b0e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ddccf08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff8ddcffb9 start_wqthread + 13
Thread 10:
0 libsystem_kernel.dylib 0x00007fff8d1b0e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ddccf08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff8ddcffb9 start_wqthread + 13
Thread 11:
0 libsystem_kernel.dylib 0x00007fff8d1aca1a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8d1abd18 mach_msg + 64
2 com.apple.CoreFoundation 0x00007fff87ba8155 __CFRunLoopServiceMachPort + 181
3 com.apple.CoreFoundation 0x00007fff87ba7779 __CFRunLoopRun + 1161
4 com.apple.CoreFoundation 0x00007fff87ba70b5 CFRunLoopRunSpecific + 309
5 com.apple.AppKit 0x00007fff815fa16e _NSEventThread + 144
6 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
7 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
8 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 12:
0 libsystem_kernel.dylib 0x00007fff8d1b0e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ddccf08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff8ddcffb9 start_wqthread + 13
Thread 13:
0 libsystem_kernel.dylib 0x00007fff8d1b0e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ddccf08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff8ddcffb9 start_wqthread + 13
Thread 14:
0 libsystem_kernel.dylib 0x00007fff8d1b0716 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ddcdc3b _pthread_cond_wait + 727
2 com.apple.Xcode.DevToolsCore 0x000000010c476363 -[XCBlockQueue _processBlocksInThreadSlotNumber:] + 524
3 com.apple.Foundation 0x00007fff87db876b __NSThread__main__ + 1318
4 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
5 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
6 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 15:
0 libsystem_kernel.dylib 0x00007fff8d1b0716 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ddcdc3b _pthread_cond_wait + 727
2 com.apple.Xcode.DevToolsCore 0x000000010c476363 -[XCBlockQueue _processBlocksInThreadSlotNumber:] + 524
3 com.apple.Foundation 0x00007fff87db876b __NSThread__main__ + 1318
4 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
5 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
6 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 16:
0 libsystem_kernel.dylib 0x00007fff8d1b0716 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ddcdc3b _pthread_cond_wait + 727
2 com.apple.Xcode.DevToolsCore 0x000000010c476363 -[XCBlockQueue _processBlocksInThreadSlotNumber:] + 524
3 com.apple.Foundation 0x00007fff87db876b __NSThread__main__ + 1318
4 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
5 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
6 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 17:: <lldb.comm.debugger.input>
0 libsystem_kernel.dylib 0x00007fff8d1b09aa __select + 10
1 com.apple.LLDB.framework 0x0000000113d965f0 lldb_private::ConnectionFileDescriptor::BytesAvailable(unsigned int, lldb_private::Error*) + 888
2 com.apple.LLDB.framework 0x0000000113d96052 lldb_private::ConnectionFileDescriptor::Read(void*, unsigned long, unsigned int, lldb::ConnectionStatus&, lldb_private::Error*) + 170
3 com.apple.LLDB.framework 0x0000000113d94493 lldb_private::Communication::ReadFromConnection(void*, unsigned long, unsigned int, lldb::ConnectionStatus&, lldb_private::Error*) + 97
4 com.apple.LLDB.framework 0x0000000113d940f1 lldb_private::Communication::ReadThread(void*) + 147
5 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
6 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
7 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 18:: <lldb.comm.xcode.lldb.comm>
0 libsystem_kernel.dylib 0x00007fff8d1b09aa __select + 10
1 com.apple.LLDB.framework 0x0000000113d965f0 lldb_private::ConnectionFileDescriptor::BytesAvailable(unsigned int, lldb_private::Error*) + 888
2 com.apple.LLDB.framework 0x0000000113d96052 lldb_private::ConnectionFileDescriptor::Read(void*, unsigned long, unsigned int, lldb::ConnectionStatus&, lldb_private::Error*) + 170
3 com.apple.LLDB.framework 0x0000000113d94493 lldb_private::Communication::ReadFromConnection(void*, unsigned long, unsigned int, lldb::ConnectionStatus&, lldb_private::Error*) + 97
4 com.apple.LLDB.framework 0x0000000113d940f1 lldb_private::Communication::ReadThread(void*) + 147
5 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
6 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
7 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 19:
0 libsystem_kernel.dylib 0x00007fff8d1aca1a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8d1abd18 mach_msg + 64
2 com.apple.CoreFoundation 0x00007fff87ba8155 __CFRunLoopServiceMachPort + 181
3 com.apple.CoreFoundation 0x00007fff87ba7779 __CFRunLoopRun + 1161
4 com.apple.CoreFoundation 0x00007fff87ba70b5 CFRunLoopRunSpecific + 309
5 com.apple.CoreFoundation 0x00007fff87c5c811 CFRunLoopRun + 97
6 com.apple.DebugSymbols 0x00007fff834007e3 SpotlightQueryThread(void*) + 355
7 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
8 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
9 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 20:: <lldb.process.gdb-remote.async>
0 libsystem_kernel.dylib 0x00007fff8d1b0716 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ddcdc3b _pthread_cond_wait + 727
2 com.apple.LLDB.framework 0x0000000113e37697 lldb_private::Condition::Wait(lldb_private::Mutex&, lldb_private::TimeValue const*, bool*) + 109
3 com.apple.LLDB.framework 0x0000000113e81752 lldb_private::Predicate<bool>::WaitForValueEqualTo(bool, lldb_private::TimeValue const*, bool*) + 90
4 com.apple.LLDB.framework 0x0000000113dadcb4 lldb_private::Listener::WaitForEventsInternal(lldb_private::TimeValue const*, lldb_private::Broadcaster*, lldb_private::ConstString const*, unsigned int, unsigned int, std::__1::shared_ptr<lldb_private::Event>&) + 324
5 com.apple.LLDB.framework 0x0000000113daddcb lldb_private::Listener::WaitForEvent(lldb_private::TimeValue const*, std::__1::shared_ptr<lldb_private::Event>&) + 27
6 com.apple.LLDB.framework 0x0000000113e8bb51 ProcessGDBRemote::AsyncThread(void*) + 1213
7 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
8 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
9 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 21 Crashed:: <lldb.process.internal-state(pid=1804)>
0 com.apple.LLDB.framework 0x0000000113d98990 lldb_private::DataExtractor::GetU32(unsigned long long*) const + 52
1 com.apple.LLDB.framework 0x0000000113e73045 ObjectFileMachO::ParseHeader() + 91
2 com.apple.LLDB.framework 0x0000000113e724fd ObjectFileMachO::CreateInstance(std::__1::shared_ptr<lldb_private::Module> const&, std::__1::shared_ptr<lldb_private::DataBuffer>&, unsigned long long, lldb_private::FileSpec const*, unsigned long long, unsigned long long) + 661
3 com.apple.LLDB.framework 0x0000000113ee9ac5 lldb_private::ObjectFile::FindPlugin(std::__1::shared_ptr<lldb_private::Module> const&, lldb_private::FileSpec const*, unsigned long long, unsigned long long, std::__1::shared_ptr<lldb_private::DataBuffer>&, unsigned long long&) + 1705
4 com.apple.LLDB.framework 0x0000000113e6bf43 ObjectContainerUniversalMachO::GetObjectFile(lldb_private::FileSpec const*) + 427
5 com.apple.LLDB.framework 0x0000000113ee9bd7 lldb_private::ObjectFile::FindPlugin(std::__1::shared_ptr<lldb_private::Module> const&, lldb_private::FileSpec const*, unsigned long long, unsigned long long, std::__1::shared_ptr<lldb_private::DataBuffer>&, unsigned long long&) + 1979
6 com.apple.LLDB.framework 0x0000000113ddafbc lldb_private::Module::GetObjectFile() + 210
7 com.apple.LLDB.framework 0x0000000113dde60f lldb_private::ModuleList::GetSharedModule(lldb_private::ModuleSpec const&, std::__1::shared_ptr<lldb_private::Module>&, lldb_private::FileSpecList const*, std::__1::shared_ptr<lldb_private::Module>*, bool*, bool) + 805
8 com.apple.LLDB.framework 0x0000000113f274d9 lldb_private::Target::GetSharedModule(lldb_private::ModuleSpec const&, lldb_private::Error*) + 543
9 com.apple.LLDB.framework 0x0000000113e64879 DynamicLoaderMacOSXDYLD::FindTargetModuleForDYLDImageInfo(DynamicLoaderMacOSXDYLD::DYLDImageInfo&, bool, bool*) + 391
10 com.apple.LLDB.framework 0x0000000113e6699f DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfos(std::__1::vector<DynamicLoaderMacOSXDYLD::DYLDImageInfo, std::__1::allocator<DynamicLoaderMacOSXDYLD::DYLDImageInfo> >&) + 487
11 com.apple.LLDB.framework 0x0000000113e65d7b DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfosAddress(unsigned long long, unsigned int) + 165
12 com.apple.LLDB.framework 0x0000000113e65612 DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos() + 154
13 com.apple.LLDB.framework 0x0000000113e65a0c DynamicLoaderMacOSXDYLD::NotifyBreakpointHit(void*, lldb_private::StoppointCallbackContext*, unsigned long long, unsigned long long) + 44
14 com.apple.LLDB.framework 0x0000000113d45d0f lldb_private::BreakpointOptions::InvokeCallback(lldb_private::StoppointCallbackContext*, unsigned long long, unsigned long long) + 43
15 com.apple.LLDB.framework 0x0000000113d43250 lldb_private::BreakpointLocation::InvokeCallback(lldb_private::StoppointCallbackContext*) + 82
16 com.apple.LLDB.framework 0x0000000113d43889 lldb_private::BreakpointLocation::ShouldStop(lldb_private::StoppointCallbackContext*) + 115
17 com.apple.LLDB.framework 0x0000000113d44386 lldb_private::BreakpointLocationCollection::ShouldStop(lldb_private::StoppointCallbackContext*) + 76
18 com.apple.LLDB.framework 0x0000000113f22748 lldb_private::StopInfoBreakpoint::ShouldStopSynchronous(lldb_private::Event*) + 232
19 com.apple.LLDB.framework 0x0000000113f319cf lldb_private::Thread::ShouldStop(lldb_private::Event*) + 653
20 com.apple.LLDB.framework 0x0000000113f365a3 lldb_private::ThreadList::ShouldStop(lldb_private::Event*) + 339
21 com.apple.LLDB.framework 0x0000000113f12485 lldb_private::Process::ShouldBroadcastEvent(lldb_private::Event*) + 375
22 com.apple.LLDB.framework 0x0000000113f1048c lldb_private::Process::HandlePrivateEvent(std::__1::shared_ptr<lldb_private::Event>&) + 356
23 com.apple.LLDB.framework 0x0000000113f12ae7 lldb_private::Process::RunPrivateStateThread() + 507
24 com.apple.LLDB.framework 0x0000000113f1262d lldb_private::Process::PrivateStateThread(void*) + 9
25 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
26 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
27 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 22:: DBGLLDBSessionThread
0 libsystem_kernel.dylib 0x00007fff8d1b0716 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ddcdc3b _pthread_cond_wait + 727
2 com.apple.LLDB.framework 0x0000000113e37697 lldb_private::Condition::Wait(lldb_private::Mutex&, lldb_private::TimeValue const*, bool*) + 109
3 com.apple.LLDB.framework 0x0000000113e81752 lldb_private::Predicate<bool>::WaitForValueEqualTo(bool, lldb_private::TimeValue const*, bool*) + 90
4 com.apple.LLDB.framework 0x0000000113dadcb4 lldb_private::Listener::WaitForEventsInternal(lldb_private::TimeValue const*, lldb_private::Broadcaster*, lldb_private::ConstString const*, unsigned int, unsigned int, std::__1::shared_ptr<lldb_private::Event>&) + 324
5 com.apple.LLDB.framework 0x0000000113daddcb lldb_private::Listener::WaitForEvent(lldb_private::TimeValue const*, std::__1::shared_ptr<lldb_private::Event>&) + 27
6 com.apple.LLDB.framework 0x0000000112c6f995 lldb::SBListener::WaitForEvent(unsigned int, lldb::SBEvent&) + 203
7 com.apple.dt.dbg.DebuggerLLDB 0x000000010981aa22 DBGLLDBSessionThread(void*) + 813
8 libsystem_pthread.dylib 0x00007fff8ddcb899 _pthread_body + 138
9 libsystem_pthread.dylib 0x00007fff8ddcb72a _pthread_start + 137
10 libsystem_pthread.dylib 0x00007fff8ddcffc9 thread_start + 13
Thread 21 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fe807c15fa0 rcx: 0x00000000000e4850 rdx: 0x00000000000e4850
rdi: 0x00007fe807c15ff8 rsi: 0x0000000124690310 rbp: 0x0000000124690290 rsp: 0x0000000124690290
r8: 0x0000000124718000 r9: 0x0000000000000004 r10: 0x0000000001555568 r11: 0x000000002fd20404
r12: 0x0000000000001000 r13: 0x00007fe807c15fa0 r14: 0x00007fe807c15ff8 r15: 0x00000000000e4850
rip: 0x0000000113d98990 rfl: 0x0000000000010246 cr2: 0x0000000124718000
Logical CPU: 2
Error Code: 0x00000004
Trap Number: 14
I've tried to repair permissions using the Disk Utility and also disabled Source Control in Xcode. The problem disappears if I simply delete the reference to SDL. For example the following program works initially, but crashes when I link the project to SDL:
// #include <SDL2/SDL.h>
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
Am I doing something wrong here?
Source: (StackOverflow)
I'm starting with SDL2 and having some trouble trying to understand what is a SDL_Renderer.
What is it? What does it do? Whats the difference between SDL_Renderer, SDL_Window, SDL_Surface and SDL_Texture and how they are related?
I had issues with this when trying to understand this introductory code:
#include <iostream>
#include <SDL2/SDL.h>
int main()
{
/* Starting SDL */
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
/* Create a Window */
SDL_Window *window = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
if (window == nullptr) {
std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
return 1;
}
/* Create a Render */
SDL_Renderer *render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (render == nullptr) {
std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl;
return 1;
}
/* Load bitmap image */
SDL_Surface *bmp = SDL_LoadBMP("./Tutorial/res/Lesson1/hello.bmp");
if (bmp == nullptr) {
std::cout << "SDL_LoadBMP Error: " << SDL_GetError() << std::endl;
return 1;
}
/* Upload surface to render, and then, free the surface */
SDL_Texture *texture = SDL_CreateTextureFromSurface(render, bmp);
SDL_FreeSurface(bmp);
if (texture == nullptr){
std::cout << "SDL_CreateTextureFromSurface Error: " << SDL_GetError() << std::endl;
return 1;
}
/* Draw the render on window */
SDL_RenderClear(render); // Fill render with color
SDL_RenderCopy(render, texture, NULL, NULL); // Copy the texture into render
SDL_RenderPresent(render); // Show render on window
/* Wait 2 seconds */
SDL_Delay(5000);
/* Free all objects*/
SDL_DestroyTexture(texture);
SDL_DestroyRenderer(render);
SDL_DestroyWindow(window);
/* Quit program */
SDL_Quit();
return 0;
}
I was using Twinklebear tutorial (suggested on SDL Wiki) and looked also on SDL Wiki Documentation and some books. But all of them assume that I know these definitions.
Source: (StackOverflow)
I need to suppress "-arch x86_64 -arch i386" flags Waf is passing to GCC.
I am building an SDL/Opengl application. If I link against 32 bit SDL runtime I get error
Undefined symbols for architecture i386:
"_SDL_Quit", referenced from:
__del_video in SDL_functions.c.2.o
__init_video in SDL_functions.c.2.o
If I link against 64 bit SDL runtime, I get error "Undefined symbols for architecture x86_64"
The compiler is apparently using flags
-arch x86_64 -arch i386
I understand that this causes GCC on OSX to try to compile for both architectures. I want to either compile for 64 bit, or compile for 32 bit. How do I suppress the flags for one architecture?
Source: (StackOverflow)
I'm kind of stuck on the logic behind an SDL2 texture. To me, they are pointless since you cannot draw to them.
In my program, I have several surfaces (or what were surfaces before I switched to SDL2) that I just blitted together to form layers. Now, it seems, I have to create several renderers and textures to create the same effect since SDL_RenderCopy
takes a texture pointer.
Not only that, but all renderers have to come from a window, which I understand, but still fouls me up a bit more.
This all seems extremely bulky and slow. Am I missing something? Is there a way to draw directly to a texture? What are the point of textures, and am I safe to have multiple (if not hundreds) of renderers in place of what were surfaces?
Source: (StackOverflow)