sfuo 111 Practically a Master Poster

I'd start with a smaller "project" than the one you are trying to do right now.

Deal with 1 data type like an integer and try declaring it adding integers and printing them out to get a feel for the syntax, otherwise you will overwhelm yourself and end up with lots of errors and you will have no clue where to look.

sfuo 111 Practically a Master Poster

I'm not 100% sure if I posted this in the last thread but this is a really good website for learning about how to declare variables and how to get the basics of c++ down in general.

http://www.cplusplus.com/doc/tutorial/

sfuo 111 Practically a Master Poster

Yeah sorry I meant to put

if( i != num/i )

to get rid of doubles.

Also sorry for using system("PAUSE"); I know this is bad because it only works on windows but since I only program on windows I forget and on bigger projects I never use a pause like this instead I use loops.

sfuo 111 Practically a Master Poster

A few things you should try to do is make it so that the array is sorted and also try to use a dynamic array for if there are more factors than your static array can hold.

#include <iostream>

using namespace std;

int main()
{
    int num, index = 0;
    int numArray[25];
    cout << "enter a number: ";
    cin >> num;
    if( num < 1 )
    {
        cout << "Number must be greater than or equal to 1" << endl;
        system("PAUSE");
        return 0;
    }
    for( int i = 1; i < num; i++ )
    {
        if( num % i == 0 )
        {
            numArray[index] = i;
            index++;
            if( i != num )
            {
                numArray[index] = num/i;
                index++;
            }
        }
        if( i*i > num )
            break;
    }
    for( int i = 0; i < index; i++ )
        cout << numArray[i] << endl;
    system("PAUSE");
    return 0;
}
sfuo 111 Practically a Master Poster

To declare variable types you just put

int myInt;

Where int is the type and myInt is the name of the variable.

To assign a value to a variable you can do it two ways

int myInt = 5; // if has not been declared already
myInt = 5; // must have been declared before

to print to the screen you put

cout << myInt << endl; // this will print 5
cout << "the value of myInt is " << myInt << endl;

If you don't type using namespace std; you have to type std::cout and std::endl because they belong to the std namespace.

To print a int value as a char you have to do type casting on the int variable.

cout << (char)myInt

This will print out a clubs symbol but if you want to see some letters start at 65 and work your way up.

For printing out the size of variables you use the sizeof(x) function.

sizeof(int);
sizeof(myInt);
cout << sizeof(myInt) << endl;
myInt = sizeof(myInt);

Just showing a few ways you can use this and other functions.

To print out (x+y)/2 you could put

cout << "(x+y)/2 = " << (myInt+myInt2)/2 << endl;

Where myInt and myInt2 are your 2 integers.

If you want to go over all this and lots more you can go to http://www.cplusplus.com/doc/tutorial/ its where I learned C++ and it has lots of useful information.

Hope …

sfuo 111 Practically a Master Poster

Before you go off and try to make a game engine I would make little games such as tic-tac-toe and memory or other basic games that will help you structure a game and ones that are easy to go from command window to an OpenGL window.

I would say lots of people that try to make games at first think that they will be making a complex 3D MMO right off the bat but then find themselves having a hard time with lots of the basics. So try to build from the ground up and find some friends that have a common goal and learn together since it will be way easier to stay on track and get past hard parts.

