Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9159465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:29:57+00:00 2026-06-17T13:29:57+00:00

I am trying to pass a pointer to an array of Vertex Data, (base

  • 0

I am trying to pass a pointer to an array of Vertex Data, (base class member) into a method used to initialize the Direct3D Vertex Buffer, (ID3D11Buffer).

I want to use the variable, “v4”, the pointer to the array, but I think I am not dereferencing the pointer correctly. Could someone point me in the right direction?

I have tried many ways to make this assignment, but I can only get a basic array work, (sometimes I end up with casting to “const void *” errors).

How would I use a pointer?

The line I am having issue with is …
vertexSubResourceData.pSysMem = v1;

(p.s. Using the V.S. C++ Nov 2012 CTP compiler .. not released yet ..)

*Answered: Have confirmed that it is a Visual Studio 2012 C++ Nov. CTP Compiler Bug. Arrays of Vector structures declared, even outside of the class, using C++ 11 initialization syntax are being interpreted incorrectly, (unless of course I am using the incorrect array initialization syntax). Also Note: This only pertains to initialization lists associated with pointers. *

Thanks!

// Simplified Code

void Triangle::InitializeVertexBuffer()
{
    struct V
    {
        float X, Y, Z;    // vertex position
    };

    // Compiles But doesn't work as desired.
    // changed from V* v4 = new V[] // Compiled without range.
    // Pointer to this data would ideally come from base static pointer, or file.
    V* v4 = new V[3]     
    {
        { 0.50f, 0.5f, 0.0f },
        { 0.50f, -0.5f, 0.0f },
        { -0.50f, -0.5f, 0.0f },
    };

    // Compiles and Works to prove compiler issue with initialization lists. 
    V* vectorList = new V[3];
    vectorList[0].X = 0.5f;
    vectorList[0].Y = 0.5f;
    vectorList[0].Z = 0.00f;

    vectorList[1].X = 0.5f;
    vectorList[1].Y = -0.5f;
    vectorList[1].Z = 0.00f;

    vectorList[2].X = -0.5f;
    vectorList[2].Y = -0.5f;
    vectorList[2].Z = 0.00f;


    unsigned int size = sizeof(V) * 3; //sizeof(* Model::Vertices);

    // The Description of the Vertex Buffer
    D3D11_BUFFER_DESC vertexBufferDescription = {0};
    vertexBufferDescription.ByteWidth = size;
    vertexBufferDescription.BindFlags = D3D11_BIND_VERTEX_BUFFER; 

    // Model Data to be transferred to GPU Buffer.

    D3D11_SUBRESOURCE_DATA vertexSubResourceData = {0};
    vertexSubResourceData.SysMemPitch = 0;
    vertexSubResourceData.SysMemSlicePitch = 0;

    // Can't figure out how to dereference v4

    vertexSubResourceData.pSysMem = vectorList; // works, but using "v4" doesn't.

    // vertexSubResourceData.pSysMem = Model::Vertices; 
    // This is what I /really/ want .. Pointer to vertice array data from base class


    NS::DeviceManager::Device->CreateBuffer(
        &vertexBufferDescription, 
        &vertexSubResourceData, 
        &NS::ModelRenderer::VertexBuffer);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:29:58+00:00Added an answer on June 17, 2026 at 1:29 pm

    When you write V* v4 = new V[]{...}; it is illegal C++. The CTP compiler is accepting malformed code. Try V* v4 = new V[3]{...};

    Checking the C++ standard, from 5.3.4p1:

    [ expression ] attribute-specifier-seqopt

    So, it looks like an expression is required in the []. I believe new V[] is an extension for compilers (still checking into this).

    And as ildjarn points out, you want vertexSubResourceData.pSysMem = v4; as &4 would you give you the address of the pointer, not the array.

    Update

    I think this is a bug in the compiler. Try the old C++03 syntax: V* v4 = new V[3]; v4[0] = ...; and if that works, then it definitely is a bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass a structure array pointer and a pointer to a
I am trying to pass a character pointer array as an input from C
I'm trying to pass pointer to pointer to a method, but apparently ARC has
I am trying to pass a function pointer using boost::bind. void Class::ThreadFunction(Type(*callbackFunc)(message_type::ptr&)) { }
I'm trying to pass a pointer to an array of struct. This code should
I am newbie to programming and I am trying to pass an array into
I am trying pass class as value in hashmap. I need to get the
Trying to pass a string argument to a function, which will then be used
When trying to pass a CGPoint to a method the point is passed, but
Okay so I am trying to pass a char pointer to another function. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.