Jump to content

  • Log In with Google      Sign In   
  • Create Account


OpenGl and access violations...a sad story


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 griffenjam   Members   -  Reputation: 193

Like
Likes
Like

Posted 07 August 2001 - 11:31 AM

I''m trying to use glDrawPixels() and am not having ANY luck. I''m sending an unsigned char * but when the function runs I get an ACCESS VIOLATION!!! When I debug it it looks like the violation is in one of my video cards driver files (nVidia GeForce 2). This is all happening inside a class, I was also getting access violations when trying to set a value in the array. That is fixed now (I don''t really know how). is this correct? unsigned char *bitmap; bitmap = new unsigned char[imagesize]; //load the bitmap . . glDrawPixels(,,,, bitmap); if so why am I getting access violations? also why would mearly setting a value in bitmap (bitmap[0] = ''a'' cause an acces violation? Jason Mickela ICQ : 873518 E-Mail: jmickela@pacbell.net ------------------------------ "Evil attacks from all sides but the greatest evil attacks from within." Me ------------------------------

Sponsor:

#2 Zerosignull   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 August 2001 - 12:00 PM

#define Height 64
#defein width 64
GLubyte *bitmap;

bitmap = new GLubyte bitmap[height][width];
//load the bitmap
.
.
glDrawPixels(Width, height, GL_RGB, GL_UNSIGNED_BYTE, bitmap);


make sure that the type ie ''GL_UNSIGNED_BYTE'' is the same type as the data u are using. the abouve code should work.. plz post a rply if it does/doesnt

~prevail by daring to fail~

#3 griffenjam   Members   -  Reputation: 193

Like
Likes
Like

Posted 07 August 2001 - 12:21 PM

I am reading from a file straight into bitmap.

read(bitmap, sizeof(unsigned char), datasize, fp);

Would a 2d array work with this?

#4 Zerosignull   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 August 2001 - 12:35 PM

shit i fogot to ass another array tot the bitmap array

#define Height 64
#defein width 64
GLubyte *bitmap;

bitmap = new GLubyte bitmap[height][width][3];
//load the bitmap
.
.
glDrawPixels(Width, height, GL_RGB, GL_UNSIGNED_BYTE, bitmap);


the following wont do ne thing. u dont know the actuall size of each variable ie a 24bpp bitmap will have 8bits (a byte) per color adn so the variables will have to be of type GLubyte || unsigned short (dont use char and all data will be unsigned!!!). and also if u load the entire file into the array u will also get the file header in with thae data and u dont want that. if u dont know the file structire of a bmp ull have to go find out so u can extract the depth information and the data offset from the begining of the file.

read(bitmap, sizeof(unsigned char), datasize, fp);


~prevail by daring to fail~

#5 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 07 August 2001 - 02:51 PM

>> bitmap = new unsigned char[imagesize]; <<

are u taking account of the images bitdepth eg
greyscale = imagesize*1
RGB = imagesize*3
RGBA = imagesize*4

#6 griffenjam   Members   -  Reputation: 193

Like
Likes
Like

Posted 07 August 2001 - 03:57 PM

In my code I have already grabed the file header, that is where I got the imagesize value from.
No, I have not taken the type of image into account, none of the sample code that I have seen has either.
Nor would it matter for the question I am asking. IT doesn''t matter what I''m loading or it I''m loading it wrong, wrong data wouldn''t give an access violation, it jus''t wouldn''t work right.
AFAIK the statement
bitmap[1] = temp; //Where temp is of type unsigned char
should cause ANY problems.
I am testing to make sure I was able to allocate the memory.
Why am I getting access violations?
I can worry about the bitmap loading being incorrect when I can actaully run my code,
as it is I can''t test anything.

#7 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 07 August 2001 - 09:03 PM

u should get an access voilation (or some error)

ubyte data[2*2] // 4 pixels

glDrawPixels( GL_RGB, 2,2, ubyte, data ) // bang error

drawpixels wants 12 pixels ie 2x2x3 (3 cause its RGB) but youve only given it 4

try this in your code
bitmap = new unsigned char[imagesize*4];
instead of
bitmap = new unsigned char[imagesize];




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS