Emuforums.com

Go Back   Emuforums.com > General Discussion > Web development / Programming
Home Register Downloads FAQ Members List Calendar Arcade Mark Forums Read

WON'T YOU JOIN US?
You are not a registered member and
are viewing this site as a guest.
Registration is simple and FREE.
Join this CrowdGather community today.
Registration offers the following perks:

» Less advertising throughout
» Post and participate in discussions
» Network with other forum members
» Free private messaging

join

Reply
 
Thread Tools Display Modes
Old December 2nd, 2009, 03:45   #21
fried_egg
Registered User
 
fried_egg's Avatar
 
Join Date: Apr 2007
Location: indiana
Posts: 694
hey, huffman encoding assignment. yay.

Code:
#include <iostream>
#include <fstream>
#include <queue>
#include <string>
#include <ostream>
#include <sstream>
#define ENCODE 1
#define DECODE 0
#define QUIT 2
using namespace std;

class Encoder
{
public:
	//----------methods----------------
	//constructor for the Encoder class
	Encoder(){}
	//DESTRUCTOR
	~Encoder(){}
	//the method used to encode a file into huffman's code
	void encode(const char* inputName,const char* outputName)
	{
		FREQUENCY_NODE* huffmanTree;
		priority_queue<FREQUENCY_NODE*,vector<FREQUENCY_NODE*>,node_compare > freqQueue;
		int* frequencies;
		//read the input file and store the frequencies of each char
		frequencies = frequencyCounter(inputName);
		//convert the array which is stores the frequencies to a min priority queue
		freqQueue=convertArrayToQueue(frequencies);
		//convert the min priority queue into a huffman tree
		huffmanTree = huffman(freqQueue);
		//write the characters of the input file into the output file after encoding them terminated by a line feed
		printEncoding(huffmanTree,inputName,outputName);
		//write the tree into an output file
		ofstream output;
		output.open(outputName,ios::app);
		output<< '\n' + appendFreqs(frequencies);
		output.flush();
		output.close();
		//clean up the allocated memory
		cleanTree(huffmanTree);
		delete frequencies;
	}//encode
	//a method to decode a huffman encoded file and then return it to an original encoding
	void decode(const char* inputName,const char* outputName)
	{	
		//create a tree from the input file
		FREQUENCY_NODE* huffmanTree;
		huffmanTree = huffmanFromFile(inputName);
		//write the output file
		writeDecoded(inputName,outputName,huffmanTree);
		//clean up the memory
		cleanTree(huffmanTree);
	}
private:


	//-----------struct def------------------
	// a struct to represent the nodes of the B-Tree created by the Huffman algorithm
	struct FREQUENCY_NODE{
		int frequency;
		unsigned char charValue ;
		FREQUENCY_NODE* leftChild;
		FREQUENCY_NODE* rightChild;
		string toString()
		{

			string returnString(1,charValue);
			returnString+=",";
			stringstream s;
			s << frequency;
			returnString+=s.str();
			returnString+=",";
			return returnString;
		}

	};
	//this is needed to prevent the compare of two nodes from comparing addresses instead of key values
	struct node_compare : binary_function<FREQUENCY_NODE*,FREQUENCY_NODE*, bool>
   {
    bool operator()(const FREQUENCY_NODE* v1, const FREQUENCY_NODE* v2) const
    {
        return (v1->frequency > v2->frequency);
    }
   }; 
	//-----------methods---------------------
	//a function that populates an array from 0-'127' where the index is the int value of the corresponding character. 
	int* frequencyCounter(const char* inputName)
	{
		unsigned char currentChar=0;
		int* frequencies = new int[256];
		for(int i=0;i<256;i++)
		{
			frequencies[i]=0;
		}
		ifstream inputFile;
		inputFile.open(inputName, ios::in);
		//fill the array of the frequencies using the char's ascii values as the index of the array
		while(inputFile.good())
		{
				currentChar=inputFile.get();
				if(inputFile.good())
				{
					frequencies[currentChar]++;	
				}
	
		}
		inputFile.close();
		return frequencies;
	}//frequencyCounter()

	//a function for creating a priority queue from the frequencies read from the input file
	priority_queue<FREQUENCY_NODE*,vector<FREQUENCY_NODE*>,node_compare > convertArrayToQueue(int* input)
	{
		// create min priority queue
		priority_queue<FREQUENCY_NODE*,vector<FREQUENCY_NODE*>,node_compare > frequency_queue;
		// for all of the elements in frequencies[], if the value of the frequency is not equal to zero, 
		// create a frequency node and insert it into the queue keyed by frequency. 
		for(int i =0; i < 256;i++)
		{
			if(input[i]!=0)
			{
				FREQUENCY_NODE* newNode = new FREQUENCY_NODE;
				newNode->charValue=i;
				newNode->frequency=input[i];
				newNode->leftChild=NULL;
				newNode->rightChild=NULL;
				frequency_queue.push(newNode);
			}
		}
		return frequency_queue;
	}//convertArrayToQueue()
	//a function for creating a huffman's tree from a min priority queue
	FREQUENCY_NODE* huffman(priority_queue<FREQUENCY_NODE*,vector<FREQUENCY_NODE*>,node_compare > inputQueue)
	{

		//while the queue has more than one element
		while(inputQueue.size()>1)
		{		
			//	pop off 2 elements
			//	create a new node with those two elements as its children and with the sum of their frequencies as its own frequency

			FREQUENCY_NODE* compositeNode = new FREQUENCY_NODE;
			compositeNode->charValue='`';
			compositeNode->leftChild=(inputQueue.top());
			inputQueue.pop();
			compositeNode->rightChild=(inputQueue.top());
			inputQueue.pop();
			(compositeNode->frequency)=((compositeNode->rightChild)->frequency+(compositeNode->leftChild)->frequency);
			//	push the new node back into the queue
			inputQueue.push(compositeNode);
		}


		//return the final remaining node
		return (inputQueue.top());
	}//huffman()