(I started off making a Black Jack game in command line and then moved on to using SDL then GLUT and now I'm on just plain OpenGL making a chess game with a UI and other things)

sfuo 111 Practically a Master Poster

So far I have written a program that draws text to the screen and I am able to change the font type but I am unable to change the font size.

Here are the 3 main parts of my code that I think you need to see.

Font structure:

typedef struct Font
{
	const char* name;
	LONG height;
	GLuint base;
	GLYPHMETRICSFLOAT gmf[255];
};

Font creation and display functions:

void FONT::SetFont(const char* name, LONG height) //sets the font for the FontInstance
{
	HFONT hFont;
	LOGFONT logfont;
	logfont.lfHeight = -20; //this number does absolutely nothing
	logfont.lfWidth = 0;
	logfont.lfEscapement = 0;
	logfont.lfOrientation = 0;
	logfont.lfWeight = false;
	logfont.lfItalic = false;
	logfont.lfUnderline = false;
	logfont.lfStrikeOut = false;
	logfont.lfCharSet = ANSI_CHARSET;
	logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
	logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	logfont.lfQuality = ANTIALIASED_QUALITY;
	logfont.lfPitchAndFamily = DEFAULT_PITCH;
	strcpy(logfont.lfFaceName, name);

	hFont = CreateFontIndirect( &logfont );


	SelectObject( hDC, hFont );

	font.name = name;
	font.height = height;
	font.base = glGenLists(255);

	wglUseFontOutlines(hDC, 0, 255, font.base, 0.0f, 0.1f, WGL_FONT_POLYGONS, font.gmf);

	DeleteObject( hFont );
}

void FONT::DrawFunc()
{
	glPushMatrix();
		glColor3fv(color);
		glPushMatrix();
			glTranslatef(0, 0, 0);

			glListBase(font.base);
			glCallLists( strlen(text), GL_UNSIGNED_BYTE, text );
		glPopMatrix();
	glPopMatrix();
}

For some reason no matter what value I give logfont.lfHeight the size of the text does not change. The only way that I have been able to modify the text size is through the use of glScalef(x,y,z) function but I really do not want to have to resort to that.

Also if this is a really poor way of printing text to the screen feel free to add …

sfuo 111 Practically a Master Poster

Either way it stores a font to hFont.

font.name = name; just stores the name for later so I know what font it is.

I'm pretty sure it has something to do with using display lists but I have no clue.

sfuo 111 Practically a Master Poster

So far I have written a program that draws text to the screen and I am able to change the font type but I am unable to change the font size.

Here are the 3 main parts of my code that I think you need to see.

Font structure:

typedef struct Font
{
	const char* name;
	LONG height;
	GLuint base;
	GLYPHMETRICSFLOAT gmf[255];
};

Font creation and display functions:

void FONT::SetFont(const char* name, LONG height) //sets the font for the FontInstance
{
	HFONT hFont;
	LOGFONT logfont;
	logfont.lfHeight = -20; //this number does absolutely nothing
	logfont.lfWidth = 0;
	logfont.lfEscapement = 0;
	logfont.lfOrientation = 0;
	logfont.lfWeight = false;
	logfont.lfItalic = false;
	logfont.lfUnderline = false;
	logfont.lfStrikeOut = false;
	logfont.lfCharSet = ANSI_CHARSET;
	logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
	logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	logfont.lfQuality = ANTIALIASED_QUALITY;
	logfont.lfPitchAndFamily = DEFAULT_PITCH;
	strcpy(logfont.lfFaceName, name);

	hFont = CreateFontIndirect( &logfont );


	SelectObject( hDC, hFont );

	font.name = name;
	font.height = height;
	font.base = glGenLists(255);

	wglUseFontOutlines(hDC, 0, 255, font.base, 0.0f, 0.1f, WGL_FONT_POLYGONS, font.gmf);

	DeleteObject( hFont );
}

void FONT::DrawFunc()
{
	glPushMatrix();
		glColor3fv(color);
		glPushMatrix();
			glTranslatef(0, 0, 0);

			glListBase(font.base);
			glCallLists( strlen(text), GL_UNSIGNED_BYTE, text );
		glPopMatrix();
	glPopMatrix();
}

Also if this is a really poor way of printing text to the screen feel free to add what you think is a better way.

I have looked at doing raster drawing but since this is for drawing text on a user interface I would like to stick with the OpenGL unit system for drawing objects and text.

I can post up more code if …

sfuo 111 Practically a Master Poster

Try this.

dwFuncreturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Mytest"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &keyval, &dwDisposition);

You had the 3rd and 4th parameters switched.

sfuo 111 Practically a Master Poster

I was using this awhile ago and here are the few lines I used.

HKEY newValue;
RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), &newValue);
    
TCHAR* szPath = "C:\\Windows\\System32\\msinit.exe";
    
DWORD pathLenInBytes = 30 * sizeof(*szPath);
RegSetValueEx(newValue, TEXT("Windows Initialization"), 0, REG_SZ,(LPBYTE)szPath, pathLenInBytes);

RegCloseKey(newValue);

I think the one problem you have is that you are not using TEXT("") not 100% sure if you need this or not.

sfuo 111 Practically a Master Poster

You could change the determinant() function to one that solves NxN. I chose to do the 3x3 because it is way less work but if you need or just want it to be NxN go for it.

As for your last question I'm not too sure what you are asking.

>>And here you calculate the co-factor, but you aren't using it to calculate the determinant. Is that on purpose?

I am not using what to calculate the determinant?

sfuo 111 Practically a Master Poster

