Amiga-Development

Please login or register.

Login with username, password and session length
Advanced search  

News:

Created for developers of all Amiga camps

Pages: [1] 2

Author Topic: load gfx in my game  (Read 5225 times)

0 Members and 1 Guest are viewing this topic.

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
load gfx in my game
« on: February 19, 2015, 10:17:08 PM »

I am trying to port muy little sdl functions to amigos api.
I want lo load the game gfx and I have no idea what is the best option.
Do I use iff.library or similar library? Use datatypes.library? Convert the gfx to c code and insert it in my code?
Help mates! ;)
Logged

Veda

  • Hero Member
  • *****
  • Gender: Male
  • Posts: 1008
  • Sleep is overrated
    • View Profile
Re: load gfx in my game
« Reply #1 on: February 19, 2015, 10:31:18 PM »

depends on how much time your code eats.
Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: load gfx in my game
« Reply #2 on: February 20, 2015, 04:50:15 AM »

Quote
I am trying to port muy little sdl functions to amigos api.
What do you mean exactly by that ?

Is it the process of wanting todo so yourself, amiga sdl libraries are unwanted or that you just want to 'port' your functions into real amigacode (e.g. ignore original sdl function compatibility)

How to approach/proceed would depend on that answer.

iff library is used specifically for iff files. So in case your original graphics data is stored in iff format then i would use iff.library ;)

datatypes, could be an option. also depending on the original graphics format.

Could you share a little more about your type (stored format) of graphics ?

It might very well be the original data is f.e. in bmp or png format. In which you could benefit from converting the graphics data into a more Amiga suitable format before even continuing. This also depends a littel on your original intention of wanting to 'convert' sdl functions into amigaos api.

You can't ask a cat to eat the bird before the bird was feeded ;)
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: load gfx in my game
« Reply #3 on: February 20, 2015, 08:01:11 AM »

Hehehehe I haven't explained It well with my trusty english.
My game is very very simple so is not CPU demand.
What I want is erase sdl from my project and use only amigaos api...actually my gfx data is in PNG but I think there is not a problem to convert them to any format.
Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: load gfx in my game
« Reply #4 on: February 20, 2015, 08:04:50 AM »

Alright then. a little more reference material / background for your pleasure :)

Iff is a fileformat which can hold several different types of data. Most people think of iff as being a actual graphics fileformat, but it is actually a container format (same confusion as with OGG and Vorbis).

EA wrote down a very nice document on iff, which can be found on the developer cd here.

The RKRM is full of iff references, so if you got some time to spare...

In case you are in a hurry, then i found this very nice blog entry.

Either way, you might find this table interesting as well.

If you are not into such stuff as reading documentation, then perhaps a little example code of using iffparse library might be more helpful.

^^ that is _one_ way of reading graphics data and displaying it onto the screen. Unfortunately, there are many many many many (did i say many already ?) roads that lead to rome :)

(post was started before your last post)
Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: load gfx in my game
« Reply #5 on: February 20, 2015, 08:14:27 AM »

ok, tear out sdl altogether and replace with your own routines. That should be no problem :D

The example given above let's you use iffparse to read data and display it, but that might perhaps not be all too convenient.  Depending on your bitdepth, it ouwld be easier to convert the png data (depend also on gfx hardware you want to support, e.g. OCS/ECS/AGA/24/32bit gfx card).

If your system (or game running on the systems) have a datatype that has support for png, then you might be able to use datatypes in order to load our png data directly (without converting... well actually the converting is then done runtime).

Now that your goal is more clear, you need to think about terms as, is there enough memory to hold all (gfx) data into memory or do you need to keep it on disk and load it on demand. For animations, some buffering might be required etc.

If your graphics are 'simple' and not many, you might even think about using a raw format (if small include them in your source), and write your own (custom) loader.

As i said, many choices for that dratful road to rome ;)
Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: load gfx in my game
« Reply #6 on: February 20, 2015, 08:32:14 AM »

Another road might perhaps be exploring aminet and use something like libpng ?

Because libpng is a so called port, it is not part of amiga OS itself and introduces new additional features to amigaos instead (once the library is installed). In that case you will not be able to find documentation (SDk) other then provided with that library. So in case you would like to find out how things work, download the archive and read its documentation (and hopefully there are header files for your programming language included, with as bonus a little example so you can peek how to use the library).
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: load gfx in my game
« Reply #7 on: February 20, 2015, 11:48:33 PM »

Great Magorium! I have enough info to study this weekend! Time to read and code! Thanks mate!
Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: load gfx in my game
« Reply #8 on: February 21, 2015, 03:16:33 PM »

In case you planned on spending your weekend that way, then it might be beneficial to also look into datatypes.

I have no idea if you can use this datatype for what you intended. Here is a little example of how to use a datatype on AROS (things might vary a little on classic amigaos).

Whatever you do, in case you feel lost, then try a search on aminet. There are many sources there that make use of different kind of image loading/displaying. There's bound to be one that fits your needs or who's code is more understanding for you.

Of course, in case you are stuck then feel free to ask for help. Any which way, good luck, because things can be a bit overwhelming if you are new to the subject.
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: load gfx in my game
« Reply #9 on: May 05, 2015, 11:12:52 PM »