	//free all the memory in the huffman tree
	void cleanTree(FREQUENCY_NODE* tree)
	{
		if(tree->leftChild == NULL && tree->rightChild == NULL)
		{
			delete tree;
		}
		else
		{		
			cleanTree(tree->leftChild);
			cleanTree(tree->rightChild);
			delete tree;
		}


	}
	//this method will print out the encoding of the input 
	void printEncoding(FREQUENCY_NODE* tree,const char* inputFile,const char* outputFile)
	{
		unsigned char currentChar;
		string encoding = "";
		ifstream input;
		input.open(inputFile, ios::in);
		ofstream output;
		output.open(outputFile);
		while(input.good())
		{
			//while the input still has more characters, use the recursive helper function to generate
			//the encoding of the character.
			currentChar=input.get();
			if(input.good())
			{
				output<<generateEncoding(tree,currentChar,encoding);	
			}

		}
		input.close();
		output.flush();
		output.close();

	}//printencoding()
	// a recursive method to generate the encoding of a character
	string generateEncoding(FREQUENCY_NODE* _tree, char currentChar, string encodingString)
	{
		if(_tree->leftChild==NULL && _tree->rightChild==NULL)
		{
			//if we are in a leaf node check for the character match
			if(_tree->charValue==currentChar)
			{
				//if this isnt true, the character is not in this node, so we reset the string
				return encodingString;
			}

			return "";
		}
		string leftValue;
		string rightValue;
		leftValue=generateEncoding(_tree->leftChild, currentChar,encodingString+'0');
		rightValue=generateEncoding(_tree->rightChild, currentChar,encodingString+'1');
		//check for which branch the character is in
		if(!leftValue.empty())return leftValue;
		if(!rightValue.empty())return rightValue;
		return "";
	}//generateEncoding()

	//a function for traversing the tree and appending the characters and frequencies
	string appendFreqs(int* freqs)
	{
		string returnString;
		for(int i=0;i<256;i++)
		{
			if(freqs[i]!=0)
			{
				unsigned char currentChar = i;
				returnString.push_back(i);
				returnString.push_back(',');
				stringstream s;
				s<<freqs[i];
				returnString+=s.str();
				returnString.push_back(',');
			}
		}
		return returnString;

	}//appendFreqs()
	//used to create a huffman tree from an input file
	FREQUENCY_NODE* huffmanFromFile(const char* inputFile)
	{
		priority_queue<FREQUENCY_NODE*,vector<FREQUENCY_NODE*>,node_compare > freqQueue;
		ifstream input(inputFile,ios::in);
		unsigned char currentChar=0;
		//scan to the beginning of the frequencies 
		input.ignore(100000,'\n');
		//begin to generate nodes from the frequencies 
		while(input.good())
		{
			currentChar=input.get();
			if(input.good())
			{
				string frequencyValue ="";
				FREQUENCY_NODE* newNode = new FREQUENCY_NODE;
				newNode->charValue=currentChar;
				newNode->leftChild=NULL;
				newNode->rightChild=NULL;
				//skip the comma
				input.ignore(1);
				//read until the next comma
				do
				{
					currentChar=input.get();
					frequencyValue.push_back(currentChar);			
				}while(currentChar!=','&&input.good());
				
				newNode->frequency=atoi(frequencyValue.c_str());
				freqQueue.push(newNode);
			}	
		}
		input.close();
		//return a huffman tree made from the queue
		return huffman(freqQueue);
	}//huffmanFromFile()

	//this function will write to a file the result of the decoding
	void writeDecoded(const char* inputFile,const char* outputFile, FREQUENCY_NODE* tree)
	{
		FREQUENCY_NODE* currentNode=tree;
		ifstream input;
		input.open(inputFile);
		ofstream output;
		output.open(outputFile);
		char currentChar;
		while(input.good())
		{
			currentChar=input.get();
			if(input.good())
			{
				//read in 1's and 0's and follow the path until at a leaf node
				if(currentChar=='0')
				{
					currentNode=(currentNode->leftChild);
				}
				else if(currentChar=='1')
				{
					currentNode=(currentNode->rightChild);
				}
				//if at a terminal node, spit out the char
				if(currentNode->rightChild==NULL)
				{
					output.put((currentNode->charValue));
					currentNode=tree;
				}
			}

		}
		input.close();
		output.flush();
		output.close();
	}
};




int main()
{
	

	Encoder encoder = Encoder();
	int goodInput=0;
	int encodeOrDecode=3;//random number here for initialization purposes
	while(encodeOrDecode!=QUIT)
	{
		Encoder encoder = Encoder();
		string inputFile="";
		string outputFile="";
		cout<<"Enter the name of the file you want to input.\n";
		getline(cin,inputFile);
		cout<<"Now enter the name of the file you wish to output to.\n";
		getline(cin,outputFile);
		while(goodInput==0)
		{
			string input="";
			cout<<"Type a 0 if you want to decode a file and a 1 if you want to encode a file\n";
			getline(cin,input);
			encodeOrDecode = atoi(input.c_str());
			if(encodeOrDecode==ENCODE||encodeOrDecode==DECODE || encodeOrDecode==QUIT)
			{
				goodInput=1;
			}

		}
		if(encodeOrDecode==DECODE)
		{
			encoder.decode(inputFile.c_str(),outputFile.c_str());
		}
		else if(encodeOrDecode=ENCODE)
		{
			encoder.encode(inputFile.c_str(),outputFile.c_str());
		}
		goodInput=0;
	}


}
fried_egg is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old December 2nd, 2009, 07:03   #22
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
Quote:
Originally Posted by @ruantec View Post
the main problem with the code you provided there is that its not going to loop and thatīs ok but...."Houston we have problem" the reason for that is because you will get the "Incorrect. Try again!" message but after that the code is going to end and nothing will happen after that. actually it should show the message but it should go back again and expect an input

last but not least thereīs no error handling and if you type "Sdad3" and hit enter you will get a big fat exception

this is probably what you wanted to do(be aware i used editor so it may have some typos ):
Code:
static void Main(string[] args) {
    Console.WriteLine("1 + 2 = ?");
    check((Console.ReadLine()).ToLower());
}

static void check(string a)
{
    if (a != "y")
        if (a == "3") Console.WriteLine("Correct, good job!");
        else if (a == "n") Console.WriteLine("1 + 2 = ?");
        else Console.WriteLine("Incorrect, try again!");
        Console.WriteLine(n0 + " + " + n1 + " = ? (Type in '0' to quit)");
        check((Console.ReadLine()).ToLower());
    }
}
My bad. I just got back from work and I was worn out to death... Fixed and... (hopefully) improved.

Just for kicks...

Code:
static void Main(string[] args) {
    int n0 = 1;
    int n1 = 2;
    Console.WriteLine(n0 + " + " + n1 + " = ? (Type in '0' to quit)");
    check(n0,n1,int.Parse(Console.ReadLine()));
}

