|
Hi all,
I'm trying to find an alternative to GDI and GDI+ for simple 2D games since it doesn't look like GDI/GDI+ are made for that (having flicker issues with GDI+).
I plan on using bitmaps and animating them. I heard of SDL and Allegro. Anything else out there I'm missing? In your experience, which do you prefer?
My language of choice is C++.
|
|
|
|
|
Adassus wrote: Anything else out there I'm missing?
Whats wrong with DirectX[^]?
Best Wishes,
-David Delaune
|
|
|
|
|
Adassus wrote: having flicker issues with GDI+
Perhaps use two buffers one to show and one to draw and then swap them:
- with GDI use CMemDC[^]
- with OpenGL use SwapBuffers[^]
- for an alternative GUI framework see QT[^]
/M
|
|
|
|
|
I came across so many checksum calculation but I need to implement the checksum as below
I have packet coming in of 60Words , 2W and 256W and for all this I need to verify checksum with checksum present in the header of each packet... the algorithm that has been recommended as below.....
Mod 128 sum of all the 4-bit nibbles in the packet. Checksum field set to zero prior to calculating .... I dont understand thi can someone help me out
THANKS!!!!
|
|
|
|
|
Just study what the & | ~ << and >> operators ar for.
We don't do class assignmetns.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Extract 4 bits from each byte using bitwise operations.
Look at this Bitwise operation[^] link on how it can be done.
Divide this number by 128 and take its remainder.
You can use the % operator for this.
Add all the remainders together to get the checksum.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Dear all,
In Vista one can manually set a process virtualised using the taskmanager and right clicking the process, next setting it virtualised.
I need a little program starter (for ease of use lets call this startvirtualised.exe) which can be passed a location of a program (e.g. C:\Program Files\Example.exe).
The code I woul dlike to have should
a) Start the process "C:\Program Files\Example.exe
b) Set the TokenVirtualizationEnabled
c) Exits
Thanks in advance, I would pay for the time it would need to code this
|
|
|
|
|
Hi,
i'm working now to complete DSA algoritm but i can't...
help me to complete thes algorithm
i'm work in c++ and i came copy to header files like sha1.h /
cdefs.h /null.h /wchar.h
featuretest.h / cdefs_aout.h /cdefs_elf.h/ common.h/ ast_common.h/
int_type.h/ ansi.h
i put all this in INCLUDE file and SYS
but featuretest.h can't open
please tell me what i can do ??????? 
|
|
|
|
|
I am using vector to store the incoming data. Now my data is stored in Struct. I want to store only "bydata[]" from my structure into vector.... as the data keeps coming in.... I will just keep adding at the end of the vector "bydata[]" .....
How do I store this data using vector... or theres any other method tht I can use it.....
#define MAX_DATA_BYTES 60
typedef struct
{
unsigned char CheckFlags;
unsigned char Checksum;
unsigned short SequenceCounter;
} sHeader; //
typedef struct
{
sHeader Header;
unsigned char byData[MAX_DATA_BYTES];
} sData; //
Below code shown previously stores the entire structure... but I just want the "sData.byData[]" to be stored....
Please can someone help me.....
modified on Friday, July 24, 2009 3:01 PM
|
|
|
|
|
typedef vector<Whatever> WhateverV;
int Store(Whatever const& w, WhateverV vw)
{
vw.push_back(w);
}
|
|
|
|
|
Create a vector of unsigned chars - std::vector<unsigned char> vBytes;
To copy the received byte to the end of the vector do this - vBytes.insert(vBytes.end(), size);
If you want to implement some sort of queue where you also consume the data you should use the deque class instead of vector .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Which is more appropriate to use in MFC document / view architecture to display (view) the document - CTabCtrl or CCtrlView?
I am looking at the CTabCtrl as a control “overlay” of views. Is that correct? For lack of other words – the document communicates with tab class first and the tab class than communicates with tabs / plain views.
Or would using CCtrlView be simpler?
Any constructive comments as always are appreciated.
Cheers Vaclav
PS I forgot to mention "minor" detail - currently I am using CCtrlView with CTabCtrl variable with some isssues.I need to investigate if CTabCtrl can be used directly as a view anyway.
modified on Friday, July 24, 2009 12:07 PM
|
|
|
|
|
Hi all,
Am i right in thinking that foo() is a very SAFE and SLOW way of passing stuff around, whereas bar() which is LESS SAFE but FASTER.
MyClass foo()
{
MyClass x;
// do something with x
return MyClass(x);
}
MyClass* bar()
{
MyClass * x = new MyClass();
// do something with *x
return x;
}
If i call foo() with something like MyClass c = foo(), there will be:-
1 instantiation, 2 copies, and 1 destruction + overhead of "do something with x"
If i call bar() with something like MyClass *b = bar(); delete b, there will be:-
1 construction, 1 destruction + overhead of "do something with x"
So, for internal codey type functions which are protected from the user, it would be quite acceptable to use a bar() type mechanism in order to gain more speed.
However, for functions designed to be used by an external user in a safe way, we should stick to foo().
Paul
|
|
|
|
|
I believe that both will have the same amount of time. You have no reason to, at the end of foo(), 'return MyClass(x);', because this will cast a MyClass object to MyClass (redundant), which in effect calls the copy constructor for MyClass. Basically, whether you use the stack or the heap, this function would have done the same exact thing if you did not call that copy constructor. And, as long as you delete the object in bar(), it is totally safe, in my opinion. If my thoughts seem incorrect, I'd love to hear about it... I could be wrong of course.
|
|
|
|
|
No, you are correct !
After playing around with the code and debugging I found what you said to be true. I am learning on the job, so sorry for the confusion in my original code.
Thanks for your help,
Paul
|
|
|
|
|
Hi,
I have an array of variants, but I'm unsure how to access the individual elements withing this array:
_RecordsetPtr ptrRS;
ptrRS = wr->GetData();
_variant_t vtRows = ptrRS->GetRows(adGetRowsRest);
int vt = vtRows.vt;
str3.Format("vt %d", vt);
MessageBox(str3);
_variant_t vRow;
vRow = vtRows[0];
Could someone please assist me with a code snippet on how to do this.
Thanks
Phil
|
|
|
|
|
Hi all, hope you could maybe give me some advice on the following...
Is the following code legal?
MyClass foo()
{
MyClass * p = new MyClass();
// do something to *p here
return *p;
}
void test()
{
foo();
}
void main()
{
test();
}
The above code compiles and works fine. The intention is to create a MyClass instance in foo, and return it without onvoking the constructor on exit. I then want this instance to be available in test. On exit of test i want this instance to be automatically deleted.
It seems to work fine, but when I use the same mechanism in large programs, including classes etc., I am running into some difficulties when the "return *p" executes.
Thanks,
Paul

