Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Generating textures

Author
Message
firestarter
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 27th Dec 2002 20:06
Is there any possibility to generate your own textures with DB Pro? If so, how do u implement it?
haggisman
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 27th Dec 2002 20:17
Generally most people make them with graphics packages, or download them. Though you could make some verysimple textures using the 2d commands.

Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
firestarter
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 28th Dec 2002 16:47
buffcycle = 0

LOCK BACKBUFFER
w = GET BACKBUFFER WIDTH()
h = GET BACKBUFFER HEIGHT()
d = GET BACKBUFFER DEPTH()
UNLOCK BACKBUFFER

MAKE MEMBLOCK 1, w*h*(d/2)

FOR buffcycle = 0 TO GET MEMBLOCK SIZE(1)-1
WRITE MEMBLOCK BYTE 1, buffercycle, rnd(80)
NEXT buffcycle

MAKE IMAGE FROM MEMBLOCK 1, 1

----------------------

Damn, is DB Pro easy or what Now i will do some serious calculations....

firestarter
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 28th Dec 2002 16:54
haggisman:

I want to generate textures because then the compiled and linked file doesnt get so fuckin huge. And they get fuckin huge using this (rapid prototyping) program

firestarter
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 28th Dec 2002 18:29
Damn, it didnt work what i thought could work in theory.
And why the hell did i generate a texture as big as the screen?

Here is the code:
------------------------

buffcycle = 0
MAKE MEMBLOCK 1, 256*256*3 // Size of texture

FOR buffcycle = 0 TO GET MEMBLOCK SIZE(1)-1
WRITE MEMBLOCK BYTE 1, buffercycle, rnd(80)
NEXT buffcycle

MAKE IMAGE FROM MEMBLOCK 1, 2
---------------------------------------------

I get an runtime error 5103 - Memblock does not exist at line 25, and thats the MAKE IMAGE FROM MEMBLOCK 1, 2 line.

Why the hell doesnt this work?

I don`t think there is any other way then to use memblocks to generate textures and stick them on 3d objects.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Dec 2002 19:16
Two problems:
1) You are not correctly generating your data.


2) There may be a bug with 'MAKE IMAGE FROM MEMBLOCK' and the help. If you swap the two arguments, then the program compiles and runs, but I could not get the image to display. Have a play.

One last thing mate, watch the language. Young'uns use this forum too.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Dec 2002 19:59
Also... try checking your variable names. I hang my head in shame for missing that one.

firestarter
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 28th Dec 2002 20:11
IanM: Thanks, i forgot about the bitmap structure, especially the header data So the bitmap has to be 32 bits?

I didn`t get the image to display either.

And the d*** manual is way to simple ( i guess i`m not the only one complaining).

And i shall watch my f***** language

firestarter
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 28th Dec 2002 20:18
IanM: So it was just the structure that was wrong + that MAKE IMAGE FROM MEMBLOCK.

THANK U VERY MUCH, IT WORKED

I owe you one. Happy new year!

The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 29th Dec 2002 00:01


Wahey, an instant skysphere texture! (Note this may not actually work, due to 'get image' size limitations.)
firestarter
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 29th Dec 2002 21:52
TheDarthster: Yeah, thats another way to do it. However your bitmap is way to big 1000*1000 256*256 or 512*512 is the standard sizes.

But what is the most effective way of generating textures? Is it the memblock way or bitmap construction way?

It seems like the bitmap construction way do generate the bitmap one place in the memory and then copied to another place in memory. While the memblock way it seems like it stays one place in memory. What do u folks think?

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Dec 2002 00:19
No, using the memblock way also creates a copy. I can't think of any real advantage of using memblocks in this way, unless you want to store images in a custom format.

Oh, and you can also create images in 16 bits by using words instead of dwords. It's just a bit harder to generate the colours you want - with 32 bit you can use the standard RGB() function.
firestarter
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: Norway
Posted: 30th Dec 2002 00:36
Hmm, i thought the compiler made a pointer to the memblock when using the bitmap.

Well, the real advantage with memblocks is that u can generate let us say 2 textures and mix them together.

In 16 bit 5 bits is used for red, 6 bit for green and 5 bit for blue. Bitwise operators must in action.

I know how to convert from 24 bit to 16 bit:

16bit = (((red >> 3) & 0x1f) << 11) || (((green >> 2) && 0x3f) << 5) || (((blue
>> 3) & 0x1f));

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Dec 2002 01:06
If the compiler just used the contents of the memblock, you would never be able to free them. Also, every time you modified the memblock, the image would change.

Some graphics cards use only 15 bits for colour (admittedly mostly older ones). When I was mucking around with DirectX6 I spent a couple of days putting together a general plotting routine that handled colours correctly at all possible pixel depths up to 32 bits. It worked too!

Login to post a reply

Server time is: 2024-05-17 18:38:11
Your offset time is: 2024-05-17 18:38:11