Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display Size and loading Lenna
#1
Hello,

When I try and get the pi to display the window in full-screen my monitor will turn black and stay black until the project breaks. When I hard code the resolution it works fine. For now I am just running the code with the resolution hard coded but any tips regarding this subject would be cool. 

I am also having another issue that could very well be a typo. When I try and get the picture of Lenna to come up I can see a opengl window opening up but the program output gives me a error until I break the program. I believe it has something to do when I draw the rectangle but I am not certain.
Good Luck,

Juston Metarref
Currently a programming student
Future Gameplay/Ai Programer
Reply
#2
Hi Juston
what code are you using to create full screen?

and what is the error that the code outputs.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#3
The code I use for full screen is
Code:
uint width, height;
    graphics_get_display_size(0, &width, &height);
    init_ogl(p_state, width, height);

As far as the error I get when loading Lenna it is just the oh bugger from this block of code: 
Code:
/*
*
*Draw a Rectangle this is a hard coded
*draw witch is only good for the triangle
*
*/
void Draw(Target_State *p_state)
{
    
    GLfloat RectVertices[] =
    {
        -0.5f, 0.5f, 0.0f,//pos 0
         0.0f, 0.0f, //texCoord 0
        -0.5f, -0.5f, 0.0f,//pos 1
         0.0f, 1.0f, //texCoord 1
        0.5f, -0.5f, 0.0f, //pos 2
        1.0f, 1.0f,//texCoord 2
        0.5f, 0.5f, 0.0f,//pos 3
        1.0f, 0.0f//texCoord 3        
    };
    
    GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
    
    // Setup the veiwport
    glViewport(0, 0, p_state->width, p_state->height);
    
    
    // Clear the color buffer
    glClear(GL_COLOR_BUFFER_BIT);
    
    
    // set up the program object
    glUseProgram(p_state->user_data->programObject);
    
    
    //Load the vertex pos
    glVertexAttribPointer(p_state->user_data->positionLoc, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &RectVertices[3]);

    //Load the texture coords
    glVertexAttribPointer(p_state->user_data->texCoordLoc, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &RectVertices[3]);
    
    glEnableVertexAttribArray(p_state->user_data->positionLoc);
    glEnableVertexAttribArray(p_state->user_data->texCoordLoc);
    
    
    //bind the texture
    glActiveTexture ( GL_TEXTURE0 );
    glBindTexture (GL_TEXTURE_2D, p_state->user_data->textureId);
    
    
    //Draw the rect as 2 sets of 3 vertices
    glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
    
    if (glGetError() != GL_NO_ERROR) printf("Oh bugger\n");
    
}
Good Luck,

Juston Metarref
Currently a programming student
Future Gameplay/Ai Programer
Reply
#4
hmmm looks, ok, better zip it up and send it over to me...
Easier for me to debug in person
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#5
ah wait... I see something Big Grin

What vertex position are you loading? See if you can see it
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#6
I see something else but it will depend what values you have for indices?
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#7
Well I fixed the issue in the vertex position, was loading &RecVertices[3] when I should have been doing just RecVertices. 

As far as the values i have for my indices I believe it is this:
Code:
    GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
Good Luck,

Juston Metarref
Currently a programming student
Future Gameplay/Ai Programer
Reply
#8
yeah indices are fine, and you fixed the typo in vertices, which is the base point where the vertices start, so by setting it 3 more, the count would go past the values and give you some odd content which can result in nothing being displayed.

Did that fix the problems, you can now see Lenna?

If not, zip it up, and I'll check it out in the morning, its a little late here in Holland and I am heading for bed.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#9
ok since you sent me the code I had a quick look and its a bit of a mess, why do you have multiple build configurations? It looks like you have an MSbuild config but not properly set up.
Because of this strange mix of MSBuld and GNU I can't actually get your project to run
Can I suggest you scrap this, start a new project and this time be careful to select GNU make...

Other issues, well you have a pragama once in your code in the cpp file, you should only put them in .h files.

in your Files to transfer you are mixing separators, you use ; for the 1st 5 or 6 then a , 
you can't mix them,  
GNU make wants to see ;
MSbuild wants to see ,


In your Main loop here, do you see that you are trying to draw, something BEFORE you load it? The book does say to load it after the Filehandler

There's an important typo too, when you try to find the address of a_position attribute, ..see if you can find that
Code:
int main(int argc, char *argv[])
{
    UserData user_data;
    bcm_host_init(); //RPI needs this
    esInitContext(p_state);
    uint width, height;
    //graphics_get_display_size(0, &width, &height);
    //init_ogl(p_state, width, height);
    init_ogl (p_state, 720, 720);
    p_state->user_data = &user_data;
    
    MyFiles FileHandler;
    
    if (!Init(p_state))
        return 0;
    esRegisterDrawFunc(p_state, Draw);
    //now do the graphic loop
    esMainLoop(p_state);
    

    int Width, Height;
    char* OurRawData = FileHandler.Load((char*)"../Assets/Lenna.png", &Width, &Height);
    if (OurRawData == NULL) printf("The thing didnt load\n");
    
    p_state->user_data->textureId = CreateTexture2D(Width, Height, OurRawData);
    
}



Something else to look at in the main loop, once you move that texture creation to just after FileHandler, what happens to the value we store in p_state->user_data->textureID .....if a few lines later we 
init p_state 

have a think...

But for sure, create a new project, I dunno what the exact cause is for the multiple configs and semi msbuild stuff, but it is confusing, so much quicker to start again and just copy your files into the new GNU Make Project.

I've fixed your project here, but I really want you to try to locate the issues, so let me know tomorrow if you need me to send this back to you as a working version.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#10
The Display size, is something else, I need to check that out.

and after a quick check, the early systems don't properly set up the display size to allow for full screen display, but you can add to the init_ogl function and the display will stretch to the size of your screen
Code:
    state->width = width;
    state->height = height;
    
    dest_rect.x = 0;
    dest_rect.y = 0;
    dest_rect.width = state->width; // it needs to know our window size
    dest_rect.height = state->height;
    
    src_rect.x = 0;
    src_rect.y = 0;
// ADD these two lines to allow full screen to work    
    src_rect.width = width << 16;
    src_rect.height = height << 16;
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)