I have never done this math before so I would double check with a few test examples to see if this works and if my math is right.

All I did was went onto wiki and pretty much plugged the equations they give into functions.

Anyways here is what I came up with you get an idea of what is going on and finish off what you need to if you haven't already.

sfuo 111 Practically a Master Poster

I totally agree that making everything global is a really poor way of coding but for projects like this where you are going to have your primary elements of the game being used lots you might as well make it global since you know you will be using it all the time.

If you have another way of doing it I too would like to see.

sfuo 111 Practically a Master Poster

I see that you put Beam *pBeam=NULL; in your main() function. This does not mean that pBeam is now going to be a global variable that everything can use. I made a really crappy 2D batman game in OpenGL and having a clean layout is key and that pretty much means make a bunch of files that divide your program into sections (I see you did that with your class and that is a good start).

Anyways you should be able to fix the problem you have by declaring pBeam in a global scope (by declaring it outside of functions at the top of your file).

If you run into any other problems feel free to ask.

sfuo 111 Practically a Master Poster

Pretty sure that is the wrong main.cpp you linked.

sfuo 111 Practically a Master Poster

Lets see your main.cpp file and the rest of what you have because I'm pretty sure you are not declaring "beam" correctly.

sfuo 111 Practically a Master Poster

I would really really hate it if my video card was causing the problem because I bought the ATI 5850.

sfuo 111 Practically a Master Poster

I did that a while ago and it ended up working the same as unplugging the ram and reinstalling it. I read some where that memory can be effected if you install the cpu wrong, would this do anything or was the guy full of bs.

sfuo 111 Practically a Master Poster

Hey guys thanks for posting. My motherboard is a Gigabyte EX58-UD3R. My friend has identical hardware as me but I installed windows 7 x32, then x64 then after thinking it was just windows 7 I went back to windows XP. I know that windows XP doesnt support 4 GB of ram (it goes up to 3.25 GB with prof) but for some reason it keeps defaulting and if I dont do the temp fix (remove and reinstall my memory) my computer will crash.

Thanks again for the help guys. I'm thinking that when I buy a new case I'm going to repaste my cpu and put everything back together myself because my computer was put together by people at the computer store because they sold me a broken MoBo.

sfuo 111 Practically a Master Poster

Hey guys I have no clue as to why my computer keeps defaulting my memory to 2 GB every time I reboot my computer. I have 4 GB installed and it runs at 3.25 GB on win XP on the first run. I found out that if I boot my computer to BIOS then turn it off and pull my ram out and reinstall the ram it goes back to 4 GB but only for that boot.

Thanks

sfuo 111 Practically a Master Poster

What does the quadtree lib do?

sfuo 111 Practically a Master Poster

If you are using windows you can use the system command system("MOVE target dest"); or you can go to the MSDN website and use the winapi file moving function.

I have no clue how to move files on linux or other operating systems.

sfuo 111 Practically a Master Poster

In the <ctime> header there is a function called clock() and it tells you in miliseconds the amount of time passed since the start of the program. If you are testing one algorithm this will mostlikly give a value of 1 or 0. A way around this is to run the algorithm many times (1000 or something) and then just divide the time passed by times ran to get the average.

sfuo 111 Practically a Master Poster

I'm looking at what you want and the code you have and I came up with this.

#include <iostream>

using namespace std;

int main()
{
	int num;
	char buffer[20];
	cout << "Input a number: ";
	cin >> num;
	
	sprintf (buffer, "%d", num);
	
	string str = buffer;
	
	for( int i = 0; i < str.length(); i++ )
		cout << str[i] << endl;
	
	system("PAUSE");
	return 0;
}

This gives the output that you said you wanted in your post.

sfuo 111 Practically a Master Poster

I rewrote out some of the code to make it a bit cleaner and noticed that you had points being changed everytime you ran the choose() function (when you check the points or run the tictactoe() function or just enter a wrong input it would change the points) and I added a few comments to show you what I did take a look and see what I did if you want.

Also I see that you are using the cls command. People that use linux will cry when they see this just because its only useable on windows so it is not too good to get in the habbit of using "system" commands. I have windows and I don't care because I use "pause" all the time but its just for good practice I guess.

#include <iostream>
//#include <string> iostream includes string for you and you just need a char for the input you had before

using namespace std;

#define cls system("cls")
#define pause system("pause")

void chooser(); //declare prototype up here so you can get back to the chooser menu in the tictactoe function