static void check(int n0, int n1, int a)
{
    if (a != 0)
        if (a != (n0 + n1)) Console.WriteLine("Incorrect, try again!");
        else Console.WriteLine("Correct, good job!");
        n0++;
        n1++;
        Console.WriteLine(n0 + " + " + n1 + " = ? (Type in '0' to quit)");
        check(n0,n1,int.Parse(Console.ReadLine()));
    }
}
And here's one with the least number of lines I can possibly cough up... I used to do a lot of code-compacting in a certain AS forums... Makes it all the more interesting since you learn more techniques that may prove helpful.

Code:
static void Main(string[] args) {
    string n = "";
    while(n != "y") {
        Console.WriteLine("1 + 2 = ?");
        n = (Console.ReadLine()).ToLower();
        if (n == "3") Console.WriteLine("Correct, good job!");
        else if (n != "n") Console.WriteLine("Incorrect, try again!");
    }
}
Maybe I'll try poking C# someday... It looks like it won't be too complicated to learn...
runawayprisoner is offline   Reply With Quote
Old December 2nd, 2009, 08:30   #23
@ruantec
Crazy GFX coder
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Dominican Republic/Austria
Posts: 8,096
Quote:
Originally Posted by runawayprisoner View Post
Maybe I'll try poking C# someday... It looks like it won't be too complicated to learn...
Nice.. in case youīre interested am planning to re-open my C# course this weekend and also re-work them. this time iīll try to provide more classes such as C/C++, ASM, VB.Net, WPF, Silverlight, ASP.Net, AJAX, Javascript and many more in fact all the languages i know lol. i hope it could be of help for others
__________________


Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6
@ruantec is offline   Reply With Quote
Old December 2nd, 2009, 09:57   #24
cooliscool
Global Moderator
 
cooliscool's Avatar
 
Join Date: Jul 2001
Location: SC, USA
Posts: 7,231
Here's my OGL fragment program based N64 color combiner "emulator" written in VB.NET. Just a small but very important portion of my N64 graphics work.

