   Guichan and SDL in game black screen :/
  Hi there,I`m trying to finish writting my first game, just normal pong-clone. So far my game works without any (known) errors and I decided to add GUI. Just normal Main screen with "New Game", "Options" and "Exit" buttons. So I decided to use Guichan (just for record demos looks great - guichan vs predator) API is awesome everything is fully OO. I wrote GUI class as a part of game engine (if i could call "engine" to heart of my silly game...). Everything compiled and linked without any errors but when i run it i can see only black screen. I compiled game with -ggdb and in debuger i tryied to "avoid" rendering GUI (i will explain this soon). So game runs and I can play without GUI, but there are strange errors with input - i mean, when player push some keys to move paddle, paddle has some lags. For instance you push UP key once and nothing. When you loose, after restarting you will be moved up to some value. Just objects in game don`t response immidiatelly to keystroke. I guess I designed render and event loop in wrong way. Because this is my first game ever and even more i tryied to add in first-game-ever first-user-interface-ever i need you advice what is wrong. Here is only important (i guess) source code:Here you are Engine.h://snip..class Engine{public:Engine(bool full_screen);~Engine();void quitGame(int code);void handleKeyDown(SDL_keysym* keysym);void handleKeyUp(SDL_keysym* keysym);void handleEngineEvent(SDL_UserEvent* user);void processEvents(void);void setupRC(int width, int height);void startEngine();void doEngine();void render();private:void renderGame();void renderGui();//........};Now we are only interested in processEvents() and render() with renderGame()& renderGui().This is implementation of those methods:Engine.cppvoid Engine::render(){  //std::cout<<"Inside render() func"<<std::endl;  if(isGui)  {    //std::cout<<"before renderGui()>>>"<<std::endl;    renderGui();    //std::cout<<"after renderGui()<<<<"<<std::endl;  }   else    renderGame();}In constructor isGui is set to true (boolean variable) when player click the "New Game" button from class GUI, this class will send SDL event called RENDER_GAME. In Engine class processingEvents() function recieve this message and set isGui to false. This is processingEvents():void Engine::processEvents(void){SDL_Event event;while(SDL_PollEvent(&event)){ //ball->handleInput(event);   paddle_left->handleInput(event);   paddle_right->handleInput(event);switch(event.type){case SDL_USEREVENT:handleEngineEvent(&event.user);break;case SDL_KEYDOWN:handleKeyDown(&event.key.keysym);break;case SDL_KEYUP:handleKeyUp(&event.key.keysym);break;case SDL_QUIT:quitGame(0);break;} gui->pushInput(event); gui->logic();}return;} And handleEngineEvents():void Engine::handleEngineEvent(SDL_UserEvent* user){if(user->code == LEFT_PADDLE_SCORE)left_score++;if(user->code == RIGHT_PADDLE_SCORE)right_score++;if(user->code == MUTE_SOUNDS)mute_sounds = true;if(user->code == NO_MOUTE_SOUNDS)mute_sounds = false;if(user->code == RENDER_GAME)isGui = false;}And now it is my GUI.h file: #ifndef GUI_H #define GUI_H #include "Constans.h" #include "SDL/SDL.h" #include <iostream> #include <guichan.hpp> #include <guichan/sdl.hpp> #include <guichan/sdl/sdlimageloader.hpp>  class GUI : public gcn::ActionListener  {    public:GUI(SDL_Surface* screen);~GUI();void draw();void logic();void pushInput(SDL_Event event);void action(const gcn::ActionEvent& actionEvent);   private:void initMain();void initNewGame();void initOptions();void startNewGame();void exitFromGame();void generateEvent(int code);gcn::SDLInput* input;gcn::SDLGraphics* graphics;gcn::SDLImageLoader* imageLoader;gcn::ImageFont* font; gcn::Container* guiTop;gcn::Container* guiMain;gcn::Container* guiOptions; gcn::Label*  labelMain;gcn::Label*  labelOptions;gcn::Button* newGameButton;gcn::Button* optionsButton;gcn::Button* exitButton;gcn::Button* backButton;gcn::CheckBox* checkBox;gcn::Gui*    gui; SDL_Surface* screen;SDL_Event    event;  }; #endifConstructor gets SDL_Surface* from Engine. I don`t know why but in guichan doc its required. Now constructor code:GUI::GUI(SDL_Surface* screen){  this->screen = screen;    imageLoader = new gcn::SDLImageLoader();  gcn::Image::setImageLoader(imageLoader);    graphics = new gcn::SDLGraphics();  graphics->setTarget(screen);  //...In samples, demos and docs i saw that here usually is called SDL_SetVideoMode() wich i call in Init() function in constructor of engine. So there is my first question: I should have only call of SDL_SetVideMode in engine ? Or GUI should call it first (because gui is first launched) ? Maybe both - GUI call it for itself later engine to render game scene ?My second question about lags in input: What is wrong with my event loop ? Why i have lags in keystrokes ? Is it due to wrong event processing by GUI ?Sorry if my post is chaotic or hard to understand. This is my first game so i can`t even explain what I done and what I am going to do. I just think that my game is simply bad designed and full of crap ideas :/   
  Your code looks quite good but it's possible that you've aimed a little bit too high for your first game, by adding in things like 3rd party GUI libraries. I expect you should have initialised SDL yourself to begin with - don't rely on the GUI to do this (unless it says otherwise in its documentation). You should almost definitely have created the video surface first, and that is the surface you pass to GUIchan to render into. So make sure all your initialisation happens in the right order.You should probably only push input to the GUI if you haven't already handled it elsewhere.And is there a reason you must only render either the GUI or the game? Most games will render the GUI on top? At least if you render both, you will be able to see if it's a problem with just the GUI rendering or a problem with all your rendering.   