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 6695481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:13:37+00:00 2026-05-26T06:13:37+00:00

I have a camera class with two reference variables. I want to pass in

  • 0

I have a camera class with two reference variables. I want to pass in two references through the constructor and assign the reference variables to these, so that if I change these in this class, the other ones I defined before (and passed in) will change too. However, I get the error:

a reference of type "D3DXMATRIX &" (not const-qualified) cannot be initialized with a value of type "D3DMATRIX"

and

error C2440: 'initializing' : cannot convert from 'D3DMATRIX' to 'D3DXMATRIX &'

here is my code:

header:

#ifndef CAMERA_H
#define CAMERA_H

#include <d3d10.h>
#include <d3dx10.h>   
#include "globals.h"
#include "direct3D.h"

class Camera
{
private:
D3DXMATRIX &matProjection, &matView;
public:
Camera(
    float fOVDeg, float nearCull, float farCull,
    float xPos, float yPos, float zPos,
    D3DMATRIX &matProjection, D3DMATRIX &matView);
void SetCamera(float fOVDeg, float nearCull, float farCull);
void AdjustCamera(float x, float y, float z);
};

#endif

source:

#include "Camera.h"

Camera::Camera(
float fOVDeg, float nearCull, float farCull,
float xPos, float yPos, float zPos,
D3DMATRIX &matProjection, D3DMATRIX &matView) 
: matProjection(matProjection), matView(matView)
{
this->SetCamera(fOVDeg, nearCull, farCull);
this->AdjustCamera(xPos, yPos, zPos);
}

// Set the fixed properties of the 3D camera
void Camera::SetCamera(float fOVDeg, float nearCull, float farCull)
{
// create a projection matrix
D3DXMatrixPerspectiveFovLH(
    &matProjection,
    (float)D3DXToRadian(fOVDeg),    // the horizontal field of view
    (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT, // aspect ratio
    nearCull,    // the near view-plane
    farCull);    // the far view-plane
}

// Set the adjustable properties of the 3D camera
void Camera::AdjustCamera(float x, float y, float z)
{
D3DXMatrixLookAtLH(&matView,
                   &D3DXVECTOR3 (x, y, z),
                   &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),
                   &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));
}

Obviously I am misunderstanding something fundamental. Any help would be greatly appreciated!

The errors I get are on the initialiser list in the constructor.

here is where I am instantiating the camera:

Camera* camera;
D3DMATRIX matProjection, matView;

//called once
void Initialise(HWND hWnd)
{
initD3D(hWnd);
    init_pipeline();
cube = new Cube();

level = new Level(*cube);

camera = new Camera(
    45.0f, 1.0f, 10000.0f,
    0.0f, 9.0f, 100.0f,
    matProjection, matView);

test = 0.0f;
}
  • 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-05-26T06:13:37+00:00Added an answer on May 26, 2026 at 6:13 am

    It seems to me you are trying to initialize reference to Derived with a reference to Base, as in:

    class D3DMATRIX {};
    class D3DXMATRIX : public D3DMATRIX {};
    
    class Camera {
    private:
        D3DXMATRIX& m_;
    
    public:
        Camera(D3DMATRIX& m) : m_(m) {}
    };
    

    MSVC9.0 says:

    test.cpp(9) : error C2440: 'initializing' : cannot convert from 'D3DMATRIX' to 'D3DXMATRIX &'
    

    Maybe you should have Camera constructor taking D3DXMATRIX& as parameters?

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

Sidebar

Related Questions

I have a camera class that has two pointers as parameters: Camera::Camera( float fOVDeg,
I have a Camera class that produces very large images at a high FPS
I have an ImageManipulator class that performs some cropping, resizing and rotating of camera
I have made an openGL camera class that uses lazy evaluation to provide the
I have made an openGL camera class that uses lazy evaluation to provide the
I have Camera class, which handles camera behavior. Among it's fields is a reference
Suppose I have the following class: class Camera { public Camera( double exposure, double
I have a working wrapper class for Dallmeier camera devices, It contains a callback
I have a camera that returns raw images that can easily be converted to
I have an app that uses the iPhone camera and puts an overlay over

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.