Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Redefine BMAP pointer #436041
01/17/14 16:43
01/17/14 16:43
Joined: Apr 2005
Posts: 796
U.S.A. Michigan
exile Offline OP
User
exile  Offline OP
User

Joined: Apr 2005
Posts: 796
U.S.A. Michigan
Hey guys,

So what I am trying to do is essentially redefine a BMAP* object. Example;

Code:
BMAP* picture;

function changePicture()
{
var change = 0;
while(1)
 {
  if(picture==NULL)
  {
    wait(1)
  }
  if(change == 1)
  {
    picture = "image_a.bmp";
  }
  else
  {
  picture = "image_b.bmp"
  }
    wait(1)
  }
}


Essentially I need to change the contents of the BMAP pointer without changing the pointer itself since the function I am using this in conjunction with is pan_setbutton. Anyone know of a good/clever way of doing this

Last edited by rayp; 01/17/14 21:21. Reason: corrected code tags
Re: Redefine BMAP pointer [Re: exile] #436043
01/17/14 17:47
01/17/14 17:47
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Why not declare 3 BMAPS and only set the data?
Code:
typedef struct BMAP {
	C_LINK	link;
	long 	width,height; // original size of the bitmap
	long	bytespp;	// original bytes per pixel (1..4)
	void	*ptr;		// internal use
	byte	*pixels;	// ptr to palettized, 565, 4444, 888 or 8888 coded original image
	long	flags;      // see BMPF_... above
	void	*d3dtex;	// 	LPDIRECT3DTEXTURE9 (usually a different format than the original image)
	float	u1,v1,u2,v2; // texture pixel bounds
	long	u,v;		// cutout start size
	long	refcount;	// for implicitely created bmaps
	long	finalwidth,finalheight,finalbytespp;
	long	pitch,finalpitch;
	long	miplevels;
	long	finalformat;
	void	*finalbits;	// bitmap content when locked, otherwise NULL
} BMAP;



If you dont know what I mean, Im talking about
Code:
void	*d3dtex;



You could also simply change ALL classmembers with memcpy. Would be the easiest one without changing the pointer:
Code:
memcpy((void*)oldBmapPtr, (void*)newBmapContent, sizeof(BMAP));


Last edited by Ch40zzC0d3r; 01/17/14 18:05.
Re: Redefine BMAP pointer [Re: Ch40zzC0d3r] #436045
01/17/14 18:17
01/17/14 18:17
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Holy fuck, don't!
Don't copy data around that you don't own, you will break stuff badly! Just alone fucking up the linked list is bad, but copying opaque pointer around... Why are you advising people to do stupid shit like that?!

@exile:
There is no way to get the same pointer or just exchanging the content. You can use the bitmap operations to make a copy of the bitmap, but this is going to be slow. What you should do is make your code able to deal with the changing pointer, eg. you could implement a notification system that allows potential listeners to listen for changes.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Redefine BMAP pointer [Re: WretchedSid] #436046
01/17/14 18:43
01/17/14 18:43
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Why shouldnt it work?? o.0
I dont really get your point frown

Re: Redefine BMAP pointer [Re: Ch40zzC0d3r] #436049
01/17/14 19:32
01/17/14 19:32
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
What's unclear about "fucking up the linked list" ? Besides that you copy several pointers you have no idea of if and how long they are valid.


Always learn from history, to be sure you make the same mistakes again...
Re: Redefine BMAP pointer [Re: Uhrwerk] #436052
01/17/14 20:46
01/17/14 20:46
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Well I dont really know how the intern clockwork of this engine works, so I thought this could work^^
But if the engine keeps all elements in an array and changes some pointers and mine not then yeah, it would be fucked up xD

Re: Redefine BMAP pointer [Re: Ch40zzC0d3r] #436054
01/17/14 21:09
01/17/14 21:09
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You should have a look at the C_LINK structure. That's a linked list. Not an array. As a general rule you should stick to JustSid's advice: "Don't copy data around that you don't own".

exile, maybe you can desribe the thing you want to do in more detail. How does using pan_setbutton make it necessary to change the bitmap but not the pointer?


Always learn from history, to be sure you make the same mistakes again...
Re: Redefine BMAP pointer [Re: Ch40zzC0d3r] #436056
01/18/14 00:32
01/18/14 00:32
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: Ch40zzC0d3r
Well I dont really know how the intern clockwork of this engine works, so I thought this could work^^
But if the engine keeps all elements in an array and changes some pointers and mine not then yeah, it would be fucked up xD

Of course the engine is going to do something with its pointers. And the point is that you don't know it! Even worse, what the engine does can change any time with an update. It's a black box that you don't know or own and that you have no power over, stay the fuck away from it.

Like... What the fuck?! What if I take one of your frameworks and randomly change internal stuff? Does it just work when I say that I don't know how your stuff work so I figured it might just work?!


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Redefine BMAP pointer [Re: WretchedSid] #436156
01/20/14 19:23
01/20/14 19:23
Joined: Apr 2005
Posts: 796
U.S.A. Michigan
exile Offline OP
User
exile  Offline OP
User

Joined: Apr 2005
Posts: 796
U.S.A. Michigan
Well, I have a panel object which is a "Map vote" panel. This panel consists of 4 elements, the panel background image, the map name, the gametype name, and a small map image. Players can vote on the map and gametype they wish to play before the match starts. Anyway, I have the structure setup in a way where the server scans a 'Maps' folder and looks for a mapConfig.xml file which contains the map file to load, map name, map description, small map image, and large map image. The server sends the information to the client machines in a multidimensional array where the client machines use the information which was sent to them. The elements for the voting panels are set based on the information they get from the server. So I need to be able to change what the BMAP pointer points to in order to change the map image. I "COULD" use the map images as their own panel and just change the BMAP but I would prefer to keep everything in a self contained object. I think I am going to make my own custom panel structure rather than rely on gamestudios pre-defined objects. draw_quad FTW lol.

Re: Redefine BMAP pointer [Re: exile] #436159
01/20/14 20:03
01/20/14 20:03
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
From my point of view exchaning the pointer would be the easiest solution and quite frankly I still do not understand why you want to avoid that.

Have you thought about copying the image data over to the bitmap with bmap_blit? http://www.conitec.net/beta/bmap_blit.htm


Always learn from history, to be sure you make the same mistakes again...
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1