unsigned char pixelR = textury[numer][jakiś_index];
unsigned char pixelR = textury[numer].pixel[jakiś_index];
struct sBitmap
{
unsigned char* pixels;
};
int main()
{
sBitmap* my_bitmap = new sBitmap[10];
for (int i = 0; i < 10; i++)
my_bitmap[i].pixels = new unsigned char[10];
my_bitmap[4].pixels[2] = 45;
// nie ma problemow
}struct sBitmap
{
unsigned char pixels;
};
sBitmap* BitmapArray;
void foo(sBitmap** data)
{
*data = (sBitmap*)malloc(5 * sizeof(sBitmap));
for (int i = 0; i < 5; i++)
{
// jak mam się dostać do data[i].pixels ? i w dodatku zaalokowac miejsce na textury?
}
}
int main()
{
foo(&BitmapArray);
}@mateusz_s, post #1
struct costam {
pixel[128*128];
};struct costam *innego
innego[i].pixel[px]
unsigned int read_px(struct textures *texture, int t_index, int p_index ) {
return texture[t_index].pixel[p_index]
}unsigned int read_px(unsigned int* data, int indeks_tekstury, int_nr_piksela){
unsigned int *pix_ptr;
pix_ptr = data + (void*) ((128*128*indeks_tekstury) + nr_piksela)
return *pix_ptr;
}@mateusz_s, post #1
struct sBitmap
{
unsigned char *pixels;
}
struct sBitmap *BitmapArrayPtr;
void foo(struct sBitmap **data)
{
*data = (struct sBitmap*)malloc(5 * sizeof(struct sBitmap));
for (i = 0; i < 5; i++)
{
(*data)[i].pixels = malloc(128*128*3);
}
}
int main(void)
{
foo(&BitmapArrayPtr);
return 0;
}Uwaga techniczna. Zazwyczaj opłaca się trzymać 8-bitowe trójki RGB w słowach 32-bitowych np. z zerem na początku. Dostęp do poszczególnych pikseli (wyznaczenie ich adresu) jest wtedy nieco szybszy.@Krashan, post #3
struct sRGBA
{
unsigned char r, g, b, a;
};
union uPixel
{
unsigned int hex;
sRGBA c;
};
struct sBitmap
{
uPixel* pixel;
};
sBitmap* BitmapArrayPtr;
void foo(sBitmap** data)
{
*data = (sBitmap*)malloc(5 * sizeof(sBitmap));
for (int i = 0; i < 5; i++)
{
(*data)[i].pixel = (uPixel*)malloc(5);
}
}
int main()
{
foo(&BitmapArrayPtr);
BitmapArrayPtr[3].pixel[4].c.r = 255;
BitmapArrayPtr[3].pixel[4].c.g = 0;
BitmapArrayPtr[3].pixel[4].c.b = 0;
BitmapArrayPtr[3].pixel[4].c.a = 0;
printf("%d", BitmapArrayPtr[3].pixel[4].c.r);
printf("%d", BitmapArrayPtr[3].pixel[4].hex);
return 0;
}output_buffer[index_i] = (mb_texture_2.pixels[texture_index] * intensity_value) >> 8; output_buffer[index_i + 1] = (mb_texture_2.pixels[texture_index + 1] * intensity_value) >> 8; output_buffer[index_i + 2] = (mb_texture_2.pixels[texture_index + 2] * intensity_value) >> 8; // gdzie intensity value [0-255]
@mateusz_s, post #5
@mastaszek, post #7
@mateusz_s, post #9
@arturB, post #10
@arturB, post #10
Mam pytanie natury lamerskiej. Jak mój kod jest pisany pod systemem - otwieranie ekaranow bibliotek etc. to jak uruchomie to na amidze z karta graficzna to bedzie dzialac i nie musze juz nic dorabiac?Im „czyściej” systemowo piszesz bez chodzenia na skróty i sztuczek, tym większa szansa, że tak będzie.
Czy taki systemowy program jest uruchamialny na NG?Co do zasady tak, uwzględniając to, co napisałem powyżej.