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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:21:56+00:00 2026-05-26T02:21:56+00:00

This is a 1024 x 512 jpg. The size variable returns 84793. One thing

  • 0

This is a 1024 x 512 jpg.
The size variable returns 84793.
One thing that I don’t understand is the 84793 as the size of the file when 1024 * 512 = 524288.
I would think this would be * 3 since 3 channels per pixel.
The count variable is returning 65.
Right now I’m getting a access violation reading location on this line when I’m setting OpenGL texture parameters:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, texPtr);

Where texWidth and texHeight where the width and height from below.

Here’s what I have currently:

int width = 1024;
int height = 512;
long size  = 0;
GLubyte * data;
FILE * file;
char name[100];
int count;

int test;

strcpy(name, filename);
// open texture data
file = fopen( name, "r" );
if ( file == NULL )
{
fputs ("File error",stderr); 
exit (1);
 }
 fseek (file , 0 , SEEK_END);
 size = ftell( file );
 rewind(file);
// allocate buffer
data = (unsigned char *)malloc( sizeof(char)*size );

count = (int) fread (data,sizeof(unsigned char) ,size,file);
fclose( file );

// allocate a texture name
glGenTextures( 1, &dayGLTexture );

initTexture(dayGLTexture, width, height, data);
  • 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-26T02:21:57+00:00Added an answer on May 26, 2026 at 2:21 am

    OpenGL does not process JPEG compression, and it also doesn’t process JPEG image file formats. You cannot just take a file on the disk, blast it into memory and hand it off to OpenGL. You have to read the file format, process it into a form that OpenGL can actually read, and then give it to OpenGL.

    There are a number of libraries you can use to do this, for various different image formats. You should also read up about how OpenGL understands the pixel data you give it, as well as understand what the internal image format parameter means.

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

Sidebar

Related Questions

I am a little stuck with this one... ReferenceTable overflow (max=512), I am sure
I have an array of ints like this: [32,128,1024,2048,4096] Given a specific value, I
This most be the second most simple rollover effect, still I don't find any
here i want to run this program and take one character pointer like char
The problem I see with this code is that although it is working, some
I read in multiple places that the default buffer size for a pipe is
I have this struct: #define sbuffer 128 #define xbuffer 1024 typedef struct{ char name[sbuffer];
Write a program that calculates Euler’s number e. To do this, first write a
what is the optimal texture size in this case for pixel perfect fit on
I am trying to compile this .c code in windows using MinGW (gcc file.c

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.