Labdabeta 182 Posting Pro in Training Featured Poster

Please put your code in CODE tags.

Labdabeta 182 Posting Pro in Training Featured Poster

I could be wrong but I do not think that you can access two dimensional arrays using pointer dereferencing like you are trying to do. Regardless I think it would be better to use a "fake" two-dimensional array like this:

int &access2DArray(int *array, int width, int height, int x, int y)
{
return *(array+(y*width)+x);
}
Labdabeta 182 Posting Pro in Training Featured Poster

How do you show code on a website? Right now I define a bunch of CSS styles called Comment, Preprocessor, Keyword, etcetera. Then make a two column table, make the left column line numbers and and the right column each row has a line of code. Then I manually go through the code assigning CSS styles where appropriate. The problem is that this is tedious, especially for long pieces of code and it is not portable so if I need to change things it takes a long time. I am very new to website programming and have no idea where to start with this. Any help?

Labdabeta 182 Posting Pro in Training Featured Poster

No, the display lists are created using a call to wglUseFontOutlines so I have no access to the code that creates the display list.

Labdabeta 182 Posting Pro in Training Featured Poster

I need to convert a true type font into a list of three dimensional vertices using openGL. I looked at the NeHe tutorial, but it only creates a display list from the font and as far as I can tell it is not possible for me to extract the vertices from a display list. So how can I get the vertices? Do I have to do some weird math with the data in the font file?

Labdabeta 182 Posting Pro in Training Featured Poster

What I meant, and what I happen to think is easier is using a dynamic array. EG:

int *myarray=NULL;
int arraylength=0;
void AddInt(int *array, int &arraylen, int toadd)
{
    if (arraylength<=0)//initialize
        {myarray=new int;*myarray=toadd;return;}//copy toadd to the array
    int *temparray=new int[arraylen+1];//make room in RAM for an extra int
    for (int i=0; i<arraylen; i++)
        {temparray[i]=array[i];}
    temparray[arraylen++]=toadd;//add the value and increment the array length
    delete [] array;//remove the old array
    array=temparray;
}

Of course you would have to modify it to work for your particular situation.

Labdabeta 182 Posting Pro in Training Featured Poster

Maybe I can create my own vertex coordinates from the ttf files? How are they formatted, and how would I calculate the coordinates? Please I need to be able to convert text to a set of three dimensional vertex coordinates using a true type font.

Labdabeta 182 Posting Pro in Training Featured Poster

From what I can see it does not appear as if you have allocated any extra space in your array, so at line 48 when you access stdRec[last+1] you are indexing an array out of bounds.

Labdabeta 182 Posting Pro in Training Featured Poster

Yes, so what you are looking for is something like this:

for (count=0;count<3;count++)
{
    cout<<"Element #"<<count+1/*to make it start counting at 1 instead of 0*/<<":"<<myarray[count]<<endl;
}
Labdabeta 182 Posting Pro in Training Featured Poster

int types are integers, that means they can only store whole numbers. You need the float type, which stores floating point numbers.

Labdabeta 182 Posting Pro in Training Featured Poster

I type using the Dvorak simplified keyboard, but I have a programming competition in a few weeks during which I have to use their keyboards, or I can plug in my own. The problem is that my keyboard is a soft-wired Dvorak keyboard (ie: The keys say dvorak letters but send the computer qwerty) I want to make myself a circuit of some kind such that I can plug my softwired keyboard into it and it will convert it to Dvorak. I have searched to buy a device like this but have never found one. I know how to make electronic circuits using gates, but I dont know how my keyboard sends data over the USB (since USBs use 4 pins and ASCII codes are 8 bits) and I dont know where to get logic gates. Any ideas on how I could create this device?

Labdabeta 182 Posting Pro in Training Featured Poster

By the way I use wglUseFontOutline to get the display lists made. All I need are the vertex coordinates of the generated display lists.

Labdabeta 182 Posting Pro in Training Featured Poster

Null is defined as 0. Whenever you use null you could also use 0 although null is used more for pointers since the pointer value of 0 is reserved. Void is a data type with absolutely no space. It is used as a pointer to be a generic data type. EG:

char *mystr = NULL;
char *mystr2 = 0;//this is the same as above
void myvoid;//this is nothing, I am not sure if it will even be allocated
void *myvoidpntr;//this cannot be used directly but can be cast into any pointer type, it is generally quite dangerous to use this
void myfunction()//this function does not return anything, so it just returns void

Hope this helps.

Labdabeta 182 Posting Pro in Training Featured Poster

You have to realize that ofstream is a class so you need to use void reader1(ofstream outf); Also I think that fstream tries to protect your programs from clashing like you describe. If you want a stripped down access to a file with no C++ failsafes I suggest a small interrupt in assembly language.