Code:
#Region "Color Combiner"
    Private Sub SETCOMBINE(ByVal w0 As UInteger, ByVal w1 As UInteger)
        If GLExtensions.GLFragProg Then
            EnableCombiner = True

            Dim ShaderCachePos As Integer = -1

            For i As Integer = 0 To FragShaderCache.Length - 1
                If (w0 = FragShaderCache(i).MUXS0) And (w1 = FragShaderCache(i).MUXS1) Then
                    ShaderCachePos = i
                    Exit For
                End If
            Next

            If ShaderCachePos > -1 Then
                Gl.glBindProgramARB(Gl.GL_FRAGMENT_PROGRAM_ARB, FragShaderCache(ShaderCachePos).FragShader)
            Else
                DecodeMUX(w0, w1, FragShaderCache, FragShaderCache.Length)
            End If
        Else
            EnableCombiner = False
        End If
    End Sub

    Private Sub SETFOGCOLOR(ByVal CMDDword() As Byte)
        FogColor(0) = CMDDword(4) / 255
        FogColor(1) = CMDDword(5) / 255
        FogColor(2) = CMDDword(6) / 255
        FogColor(3) = CMDDword(7) / 255
    End Sub

    Private Sub SETBLENDCOLOR(ByVal CMDDword() As Byte)
        BlendColor(0) = CMDDword(4) / 255
        BlendColor(1) = CMDDword(5) / 255
        BlendColor(2) = CMDDword(6) / 255
        BlendColor(3) = CMDDword(7) / 255
    End Sub

    Private Sub SETENVCOLOR(ByVal CMDDword() As Byte)
        EnvironmentColor(0) = CMDDword(4) / 255
        EnvironmentColor(1) = CMDDword(5) / 255
        EnvironmentColor(2) = CMDDword(6) / 255
        EnvironmentColor(3) = CMDDword(7) / 255
    End Sub

    Private Sub SETPRIMCOLOR(ByVal CMDDword() As Byte)
        PrimColor(0) = CMDDword(4) / 255
        PrimColor(1) = CMDDword(5) / 255
        PrimColor(2) = CMDDword(6) / 255
        PrimColor(3) = CMDDword(7) / 255
    End Sub

    Public Sub PrecompileMUXS(ByVal MUXLIST1() As UInteger, ByVal MUXLIST2() As UInteger)
        If MUXLIST1.Length = MUXLIST2.Length Then
            For i As Integer = 0 To MUXLIST1.Length - 1
                DecodeMUX(MUXLIST1(i), MUXLIST2(i), FragShaderCache, i)
            Next
        End If
        PrecompiledCombiner = True
    End Sub

    Public Sub DecodeMUX(ByVal MUXS0 As UInteger, ByVal MUXS1 As UInteger, ByRef Cache() As ShaderCache, ByVal CacheEntry As Integer)
        ColorA(0) = (MUXS0 >> 20) And &HF
        ColorB(0) = (MUXS1 >> 28) And &HF
        ColorC(0) = (MUXS0 >> 15) And &H1F
        ColorD(0) = (MUXS1 >> 15) And &H7

        AlphaA(0) = (MUXS0 >> 12) And &H7
        AlphaB(0) = (MUXS1 >> 12) And &H7
        AlphaC(0) = (MUXS0 >> 9) And &H7
        AlphaD(0) = (MUXS1 >> 9) And &H7

        ColorA(1) = (MUXS0 >> 5) And &HF
        ColorB(1) = (MUXS1 >> 24) And &HF
        ColorC(1) = (MUXS0 >> 0) And &H1F
        ColorD(1) = (MUXS1 >> 6) And &H7

        AlphaA(1) = (MUXS1 >> 21) And &H7
        AlphaB(1) = (MUXS1 >> 3) And &H7
        AlphaC(1) = (MUXS1 >> 18) And &H7
        AlphaD(1) = (MUXS1 >> 0) And &H7

        If GLExtensions.GLFragProg Then
            ReDim Preserve Cache(CacheEntry)
            Cache(CacheEntry).MUXS0 = MUXS0
            Cache(CacheEntry).MUXS1 = MUXS1
            CreateShader(2, Cache(CacheEntry).FragShader)
        Else
            'TODO - At least limited color combiner emulation without using pixel shaders *shrug*
        End If
    End Sub

    Private Sub CreateShader(ByVal Cycles As Integer, ByRef prog As Int32)
        Dim ShaderLines As String = "!!ARBfp1.0" & Environment.NewLine & Environment.NewLine & _
         "TEMP CCReg;" & Environment.NewLine & _
         "TEMP ACReg;" & Environment.NewLine & Environment.NewLine & _
         "TEMP CCRegister_0;" & Environment.NewLine & _
         "TEMP CCRegister_1;" & Environment.NewLine & _
         "TEMP ACRegister_0;" & Environment.NewLine & _
         "TEMP ACRegister_1;" & Environment.NewLine & _
         "TEMP Texel0;" & Environment.NewLine & _
         "TEMP Texel1;" & Environment.NewLine & _
         "PARAM EnvColor = program.env[0];" & Environment.NewLine & _
         "PARAM PrimColor = program.env[1];" & Environment.NewLine & _
         "ATTRIB Shade = fragment.color.primary;" & Environment.NewLine & Environment.NewLine & _
         "OUTPUT FinalColor = result.color;" & Environment.NewLine & Environment.NewLine & _
         "TEX Texel0, fragment.texcoord[0], texture[0], 2D;" & Environment.NewLine & _
         "TEX Texel1, fragment.texcoord[1], texture[1], 2D;" & Environment.NewLine & Environment.NewLine
        For i As Integer = 0 To Cycles - 1
            Select Case ColorA(i)
                Case RDP.G_CCMUX_COMBINED
                    ShaderLines += "MOV CCRegister_0.rgb, CCReg;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL0
                    ShaderLines += "MOV CCRegister_0.rgb, Texel0;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL1
                    ShaderLines += "MOV CCRegister_0.rgb, Texel1;" & Environment.NewLine
                Case RDP.G_CCMUX_PRIMITIVE
                    ShaderLines += "MOV CCRegister_0.rgb, PrimColor;" & Environment.NewLine
                Case RDP.G_CCMUX_SHADE
                    ShaderLines += "MOV CCRegister_0.rgb, Shade;" & Environment.NewLine
                Case RDP.G_CCMUX_ENVIRONMENT
                    ShaderLines += "MOV CCRegister_0.rgb, EnvColor;" & Environment.NewLine
                Case RDP.G_CCMUX_1
                    ShaderLines += "MOV CCRegister_0.rgb, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case RDP.G_CCMUX_COMBINED_ALPHA
                    ShaderLines += "MOV CCRegister_0.rgb, CCReg.a;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL0_ALPHA
                    ShaderLines += "MOV CCRegister_0.rgb, Texel0.a;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL1_ALPHA
                    ShaderLines += "MOV CCRegister_0.rgb, Texel1.a;" & Environment.NewLine
                Case RDP.G_CCMUX_PRIMITIVE_ALPHA
                    ShaderLines += "MOV CCRegister_0.rgb, PrimColor.a;" & Environment.NewLine
                Case RDP.G_CCMUX_SHADE_ALPHA
                    ShaderLines += "MOV CCRegister_0.rgb, Shade.a;" & Environment.NewLine
                Case RDP.G_CCMUX_ENV_ALPHA
                    ShaderLines += "MOV CCRegister_0.rgb, EnvColor.a;" & Environment.NewLine
                Case RDP.G_CCMUX_LOD_FRACTION
                    ShaderLines += "MOV CCRegister_0.rgb, {0.0,0.0,0.0,0.0};" & Environment.NewLine
                Case RDP.G_CCMUX_PRIM_LOD_FRAC
                    ShaderLines += "MOV CCRegister_0.rgb, {0.0,0.0,0.0,0.0};" & Environment.NewLine
                Case 15
                    ShaderLines += "MOV CCRegister_0.rgb, {0.0,0.0,0.0,0.0};" & Environment.NewLine
                Case Else
                    ShaderLines += "MOV CCRegister_0.rgb, {0.0,0.0,0.0,0.0};" & Environment.NewLine
            End Select
            Select Case ColorB(i)
                Case RDP.G_CCMUX_COMBINED
                    ShaderLines += "MOV CCRegister_1.rgb, CCReg;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL0
                    ShaderLines += "MOV CCRegister_1.rgb, Texel0;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL1
                    ShaderLines += "MOV CCRegister_1.rgb, Texel1;" & Environment.NewLine
                Case RDP.G_CCMUX_PRIMITIVE
                    ShaderLines += "MOV CCRegister_1.rgb, PrimColor;" & Environment.NewLine
                Case RDP.G_CCMUX_SHADE
                    ShaderLines += "MOV CCRegister_1.rgb, Shade;" & Environment.NewLine
                Case RDP.G_CCMUX_ENVIRONMENT
                    ShaderLines += "MOV CCRegister_1.rgb, EnvColor;" & Environment.NewLine
                Case RDP.G_CCMUX_1
                    ShaderLines += "MOV CCRegister_1.rgb, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case RDP.G_CCMUX_COMBINED_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, CCReg.a;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL0_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, Texel0.a;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL1_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, Texel1.a;" & Environment.NewLine
                Case RDP.G_CCMUX_PRIMITIVE_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, PrimColor.a;" & Environment.NewLine
                Case RDP.G_CCMUX_SHADE_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, Shade.a;" & Environment.NewLine
                Case RDP.G_CCMUX_ENV_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, EnvColor.a;" & Environment.NewLine
                Case Else
                    ShaderLines += "MOV CCRegister_1.rgb, {0.0,0.0,0.0,0.0};" & Environment.NewLine
            End Select
            ShaderLines += "SUB CCRegister_0, CCRegister_0, CCRegister_1;" & Environment.NewLine & Environment.NewLine
            Select Case ColorC(i)
                Case RDP.G_CCMUX_COMBINED
                    ShaderLines += "MOV CCRegister_1.rgb, CCReg;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL0
                    ShaderLines += "MOV CCRegister_1.rgb, Texel0;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL1
                    ShaderLines += "MOV CCRegister_1.rgb, Texel1;" & Environment.NewLine
                Case RDP.G_CCMUX_PRIMITIVE
                    ShaderLines += "MOV CCRegister_1.rgb, PrimColor;" & Environment.NewLine
                Case RDP.G_CCMUX_SHADE
                    ShaderLines += "MOV CCRegister_1.rgb, Shade;" & Environment.NewLine
                Case RDP.G_CCMUX_ENVIRONMENT
                    ShaderLines += "MOV CCRegister_1.rgb, EnvColor;" & Environment.NewLine
                Case RDP.G_CCMUX_1
                    ShaderLines += "MOV CCRegister_1.rgb, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case RDP.G_CCMUX_COMBINED_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, CCReg.a;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL0_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, Texel0.a;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL1_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, Texel1.a;" & Environment.NewLine
                Case RDP.G_CCMUX_PRIMITIVE_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, PrimColor.a;" & Environment.NewLine
                Case RDP.G_CCMUX_SHADE_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, Shade.a;" & Environment.NewLine
                Case RDP.G_CCMUX_ENV_ALPHA
                    ShaderLines += "MOV CCRegister_1.rgb, EnvColor.a;" & Environment.NewLine
                Case RDP.G_CCMUX_K5
                    ShaderLines += "MOV CCRegister_1.rgb, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case RDP.G_CCMUX_0
                    ShaderLines += "MOV CCRegister_1.rgb, {0.0,0.0,0.0,0.0};" & Environment.NewLine
                Case Else
                    ShaderLines += "MOV CCRegister_1.rgb, {0.0,0.0,0.0,0.0};" & Environment.NewLine
            End Select
            ShaderLines += "MUL CCRegister_0, CCRegister_0, CCRegister_1;" & Environment.NewLine & Environment.NewLine
            Select Case ColorD(i)
                Case RDP.G_CCMUX_COMBINED
                    ShaderLines += "MOV CCRegister_1.rgb, CCReg;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL0
                    ShaderLines += "MOV CCRegister_1.rgb, Texel0;" & Environment.NewLine
                Case RDP.G_CCMUX_TEXEL1
                    ShaderLines += "MOV CCRegister_1.rgb, Texel1;" & Environment.NewLine
                Case RDP.G_CCMUX_PRIMITIVE
                    ShaderLines += "MOV CCRegister_1.rgb, PrimColor;" & Environment.NewLine
                Case RDP.G_CCMUX_SHADE
                    ShaderLines += "MOV CCRegister_1.rgb, Shade;" & Environment.NewLine
                Case RDP.G_CCMUX_ENVIRONMENT
                    ShaderLines += "MOV CCRegister_1.rgb, EnvColor;" & Environment.NewLine
                Case RDP.G_CCMUX_1
                    ShaderLines += "MOV CCRegister_1.rgb, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case Else
                    ShaderLines += "MOV CCRegister_1.rgb, {0.0,0.0,0.0,0.0};" & Environment.NewLine
            End Select
            ShaderLines += "ADD CCRegister_0, CCRegister_0, CCRegister_1;" & Environment.NewLine & Environment.NewLine
            Select Case AlphaA(i)
                Case RDP.G_ACMUX_COMBINED
                    ShaderLines += "MOV ACRegister_0.a, ACReg;" & Environment.NewLine
                Case RDP.G_ACMUX_TEXEL0
                    ShaderLines += "MOV ACRegister_0.a, Texel0;" & Environment.NewLine
                Case RDP.G_ACMUX_TEXEL1
                    ShaderLines += "MOV ACRegister_0.a, Texel1;" & Environment.NewLine
                Case RDP.G_ACMUX_PRIMITIVE
                    ShaderLines += "MOV ACRegister_0.a, PrimColor;" & Environment.NewLine
                Case RDP.G_ACMUX_SHADE
                    ShaderLines += "MOV ACRegister_0.a, Shade;" & Environment.NewLine
                Case RDP.G_ACMUX_ENVIRONMENT
                    ShaderLines += "MOV ACRegister_0.a, EnvColor;" & Environment.NewLine
                Case RDP.G_ACMUX_1
                    ShaderLines += "MOV ACRegister_0.a, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case RDP.G_ACMUX_0
                    ShaderLines += "MOV ACRegister_0.a, {0.0,0.0,0.0,0.0};" & Environment.NewLine
                Case Else
                    ShaderLines += "MOV ACRegister_0.a, {0.0,0.0,0.0,0.0};" & Environment.NewLine
            End Select
            Select Case AlphaB(i)
                Case RDP.G_ACMUX_COMBINED
                    ShaderLines += "MOV ACRegister_1.a, ACReg.a;" & Environment.NewLine
                Case RDP.G_ACMUX_TEXEL0
                    ShaderLines += "MOV ACRegister_1.a, Texel0.a;" & Environment.NewLine
                Case RDP.G_ACMUX_TEXEL1
                    ShaderLines += "MOV ACRegister_1.a, Texel1.a;" & Environment.NewLine
                Case RDP.G_ACMUX_PRIMITIVE
                    ShaderLines += "MOV ACRegister_1.a, PrimColor.a;" & Environment.NewLine
                Case RDP.G_ACMUX_SHADE
                    ShaderLines += "MOV ACRegister_1.a, Shade.a;" & Environment.NewLine
                Case RDP.G_ACMUX_ENVIRONMENT
                    ShaderLines += "MOV ACRegister_1.a, EnvColor.a;" & Environment.NewLine
                Case RDP.G_ACMUX_1
                    ShaderLines += "MOV ACRegister_1.a, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case RDP.G_ACMUX_0
                    ShaderLines += "MOV ACRegister_1.a, {0.0,0.0,0.0,0.0};" & Environment.NewLine
                Case Else
                    ShaderLines += "MOV ACRegister_1.a, {0.0,0.0,0.0,0.0};" & Environment.NewLine
            End Select
            ShaderLines += "SUB ACRegister_0.a, ACRegister_0.a, ACRegister_1.a;" & Environment.NewLine
            Select Case AlphaC(i)
                Case RDP.G_ACMUX_COMBINED
                    ShaderLines += "MOV ACRegister_1.a, ACReg.a;" & Environment.NewLine
                Case RDP.G_ACMUX_TEXEL0
                    ShaderLines += "MOV ACRegister_1.a, Texel0.a;" & Environment.NewLine
                Case RDP.G_ACMUX_TEXEL1
                    ShaderLines += "MOV ACRegister_1.a, Texel1.a;" & Environment.NewLine
                Case RDP.G_ACMUX_PRIMITIVE
                    ShaderLines += "MOV ACRegister_1.a, PrimColor.a;" & Environment.NewLine
                Case RDP.G_ACMUX_SHADE
                    ShaderLines += "MOV ACRegister_1.a, Shade.a;" & Environment.NewLine
                Case RDP.G_ACMUX_ENVIRONMENT
                    ShaderLines += "MOV ACRegister_1.a, EnvColor.a;" & Environment.NewLine
                Case RDP.G_ACMUX_1
                    ShaderLines += "MOV ACRegister_1.a, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case RDP.G_ACMUX_0
                    ShaderLines += "MOV ACRegister_1.a, {0.0,0.0,0.0,0.0};" & Environment.NewLine
                Case Else
                    ShaderLines += "MOV ACRegister_1.a, {0.0,0.0,0.0,0.0};" & Environment.NewLine
            End Select
            ShaderLines += "MUL ACRegister_0.a, ACRegister_0.a, ACRegister_1.a;" & Environment.NewLine
            Select Case AlphaD(i)
                Case RDP.G_ACMUX_COMBINED
                    ShaderLines += "MOV ACRegister_1.a, ACReg.a;" & Environment.NewLine
                Case RDP.G_ACMUX_TEXEL0
                    ShaderLines += "MOV ACRegister_1.a, Texel0.a;" & Environment.NewLine
                Case RDP.G_ACMUX_TEXEL1
                    ShaderLines += "MOV ACRegister_1.a, Texel1.a;" & Environment.NewLine
                Case RDP.G_ACMUX_PRIMITIVE
                    ShaderLines += "MOV ACRegister_1.a, PrimColor.a;" & Environment.NewLine
                Case RDP.G_ACMUX_SHADE
                    ShaderLines += "MOV ACRegister_1.a, Shade.a;" & Environment.NewLine
                Case RDP.G_ACMUX_ENVIRONMENT
                    ShaderLines += "MOV ACRegister_1.a, EnvColor.a;" & Environment.NewLine
                Case RDP.G_ACMUX_1
                    ShaderLines += "MOV ACRegister_1.a, {1.0,1.0,1.0,1.0};" & Environment.NewLine
                Case RDP.G_ACMUX_0
                    ShaderLines += "MOV ACRegister_1.a, {0.0,0.0,0.0,0.0};" & Environment.NewLine
                Case Else
                    ShaderLines += "MOV ACRegister_1.a, {0.0,0.0,0.0,0.0};" & Environment.NewLine
            End Select
            ShaderLines += "ADD ACRegister_0.a, ACRegister_0.a, ACRegister_1.a;" & Environment.NewLine & Environment.NewLine
            ShaderLines += "MOV CCReg.rgb, CCRegister_0;" & Environment.NewLine
            ShaderLines += "MOV ACReg.a, ACRegister_0.a;" & Environment.NewLine
        Next
        ShaderLines += "MOV CCReg.a, ACReg.a;" & Environment.NewLine
        ShaderLines += "MOV FinalColor, CCReg;" & Environment.NewLine
        ShaderLines += "END" & Environment.NewLine

        Dim program() As Byte = System.Text.Encoding.ASCII.GetBytes(ShaderLines)

        Gl.glGenProgramsARB(1, prog)
        Gl.glBindProgramARB(Gl.GL_FRAGMENT_PROGRAM_ARB, prog)
        Gl.glProgramStringARB(Gl.GL_FRAGMENT_PROGRAM_ARB, Gl.GL_PROGRAM_FORMAT_ASCII_ARB, program.Length, program)

    End Sub
#End Region
__________________

Last edited by cooliscool; December 2nd, 2009 at 13:46..
cooliscool is offline   Reply With Quote
Old December 2nd, 2009, 10:26   #25
@ruantec
Crazy GFX coder
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Dominican Republic/Austria
Posts: 8,096
Nice code cooliscool! makes me remember my VB6 days hehehehehe.
__________________


Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6
@ruantec is offline   Reply With Quote
Old December 2nd, 2009, 15:42   #26
cooliscool
Global Moderator
 
cooliscool's Avatar
 
Join Date: Jul 2001
Location: SC, USA
Posts: 7,231
Quote:
Originally Posted by @ruantec View Post
Nice code cooliscool! makes me remember my VB6 days hehehehehe.
Hehe. While I know C# and C++, to me VB.NET's clear and concise syntax makes for much more understandable/maintainable code. Its power (along with C#.NET, thanks to .NET's intermediate language) is vastly underrated, too. I've had no language limitations in any app I've written, including my relatively complex Zelda 64 editor. It's pretty well optimized (but there's room for more as it's a huge project), and models load in milliseconds and achieve ~400 to ~2000 FPS during runtime. Taking into account that it's an editor and keeps track of thousands and thousands of things constantly (including parsing each N64 display list per each frame - I can't take advantage of OGL display list objects because, as an editor, graphical properties such as vertices can be changed), that's not too bad.

