struggling with loading bitmap
Moderator: Stef
struggling with loading bitmap
Hi,
I've successfully ran the hello world tutorial and am now doing the tile and tilemap tutorial but i get compile errors.
Launching tool 'Make': C:\Dev\md\sdk\bin\make -f C:\Dev\md\sdk\makefile.gen (in C:\Users\Matt\DevWork\md\TheGame)
stdout> C:/Dev/md/sdk/bin/mkdir -p out
stdout> C:/Dev/md/sdk/bin/mkdir -p out/src
stdout> C:/Dev/md/sdk/bin/mkdir -p out/res
stdout> C:/Dev/md/sdk/bin/gcc -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy -IC:/Dev/md/sdk/include -Iinclude -Isrc -Ires -c main.c -o out/main.o
stderr> main.c: In function `main':
stderr> main.c:8: error: subscripted value is neither array nor pointer
stderr> main.c:10: error: subscripted value is neither array nor pointer
stderr> main.c:13: error: subscripted value is neither array nor pointer
stderr> main.c:20: error: subscripted value is neither array nor pointer
stderr> make: *** [out/main.o] Error 1
Tool execution terminated with status 2
I've successfully ran the hello world tutorial and am now doing the tile and tilemap tutorial but i get compile errors.
Launching tool 'Make': C:\Dev\md\sdk\bin\make -f C:\Dev\md\sdk\makefile.gen (in C:\Users\Matt\DevWork\md\TheGame)
stdout> C:/Dev/md/sdk/bin/mkdir -p out
stdout> C:/Dev/md/sdk/bin/mkdir -p out/src
stdout> C:/Dev/md/sdk/bin/mkdir -p out/res
stdout> C:/Dev/md/sdk/bin/gcc -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy -IC:/Dev/md/sdk/include -Iinclude -Isrc -Ires -c main.c -o out/main.o
stderr> main.c: In function `main':
stderr> main.c:8: error: subscripted value is neither array nor pointer
stderr> main.c:10: error: subscripted value is neither array nor pointer
stderr> main.c:13: error: subscripted value is neither array nor pointer
stderr> main.c:20: error: subscripted value is neither array nor pointer
stderr> make: *** [out/main.o] Error 1
Tool execution terminated with status 2
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
I updated the tutorial so it should now compile with the last version of SGDK :
http://code.google.com/p/sgdk/wiki/Tiles
I only fixed the tutorial, the archives is still in old format. There is a lot of changes to do on the tutorial to reflect the last SGDK capabilities !
http://code.google.com/p/sgdk/wiki/Tiles
I only fixed the tutorial, the archives is still in old format. There is a lot of changes to do on the tutorial to reflect the last SGDK capabilities !
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
You can look into music and sprite samples provided with SGDK.bastien wrote:Did you have a syntaxe exemple for using the new rescomp.?
Thanks
Also the rescomp.txt explain you how to write your res file.
Here are the sprite sample examples :
http://code.google.com/p/sgdk/source/br ... /music.res
http://code.google.com/p/sgdk/source/br ... es/gfx.res
One important thing is to always have the filename between quotes
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Indeed, you just need to write your .res file and rescomp will convert it for you and generate header file (.h) according to the .res file =)
Actually that is the same idea as genres but i believe genres was not generating header file and supporting less resource type.
I worked hardly on this tool and it still need improvements but i believe it is already quite useful in its state
Actually that is the same idea as genres but i believe genres was not generating header file and supporting less resource type.
I worked hardly on this tool and it still need improvements but i believe it is already quite useful in its state
Wow things are becoming a lot more OO in syntax
still having trouble is would seem!
I'm running CodeBlocks, I couldn't get it anything to compile in codebocks due to an error (someone suggested reinstalling which i tried with no joy).
I've created a custom "make" Option in Tools, which compiles from the cmd prompt.
I've got hello world working easily enough just struggling with this. I've modified my code from the old tutorial to reflect the new
car.h
still having trouble is would seem!
I'm running CodeBlocks, I couldn't get it anything to compile in codebocks due to an error (someone suggested reinstalling which i tried with no joy).
I've created a custom "make" Option in Tools, which compiles from the cmd prompt.
I've got hello world working easily enough just struggling with this. I've modified my code from the old tutorial to reflect the new
Code: Select all
#include <genesis.h>
#include "car.h"
int main( )
{
// get the image width (in pixel) ==> should be 8pix aligned
u16 w = car.w;
// get the image height (in pixel) ==> should be 8px aligned
u16 h = car.h;
// get the palette at moon[2 to 17]
VDP_setPalette(PAL1, car.palette->data);
// load bitmap data at moon[18....] in VRAM
// w/8 = width in tiles we want to load
// h/8 = height in tile we want to load
// w/8 = width in tiles of the bitamp
// the 3rd arg is needed because you could load only a part of the bitmap if you want but SGDK needs the width as reference
VDP_loadBMPTileData(car.image, 1, w / 8, h / 8, w/8 );
VDP_fillTileMapRectInc(BPLAN, TILE_ATTR_FULL(PAL1, 0, 0, 0, 1), 12, 12, w / 8, h / 8);
while(1)
{
VDP_waitVSync();
}
return 0;
}
Code: Select all
#ifndef _CAR_H_
#define _CAR_H_
extern const Bitmap car;
#endif // _CAR_H_
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
The warning is normal and can be freely ignored (it will be remove in the next version, but the error should not be there.matteus wrote:sorry! I forgot to post it
stderr> main.c:13: error: request for member `data' in something not a structure or union
stderr> main.c:21: warning: passing arg 1 of `VDP_loadBMPTileData' from incompatible pointer type
The message you got is like you were trying to pass "car.palette.data" instead of "car.palette->data" parameter...
Did you updated all your SGDK files ?
I will make sure I'm up to date with the SGDK files. Thank you for your support Stef it is very much appreciated. It's great that you've created the SGDK and hopefully in time I will create something worth playing from it Just need to get the basics under my belt first!Stef wrote:The warning is normal and can be freely ignored (it will be remove in the next version, but the error should not be there.matteus wrote:sorry! I forgot to post it
stderr> main.c:13: error: request for member `data' in something not a structure or union
stderr> main.c:21: warning: passing arg 1 of `VDP_loadBMPTileData' from incompatible pointer type
The message you got is like you were trying to pass "car.palette.data" instead of "car.palette->data" parameter...
Did you updated all your SGDK files ?
Out of interest would doing things like this not work?
When the project is built is my image output to an object /class file that has properties?
car.w - width property
car.h - height property
car.palette - palette data
car.image - image data
Code: Select all
#include <genesis.h>
#include "car.h"
int main( )
{
// Load Palette
VDP_setPalette(PAL1, car.palette->data);
// Load Tiles into VRAM
VDP_loadBMPTileData(car.image, 1, car.w / 8, car.h / 8, car.w / 8 );
// Load Tiles and Palette to Plane B (background B)
VDP_fillTileMapRectInc(BPLAN, TILE_ATTR_FULL(PAL1, 0, 0, 0, 1), 12, 12, car.w / 8, car.h / 8 );
while(1)
{
VDP_waitVSync();
}
return 0;
}
car.w - width property
car.h - height property
car.palette - palette data
car.image - image data
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Of course it would work, you can even use simpler methods now :
or
depending you declared your image resource as BITMAP or IMAGE
Code: Select all
u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
Code: Select all
u16 VDP_drawImage(u16 plan, const Image *image, u16 x, u16 y);
You've removed the need to load the palette and tiles now too?!?Stef wrote:Of course it would work, you can even use simpler methods now :
orCode: Select all
u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
depending you declared your image resource as BITMAP or IMAGECode: Select all
u16 VDP_drawImage(u16 plan, const Image *image, u16 x, u16 y);
Ok I've only just discovered the doc folder in the SGDK, I wondered where everyone was getting their information from...Stef wrote:Of course it would work, you can even use simpler methods now :
orCode: Select all
u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
depending you declared your image resource as BITMAP or IMAGECode: Select all
u16 VDP_drawImage(u16 plan, const Image *image, u16 x, u16 y);