|
Hi again fellows
I have this function in my code:
void ImprimeTexto(unsigned int iFont, const char* cValue)
{
if(iFont == 0) return;
glEnable(GL_BLEND);
glPushAttrib(GL_LIST_BIT);
glListBase(iFont - 32);
glCallLists(strlen(cValue), GL_UNSIGNED_BYTE, cValue);
glPopAttrib();
glDisable(GL_BLEND);
}
Because of my const char cValue variable I have a leak memory of 4kbytes.
I need to pass a variable of type const char because the glCallLists(an OpenGL function) needs. The last parameter is a pointer to GLVoid.
Here is the function signature:
GLAPI void APIENTRY glCallLists( GLsizei n, GLenum type, const GLvoid *lists );
I've tried to pass a std::string but the function doesn't works .
Guys, can you help me in this??
Thanks a lot
|
|
|
|
|
pass a std::String, and then use the c_str() function to get a char * to pass into the OpenGL function.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I suppose that you dynamically allocate the list array before calling ImprimeTexto, and then you forget to deallocate it.
|
|
|
|
|
Some questions on Win32/.Net interaction DLLs:
When compiling a managed DLL that uses Win32 funcs, what character set should be selected, or does it always become unicode due to /clr?
If one creates a native DLL that is to be used with [DllImport...] from .Net, what character set should be used there? I've seen them set to compile with MBCS. Is there a point in this? I know if it was set to Unicode it wouldn't work on W98, but does MBCS enable it to receive "exotic" unicode glyphs (they translate) from a .Net client app, or might it just as well be set to "Not Set"?
|
|
|
|
|
|
- who are you ?
- what is the question ?
- why do you shout ?
- what is a popup dictionnary ?
- do you know you worth a '1' ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
probably one of the most useless topic I've ever seen. I think I know what you want to do, but it's really complicated. And if you don't give more infos, noone will help you.
|
|
|
|
|
Moooommmmmm, i'm seeing anonymous everywhere now !!!
hummm, this one seems to be nicer however
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
the second "Anonymous" guy with no name was me. sorry, problem with my name and html
|
|
|
|
|
|
toxcct wrote: cynferdd wrote:
"Anonymous" guy with no name
isn't it the same ?!
I meant "with no name written"
lol
|
|
|
|
|
what he wants do to is probably the same as i; getting members a la IntelliSense...
|
|
|
|
|
maybe you could ask the Visual Assist team...
i doubt you have some answers, but why not to try ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Calling EgWin::Calibrate works only if i do some stuff like Write nothing before i call another void in an unmanaged dll. Why does it not work if i take out this stupid Console::Write("") ??
<code>
class EgWin
{
public:
EgWin() {}
~EgWin() {}
int Init() { return EgInit(&stEgControl);}
void Calibrate(IntPtr hwnd){Console::Write(""); EgCalibrate(hwnd);}
};
public __gc class EgWinProxy
{
public:
EgWinProxy(){}
~EgWinProxy(){}
int _EgInit(){return mpC->Init();}
void _EgCalibrate(IntPtr hwnd){mpC->Calibrate(hwnd);}
private:
EgWin * mpC;
};
</code>
|
|
|
|
|
How is EgWin able to see methods on EgWinProxy at all ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The call gets from EgWinProxy to EgWin and from EgWin to an unmanaged dll wich is not visible in this sniplet. EgWin can not see EgWinProxy, but EgWinProxy keeps a pointer to EgWin.
Hope you have an idea...
|
|
|
|
|
Hi fellows
I've discovered the direct.h recently and I would like to know where I can find more infomation about this header file. Someone can pass this infos for me? Tutorials and links are very good ideas.
Thanks for help
|
|
|
|
|
I think you've found a DirectX header. The header is worthless without hte rest of the library. Google for DirectX.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
I found really unexpected behaviour of calls from C++ managed extensions, to native code. Following code shows what I wanted to do:
#pragma unmanaged
class UnmanagedClass
{
public:
virtual bool unmanagedFunction() const
{
return false;
}
};
#pragma managed
void managedFunction()
{
UnmanagedClass* object = new UnmanagedClass();
bool result = object->unmanagedFunction();
}
The question is- what would be the value of "result" after
virtual function call? Well.. believe me or not, but it's TRUE!
I debuged it in disassembly window, and inside native code-
the value of EAX (AL actually) register is correctly set to FALSE (xor al, al)
When the function does return, my debuger shows that EAX value has changed- into TRUE! There must be some kind of managed wrapper between Managed Extensions code and native code.
Has anybody any idea what is going on here?
And how to solve the problem?
|
|
|
|
|
I got the same result you got. Don't know why.
Anyway, normally I use the #pragma managed and unmanaged to control the function compilation only and for the class, I use either __nogc or __gc to tell it if I want the class managed or unmanaged.
I tried the modified code below and it works. hope this help.
__nogc class UnmanagedClass
{
public:
virtual bool unmanagedFunction() const
{
return false;
}
};
#pragma managed
void managedFunction()
{
UnmanagedClass* object = new UnmanagedClass();
bool result = object->unmanagedFunction();
}
|
|
|
|
|
I believe its been mentioned somewhere that there is a bug in the compiler, or perhaps the runtime, that gets confused with bool in regards to calling unmanaged code from managed code. I believe one work around is to use BOOL instead of bool. I think what happens is that the size is wrong between the two worlds, 8bit in unmanaged, but 32bit in managed, and the translation doen't account for it. I could be wrong, of course.
--
Joel Lucsy
|
|
|
|
|
Initially i allocated a buffer:
void *mem = new char[512];
now i want to use 100 bytes start from mem + 10,
so i wrote like this:
void *addr = static_cast<void*>
( static_cast <size_t> mem + 10 );
error occured! so please help me
my IDE is VS.NET 2003!
-- modified at 2:08 Tuesday 25th October, 2005
|
|
|
|
|
void* size is null, better cast it on char* :
void* addr = (void*) ((char*) &mem[10]);
If it doesn't compile, try to move the (char*) casting in another location, such :
void* addr = (void*) &((char*) mem[10]);
Kochise
In Code we trust !
|
|
|
|
|
firstly, provide the error message caugth instead of saying that an error occurs. it will help use more efficiently to understand what's happenning.
secondly, be careful when posting template codes (here, with static_cast<> ) because the < > are interpreted as html tag delimiters. use the & l t ; and the & g t ; codes, without spaces or check the Ignore HTML tags in this message (good for code snippets) check box at the bottom of where you type your post.
to finish, i'd suggest you this (as i don't know in what type you static_cast your pointer, i may be wrong) :
you cannot apply the + pointer addition operator on a void* operand because the operator + have to know of how many byte it will move to and void have by definition no size. what happens now if you firslty cast mem into char*, add 10 to it (to move it 10 bytes forward) and type cast it back to void* (like following) ??
void* mem = new char[512];
void* addr = static_cast<void*>(static_cast<char*>(mem)+10);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Is there a hash string function that preserves the capability to compare two strings just by comparing their respective hash values ?
Currently, I have to perform a full Str.Compare("other string") in order to sort them. I had also calculated their hash value, but the sorting (Quick Sort, Bubble Sort, whatever...) fails using the hash value. The hash value is mostly random, especially on long strings.
Comparing the hash values (int) would have been quite faster, I have to perform the quickest sort possible on text files larger than 100 MB ! So please don't come with CString as a solution. It works, but asks hours to do the job. CString is perfect to manipulate UI strings, but bad for heavy duty purposes...
So, to sum up, it there a good hash function that will allow :
"Minus string" < "Plus string"
HASH("Minus string") < HASH("Plus string")
Kochise
In Code we trust !
|
|
|
|