hamidrm
Posts: 6
Joined: Fri Aug 11, 2017 10:27 pm

rPi3 : Special Distro Without X

Fri Aug 11, 2017 10:38 pm

I build my own distro for rPi3 by buildroot ( Kernel + BusyBox + SDL + OpenGL ES) and did not use X server, but I needed to render images on fb, then I chose SDL and OpenGL ES to do this.
I have two problem now :

1. I wrote below code as a test program:

Code: Select all

        #include "bcm_host.h"
        #include <SDL/SDL.h>
        #include <GLES/gl.h>

        int cont = 1;
        SDL_Surface * screenSurface = NULL;

        void initOGL(){
             if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
                return;
             }

             if((screenSurface = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL) {
                 return;
             }
             SDL_ShowCursor(SDL_DISABLE);
             glClearColor(0, 0, 1, 0);
    
             glViewport(0, 0, 640, 480);

             glMatrixMode(GL_PROJECTION);
             glLoadIdentity();

             glMatrixMode(GL_MODELVIEW);

             glEnable(GL_TEXTURE_2D);

             glLoadIdentity();
         }
         void render(){
             glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
             glLoadIdentity();
             glClearColor(1, 0.8, 0.2, 0);
             SDL_GL_SwapBuffers();
         }
         void exitfunc()
         {
            SDL_Quit();
            bcm_host_deinit();
         }



         int main(int argc, char *argv[]) {
           bcm_host_init();
           atexit(exitfunc);
           initOGL();
           while (cont) {
             render();
             SDL_PumpEvents();
             Uint8 *state = SDL_GetKeyState(NULL);
             if (state[SDLK_RETURN])
                 cont = 0;
           }
           return 0;
         }
I expect to screen color be blue , But it is black!
And "Enter" key does not effect. Where is my mistake(s) ?

2. I want to have tty2 on a different frame buffer than tty1.
Thus when user switch to tty1 , can access to console and when switch to tty2 can see SDL output. my question is how can I make tty2 displying on another fb?

Return to “Graphics programming”

Who is online

Users browsing this forum: No registered users and 2 guests