pointer to int

Discussion in 'C++' started by Michael, Jul 18, 2010.

  1. Michael

    Michael Guest

    Hi
    If I do:
    SDL_Surface* vector[9];
    vector[0] = IMG_load(...);
    vector[1] = ...
    I get:
    invalid conversion from ‘SDL_Surface*’ to ‘int’
    Any ideas on how to do such? Many thanks
    Michael
     
    Michael, Jul 18, 2010
    #1
    1. Advertising

  2. Michael

    Michael Guest

    PS: Exactly like so and TextureId is a int

    lotto[TextureId] = IMG_Load(TextureFileName);
     
    Michael, Jul 18, 2010
    #2
    1. Advertising

  3. * Michael, on 18.07.2010 13:27:
    > Hi
    > If I do:
    > SDL_Surface* vector[9];
    > vector[0] = IMG_load(...);
    > vector[1] = ...
    > I get:
    > invalid conversion from ‘SDL_Surface*’ to ‘int’
    > Any ideas on how to do such? Many thanks


    Under reasonable assumptions the code you've shown should work.

    Post a more complete example, like, actual code, and actual error message and
    error location.


    Cheers & hth.,

    - Alf

    --
    blog at <url: http://alfps.wordpress.com>
     
    Alf P. Steinbach /Usenet, Jul 18, 2010
    #3
  4. Michael

    Michael Guest

    Well I try to get around this error:
    libpng error: Decompression error
    which i get at runtime. So i want to move this out of the texture load
    function into a init function:

    SDL_Surface* lotto[TextureId]

    than later the texture load function:

    lotto[TextureId] = IMG_Load(TextureFileName)


    but now I get at compile:
    ‘lotto’ was not declared in this scope. How should i declare lotto?
    Many thanks
    Michael
     
    Michael, Jul 18, 2010
    #4
  5. Michael

    Michael Guest

    So now to avoid:
    >> libpng error: Decompression error

    which occurs at: IMG_Load
    I could move SDL_Surface out of the texture load function?

    int LoadGLTexture(char *pFileName, int TextureId, SDL_Surface* lotto[]);

    This prototype is wrong. How should it be? See also here:
    http://www.gamedev.net/community/forums/topic.asp?topic_id=546917
    Thanks
     
    Michael, Jul 19, 2010
    #5
  6. Michael

    Michael Guest

    if u don't know get lost
     
    Michael, Jul 19, 2010
    #6
  7. * Michael, on 19.07.2010 14:28:
    > if u don't know get lost


    You're supplying to little information for anyone to help you.

    Please read <url: http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8
    >.


    Then repost your questions following the guidlelines there.


    Cheers & hth.,

    - Alf

    --
    blog at <url: http://alfps.wordpress.com>
     
    Alf P. Steinbach /Usenet, Jul 19, 2010
    #7
  8. Michael

    LR Guest

    Michael wrote:
    > Well I try to get around this error:
    > libpng error: Decompression error
    > which i get at runtime.


    Can you say what compiler, linker and debugger you are using?


    > So i want to move this out of the texture load
    > function into a init function:
    >
    > SDL_Surface* lotto[TextureId]
    >
    > than later the texture load function:
    >
    > lotto[TextureId] = IMG_Load(TextureFileName)
    >
    >
    > but now I get at compile:
    > ‘lotto’ was not declared in this scope.


    It sounds to me like you want to do something like this:

    void someFunction() {
    int someVariable;
    }

    void someOtherFunction() {
    someVariable = 5; // someVariable isn't in scope here
    }

    "lotto" must be declared in the scope in which you intend to use it.
    You can consider making it global, but that's probably not a good idea.
    You may also consider passing a pointer or reference to "lotto" to the
    function you want to use it in.

    Was lotto a data member of a class? Are the functions you mentioned
    member functions? That would be different.

    class SomeClass {
    int someVariable;
    public:
    void someFunction() {
    someVariable = -92;
    }
    };



    I'm sorry, but I can't tell what your problem is from the description
    you've given. Can you please be more specific?

    > How should i declare lotto?


    I think it's more a question of where, but I'm not really sure. Again,
    if you'll please be more specific about the problem you are having, I'm
    sure someone will try to give you a more useful answer.


    Also please consider,
    const int n = 5;
    int a[n];
    a[n] = 1;
    May compile but will not work. In this little code snippet "a" is an
    array of five ints and has valid indicies [0,4].


    > Many thanks


    HTH.

    LR
     
    LR, Jul 19, 2010
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schnoffos
    Replies:
    2
    Views:
    1,236
    Martien Verbruggen
    Jun 27, 2003
  2. Hal Styli
    Replies:
    14
    Views:
    1,682
    Old Wolf
    Jan 20, 2004
  3. arun
    Replies:
    8
    Views:
    467
    Dave Thompson
    Jul 31, 2006
  4. aling
    Replies:
    8
    Views:
    981
    Jim Langston
    Oct 20, 2005
  5. Replies:
    9
    Views:
    452
    James Kanze
    Apr 17, 2007
Loading...

Share This Page