|
|
|
|
|
In your
void test()
{
foo();
}
You did not handle "p". This is a memory leak. You should delete p;
void test()
{
Myclass* p = foo();
do something with "p" then
delete p;
}
|
|
|
|
|
Thanks for the reply.
I've debugged the presented code step by step and witnessed that the compiler deletes p itself on exit from test() !
However, the presented code is not OOP. When the same mechanism is used in an OOP set-up SOMETIMES I get errors. Perhaps I'm missing something.
--------------------------------------------------------------
Anyway, is there a way to achieve what I want without having to delete p by hand?... I basically want to instantiate an object in foo and then return it to the calling function. I would then like the calling function to auto-delete that instance on exit.
Paul
|
|
|
|
|
paolosh wrote: I've debugged the presented code step by step and witnessed that the compiler deletes p itself on exit from test() !
It does not.
What happens is this:
new MyClass creates a new MyClass instance on the heap
return *p returns a COPY of that object
That copy is a temporary variable, and will be destroyed. However, the instance allocated on the heap will not be destroyed.
You may want to lear a bit more about C++ pointers, copy constructors and temporary values (it is not an easy topic).
When you understand these things, I would suggest my article about smart pointers[^] as an introduction to a common solution to your original question - "returning large objects from a function".
|
|
|
|
|
So what of the overloaded functions?
in standard C++ you can do something like this...
double x, y, z;
z = x + y;
does x.operator +(y) return a temporary double? which is then destroyed after it's contents is assigned to z??
|
|
|
|
|
Yes, exactly.
With a "double", there is no constructor or destructor, so there is not much to see.
But you can try these things with a class like this you can play around and see the effects:
class MyTest
{
public:
MyTest() { cout << "Creating MyTest " << this << endl; }
MyTest(MyTest const & rhs) { cout << "Copy-Construct MyTest " << this << " from " << &rhs << endl; }
MyTest& operator=(MyTest const & rhs) { cout << "Assign MyTest " << this << " from " << &rhs << endl; }
~MyTest() { cout << "Destroying " << this; }
}
Be aware that the effects are not exactly the same on every compiler, since the standard allows some optimizations.
|
|
|
|
|
I have a question for you.
I checked following:
p1 = new myclass();
p2 = foo()
p1 is exactly same as p2.
If foo() return a COPY of a POINTER, why the address of the COPY will be same as the original one?
Thanks
|
|
|
|
|
paolosh's original code is more akin to this:
MyClass * p1 = new MyClass;
MyClass temp = *p1;
|
|
|
|
|
When returning a "POINTER", it return POINTER itself or just a copy of the POINTER?
I debug the code. I found out the address of the "return" one is exactly same as the original one (new Myclass()).
Thanks,
|
|
|
|