Hi again!

Finally loaded the gfx with datatypes.library but now I have a new problem.
I blit the bitmap loaded with datatypes to my window but the colors are not correct so I think datatypes doesnt care about It.
I'm trying to remap my colors with ObtainBestPen() but the problem I donīt understand where the colors are stored.
Reading includes and autodocs are confusing with cregs, colormaps etc etc...Iīm reading Rom Kernel Refence Manual but I need light with all those structs.
Where screen colors are stored?
Where bitmap colors are stored?

I guess they are simple questions and try to resolve by myself but with a 12h job and 3 childrens is difficult to go faster.
I need to study a bit more...Thanks.
Logged

SamuraiCrow

  • Administrator
  • Sr. Member
  • *****
  • Gender: Male
  • Posts: 378
  • Coolness is compiled
    • View Profile
Re: load gfx in my game
« Reply #10 on: May 06, 2015, 12:36:31 PM »

The graphics-loader base class for datatypes.library does palette remapping.  I've never found a way to disable it.  If you're going to use a paletted display that doesn't share the screen with Workbench, don't use datatypes.library.  The datatypes are intended for 16-bit or higher display modes and displays that don't care which color goes to which pen.  If you want PNG compression, use LibPNG to load it.  I wish I had better news about the datatypes but they are terrible to use with 256-color displays or less.  I've been trying for years to use palette cycling effects and other Amiga effects on Datatype loaded images.  Just trust me:  it doesn't work.
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: load gfx in my game
« Reply #11 on: May 07, 2015, 01:42:21 PM »

Damn! Will try libpng then. Thanks for the info. You saved me a lo tof time. Thanks.
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: load gfx in my game
« Reply #12 on: May 07, 2015, 08:44:36 PM »

What I dont understand is how multiview, which use datatypes, shows my 8bit images correctly.
Logged

SamuraiCrow

  • Administrator
  • Sr. Member
  • *****
  • Gender: Male
  • Posts: 378
  • Coolness is compiled
    • View Profile
Re: load gfx in my game
« Reply #13 on: May 08, 2015, 06:02:04 PM »

Palette remapping works by making the pen colors used to plot the graphics correspond to other palette entries than the ones they were intended to be used with.  This is handy for showing pictures in a window on the Workbench screen or any other public screen with palette entries already used by other programs.  For games, however, it is likely that you'll be using certain palette entries for specific things such as sprite-to-playfield collision detection and palette cycling effects.  Until a version of the ImageClass that came with AmigaOS is totally rewritten or patched to allow suppression of palette remapping, image datatypes will be mostly useless for chipset games.

RANT START
If you use some foreign, PC-style chipset with your Amiga, palette remapping is necessary to implement palette emulation in screenmodes that don't support palettes.  To me this represented the beginning of the abomination known as re-targetable graphics and was Commodore's attempt at trying to make something they would attempt to call "Amiga" that contained non-Amiga graphics chips.  I used to think that was OK but once I learned how absolutely foreign PC-style graphics chips are to the Amiga, I gave up on RTG and became what some would call a "purist" Amigan.

I think that RTG helps the Amiga-ish platforms to run some rare pieces of "system-friendly" code on non-Amiga hardware.  The AmigaOne series is an example of this.  There are some problems trying to run some software on PC chipsets without direct mappings of many of the features that made the Amiga chipsets great in the first place.  This requires shifting a heavy chipset-emulation load onto the main CPU in an emulator to mimic these features.  Perhaps someday the emulator developers will implement the chipset emulation into a separate thread from the CPU so that a multicore emulator can emulate more accurately and efficiently on systems with multiple cores.
END RANT
Logged

itix

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: load gfx in my game
« Reply #14 on: May 10, 2015, 11:25:25 AM »

Finally loaded the gfx with datatypes.library but now I have a new problem.
I blit the bitmap loaded with datatypes to my window but the colors are not correct so I think datatypes doesnt care about It.

Datatypes load image "as is" because it does nothing about your display capabilities. It could be palette based 2/4/8/16/32/64/128/256 or hi/true color display.

To get correct colours you must remap picture. It can be done with DTM_PROCLAYOUT method and you must supply valid screen pointer to datatype.

There are other methods but they are more relevant to NG systems so I dont go there now.

Quote
I'm trying to remap my colors with ObtainBestPen() but the problem I donīt understand where the colors are stored.
Reading includes and autodocs are confusing with cregs, colormaps etc etc...Iīm reading Rom Kernel Refence Manual but I need light with all those structs.

You get image colors with PDTA_ColorRegisters tag.

Quote
Where screen colors are stored?

In ColorMap structure from ViewPort.

Quote
Where bitmap colors are stored?

Officially palette based bitmaps have none (they have hidden palette in some cases but it is not relevant now). When you are operating with palette based bitmaps image data is only index to palette from your target display.

Quote
I guess they are simple questions and try to resolve by myself but with a 12h job and 3 childrens is difficult to go faster.
I need to study a bit more...Thanks.

Datatypes are quite cumbersome but with careful reading and trial and error you get it :)

Unfortunately I dont have useful example code for you. It sort of makes sense when you read it through.
Logged
Pages: [1] 2