Hi all,
I have a problem initializing an array of custom structures.
It all occurs trying to visualize solids in XNA (ie new version of
managed directx) but I think the problem resides in something I do
wrong in c#. I really hope not to be off topic, furthermore I'm not a
frequent reader of this newsgroup.
Let's get to the point.
Everything works if I initialize the array in the form:
_Rendervertices = new VertexPositionColoredNormal[ { value1, value2,
value3 };
whereas if I initialize it like this:
_Rendervertices = new VertexPositionColoredNormal[3];
_Rendervertices[0] = value1;
_Rendervertices[1] = value2;
_Rendervertices[2] = value2;
I have problems when using the array to fill a vertexbuffer
I believe vertexbuffers read the memory offsets of specified
information and in fact the structure is defined with an attribute
[StructLayout(LayoutKind.Sequential)] should the array be defined with
some similar attribute as well?
I'm really lost with this. I thought the two methods would result in
the same memory allocation.
Many thanks for any hint you could provide.
Claudio 3 1139
On Jun 3, 4:07 pm, Bonghi <claudio.ben...@gmail.comwrote:
I have a problem initializing an array of custom structures.
It all occurs trying to visualize solids in XNA (ie new version of
managed directx) but I think the problem resides in something I do
wrong in c#. I really hope not to be off topic, furthermore I'm not a
frequent reader of this newsgroup.
No problem - sounds like you've got the right group.
Let's get to the point.
Everything works if I initialize the array in the form:
_Rendervertices = new VertexPositionColoredNormal[ { value1, value2,
value3 };
whereas if I initialize it like this:
_Rendervertices = new VertexPositionColoredNormal[3];
_Rendervertices[0] = value1;
_Rendervertices[1] = value2;
_Rendervertices[2] = value2;
Note that you've got value2 twice there - is that in the original
code?
Otherwise, the two snippets should be the same.
I have problems when using the array to fill a vertexbuffer
What kind of problems? Can you post a short but complete program which
demonstrates the problem? See http://pobox.com/~skeet/csharp/complete.html for what I mean by that.
Jon
On Jun 3, 5:05 pm, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:
On Jun 3, 4:07 pm, Bonghi <claudio.ben...@gmail.comwrote:
I have a problem initializing an array of custom structures.
It all occurs trying to visualize solids in XNA (ie new version of
managed directx) but I think the problem resides in something I do
wrong in c#. I really hope not to be off topic, furthermore I'm not a
frequent reader of this newsgroup.
No problem - sounds like you've got the right group.
Let's get to the point.
Everything works if I initialize the array in the form:
_Rendervertices = new VertexPositionColoredNormal[ { value1, value2,
value3 };
whereas if I initialize it like this:
_Rendervertices = new VertexPositionColoredNormal[3];
_Rendervertices[0] = value1;
_Rendervertices[1] = value2;
_Rendervertices[2] = value2;
Note that you've got value2 twice there - is that in the original
code?
Otherwise, the two snippets should be the same.
I have problems when using the array to fill a vertexbuffer
What kind of problems? Can you post a short but complete program which
demonstrates the problem? Seehttp://pobox.com/~skeet/csharp/complete.htmlfor what I mean by that.
Jon
Jon, thanks a lot for replying...
The problem lied somewhere else... I've found the error in a
completely different piece of code and in fact
the two methods I mentioned are perfectly equivalent.
The double value2 was just a typo on this post but the code was
different but too complex for a post so I
modified it to help people have a better understanding... of what
turned out to be a false problem.
:)
Many thanks again and apologies for wasting your time.
Claudio
On Jun 3, 6:11 pm, Bonghi <claudio.ben...@gmail.comwrote:
Jon, thanks a lot for replying...
The problem lied somewhere else... I've found the error in a
completely different piece of code and in fact
the two methods I mentioned are perfectly equivalent.
Excellent. It would have been very strange otherwise.
<snip>
Many thanks again and apologies for wasting your time.
No problem at all - just glad it was all sorted out :)
Jon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JesusFreak |
last post by:
From: us_traveller@yahoo.com (JesusFreak)
Newsgroups: microsoft.public.scripting.jscript
Subject: toolbar script problem
NNTP-Posting-Host: 192.92.126.136
Recently, I downloaded the following...
|
by: Tony Johansson |
last post by:
Hello Experts!!
I have two small classes called Intvektor and Matris shown below and a main.
Class Intvektor will create a one dimension array of integer by allocate
memory dynamically as you...
|
by: Brady |
last post by:
Hi,
I'm having a problem reading and writing to a file. What I'm trying
to do is read a file, modify the portion of the file that I just read,
and then write the modified data back to the same...
|
by: mytfein |
last post by:
Hi Everyone,
Background:
Another department intends to ftp a .txt file from the mainframe, for me
to process.
The objective is to write a vb script that would be scheduled to run
daily to...
|
by: intrepid_dw |
last post by:
Hello, all.
I've created a C# dll that contains, among other things, two functions
dealing with byte arrays. The first is a function that returns a byte
array, and the other is intended to...
|
by: daroman |
last post by:
Hi Guys,
i've problem with my small C++ programm. I've just small template
class which represetns a array, everything works fine up to
combination with std::string. I did tried it with M$ VC++ and...
|
by: weidongtom |
last post by:
Hi,
I tried to implement the Universal Machine as described in
http://www.boundvariable.org/task.shtml, and I managed to get one
implemented (After looking at what other's have done.) But when I...
|
by: weidongtom |
last post by:
Hi,
I've written the code that follows, and I use the function add_word(),
it seems to work fine
*before* increase_arrays() is called that uses realloc() to allocate
more memory to words. But...
|
by: biplab |
last post by:
Hi all,
I am using TC 3.0..there if I declare a integer array with dimension
162*219...an error msg saying that too long array is shown....what
should I do to recover from this problem???
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |