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

  • SEARCH
  • Home
  • 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 7715277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:20:41+00:00 2026-06-01T02:20:41+00:00

Below is the code I am using and the error happens when I attempt

  • 0

Below is the code I am using and the error happens when I attempt to check for the available tenique within the FX file. I’m not sure if the FX file is bad or what. I am using the default simple.fx that comes with DirectX.

// Include the basic Windows header files and the Direct3D header file
#include <windows.h>
#include <windowsx.h>
#include <d3d9.h>
#include <d3dx9.h>

// Define the screen resolution and keyboard macros
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

// Include the Direct3D library files
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

// Global declarations
LPDIRECT3D9 d3d;    // The pointer to our Direct3D interface
LPDIRECT3DDEVICE9 d3ddev;    // The pointer to the device class

// Mesh declarations
LPD3DXMESH meshTeapot;    // Define the mesh pointer

// effect declarations
LPD3DXEFFECT effect;    // Define the effect pointer
D3DXHANDLE technique;    // Define the handle for the best technique

// Function prototypes
void initD3D(HWND hWnd);    // Sets up and initializes Direct3D
void render_frame(void);    // Renders a single frame
void cleanD3D(void);    // Closes Direct3D and releases memory
void init_graphics(void);    // 3D declarations

// The WindowProc function prototype
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

// The entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
               HINSTANCE hPrevInstance,
               LPSTR lpCmdLine,
               int nCmdShow)
{
    HWND hWnd;
    WNDCLASSEX wc;

    ZeroMemory(&wc, sizeof(WNDCLASSEX));

    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = (WNDPROC)WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.lpszClassName = L"WindowClass";

    RegisterClassEx(&wc);

    hWnd = CreateWindowEx(NULL, L"WindowClass", L"Our Direct3D Program",
                          WS_EX_TOPMOST | WS_POPUP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
                          NULL, NULL, hInstance, NULL);

    ShowWindow(hWnd, nCmdShow);

    // Set up and initialize Direct3D
    initD3D(hWnd);

    // Enter the main loop:

    MSG msg;

    while(TRUE)
    {
        DWORD starting_point = GetTickCount();

        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
                break;

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        render_frame();

        // Check the 'escape' key
        if(KEY_DOWN(VK_ESCAPE))
            PostMessage(hWnd, WM_DESTROY, 0, 0);

        while ((GetTickCount() - starting_point) < 25);
    }

    // Clean up DirectX and COM
    cleanD3D();

    return msg.wParam;
}


// This is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_DESTROY:
        {
            PostQuitMessage(0);
            return 0;
        }
        break;
    }

    return DefWindowProc (hWnd, message, wParam, lParam);
}


// This function initializes and prepares Direct3D for use
void initD3D(HWND hWnd)
{
    d3d = Direct3DCreate9(D3D_SDK_VERSION);

    D3DPRESENT_PARAMETERS d3dpp;

    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.hDeviceWindow = hWnd;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferWidth = SCREEN_WIDTH;
    d3dpp.BackBufferHeight = SCREEN_HEIGHT;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

    // Create a device class using this information and the information from the d3dpp stuct
    d3d->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      hWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);

    init_graphics(); // Call the function to initialize the triangle

    LPD3DXBUFFER errorlog; // For storing errors

    // Load the effect file
    D3DXCreateEffectFromFile(d3ddev, L"simple.fx", 0, 0, 0, 0, &effect, &errorlog);

    // Find the best technique
    effect->FindNextValidTechnique(NULL, &technique);

    return;
}

// This is the function used to render a single frame
void render_frame(void)
{
    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
    d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

    d3ddev->BeginScene();

    // Set the view transform
    D3DXMATRIX matView;    // The view transform matrix
    D3DXMatrixLookAtLH(&matView,
    &D3DXVECTOR3 (0.0f, 3.0f, 6.0f),    // The camera position
    &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),    // The look-at position
    &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));    // The up direction
    effect->SetMatrix("View", &matView);

    // Set the projection transform
    D3DXMATRIX matProjection;    // The projection transform matrix
    D3DXMatrixPerspectiveFovLH(&matProjection,
                               D3DXToRadian(45),    // The horizontal field of view
                               (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT, // Aspect ratio
                               1.0f,    // The near view-plane
                               100.0f);    // The far view-plane
    effect->SetMatrix("Projection", &matProjection);

    // Set the world transform
    static float index = 0.0f; // An ever-increasing float value
    index+=0.03f;
    D3DXMATRIX matRotateY;    // A matrix to store the rotation for each triangle
    D3DXMatrixRotationY(&matRotateY, index); // The rotation matrix
    effect->SetMatrix("World", &matRotateY);

    effect->Begin(NULL, NULL);    // Begin using the effect
    effect->BeginPass(0);    // Begin the pass

    // Render whatever
    meshTeapot->DrawSubset(0);

    effect->EndPass(); // End the pass
    effect->End();    // End the effect

    d3ddev->EndScene();

    d3ddev->Present(NULL, NULL, NULL, NULL);

    return;
}

// This is the function that cleans up Direct3D and COM
void cleanD3D(void)
{
    meshTeapot->Release();    // Close and release the teapot mesh
    effect->Release();    // Close and release the effect
    d3ddev->Release();    // Close and release the 3D device
    d3d->Release();    // Close and release Direct3D

    return;
}

// This is the function that puts the 3D models into video RAM
void init_graphics(void)
{
    D3DXCreateTeapot(d3ddev, &meshTeapot, NULL);    // Create the teapot

    return;
}
  • 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-01T02:20:42+00:00Added an answer on June 1, 2026 at 2:20 am

    I presume you have copied the code from www.directxtutorial.com. I had the same problem.
    You should keep track of the errors the Effect compiler throws at you. Convert the errorlog variable to a string in order to read the errors properly:

    char * Error = (char *)errorlog->GetBufferPointer();
    

    The first error you get is:

    error X3539: ps_1_x is no longer supported; use /Gec in fxc to automatically upgrade to ps_2_0

    It seems that ps_1_x is not supported. So if you open the simple.fx file, you should find something like this:

    PixelShader = compile ps_1_1 PS();
    

    Change ps_1_1 to ps_2_0 and everything should run like a charm.

    I forgot to mention that you should only try to get a buffer pointer from the errorlog if it’s not NULL, so:

    if(errorlog)
    {
        char * Error = (char *)errorlog->GetBufferPointer();
        // And do the output somewhere 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I execute the code saveXML below it generates the error above, why?? using
Below is some of my error logging code. When an exception happens inside my
VS C# 2005 I am using the code below to upload a file Async
I first got an error usign the code below, explaining that DataGridLinkButton' must be
i am using below code to change the the font type of text view.
I am using below code to create a reminder in Google calendar (using Google
I am using below code for Embed MP3 Audio Files In Web Pages, <embed
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
I have the code below: using (SqlCommand command = new SqlCommand()) { command.CommandType =
As I created a Progress bar using below code in a on click method

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.