Labdabeta 182 Posting Pro in Training Featured Poster

I suggest you dont use global variables, as they tend to be messy and you tend to run into problems like this one. Instead make your Reader/Writer functions take an ofstream variable and use it.

Labdabeta 182 Posting Pro in Training Featured Poster

I need to know how to extract the data in a display list in opengl. I have a font and use it to create a display list to draw, but then I want to get the actual vertexes of it so I can use them for collision checking. How can I do this?

Labdabeta 182 Posting Pro in Training Featured Poster

That looks about right to me... how do I use it?

Labdabeta 182 Posting Pro in Training Featured Poster

Is it possible to create an array of functions in Java? Or is this not possible?

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks.

Labdabeta 182 Posting Pro in Training Featured Poster

That thread asked the exact question I need an answer to actually and that atan2 function looks promising. But I cant get it to work. Here is a better question for my needs: I have two points, (x1,y1) and (x2,y2) and I need to get their angle in degrees clockwise from pure "North". How do I do this?

Labdabeta 182 Posting Pro in Training Featured Poster

What is the equivalent of tan-1(theta) [inverse tangent] in Java?

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks.

Labdabeta 182 Posting Pro in Training Featured Poster

Is it possible to define a union at creation. ie:

union Colour
{
   unsigned int i;
   char c[4];
   struct{
      char a;
      char r;
      char g;
      char b;
   }col;
}Black(0xFF000000),White(0xFFFFFFFF),Red(0xFFFF0000),Green(0xFF00FF00),Blue(0xFF0000FF)/*etc...*/;
Labdabeta 182 Posting Pro in Training Featured Poster

Its a documentation program... and its ignoring the conditional code inside the preprocessors.

Labdabeta 182 Posting Pro in Training Featured Poster

You could simulate those kind of graphics with a 2D graphics library like SDL and some code to make it low resolution and low saturation.

Labdabeta 182 Posting Pro in Training Featured Poster

Not sure I fully understand, but for windows based DOS console style you can take a look at Win32 Console Applications.

Labdabeta 182 Posting Pro in Training Featured Poster

I am VERY confused by the Doxygen configuration file. I cant seem to figure out how to make it compile code between #ifdef __cplusplus and #endif Also I dont understand how to change what it does with preprocessor symbols or how to make it NOT generate documentation on something. Any help would be appreciated.

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks, that is what I was looking for.

Labdabeta 182 Posting Pro in Training Featured Poster

New operator, and I guess I will refine my question to how can I know if I have created too many elements? ie:

