Forums
Display Size and loading Lenna - Printable Version

+- Forums (http://www.scratchpadgames.net/forums)
+-- Forum: Main Forums (http://www.scratchpadgames.net/forums/forumdisplay.php?fid=1)
+--- Forum: Help my code won't work?? (http://www.scratchpadgames.net/forums/forumdisplay.php?fid=22)
+--- Thread: Display Size and loading Lenna (/showthread.php?tid=74)

Pages: 1 2


Display Size and loading Lenna - mayoricecream - 04-24-2018

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.


RE: Display Size and loading Lenna - Brian Beuken - 04-24-2018

Hi Juston
what code are you using to create full screen?

and what is the error that the code outputs.


RE: Display Size and loading Lenna - mayoricecream - 04-24-2018

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");
    
}



RE: Display Size and loading Lenna - Brian Beuken - 04-24-2018

hmmm looks, ok, better zip it up and send it over to me...
Easier for me to debug in person


RE: Display Size and loading Lenna - Brian Beuken - 04-24-2018

ah wait... I see something Big Grin

What vertex position are you loading? See if you can see it


RE: Display Size and loading Lenna - Brian Beuken - 04-24-2018

I see something else but it will depend what values you have for indices?


RE: Display Size and loading Lenna - mayoricecream - 04-24-2018

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 };



RE: Display Size and loading Lenna - Brian Beuken - 04-24-2018

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.


RE: Display Size and loading Lenna - Brian Beuken - 04-25-2018

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.


RE: Display Size and loading Lenna - Brian Beuken - 04-25-2018

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;