Results 1 to 7 of 7

Thread: Crashes after 3rd glGenTextures

  1. #1
    Member Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    93

    Crashes after 3rd glGenTextures

    Edit: Damn I meant its glTexImage2D in the subject.

    I use 3 textures, all 512x512 RGB. Heres the code

    Code :
     
    GLvoid Opengl_Init(GLvoid)
    {
    	glClearColor(1.0, 1.0, 1.0, 0.0);
    	glShadeModel(GL_FLAT);
    	glLineWidth(2.5);
     
    	glGenTextures(1, &StartupTex_Name);
    	glBindTexture(GL_TEXTURE_2D, StartupTex_Name);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, startscreen);
     
    	glGenTextures(2, &MainmenuTex_Name);
    	glBindTexture(GL_TEXTURE_2D, MainmenuTex_Name);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, mainmenu);
     
    	glGenTextures(3, &HelpTex_Name);
    	glBindTexture(GL_TEXTURE_2D, HelpTex_Name);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, helpscreen);
     
    }
    Now it crashes on the last glTexImage2D (helpscreen) though I cant see how! The pointer helpscreen does contain the bitmap, I tested it by outputting them.
    So can anyone help me?

    [This message has been edited by blood.angel (edited 07-06-2003).]

  2. #2
    Member Contributor
    Join Date
    Apr 2002
    Location
    kremnica, slovakia, europe, earth, sol :-)
    Posts
    99

    Re: Crashes after 3rd glGenTextures

    do you have declarations like this:

    GLuint startscreen;
    GLuint mainmenu[2];
    GLuint helpscreen[3];

    because you are generating 1 texture name and storing it at address &startscreen, 2 names at &mainmenu and 3 names at &helpscreen... i think this is your mistake. if not, are startscreen, mainmenu and helpscreen arrays of GLuint? are you using drivers compatible with your os? are you sure you haven't corrupted something before? and so on....

    [This message has been edited by miko (edited 07-06-2003).]

  3. #3
    Member Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    93

    Re: Crashes after 3rd glGenTextures

    I had it working when helpscreen, startscreen and mainmenu were arrays (eg GLubyte helpscreen[512][512][3]) but I thought that was not elegant and wanted to change them to GLubyte* calloc(512*512*3, sizeof(GLubyte)) allocated arrays instead.

    Now its stumped me why it doesnt work. Ive forced the three to output what they store to .raw files before the above listed function and all three are perfect.

    [This message has been edited by blood.angel (edited 07-06-2003).]

    [This message has been edited by blood.angel (edited 07-06-2003).]

  4. #4
    Member Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    93

    Re: Crashes after 3rd glGenTextures

    Nevermind, I went back to test them again. Somehow the pics ares getting passed back from the reading function.

    Stil, pretty weird why the error shows up here though.

  5. #5
    Member Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    93

    Re: Crashes after 3rd glGenTextures

    Ignore my last post.
    IT DOES PASS the textures properly.
    So Im back at still having the problem.

    Can you pass (Glubyte *) arrays to glTexImage2D in the first place?

  6. #6
    Member Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    93

    Re: Crashes after 3rd glGenTextures

    Originally posted by miko:
    do you have declarations like this:

    GLuint startscreen;
    GLuint mainmenu[2];
    GLuint helpscreen[3];

    because you are generating 1 texture name and storing it at address &startscreen, 2 names at &mainmenu and 3 names at &helpscreen... i think this is your mistake. if not, are startscreen, mainmenu and helpscreen arrays of GLuint? are you using drivers compatible with your os? are you sure you haven't corrupted something before? and so on....

    [This message has been edited by miko (edited 07-06-2003).]
    Thanks that was it!
    From reading the red book I thought it meant you could state the number for its label. Its a bit vague explaining it IMO.

    And its weird that it worked when the bitmaps were stored in 3D arrays.
    Thanks again.

  7. #7
    Member Contributor
    Join Date
    Apr 2002
    Location
    kremnica, slovakia, europe, earth, sol :-)
    Posts
    99

    Re: Crashes after 3rd glGenTextures

    yup... next time i will not post at 3am i wanted this

    // startup screen will be covered by single texture
    GLuint StartupTex_Name;
    // i will need 2 textures for mainmenu
    GLuint MainmenuTex_Name[2];
    // help will be veeeery big it will require 3 textures
    GLuint HelpTex_Name[3];

    but i assume this is not the think you wanted to do. i assume you wanted a single texture for startup, menu and help. you should solve it like this:

    GLuint temp[3], StartupTex_Name,
    MainmenuTex_Name,
    HelpTex_Name;
    unsigned char startscreen[512*512*3];
    unsigned char mainmenu[512*512*3];
    unsigned char helpscreen[512*512*3];

    /*
    fill startscreen, mainmenu and helpscreen with some data
    */

    glGenTextures(3, &temp);
    StartupTex_Name = temp[0];
    MainmenuTex_Name = temp[1];
    HelpTex_Name = temp[2];

    glBindTexture(GL_TEXTURE_2D,StartupTex_Name);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, startscreen);

    glBindTexture(GL_TEXTURE_2D, MainmenuTex_Name);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, mainmenu);

    glBindTexture(GL_TEXTURE_2D, HelpTex_Name);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, helpscreen);

    or

    glGenTextures(1, &StartupTex_Name);
    glBindTexture(GL_TEXTURE_2D, StartupTex_Name);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, startscreen);

    glGenTextures(1, &MainmenuTex_Name);
    glBindTexture(GL_TEXTURE_2D, MainmenuTex_Name);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, mainmenu);
    glGenTextures(1, &HelpTex_Name);
    glBindTexture(GL_TEXTURE_2D, HelpTex_Name);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, helpscreen);

    this is all what i tried to say but.... i screwed it up and i hope it's clear now

    [This message has been edited by miko (edited 07-06-2003).]

Similar Threads

  1. glGenTextures
    By Omaha in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-22-2005, 07:14 PM
  2. glGenTextures() gives 0
    By Markkos in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-10-2004, 01:06 AM
  3. glGenTextures ... what's going on?
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-03-2004, 05:10 AM
  4. glBindTexture and glGenTextures
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-09-2001, 11:48 PM
  5. glGenTextures gives back a zero
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-10-2000, 12:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean