pointer to int

  • Follow


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
0
Reply Michael106 (11) 7/18/2010 11:27:18 AM

PS: Exactly like so and TextureId is a int
	
lotto[TextureId] = IMG_Load(TextureFileName);
0
Reply Michael 7/18/2010 11:30:19 AM


* 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>
0
Reply Alf 7/18/2010 11:48:02 AM

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
0
Reply Michael 7/18/2010 1:06:37 PM

Michael <Michael@notspam.com> wrote:

> 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,

We want to help, but we can't. Please read the following to understand 
why.

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
0
Reply Daniel 7/18/2010 2:17:26 PM

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
0
Reply Michael 7/19/2010 9:00:26 AM

Michael <Michael@notspam.com> wrote:

> 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

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
0
Reply Daniel 7/19/2010 11:38:18 AM

if u don't know get lost
0
Reply Michael 7/19/2010 12:28:46 PM

* 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>
0
Reply usenet30 (678) 7/19/2010 12:44:48 PM

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

0
Reply LR 7/19/2010 6:48:52 PM

Michael <Michael@notspam.com> wrote in news:ae100$4c4444fe$c299b603$13211
@news.hispeed.ch:

> if u don't know get lost

LMAO at someone asking for help who can't spell 'you'.
0
Reply Eric 7/20/2010 5:13:24 PM

10 Replies
171 Views

(page loaded in 0.202 seconds)


Reply: