Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Can someone help me with shaderhud in c++ ?
Can someone help me with shaderhud in c++ ? [message #389479] Sun, 07 June 2009 03:50 Go to next message
Raptor RSF is currently offline  Raptor RSF
Messages: 210
Registered: July 2007
Location: Netherlands
Karma: 0
Recruit
Hello guys! Satisfied

Im here now to request some help for some little things.

I have now c++ experience for 5 weeks. That means im still a big noob Tell Me


1. I now have 5000 lines of code for my shaderhud.cpp.
Can someone tell me how to store some parts of the code (for example the creditsText) in a different cpp file?

It somehow need to be linked, but i dont know how to do so.

I have seen this hapening to MiniHealthHUD and MiniAmmoHUD of the D6 hud code

I really apriciate any help Big Grin


Rencom server Fan - Marathon#1

http://bfbc2.statsverse.com/sig/clean1/pc/Raptor_RSF.png
Re: Can someone help me with shaderhud in c++ ? [message #389486 is a reply to message #389479] Sun, 07 June 2009 04:27 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
myheaderfile.h
void myfunction();
int anotherfunction();


myfunction.cpp
#include "myheaderfile.h"

void myfunction()
{
    //do something
}


anotherfunction.cpp
#include "myheaderfile.h"

int anotherfunction()
{
   return 10;
}
Re: Can someone help me with shaderhud in c++ ? [message #389494 is a reply to message #389486] Sun, 07 June 2009 05:19 Go to previous messageGo to next message
Raptor RSF is currently offline  Raptor RSF
Messages: 210
Registered: July 2007
Location: Netherlands
Karma: 0
Recruit
Thanks so much for this! Big Ups

Rencom server Fan - Marathon#1

http://bfbc2.statsverse.com/sig/clean1/pc/Raptor_RSF.png
Re: Can someone help me with shaderhud in c++ ? [message #389498 is a reply to message #389486] Sun, 07 June 2009 06:00 Go to previous messageGo to next message
Sir Kane
Messages: 1701
Registered: March 2003
Location: Angerville
Karma: 0
General (1 Star)
jnz wrote on Sun, 07 June 2009 06:27

myheaderfile.h
void myfunction();
int anotherfunction();


No.

#ifndef _MYHEADERFILE_H_
#define _MYHEADERFILE_H_

void myfunction();
int anotherfunction();

#endif //!_MYHEADERFILE_H_




Proud N9500 and proud N6270 user. Creator of the IEE libraries (original bhs.dll) and the RB series software.
http://n00bstories.com/image.fetch.php?id=1189992501http://www.n00bstories.com/image.fetch.php?id=1257492907
Re: Can someone help me with shaderhud in c++ ? [message #389547 is a reply to message #389498] Sun, 07 June 2009 10:28 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
Sir Kane wrote on Sun, 07 June 2009 14:00


#ifndef _MYHEADERFILE_H_
#define _MYHEADERFILE_H_

void myfunction();
int anotherfunction();

#endif //!_MYHEADERFILE_H_





That's only if you're silly enough to try and include it twice.
Re: Can someone help me with shaderhud in c++ ? [message #389563 is a reply to message #389479] Sun, 07 June 2009 11:46 Go to previous messageGo to next message
Raptor RSF is currently offline  Raptor RSF
Messages: 210
Registered: July 2007
Location: Netherlands
Karma: 0
Recruit
I only get errors when i try to compile Rocked Over

This code works when i placed it inside shaderhud.pp only.

it may dont understand some callers maybe i dont know anything about this Blush


Can anybody plz tell me whats wrong ?

I would be happy if someone can help me Thumbs Up



This is my testhud.h:
/*	TestHUDItemClass
	Copyright 2009 Mark Sararu

	This file is part of the Renegade scripts.dll
	The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
	the terms of the GNU General Public License as published by the Free
	Software Foundation; either version 2, or (at your option) any later
	version. See the file COPYING for more details.
	In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module 
	that does not contain code covered by this licence.
	Only the source code to the module(s) containing the licenced code has to be released.
*/

// Created by Raptor*[RSF]

#ifndef SHADERS_TestHUD_H_
#define SHADERS_TestHUD_H_

class TestHUDItemClass
{
protected:
	bool Enabled;

	Render2DClass*		Render2D;
	Render2DTextClass*	Render2DText;

	float				LastHealth;
	bool				FlashActive;
	unsigned int		EndFlashTime;
	unsigned int		EndBlinkTime;

	bool				ForceInfoDisplayDuringLowHealth;
	float				LowHealthThreshold;

	unsigned int		HealthInfoFlashDuration; // in msec
	unsigned int		LowHealthBlinkDuration;  // ^

	Vector2				BackgroundSize;
	Vector2				BackgroundPosition;
	RectClass			BackgroundUV;
	char *				BackgroundTextureFile;

	Vector2				TextPosition;
	char *				TextFontFile;

public:
	TestHUDItemClass();
	~TestHUDItemClass();
	void Load(INIClass* ini);
	void Render();
};

extern TestHUDItemClass TestHUD;

#endif



This is my testhud.cpp:
//--------------------------------------------------------------------------------
// health hud item rendering/loading code
//--------------------------------------------------------------------------------
TestHUDItemClass::TestHUDItemClass():
// TeamVehCount-number
Render2DTextClass *TeamVehCountRender2DClass = 0;
bool RenderTeamVehCountText = false;
unsigned int TeamVehCountColor = 0;
Vector2 *TeamVehCountPosition = 0;
bool TeamVehCountEnabled = false;
Vector2 *TeamVehCountOffset = 0;
{
};



TestHUDItemClass::~TestHUDItemClass()
{
	SAFE_DELETE(TeamVehCountPosition);
	SAFE_DELETE(TeamVehCountRender2DClass);
};



void TestHUDItemClass::Load(INIClass *ini)
{
	if (!ini) return; // if you don't have an ini, something is horribly wrong!

			// TeamVehCount-Number
	TeamVehCountEnabled = hudini->Get_Bool("General","TeamVehCountEnabled",false);
	if (TeamVehCountEnabled)
	{
		bool TeamVehCountVisible = hudini->Get_Bool("General","TeamVehCountVisible",true);
		float TeamVehCountXPos = hudini->Get_Float("General","TeamVehCountXPos",118);
		float TeamVehCountYPos = hudini->Get_Float("General","TeamVehCountYPos",717);
		if (TeamVehCountXPos < 0)
		{
			TeamVehCountXPos += ScreenResolution->Right;
		}
		if (TeamVehCountYPos < 0)
		{
			TeamVehCountYPos += ScreenResolution->Bottom;
		}
		char TeamVehCountFont[100];
		hudini->Get_String("General","TeamVehCountFont","FONT6x8.TGA",TeamVehCountFont,sizeof(TeamVehCountFont));
		unsigned int TeamVehCountCol = hudini->Get_Int("General","TeamVehCountColor",0);
		TeamVehCountPosition = new Vector2(TeamVehCountXPos,TeamVehCountYPos);
		RenderTeamVehCountText = TeamVehCountVisible;
		TeamVehCountColor = (*Colors)[TeamVehCountCol];
		TeamVehCountRender2DClass = CreateRender2DTextClass(TeamVehCountFont);
	}
};



void TestHUDItemClass::Render()
{
	if (RenderTeamVehCountText)
	{
		TeamVehCountRender2DClass->Reset();
		RectClass *r = (RectClass *)((char *)TeamVehCountRender2DClass+0x5B8);
		float TeamVehCount = float(Get_Team_Vehicle_Count(Get_Player_Type(obj)));
		r->Right = TeamVehCountPosition->X;
		r->Left = TeamVehCountPosition->X;
		r->Top = TeamVehCountPosition->Y;
		r->Bottom = TeamVehCountPosition->Y;
		char text[10];
		unsigned int h = (unsigned int)(TeamVehCount + 0.5f);
		sprintf(text,"Team Vehicle Count: %d",h);
		unsigned int color = TeamVehCountColor;
		TeamVehCountRender2DClass->Draw_Text(text,color);
		TeamVehCountRender2DClass->Render();
	}
};


//--------------------------------------------------------------------------------
// globals
//--------------------------------------------------------------------------------
TestHUDItemClass TestHUD;







TestHUD.cpp
.\TestHUD.cpp(49) : error C2059: syntax error : '*'
.\TestHUD.cpp(50) : error C2062: type 'bool' unexpected
.\TestHUD.cpp(50) : error C2630: ';' found in what should be a comma-separated list
.\TestHUD.cpp(51) : error C2062: type 'unsigned int' unexpected
.\TestHUD.cpp(51) : error C2630: ';' found in what should be a comma-separated list
.\TestHUD.cpp(52) : error C2059: syntax error : '*'
.\TestHUD.cpp(52) : error C2630: ';' found in what should be a comma-separated list
.\TestHUD.cpp(53) : error C2062: type 'bool' unexpected
.\TestHUD.cpp(53) : error C2630: ';' found in what should be a comma-separated list
.\TestHUD.cpp(54) : error C2059: syntax error : '*'
.\TestHUD.cpp(54) : error C2630: ';' found in what should be a comma-separated list
.\TestHUD.cpp(55) : error C2059: syntax error : '{'
.\TestHUD.cpp(55) : error C2630: ';' found in what should be a comma-separated list
.\TestHUD.cpp(62) : error C2065: 'TeamVehCountPosition' : undeclared identifier
.\TestHUD.cpp(62) : error C2541: 'delete' : cannot delete objects that are not pointers
.\TestHUD.cpp(63) : error C2065: 'TeamVehCountRender2DClass' : undeclared identifier
.\TestHUD.cpp(63) : error C2541: 'delete' : cannot delete objects that are not pointers
.\TestHUD.cpp(73) : error C2065: 'TeamVehCountEnabled' : undeclared identifier
.\TestHUD.cpp(73) : error C2065: 'hudini' : undeclared identifier
.\TestHUD.cpp(73) : error C2227: left of '->Get_Bool' must point to class/struct/union/generic type
        type is ''unknown-type''
.\TestHUD.cpp(76) : error C2227: left of '->Get_Bool' must point to class/struct/union/generic type
        type is ''unknown-type''
.\TestHUD.cpp(77) : error C2227: left of '->Get_Float' must point to class/struct/union/generic type
        type is ''unknown-type''
.\TestHUD.cpp(78) : error C2227: left of '->Get_Float' must point to class/struct/union/generic type
        type is ''unknown-type''
.\TestHUD.cpp(88) : error C2227: left of '->Get_String' must point to class/struct/union/generic type
        type is ''unknown-type''
.\TestHUD.cpp(89) : error C2227: left of '->Get_Int' must point to class/struct/union/generic type
        type is ''unknown-type''
.\TestHUD.cpp(91) : error C2065: 'RenderTeamVehCountText' : undeclared identifier
.\TestHUD.cpp(92) : error C2065: 'TeamVehCountColor' : undeclared identifier
.\TestHUD.cpp(92) : error C2065: 'Colors' : undeclared identifier
.\TestHUD.cpp(103) : error C2227: left of '->Reset' must point to class/struct/union/generic type
        type is ''unknown-type''
.\TestHUD.cpp(105) : error C2065: 'obj' : undeclared identifier
.\TestHUD.cpp(105) : fatal error C1903: unable to recover from previous error(s); stopping compilation
tonemapsceneshader.cpp
stackingsceneshader.cpp
simplesceneshader.cpp
Build log was saved at "file://c:\Documents and Settings\Administrator\Bureaublad\scripts344_Raptor-RSF\tmp\shaders\BuildLog.htm"
shaders - 31 error(s), 0 warning(s)




I have these inside my shaderhud.cpp:

#include "testhud.h" // TestHUD


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


extern "C"
{
void __declspec(dllexport) ReadHUDBits(INIClass *hudini)
{

	TestHUD.Load(hudini); // TestHUD
	
	
	
//------------------------------------------------------
	
	
void __declspec(dllexport) UpdateHUD2()
{

	TestHUD.Render(); // TestHUD
	



Rencom server Fan - Marathon#1

http://bfbc2.statsverse.com/sig/clean1/pc/Raptor_RSF.png

[Updated on: Sun, 07 June 2009 12:48]

Report message to a moderator

Re: Can someone help me with shaderhud in c++ ? [message #389570 is a reply to message #389479] Sun, 07 June 2009 12:09 Go to previous messageGo to next message
ErroR is currently offline  ErroR
Messages: 2984
Registered: March 2008
Location: Moldova
Karma: 0
General (2 Stars)
just quite it with the building bars, that really annoys me Sarcasm you don't have to say that all the time
EDIT: it actually looks liek ur lieng Rocked Over

[Updated on: Sun, 07 June 2009 12:10]

Report message to a moderator

Re: Can someone help me with shaderhud in c++ ? [message #389572 is a reply to message #389479] Sun, 07 June 2009 12:12 Go to previous messageGo to next message
mrãçķz is currently offline  mrãçķz
Messages: 3069
Registered: August 2007
Karma: 0
General (3 Stars)
Permabanned for trying and failing DDoS
Go to hell if you post more of the Code. Sneaky
Re: Can someone help me with shaderhud in c++ ? [message #389574 is a reply to message #389479] Sun, 07 June 2009 12:41 Go to previous messageGo to next message
Raptor RSF is currently offline  Raptor RSF
Messages: 210
Registered: July 2007
Location: Netherlands
Karma: 0
Recruit
why do you get angry becoz of the code ? i dont get it

Rencom server Fan - Marathon#1

http://bfbc2.statsverse.com/sig/clean1/pc/Raptor_RSF.png
Re: Can someone help me with shaderhud in c++ ? [message #389579 is a reply to message #389570] Sun, 07 June 2009 13:33 Go to previous message
Raptor RSF is currently offline  Raptor RSF
Messages: 210
Registered: July 2007
Location: Netherlands
Karma: 0
Recruit
ErroR wrote on Sun, 07 June 2009 14:09

just quite it with the building bars, that really annoys me Sarcasm you don't have to say that all the time
EDIT: it actually looks liek ur lieng Rocked Over


Of course i am not gonna post the building health bars! thats why i replaced it with an example code


Rencom server Fan - Marathon#1

http://bfbc2.statsverse.com/sig/clean1/pc/Raptor_RSF.png

[Updated on: Sun, 07 June 2009 13:34]

Report message to a moderator

Previous Topic: Comment on More Realistic Water
Next Topic: Comment on Buggy
Goto Forum:
  


Current Time: Sat Dec 21 03:38:31 MST 2024

Total time taken to generate the page: 0.00890 seconds