473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

class types as proxies to an array

I'm in a situation where I want to be sure all my data is organized in a
specific pattern in memory. The array is vertex data which I want to
represent as individual vectors per vertex, and per vertex type. That is,
the array has data such as position, color, normal vectors, etc. I wrote
what I consider to be a pretty nice vector class template and a
corresponding matrix template. The vector I have stores its data locally,
rather than through a reference or pointer.

I want virtuall the same behavior as the current vector gives me, with the
exception that the data should be a reference into the vertex array. If I
derive from vector to create a vectorRef class, I'm pretty sure I'll need
to make most of the functions in the vector virtual. My understanding is
doing so will mean that they will not be inlined because the actual call is
determined after compilation.

Is there a standard strategy for dealing with this kind of situation?
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #1
4 1246
Steven T. Hatton wrote:
I'm in a situation where I want to be sure all my data is organized in a
specific pattern in memory. The array is vertex data which I want to
represent as individual vectors per vertex, and per vertex type. That is,
the array has data such as position, color, normal vectors, etc. I wrote
what I consider to be a pretty nice vector class template and a
corresponding matrix template. The vector I have stores its data locally,
rather than through a reference or pointer.

I want virtuall the same behavior as the current vector gives me, with the
exception that the data should be a reference into the vertex array. If I
derive from vector to create a vectorRef class, I'm pretty sure I'll need
to make most of the functions in the vector virtual. My understanding is
doing so will mean that they will not be inlined because the actual call is
determined after compilation.

Is there a standard strategy for dealing with this kind of situation?


Templates. Possibly, policies. A vector template will have policies
for storing its values and accessing these values as template template
arguments. Take a look at "Modern C++ Design".

V
Jul 22 '05 #2
Victor Bazarov wrote:
Templates. Possibly, policies. A vector template will have policies
for storing its values and accessing these values as template template
arguments. Take a look at "Modern C++ Design".


That does sound like a (good) solution. It also sounds a bit beyond what I'm
ready to take on just yet. I'm going to try the living dangerously
approach and simply put all my data for a vertex in a concrete class and
shove it all into a boost::array<> then throw it at OpenGL with something
like glInterleavedArrays. My expectation (guess) is the data will be
arranged correctly.

It really is a shame there isn't a better C++ OO interface to OpenGL. I
wish I had the resources to dedicate to developing such an interface. As
it stands it's like buying a new house and having the seller go to the lot
with a dumptruck and dumping all the building materials and giving you the
keys.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #3
Steven T. Hatton wrote:
[...]
It really is a shame there isn't a better C++ OO interface to OpenGL.
<offtopic>
Better than what? We here are using Cosmo3d and Optimizer (these are
old, but manageable), and there is the Performer. Another group here
use Hoops3d (and I've seen many references to it). How much better do
you really need?

Take a good look at those libraries. There are others, too. Post to
comp.graphics.api.opengl and see what they suggest.
</offtopic>
[...]


V
Jul 22 '05 #4
Victor Bazarov wrote:
Steven T. Hatton wrote:
[...]
It really is a shame there isn't a better C++ OO interface to OpenGL.


<offtopic>
Better than what? We here are using Cosmo3d and Optimizer (these are
old, but manageable), and there is the Performer. Another group here
use Hoops3d (and I've seen many references to it). How much better do
you really need?

Take a good look at those libraries. There are others, too. Post to
comp.graphics.api.opengl and see what they suggest.
</offtopic>
> [...]


V


There are many different abstractions built over OpenGL which support C++
programming. I've come to favor OpenSceneGraph since it does seem to be
consistent with the spirit of C++. What I had intended by my comment
lamenting the lack of a C++ interface to OpenGL is that there seems to be a
possible level of abstraction that would be much closer to design of OpenGL
than what I've seen so far. I'll have to take a closer look at Performer
before I can really say it doesn't provide what I'm looking for.

The biggest problem with Performer I've had so far is that the documentation
and demos focus on features I don't currently have an interest in. I'll
have to plow through a lot of material to get to the features I'm looking
for.

I actually started writing my own SceneGraph API because I find the others
unintuitive, but I can to the conclusion that the undertaking is huge, and
probably not overly productive.

--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Johan Bergman | last post by:
Hi, Maybe someone can help me with this one. The following describes a somewhat simplified version of my problem, but I think it will be sufficient. I want to use class factories (virtual...
41
by: AngleWyrm | last post by:
I have created a new container class, called the hat. It provides random selection of user objects, both with and without replacement, with non-uniform probabilities. Uniform probabilities are a...
2
by: Fred Zwarts | last post by:
If I am right, members of a class that are const and not static must be initialized in the initialization part of a constructor. E.g. class C { private: const int I; public: C(); };
8
by: Joe | last post by:
I have a web service which returns many types (classes) to match the return type. I want to cast the return type to the actual class type. For example: namespace Test { class MyClass { ...
9
by: Ed Gonen | last post by:
Hi, I have the following problem. I've created 2 WebServices (A and B) that reference to the same assembly - Credentials. Each WebService (A and B) expose method GetCredentials that returns the...
4
by: Henrik Gøttig | last post by:
Hi all Feeling a bit frustrated here. Maybe I did not find the correct info yet, that's why I am asking you. I have "developed" a .NET 2.0 WebService and generated (using wsdl.exe) the WSDL...
7
by: WXS | last post by:
Vote for this idea if you like it here: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=5fee280d-085e-4fe2-af35-254fbbe96ee9...
0
by: Andrew Brook | last post by:
Hi everyone, I've been going through an article i found on MSDN (http://msdn.microsoft.com/msdnmag/issues/02/12/WebServicesDesign/) concerning designing the messages for a webservice in a schema...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.