Too many people, but not all, have an elitist point of view when it comes to language choice, which I've found to be completely unfounded in most cases. The only problem I have is the obvious platform restrictions, but it's not much of a loss when most computer users either run Windows alone or multiboot with their OS of choice. Also can't forget how incredibly well designed Microsoft's IDEs and debuggers are. Nothing like them.
__________________

Last edited by cooliscool; December 2nd, 2009 at 16:01..
cooliscool is offline   Reply With Quote
Old December 2nd, 2009, 15:53   #27
@ruantec
Crazy GFX coder
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Dominican Republic/Austria
Posts: 8,096
Quote:
Originally Posted by cooliscool View Post
Hehe. While I know C# and C++, to me VB.NET's clear and concise syntax makes for much more understandable/maintainable code. Its power (along with C#.NET, thanks to .NET's intermediate language) is vastly underrated, too. I've had no language limitations in any app I've written, including my relatively complex Zelda 64 editor. It's pretty well optimized (but there's room for more), and even the most complex levels and actors load in milliseconds and achieve 400 (minimum) to 3000 (maximum) FPS during runtime. Taking into account that it's an editor and keeps track of thousands and thousands of things constantly (including parsing display lists on each frame - I can't take advantage of OGL display list objects because, as an editor, graphical properties such as vertices can be changed), that's not too bad. Too many people have an elitist point of view when it comes to language choice, which I've found to be completely ridiculous in most cases. The only problem I have is the obvious platform restrictions, but it's not much of a loss when most computer users either run Windows alone or multiboot with their OS of choice. Also can't forget how incredibly well designed Microsoft's IDEs and debuggers are. Nothing like them.
awesome and agree!

iīve seen your tools and they are really cool.. in my case i avoid the VB syntax(even liking VB6).. somehow i donīt like it(its just a taste thing ) eventhough iīve toyed with VB.net and its pretty awesome to say the least as for now i just stick to C# which is very confortable for me because of the C syntax.

one thing i really like about VB.net against VB6... youīre not allowed anymore to declare a variable as "Optional"(as far as i know)

Quote:
Originally Posted by cooliscool View Post
Too many people, but not all, have an elitist point of view when it comes to language choice, which I've found to be completely unfounded in most cases. The only problem I have is the obvious platform restrictions, but it's not much of a loss when most computer users either run Windows alone or multiboot with their OS of choice.
the main reason why many people have a bad view against VB languages is not just because restrinctions but i think(my opinion) because of the status.. many people that wants to learn a language feel somehow "superior" when they tell to there friends "hey i can code C/C++" while totally forgetting that a language will never make a person a good coder because thatīs a tallent and not a thing that can be optained from a language... also its really sad that the idealism of "C/C++ is the best so f**k the rest" is quite spread around the world and its something we canīt change i think. i for instance was one of those guys with such idealism sadly but thanks God time make us wiser .

