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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:57:04+00:00 2026-05-27T19:57:04+00:00

this is my first post to stack overflow! I’m using SlimDX for a game

  • 0

this is my first post to stack overflow!
I’m using SlimDX for a game that my team is making and I’ve run into an issue. I’m trying to create a ShaderResourceView from RGBA values in a Color4 object. I’ve searched looked for answers to my issue and this is as far as I have gotten.

    private ShaderResourceView GetTexture(Device device, int width, int height, Color4 color)
    {
        //create the texture
        Texture2D texture = null;
        Texture2DDescription desc2 = new Texture2DDescription();
        desc2.SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0); 
        desc2.Width = width;
        desc2.Height = height;
        desc2.MipLevels = 1;
        desc2.ArraySize = 1;
        desc2.Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
        desc2.Usage = ResourceUsage.Dynamic;
        desc2.BindFlags = BindFlags.ShaderResource;
        desc2.CpuAccessFlags = CpuAccessFlags.Write;
        texture = new Texture2D(device, desc2);


        // fill the texture with rgba values
        DataRectangle rect = texture.Map(0, MapMode.WriteDiscard, MapFlags.None);
        if (rect.Data.CanWrite)
        {
            for (int row = 0; row < texture.Description.Height; row++)
            {
                int rowStart = row * rect.Pitch;
                rect.Data.Seek(rowStart, System.IO.SeekOrigin.Begin);
                for (int col = 0; col < texture.Description.Width; col++)
                {
                    rect.Data.WriteByte((byte)color.Red);
                    rect.Data.WriteByte((byte)color.Green);
                    rect.Data.WriteByte((byte)color.Blue);
                    rect.Data.WriteByte((byte)color.Alpha);
                }
            }
        }
        texture.Unmap(0);

        // create shader resource that is what the renderer needs
        ShaderResourceViewDescription desc = new ShaderResourceViewDescription();
        desc.Format = texture.Description.Format;
        desc.Dimension = ShaderResourceViewDimension.Texture2D;
        desc.MostDetailedMip = 0;
        desc.MipLevels = 1;
        ShaderResourceView srv = new ShaderResourceView(device, texture, desc);

        return srv;
    }

I believe that the texture’s data is being set but I can’t be sure because nothing is being displayed. I know that my renderer works as I can load texture from a file perfectly fine but I seem to have a problem that I cannot find. Thanks for your help in advance!

  • 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-27T19:57:04+00:00Added an answer on May 27, 2026 at 7:57 pm

    I’ve had the code right all along. I feel like an idiot but I found out my problem, I wasn’t setting the alpha value for the texture so it was actually being drawn I just couldn’t see it >_<; Simple mistakes always eh? Thanks to all that viewed however.

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

Sidebar

Related Questions

This is my first post on Stack Overflow and I'm just wondering on the
This is my first post on Stack Overflow. I am trying to build a
This is my first post to Stack Overflow so please forgive me if I
Hello everyone this is my first post on stack overflow.com I am trying to
Heyo. This is my first stack overflow post because I am stumped and not
this is my first post on stack overflow! I'm new to Java and I've
This is my first post to stack overflow,... :) I like this site a
This is my first post to stack overflow. I've been lurking this site for
This is my very first post on Stack Overflow, so I hope I don't
Ahoy Stack Overflow! This be mai first post... I'm attempting to identify users with

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.