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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:00:03+00:00 2026-05-25T14:00:03+00:00

I want to load a new texture during runtime, replacing an existing loaded texture.

  • 0

I want to load a new texture during runtime, replacing an existing loaded texture. I have looked at a similar question ( Loading new texture into already defined texture name ) but no solution seemed to be found.

I am trying to load a new 3D texture, replacing an existing 3D texture used to draw a volume in a Cg shader. However, when the new volume (or 3d texture) is loaded, the old volume is still been drawn. I create the texture by doing the following:

glGenTextures(1, &volume_texture);
glBindTexture(GL_TEXTURE_3D, volume_texture);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);

glTexImage3D(GL_TEXTURE_3D, 0, GL_INTENSITY, WIDTH, HEIGHT, DEPTH, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, volumeData);

When I load a new texture, I do the following (where volumeData contains the new volume texture information):

glBindTexture(GL_TEXTURE_3D, volume_texture);

glTexImage3D(GL_TEXTURE_3D, 0, GL_INTENSITY, WIDTH, HEIGHT, DEPTH, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, volumeData);

I have tried glDeleteTextures to delete the existing texture before loading the new one, but it didn’t make any difference.

The data for the texture is loaded in correctly, as after the texture is created, the same data is used to build an octree, which is built correctly as it represents the loaded volume.

For rendering, I pass the 3D texture to a Cg shader. This is done using the following call, every time the scene is drawn

SetTextureParam("volumeTex", volumeTexture, fragment_main, param3);

void SetTextureParam(char* par, GLuint tex,const CGprogram &program,CGparameter param) 
{
    param = cgGetNamedParameter(program, par); 
    cgGLSetTextureParameter(param, tex); 
    cgGLEnableTextureParameter(param);
}
  • 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-25T14:00:05+00:00Added an answer on May 25, 2026 at 2:00 pm

    Try using

    glBindTexture(GL_TEXTURE_3D, &volume_texture);
    glTexSubImage3d(GL_TEXTURE_3D, 0, 0, 0, 0, WIDTH, HEIGHT, DEPTH, GL_LUMANANCE, GL_UNSIGNED_BYTE, newVolumeData)
    

    newVolumeData is a pointer to the new volume data.

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

Sidebar

Related Questions

Browser : IE6/IE7. I want to load a new document into my html modal
I want to load the data into session so that when the next button
I want to load some images into my application from the file system. There's
I want to load some data from mysql into my cocoa application view before
I want to load defined folders into my website from same system, now I
i want to load some photos into my sd card image in the emulator.
I want to load an swf into a flex 4 application in order to
Possible Duplicate: jquery/ajax load new content when available i have a table named news
I'm relatively new to DirectX and have to work on an existing C++ DX9
Let's say I use jQuery to load new content into a specific DIV element.

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.