You are not logged in.

#1 2016-08-15 18:37:25

valvakir
Member
Registered: 2016-08-15
Posts: 7

SDL Wierdness

I set up my Arch Linux a few days ago, and I have been experiencing some general wierdnes, which culminated now that I have tried to build an OpenGL app with SDL. Everything compiles and when I run it, my entire desktop freezes out and starts acting wierd,  I cannot AltTab, etc.
Before, when I tried to replace nouveau with nvidia proprietary drivers and libgl docky would show and I could launch programs but I got an error message along the lines: Unable to start Plasma 5 due to OpenGL2 problems.
I think there is something up with drivers. I have a laptop with a GT940M and Intel integrated graphics.

I have tried searching far and wide for a solution, but haven't come up with anything, so I ask as a last resort.
If I use nouveau the desktop functions perfectly and the system is stable (and I love it, and wouldn't want to replace it), however that SDL crash keeps on happening and I cannot build programs.

If I need to post any log files, please tell me which. I'm sorry to be asking such a broad question, but I honestly have no idea how to fix it.


Thanks.

Last edited by valvakir (2016-08-15 18:37:40)

Offline

#2 2016-08-15 19:28:57

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: SDL Wierdness

I'm confused... Are you working on a compile time issue or a runtime issue?

What is the "general weirdness" you've been experiencing?

Is your video card one of those "bumblebee" thingies?

EDIT: Ohhhhhhhhhh... It's an SDL program YOU'RE writing. I see. smile

Last edited by drcouzelis (2016-08-15 20:41:00)

Offline

#3 2016-08-15 19:35:38

valvakir
Member
Registered: 2016-08-15
Posts: 7

Re: SDL Wierdness

It's a runtime issue, I'm sorry, my first post is a little confusing.
No I'm not using bumblebee, I didn't see it as necessary.

When the SDL app runs, it makes my taskbar on KDE unclickable, it cuts off the bottom portion of the enitre screen and makes it black. The SDL window that I'm trying to create pops up and closes as it should, but it is not movable, and also I can't use any systemwide keyboard shortcuts.

Offline

#4 2016-08-15 19:43:01

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: SDL Wierdness

Buggy graphics code, especially in the main loop or game loop, will cause a bunch of weird stuff. I doubt you have any driver/hardware problems. Some things to check...
-Do you have the correct sdl and opengl libraries?
-Are you linking them correctly, and in the right order?
-Are you using any "odd" compiler flags IE cpu optimizations?

Once this is done and confirmed fine, we debug the program. Without code this is guesswork on my part. Perhaps a paste of relevant portions of code to a pastebin service would be a good idea. However, things that cause the type of error you describe, or a "permanent zombie" process are, in my experience:
-Incorrect clear/draw cycle. Drawing before clearing, forgetting to clear, neglecting the importance of a clear/draw cycle and thus not having one...
-Incorrect event handling. Lack of an event handler, or forgetting to check for any exit condition...
-Improper use of while loops. Infinite loops, loops getting stuck and then missing the event handler or something else that's important...
-Improper window settings at creation time, missing window attributes... Though this would likely segfault.

Almost all of these will compile, some without warnings, and then produce run-time errors you are experiencing. The fix is to make sure your code is not bugged, that you have all the libraries, and they are linked correctly.

Good luck!

EDIT: I believe SDL has window handle/decoration flags you need to set. Then it should respond to movement.

EDIT 2: This is it: https://wiki.libsdl.org/SDL_WindowFlags it also talks about opengl, and should be a good tid-bit for you smile

Last edited by JohnBobSmith (2016-08-15 19:47:47)


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#5 2016-08-15 19:50:41

valvakir
Member
Registered: 2016-08-15
Posts: 7

Re: SDL Wierdness

No, I have no game loop, it is literally the SDL2 boilerplate code (I even tried copy-pasting code directly from the SDL2 examples on their wiki).
I do think it may be a problem with openGL libraries and I also didn't think the order mattered. The examples online show to only link SDL2 library.

I tried the -lGL linker flag before and after the -lSDL2 flag and it did not matter. I've been google-ing for hours now.


EDIT: I saw your edit just now, and I will try with creating an OpenGL context.
EDIT: Thanks very much for your help, I know that this very likely isn't an Arch problem, and thus does not belong here.

Last edited by valvakir (2016-08-15 19:52:51)

Offline

#6 2016-08-15 19:57:30

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: SDL Wierdness

Doh! Which tutorial sites? And why are you copy-pasting? You should be typing everything, to learn it more effectively. smile Post whatever code you have, preferably to an external stie.

EDIT: Happy To Help. If you found a working solution, please append solved to your original posts title. smile

Last edited by JohnBobSmith (2016-08-15 20:00:10)


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#7 2016-08-15 20:36:42

valvakir
Member
Registered: 2016-08-15
Posts: 7

Re: SDL Wierdness

Nope, still not happening. I setup the entire GL loop, with event handling and it still nearly crashes my entire desktop. I get some errors when i run journalctl -xe:

Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 876, resource id: 54606871, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 887, resource id: 54606875, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 898, resource id: 54606879, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 909, resource id: 54606883, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 920, resource id: 54606887, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 931, resource id: 54606891, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 946, resource id: 54606895, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 957, resource id: 54606899, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1082, resource id: 54606954, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:14 artemis plasmashell[503]: Could not resolve property : radialGradient4857
Aug 15 22:28:14 artemis plasmashell[503]: Could not resolve property : radialGradient4857
Aug 15 22:28:14 artemis plasmashell[503]: Could not resolve property : radialGradient4857
Aug 15 22:28:14 artemis plasmashell[503]: Could not resolve property : radialGradient4857
Aug 15 22:28:16 artemis kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 2025, resource id: 54607113, major code: 18 (ChangeProperty), minor code: 0
Aug 15 22:28:16 artemis kdeinit5[407]: powerdevil: Scheduling inhibition from ":1.16" "/opt/google/chrome/google-chrome" with cookie 67 and reason "Playing video"
Aug 15 22:28:16 artemis kdeinit5[407]: powerdevil: Scheduling inhibition from ":1.151" "/opt/google/chrome/google-chrome" with cookie 68 and reason "Playing video"
Aug 15 22:28:16 artemis kdeinit5[407]: powerdevil: Scheduling inhibition from ":1.152" "/opt/google/chrome/google-chrome" with cookie 69 and reason "Playing audio"
Aug 15 22:28:18 artemis kdeinit5[407]: powerdevil: Releasing inhibition with cookie  68
Aug 15 22:28:18 artemis kdeinit5[407]: powerdevil: It was only scheduled for inhibition but not enforced yet, just discarding it
Aug 15 22:28:18 artemis kdeinit5[407]: powerdevil: Releasing inhibition with cookie  67
Aug 15 22:28:18 artemis kdeinit5[407]: powerdevil: It was only scheduled for inhibition but not enforced yet, just discarding it
Aug 15 22:28:20 artemis kdeinit5[407]: powerdevil: Releasing inhibition with cookie  69
Aug 15 22:28:20 artemis kdeinit5[407]: powerdevil: It was only scheduled for inhibition but not enforced yet, just discarding it
Aug 15 22:28:21 artemis kdeinit5[407]: powerdevil: Enforcing inhibition from ":1.16" "/opt/google/chrome/google-chrome" with cookie 67 and reason "Playing video"
Aug 15 22:28:21 artemis kdeinit5[407]: powerdevil: By the time we wanted to enforce the inhibition it was already gone; discarding it
Aug 15 22:28:21 artemis kdeinit5[407]: powerdevil: Enforcing inhibition from ":1.151" "/opt/google/chrome/google-chrome" with cookie 68 and reason "Playing video"
Aug 15 22:28:21 artemis kdeinit5[407]: powerdevil: By the time we wanted to enforce the inhibition it was already gone; discarding it
Aug 15 22:28:21 artemis kdeinit5[407]: powerdevil: Enforcing inhibition from ":1.152" "/opt/google/chrome/google-chrome" with cookie 69 and reason "Playing audio"
Aug 15 22:28:21 artemis kdeinit5[407]: powerdevil: By the time we wanted to enforce the inhibition it was already gone; discarding it
Aug 15 22:28:53 art kwin_x11[491]: QXcbConnection: XCB error: 3 (BadWindow), sequence: 10807, resource id: 54607284, major code: 18 (ChangeProperty), minor code: 0

I know it only states some chrome errors, but the cause must be my shitty little program, because those errors only occur when I run the SDL app. It is a bit unstructured, because I'm only trying to get it to work, but this is the code:

#include <stdio.h>
#include "SDL2/SDL.h"
#include <GL/glew.h>


int main(int argc, char *argv[])
{

	SDL_Window *window;               
	SDL_GLContext glContext;

	SDL_Init(SDL_INIT_EVERYTHING);             
	
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    	// Create an application window with the following settings:
    	window = SDL_CreateWindow(
        	"An SDL2 window",                  
        	SDL_WINDOWPOS_CENTERED,           
        	SDL_WINDOWPOS_CENTERED,          
        	640, 480, SDL_WINDOW_OPENGL);

	glContext = SDL_GL_CreateContext(window);
	

	GLenum status = glewInit();

	if(status != GLEW_OK) {
		printf("Shit just hit the fan!\n");
		return -10;
	}


    	if (window == NULL) {
        	// In the case that the window could not be made...
        	printf("Could not create window: %s\n", SDL_GetError());
        	return 1;
    	}
	

	SDL_Event e;
	bool isClosed = false;
	
	while(!isClosed) {
		
		glClearColor(0.0f, 0.15f, 0.3f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT);

		while(SDL_PollEvent(&e)){
			if(e.type == SDL_QUIT)
				isClosed = true;
		}
	}




    	SDL_GL_DeleteContext(glContext);
	SDL_DestroyWindow(window);
	
    	SDL_Quit();
    
	return 0;
}

I usually don't write code ths ugly smile

I'm plain out of ideas and don't know what to do.

Last edited by valvakir (2016-08-15 20:38:05)

Offline

#8 2016-08-16 01:39:59

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: SDL Wierdness

You're missing a bracket right at the end, which closes your while(!isClosed) { loop. The correct last ~5 lines should be:

        while(!isClosed) { //Missing end bracket! 
        //Do whatever..
        // ...
    	SDL_GL_DeleteContext(glContext);
	SDL_DestroyWindow(window);
	
    	SDL_Quit();
    
	return 0;
    } //Place bracket here, close while loop.
} //Close main.

EDIT: I hope that makes sense, edited for clarity.

EDIT 2: You have more bracket errors, so I will do a completely fixed pastebin for you to use. One moment...

EDIT 3: Differences in style have thrown me off. For instance, I would never write:

			if(e.type == SDL_QUIT)
				isClosed = true;

Hence why I suspected bad brackets. The same line for me would be:

			if(e.type == SDL_QUIT) {
				isClosed = true;
                        }

And I can no longer troubleshoot at this time. I will try to get back to you tomorrow... smile

Last edited by JohnBobSmith (2016-08-16 01:54:12)


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

Board footer

Powered by FluxBB