Quote:
Originally Posted by cooliscool View Post
Also can't forget how incredibly well designed Microsoft's IDEs and debuggers are. Nothing like them.
i totally agree with that too because i use several tools from MS that probably not many coders here know and in comparation to the tools available for linux or even for macs they are just insanely awesome.. not to mention the other ones looks like toys(so to say) functionality/feature/GUI wise against the MS ones(not even talking about the professional touch).

last but not least i consider myself a defender of C/C++, C# and even VB but i choosed not to promote any silly idealism like the one i mentioned above .
__________________


Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6

Last edited by @ruantec; December 2nd, 2009 at 16:58..
@ruantec is offline   Reply With Quote
Old December 2nd, 2009, 16:28   #28
cooliscool
Global Moderator
 
cooliscool's Avatar
 
Join Date: Jul 2001
Location: SC, USA
Posts: 7,231
Quote:
Originally Posted by @ruantec View Post
the main reason why many people have a bad view against VB languages is not just because restrinctions but i think(my opinion) because of the status.. many people that wants to learn a language feel somehow "superior" when they tell to there friends "hey i can code C/C++" while totally forgetting that a language will never make a person a good coder because thatīs a tallent and not a thing that can be optained from a language... also its really sad that the idealism of "C/C++ is the best so f**k the rest" is quite spread around the world and its something we canīt change i think. i for instance was one of those guys with such idealism sadly .

i consider myself a defender of C/C++, C# and even VB but i do not promote any silly idealism.
Couldn't have said it better myself. Writing good code is completely independent of the language choice; I think this is the most important point.
__________________
cooliscool is offline   Reply With Quote
Old December 2nd, 2009, 18:57   #29
fried_egg
Registered User
 
fried_egg's Avatar
 
Join Date: Apr 2007
Location: indiana
Posts: 694
Quote:
Originally Posted by cooliscool View Post
Couldn't have said it better myself. Writing good code is completely independent of the language choice; I think this is the most important point.
heres a good reason

PayScale - VB.Net Skill Salary, Average Salaries

PayScale - C# Skill Salary, Average Salaries

I'm not saying one way or another whether or not I agree with the stigma against VB, but the fact is that it does exist. Given that it does exist, it is a good thing to keep in mind when choosing which skill set you wish to develop.
fried_egg is offline   Reply With Quote
Old December 2nd, 2009, 19:12   #30
cooliscool
Global Moderator
 
cooliscool's Avatar
 
Join Date: Jul 2001
Location: SC, USA
Posts: 7,231
I was referring to personal preference when it comes to my own projects; I do know C#/C++ quite well, but I prefer VB.
__________________
cooliscool is offline   Reply With Quote
Old December 2nd, 2009, 19:40   #31
@ruantec
Crazy GFX coder
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Dominican Republic/Austria
Posts: 8,096
it is me or is Java the better payed job followed by C#? anyways money isnīt everything and he was refering to personal preferences so a higher salary is totally irrelevant in this case.





__________________


Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6

Last edited by @ruantec; December 2nd, 2009 at 19:59..
@ruantec is offline   Reply With Quote
Old December 2nd, 2009, 20:15   #32
cottonvibes
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Planet Vegeta
Posts: 5,385
Quote:
Originally Posted by cooliscool View Post
I was referring to personal preference when it comes to my own projects; I do know C#/C++ quite well, but I prefer VB.
i started with vb and basic, but after learning c-like languages, i've moved on.

java/c#/c/c++ are all very similar syntax so coding with them feels kindoff the same (especially with java&c# or c&c++).
so i always 'remember' the basic syntax for those languages, but vb is very different compared to those, so it takes more effort to remember.

since vb is intended for rapid application development, yet i'm forgetting the language, it loses its purpose.
so for me i think i'm abandoning it for the most part.

if for some reason i have to use it again, it shouldn't be too difficult to learn though.
__________________

"It was, of course, a lie what you read about my religious convictions, a lie which is being systematically repeated. I do not believe in a personal God and I have never denied this but have expressed it clearly. If something is in me which can be called religious then it is the unbounded admiration for the structure of the world so far as our science can reveal it." - Albert Einstein
check out my blog
cottonvibes is offline   Reply With Quote
Old December 2nd, 2009, 20:34   #33
Proto
Knowledge is the solution
 
Proto's Avatar
 
Join Date: Dec 2002
Location: Pittsburgh, US. Previously in Mexico City
Posts: 7,160
Then again you might prefer you use python, which is intended for RAD as well and is quite similar to the likes of C++/Java.
__________________
Proto is offline   Reply With Quote
Old December 2nd, 2009, 21:37   #34
@ruantec
Crazy GFX coder
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Dominican Republic/Austria
Posts: 8,096
Cooliscool... i Just forgot to mention on my other post that VB.Net has advantages over VB6.. the only advantage of VB6 i can remember so far is that it doesnīt require the .net framework

VB.Net isnīt that bad but quite the opposite as its more powerfull than older versions... just as i mentioned before they removed the posibility to declare a variable as "Optional" which to me was a nonsense.. also they added better stuff i wonīt mention here to keep my post as small as possible . another advantage of VB.Net over VB6 is that you can create intranet apps quite easy, Silverlight and WPF applications not to mention you have a very powerfull framework on your hands so i consider VB.Net is undertimated by many coders probably..

anyways such confusions seems to be common nowdays as VB isnīt the only one... most people when they hear about C# the first thing that comes to there minds is "Java" but in reality that isnīt right at all.. the reason for that is because C# original name wasnīt Java++ or something like that.. what they forget is that its original codename was C+++ as it was developed as the sucessor of C++ and not Java. the addition of some java features makes sense as they are very usefull in many cases. eventhough C# main concept is based in no other than C++. so again the VB confusion isnīt the only one
__________________


Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6

