You are not logged in.

#1 2009-12-02 22:09:37

mnta
Member

[RESOLVED] Vector with Images

This might not be a direct GRRLIB question and I am extremely new to C programming - been using Java and C# all so far. But here goes.

If i want to fill a vector (its important that it is not an array since i have a variable size) with images or a struct that defines informations about a image/shape..

Fx.

Code:

typedef struct
{
    int number;
    GRRLIB_texImg *shape;
    int x_coord;
    int y_coord;
    int angle;

}
shape;

How do i do this? What is the syntax for using vectors? Do i need to include something or?

I found out that if i want a array of shapes i can do the following

shape shapes[100];

But now i have an upperlimit. That is not my how i want it because this upperlimit can easily be out of bounced by the user placing more than 100 shapes.

Many thx in advance.

Offline

 

#2 2009-12-02 22:48:03

Crayon
Bad Mother Fucker

Re: [RESOLVED] Vector with Images

Hi, look at the GRRLIB_LoadBMF function at the place where I allocate the numbers of GRRLIB_bytemapChar dynamically:

Code:

        fontArray->charDef = (GRRLIB_bytemapChar *)calloc(fontArray->nbChar, sizeof(GRRLIB_bytemapChar));

Offline

 

#3 2009-12-02 22:55:30

Crayon
Bad Mother Fucker

Re: [RESOLVED] Vector with Images

Check malloc, realloc, calloc and free on this Web site: http://msdn.microsoft.com/en-us/library/hk1k7x6x.aspx

Offline

 

#4 2009-12-17 01:06:41

Crayon
Bad Mother Fucker

Re: [RESOLVED] Vector with Images

If you want to program in C++, then you could use std::vector. There is a demo at http://code.google.com/p/grrlib/source/ … e/main.cpp

Offline

 

Board footer

Powered by FluxBB