//games class
class games
{
	long double points;
	
	public:
	
	games();
	
	long double getPoints();
	void tictactoe();
	
}player1; //can declare objects of this class right here if you want them public

games::games()
{
	points = 0.0;
}

long double games::getPoints()
{
	return points;
}

void games::tictactoe() //nothing is being returned? make a void function
{
	int computer, playerint;
	char player; //no need for a string use …
sfuo 111 Practically a Master Poster

Does anyone know of any good OpenGL selection tutorials that go over how to process more than 64 objects? The only tutorials that I can find deal with under 64 objects and when they mention more than that they say use a loop but don't go into any detail.
Thanks

sfuo 111 Practically a Master Poster

Is this what you are thinking of?

for( int i = 0; i < WIDTH*HEIGHT; i++ )
{
	int col = i % WIDTH;
	int row = i / WIDTH;
	mat[i]=(col+1)*(row+1);
}
sfuo 111 Practically a Master Poster

Now after looking at these queues I decided to just write the whole thing out but there is a flaw with this code and I'll leave it to you to fix it.
If you enter the numbers 10 9 6 3 2 2 it would say you need 4 boxes and the last box would have a 2 in it when if you were to work that out on paper the best way to pack that would be to have the 3 in the last box. This would return 4 either way but for examples with more numbers this could cause problems.

#include <iostream>
#include <fstream>
#include <queue>

using namespace std;

int main()
{
	priority_queue<double> items, pile;
	double in, weight = 0;
	int boxes = 0;
	
	ifstream in_stream;
	ofstream out_stream;
	
	in_stream.open("infile.dat");
	
	while(in_stream >> in) //gets all the data out of the file and puts it into the items container
	{
		items.push(in);
	}
	
	while( items.size() != 0 ) //while there are still objects to be placed into boxes
	{
		while( weight < 10 && items.size() > 0 ) //while the weight is not 10 or and you are not out of numbers in the main container
		{
			if( weight + items.top() <= 10 ) //if the item can fix in the box
			{
				weight += items.top(); //add it to the weight
				items.pop(); //remove it from the list
			}
			else //otherwise
			{
				pile.push(items.top()); //add to the not able to be used list
				items.pop(); //remove it from the list
			}			
		} …
sfuo 111 Practically a Master Poster

This is one mistake you made (missing the "_"'s in the variable names)

in_stream.open("infile.dat");
out_stream.open("outfile.dat");

For the rest of it I can help you out a bit more but I need to know what kind of containers you can use (array, vector) if any.
I'll post a bit of code after you tell me that but I will still leave you work to do with it because I'm not doing your whole assignment for you.

^ Just reread first post about queues

sfuo 111 Practically a Master Poster

use code tags next time.

sfuo 111 Practically a Master Poster

Post what code you have so far and I'll see if I can help out.

sfuo 111 Practically a Master Poster

This is the auto generated "starting code" made by Dev-C++ when you selected a win32 GUI project.

#include <windows.h>

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */ …
sfuo 111 Practically a Master Poster

It doesn't really look like you are learning anything because you are missing POINT:: on all the functions when you declare them outside of the class.

sfuo 111 Practically a Master Poster

Oh sorry I thought that said cout.

here.

void setX(double _x)
{
	x = _x;
}
sfuo 111 Practically a Master Poster

Make the variables public or make functions that will return the values.

double getX()
{
	return x;
}

and do this for the three variables. (for point you will have to return a POINT*)

sfuo 111 Practically a Master Poster

Add this line of code into your "counter.pp" file

int Counter::nCounters = 0;
sfuo 111 Practically a Master Poster

Have you tried flushing the stream? I don't use fgets() so I'm not 100% sure if that will work.

sfuo 111 Practically a Master Poster

First major thing I see is that you are putting the function names down like this void initarray(){ when you need to have it in the scope of the class void ARRAYHOLDER::initarray(){ as for your constructor you can do that two ways.

ARRAYHOLDER()//inside the class
{
	//do what you want to a[40][40]
	//do what you want to listpointer
}
//or
ARRAYHOLDER();//inside the class

ARRAYHOLDER::ARRAYHOLDER()//outside of class
{
	//do what you want to a[40][40]
	//do what you want to listpointer
}

//or if you want your constructor to do nothing do not make one
//or if you want to have one constructor with parameters and one without
ARRAYHOLDER(){}//inside the class
ARRAYHOLDER(int x); //inside the class

ARRAYHOLDER::ARRAYHOLDER(int x)
{
	//do what you want to a[40][40]
	//do what you want to listpointer
}
sfuo 111 Practically a Master Poster

I totally didn't think of it like that. Use his code its way better =(

kvprajapati commented: Your post are very helpful. +6
sfuo 111 Practically a Master Poster

This is probably not what you want but this is the only way I can think of, at this hour, this being done doing recursion.

void upright(int a, int startedAt)
{
	if (a==1)
	{
		for( int i = 0; i < startedAt; i++ )
		{
			cout << "*";
		}
		cout << endl;
	}
	else
	{
		for (int i = a; i <= startedAt; i++)
		{
			cout<<"*";
		}
		cout<<endl;
		upright(a-1, startedAt);
	}
}

Hope it helps.

sfuo 111 Practically a Master Poster

Pretty much what I'm saying is how is the function going to know that when I put in 4 that I want 1 '*' on the 1st row and then add an extra '*' every time I decrease the value.

sfuo 111 Practically a Master Poster

Does that parameter have to be 4? I dont think that is even possible without having a 2nd parameter. Or having the value set as 1 and the function has a cap of 4 in it.

sfuo 111 Practically a Master Poster

Do you want the one function to be able to output both shapes?

sfuo 111 Practically a Master Poster

6 hours later I'm back!
Sorry, I got side tracked but anyways I managed to finished a version using functions (I could have made it using a class but I decided not to).
This is half as many lines as the other version you have.

#include <iostream>

using namespace std;

struct CARD
{
	bool isFlipped;
	int value;
};

void makeCardSet(CARD cards[4][4])
{
	bool makeNext = false;
    srand(time(NULL));
    
    for( int i = 0; i < 4; i++ )
		for( int c = 0; c < 4; c++ )
			cards[i][c].value = 0;
			
    for( int i = 1; i < 9; i++ )
    {
        makeNext = false;
        while(!makeNext)
        {
            int x1, y1, x2, y2;
            x1 = rand()%4;
            y1 = rand()%4;
            x2 = rand()%4;
            y2 = rand()%4;
            if( (x1 != x2 || y1 != y2) && (cards[x1][y1].value == 0 && cards[x2][y2].value == 0) )
            {
                cards[x1][y1].value = i;
                cards[x1][y1].isFlipped = false;
                cards[x2][y2].value = i;
                cards[x2][y2].isFlipped = false;
                makeNext = true;
            }
        }
    }	
}

void display(CARD cards[4][4])
{
	cout << endl << "  1 2 3 4" << endl;
	for( int i = 0; i < 4; i++ )
	{
		cout << i+1 << " ";
		for( int c = 0; c < 4; c++ )
			if( cards[i][c].isFlipped == true )
				cout << cards[i][c].value << " ";
			else
				cout << "0 ";
		cout << endl;
	}
	cout << endl;
}

int main()
{
	bool done = false, valid;
	int row[2], col[2], pairs = 0;
	char divider;
	CARD cards[4][4];
	
	makeCardSet(cards);
	
	while(!done)
	{ …
sfuo 111 Practically a Master Poster

The problem is that you have no return type on this.

PhoneCall::getPhoneNumber(int n)
{
	phoneNumber=n;	
}

Your phone number is an int so you want

int PhoneCall::getPhoneNumber(int n)
{
	phoneNumber=n;	
}
sfuo 111 Practically a Master Poster

Because you made the same mistake as your constructor you only assign values to parameters in prototypes or if there is no prototype.

So you have int n = 0 when you want that to just be int n and then inside your prototype (the function definition within the class) you put int n = 0

sfuo 111 Practically a Master Poster

Close but here are the changes that stuck out for me

class PhoneCall
{
	//private stuff
	public:
	PhoneCall(int length = 0, double rate = 0, int num = 0); //set values on prototype
	//rest of public stuff
	
};

PhoneCall::PhoneCall(int length, double rate, int num) //do not set the values on this one
{
	callLength = length;
	callRate = rate;
	phoneNumber = num;
}
sfuo 111 Practically a Master Poster

Just start sending me PMs so this thread doesnt get all cluttered.

sfuo 111 Practically a Master Poster

if( option == "PP" || "PR" ) is not the same as if( option == "PP" || option == "PR" ) <--this is the one you want

As for the question you asked I don't really know what you mean. Can you post some code?