int *test;
int numtest;
test=new int[x];
if (test has overstepped my RAM's capability)
{
//do something
}
Labdabeta 182 Posting Pro in Training Featured Poster

I know about dynamic arrays, but my compiler gives me an error whenever I use an array index above 10000. I need to know how to determine the maximum length of a dynamic array.

Labdabeta 182 Posting Pro in Training Featured Poster

How long can an array be, and how can I extend that length?

Labdabeta 182 Posting Pro in Training Featured Poster

WOW! That is perfect!!! I was trying to do all this order and weird comment stuff because I was using a very weak, self-made documentation program. This Doxygen thing renders my problem mute. Thank you!

Labdabeta 182 Posting Pro in Training Featured Poster

Ok, first of all the __NAME__ thing is not actually that, it is DLL_FUNCTION__NAME (It is for my documentation reader to not show them) Also, what is Doxygen?

Labdabeta 182 Posting Pro in Training Featured Poster

Ok, I have a class that holds an array of ints and a pointer to a special class that contains an array of glModels. This other class only allows access to the index of those models as ints, so I cannot overload the + or += operators to add things to those classes. So I made the () operator return an integer wrapper class with overloaded operators so that I can do statements like: MyClass(IndexOfMyModel)+=WhatIWantToAddToMyModel; This works fine, but the header file has the () operator a whole class definition away from the integer wrapper class' + operator, I want them to be right on top of each other.

Now it is:

class __glModelReferenceClass__;
class glWindow
{
    private:
    __glWindow__ *win;
    public:
    //functions
    __glModelReferenceClass__& operator(int index){return __glModelReferenceClass__(win,index);}
    //more functions
};
class __glModelReferenceClass__
{
    private:
    __glWindow__ *win;
    int index;
    public:
    __glModelReferenceClass__(__glWindow__ *win):win(win){}
    __glModelReferenceClass__ &operator+=(glVertex vert){__AddVertA__(win,index);return *this;}
    __glModelReferenceClass__ &operator+=(float xyz[3]){__AddVertB__(win,index);return *this;}
    //more of these operators and the such
};

But where it says more functions it is many, many lines of code and comments describing each function to be exported to an index document. In this order the index of the () operator for glWindow is quite far from the += operators of __glModelReferenceClass__ so it is hard to read them. I have also left out some other things which are the reason for the __NAME__ or __NAMEVERSION__ of some of the classes and functions.

Labdabeta 182 Posting Pro in Training Featured Poster

Is it possible to put a gap in a class definition? IE:

class a;
class b
{
private:
a test;
public:
a getA(){return test;}
};
class a
{
private:
int i;
public:
a(int i):i(i){}
a operator+(int o)const{return a(i+o);}
};
class b continued?//what? how?
{
void outputA(){cout<<a;}
};

This is just an example, I actually want this for a reason that will make code EASIER to read.

Labdabeta 182 Posting Pro in Training Featured Poster

thanks!

Labdabeta 182 Posting Pro in Training Featured Poster

Oops! I was too hasty. How do I enable/disable culling in OpenGL?

Labdabeta 182 Posting Pro in Training Featured Poster

That sounds about right! Thanks!

Labdabeta 182 Posting Pro in Training Featured Poster

What does it mean if my opengl objects are opaque from one side and translucent from another?

Labdabeta 182 Posting Pro in Training Featured Poster

Thanks!

Labdabeta 182 Posting Pro in Training Featured Poster

here is the question, what does str(X) become

#define str_(X) #X
#define str(X) str_(X)

when X is a string? is it ""string"" or "\"string\""?

Labdabeta 182 Posting Pro in Training Featured Poster

Thank you! that is exactly what I was looking for. I am also probably going to turn the class into a struct and just pass a struct to each function that would normally be part of that class, ie:

//what i was going to do:
class test{
private:
int a;
public:
int dosomething();
int dosomethingelse();
};
//what I am going to do:
struct test{
int a;
};
test *__declspec(dllexport) __stdcall NewTest();
int __declspec(dllexport) __stdcall dosomething(test *);
int __declspec(dllexport) __stdcall dosomethingelse(test *);
Labdabeta 182 Posting Pro in Training Featured Poster

So, just for clarification, this would work (though it is missing some useful stuff, such as header guards)?:

this file is compiled as a dll:

class test
{
private:
int a;
public:
__declspec(dllexport) test(int a);
__declspec(dllexport) int num();
};
test::test(int a)
{
(*this)->a=a;
}
int test::num()
{
return a;
}

this is a header file to be used to reference the dll:

class test
{
private:
int a;
__declspec(dllimport) test(int a);
__declspec(dllimport) int num();
};

and this as an implementation cpp file:

#include "mydllheader.h"
#include <iostream>
using namespace std;
int main()
{
test tst(5);
cout<<tst.num();
return 0;
}
Labdabeta 182 Posting Pro in Training Featured Poster

So how exactly would I write a dll and implementation file for the three blocks of code in my first post in this thread?

Labdabeta 182 Posting Pro in Training Featured Poster

Could I just have an example, for example how to properly turn my above sample code into a dll?

Labdabeta 182 Posting Pro in Training Featured Poster

It sounds like you are trying to use basic file io. There are two main ways to do this, one is using standard io (stdio.h) and one is using file streams (fstream.h) you can google and learn about both of these methods.

Labdabeta 182 Posting Pro in Training Featured Poster

Windows XP, but I want compatibility up to and including windows 7 and backwards compatibility for windows 2000. Also I am using Code::Blocks which seems to have some kind of predefined DLL style project?

Labdabeta 182 Posting Pro in Training Featured Poster

So it seems like I should use a DLL, but how do I use a DLL?

Labdabeta 182 Posting Pro in Training Featured Poster

I am extremely confused about libraries and have been having trouble understanding them with google. Basically I want to create a library so that I can use a bunch of functions from another file without all of the libraries' contents being seen. EG:
library code:

class test
{
private:
int num;
public:
test(int a):num(a){}
int num(){return a;}
};

header code:

class test
{
private:
int num;
public:
test(int a);
int num();
};

cpp file code:

#include "theheaderfile.h"
#include <iostream>
using namespace std;
int main()
{
test tst(5);
cout<<tst.num();
}

What kind of library should I use and how do I implement it on my cpp files? (I am using Code::Blocks IDE)

Labdabeta 182 Posting Pro in Training Featured Poster

Is there a way to make a class visible only from within another class. i.e:

class myclass
{
private:
class anotherclass
{
    //stuff that only can be used from within a myclass function
    void dosomething();
    float dosomethingelse();
}*anotherclasses;
int numanotherclasses;
public:
int createanotherclass();//creates anotherclass object, puts it in the array and returns its index
void dosomething(int index);
float dosomethingelse(int index);
};

But in this example I would need to be unable to make an anotherclass from outside of myclass. Is this possible and if so what is the syntax for it?