Last edited by @ruantec; December 2nd, 2009 at 21:52..
@ruantec is offline   Reply With Quote
Old December 2nd, 2009, 21:57   #35
cottonvibes
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Planet Vegeta
Posts: 5,385
Quote:
Originally Posted by Proto View Post
Then again you might prefer you use python, which is intended for RAD as well and is quite similar to the likes of C++/Java.
i havn't coded with it, but from the syntax it doesn't seem too-similar though.
definining functions is a different syntax, as well as no ';' to denote end of statements (so i assume its line based, which i don't like).
and a bunch of other syntax differences...

c# i think is going to do as my RAD language.
its annoying type strictness and other limitations makes for more code than i would like though...

Quote:
Originally Posted by @ruantec View Post
anyways such confusions seems to be common nowdays as VB isnīt the only one... most people when they hear about C# the first thing that comes to there minds is "Java" but in reality that isnīt right at all.. the reason for that is because C# original name wasnīt Java++ or something like that.. what they forget is that its original codename was C+++ as it was developed as the sucessor of C++ and not Java. the addition of some java features makes sense as they are very usefull in many cases. eventhough C# main concept is based in no other than C++. so again the VB confusion isnīt the only one
c# is alot more similar to java than c++.
one of the creators of java even called c# a java imitation.

the concept and design for c# was highly influenced by java, its undeniable.
__________________

"It was, of course, a lie what you read about my religious convictions, a lie which is being systematically repeated. I do not believe in a personal God and I have never denied this but have expressed it clearly. If something is in me which can be called religious then it is the unbounded admiration for the structure of the world so far as our science can reveal it." - Albert Einstein
check out my blog

Last edited by cottonvibes; December 2nd, 2009 at 21:57.. Reason: Automerged Doublepost
cottonvibes is offline   Reply With Quote
Old December 2nd, 2009, 22:03   #36
@ruantec
Crazy GFX coder
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Dominican Republic/Austria
Posts: 8,096
Quote:
Originally Posted by cottonvibes View Post
its annoying type strictness and other limitations makes for more code than i would like though...
i wouldnīt use the term "limitations"(actually that was one of the main reasons i misunderstood several posts of yours) but i would say its done slightly different or "Stricted" in some areas.. sometimes you require more code than C++ sometimes not but many times it depends on how you write your code and if you use the intellisence wisely you will end writing your code faster and sometimes you donīt even have to write them at all(use the spacebar). while in C++ i may need slightly lower lines of code i still have an annoying intellisence that doesnīt even work as good as the C# one and therefore even needing slightly more code in C# in some areas at the end am still faster.

Quote:
Originally Posted by cottonvibes View Post
i
c# is alot more similar to java than c++.
one of the creators of java even called c# a java imitation.

the concept and design for c# was highly influenced by java, its undeniable.
i never denied that isnīt influenced by java but its main concept is actually from C++ and thatīs something people keep forgetting. the reason for the big java influence is the .net framework itself which is a imitation/improved version of the Java framework idea. and therefore day by day it got more influenced by the java concept.. still it shouldnīt be compared at all as what they did is nothing but take some of the nice java features and add them to C# and since theyīve learned from Java mistakes they just did it better(my opinion) however the C++ influence is still there just not visible at first sight because just as you mentioned its highly influenced by java mainly due to the way the framework works.
__________________


Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6

Last edited by @ruantec; December 2nd, 2009 at 22:54..
@ruantec is offline   Reply With Quote
Old December 2nd, 2009, 22:14   #37
fried_egg
Registered User
 
fried_egg's Avatar
 
Join Date: Apr 2007
Location: indiana
Posts: 694
Quote:
Originally Posted by cooliscool View Post
I was referring to personal preference when it comes to my own projects; I do know C#/C++ quite well, but I prefer VB.
My comment was in reference to this quote

Couldn't have said it better myself. Writing good code is completely independent of the language choice; I think this is the most important point.

I was just trying to say that, in general, people may have a leaning towards doing projects in c# because working on projects is in general a two-fold endeavor. People usually want to create some sort of meaningful application and they want to better learn a language that is relevant to modern software development. Therefore, it stands to reason there would be more projects being developed using c# than vb.net just for the reason that they want their learned skills to be more highly valued by potential employers.
fried_egg is offline   Reply With Quote
Old December 2nd, 2009, 22:50   #38
cottonvibes
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Planet Vegeta
Posts: 5,385
Quote:
Originally Posted by fried_egg View Post
Couldn't have said it better myself. Writing good code is completely independent of the language choice; I think this is the most important point.
that's a bit debatable depending on what you mean.
good code can mean different things depending on the coder (fastest code, cleanest code, simplest code, smart-code, code with less-overhead, etc...)

but for the sake of not getting into another programming debate, i mostly agree.
i would substitute 'mostly' or 'generally' instead of 'completely' from your statement though.

Quote:
Originally Posted by @ruantec View Post
i wouldnīt use the term "limitations"(actually that was one of the main reasons i misunderstood several posts of yours) but i would say its done slightly different or "Stricted" in some areas.. sometimes you require more code than C++ sometimes not but many times it depends on how you write your code and if you use the intellisence wisely you will end writing your code faster and sometimes you donīt even have to write them at all(use the spacebar).
its true intellisense can help write it faster.
but i dislike 'longer' code, and almost always try and go for shorter more-compact code.
intellisense won't help with that; instead its mostly restricted on how 'strict' the language is.
__________________

"It was, of course, a lie what you read about my religious convictions, a lie which is being systematically repeated. I do not believe in a personal God and I have never denied this but have expressed it clearly. If something is in me which can be called religious then it is the unbounded admiration for the structure of the world so far as our science can reveal it." - Albert Einstein
check out my blog

Last edited by cottonvibes; December 2nd, 2009 at 22:50.. Reason: Automerged Doublepost
cottonvibes is offline   Reply With Quote
Old December 2nd, 2009, 22:56   #39
@ruantec
Crazy GFX coder
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Dominican Republic/Austria
Posts: 8,096
Quote:
Originally Posted by cottonvibes View Post
its true intellisense can help write it faster.
but i dislike 'longer' code, and almost always try and go for shorter more-compact code.
intellisense won't help with that; instead its mostly restricted on how 'strict' the language is.
indeed and agree but again sometimes it depends how you write your code of course thatīs not always true.
__________________


Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6
@ruantec is offline   Reply With Quote
Old December 2nd, 2009, 23:47   #40
Proto
Knowledge is the solution
 
Proto's Avatar
 
Join Date: Dec 2002
Location: Pittsburgh, US. Previously in Mexico City
Posts: 7,160
Quote:
its true intellisense can help write it faster.
but i dislike 'longer' code, and almost always try and go for shorter more-compact code.
intellisense won't help with that; instead its mostly restricted on how 'strict' the language is.
Well, again it depends on what you are doing and where you are. Compact code in the sense of more efficient, less redundant code can be a good thing in many contexts, but compact code and trying to do things like this

Code:
   int x = (++k < t & n) ? 3 : 8 * (n++ < 3);
Is jsut giving headaches to the people who will have to maintain your code in the future, and even to yourself when you forget what the heck you were coding about.
__________________
Proto is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 05:57.

© 2006 - 2012 Emu Forums | About Emu Forums | Advertisers | Investors | Legal | A member of the Crowdgather Forum Community


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.