Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display Size and loading Lenna
#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


Messages In This Thread
Display Size and loading Lenna - by mayoricecream - 04-24-2018, 07:58 PM
RE: Display Size and loading Lenna - by mayoricecream - 04-24-2018, 10:23 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)