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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:01:41+00:00 2026-05-21T15:01:41+00:00

I have loaded textures into openGL before, worked fine. But this time I wanted

  • 0

I have loaded textures into openGL before, worked fine. But this time I wanted to load a texture within a constructor of my rendering class. (im using MVC with abstract base classes as interfaces). I was originally trying to load a png file rather than a bmp as I did before so i assumed it was something to do with that, but when i went back to my bmp code it still didn’t work. So a hunch I moved the bmp texture code into the main(of the same MVC project) and it works. The actual part that wasnt working was:

GLuint textureId;
    glGenTextures(1, &textureId); 
    glBindTexture(GL_TEXTURE_2D, textureId);
    //Map the image to the texture
    glTexImage2D(GL_TEXTURE_2D,//This bit!!               
                 0,                           
                 GL_RGB,                      
                 image->width, image->height,  
                 0,                            
                 GL_RGB, 
                 GL_UNSIGNED_BYTE,                                 
                 image->pixels);

if I stepped through the program I noticed that textureID stayed the same (didnt change to 1 becuase no texture was being mapped to it)

Why is this? and can it be fixed?

  • 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-21T15:01:42+00:00Added an answer on May 21, 2026 at 3:01 pm

    When is the constructor being called? You need a valid OpenGL context to make any GL call. A usual error is to create objects at the global scope, and that means the object is constructed at program start, before main() is called, and at that point there is no OpenGL context created yet.

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

Sidebar

Related Questions

I have a texture loaded into memory that is of RGBA format with various
I have a DXT1 texture loaded in a ByteBuffer and I'm trying to load
I'm having issues trying to get a texture loaded into VRAM. I'm using OpenGL
I have a sprite loaded as a texture and I need to animate it,
I have loaded image into a new, initialized Oracle ORDImage object and am processing
I have 2 sections within a table view and I have loaded one section
I have tried to get my head around the content processor and textures, but
Hey, I have a texture loaded with glTextImage2D. I want to get the texture's
I have loaded HTML into pyqt and would like to create a list of
I have loaded a PDF into UIWebView. Now i want to search for strings

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.