![]() |
|
#1
|
|||
|
|||
problem with castinghi,
i've got a problem with the opengl funtion glTexImage2D(); CPP / C++ / C Code:
i've tried a lot but i couldn't figure out how to do this i'm greatful for help |
|||
|
#2
|
|||
|
|||
Re: problem with castingQuote:
No, and it has nothing to do with casting. It has to do with how arrays are stored in memory. The function will read pixel values sequentially from memory starting at the adress given by the parameter "texels". (You always get a contiguous block of memory when you declare an array or a multi-dimensional array; it's guaranteed.) Generally, dynamic allocation of multi-dimensional arrays is performed by separate calls to some allocation function (malloc, calloc, new, or some such thing), and the individual elements will not all be in a single contiguous block of memory (since successive calls to malloc, for example, will not result in the blocks being contiguous). You could allocate a single large array for the pixels, but then you would not be able to access the pixels with multi-dimensional array index notation. If you have something more specific in mind (or if I have misunderstood your intentions), please tell us a little more about what you are working on. Regards, Dave Last edited by davekw7x : 04-Dec-2005 at 16:19.
|
|
#3
|
|||
|
|||
Re: problem with castingthank you
that was exactly what i was looking for, so you didn't misunderstand me. i did not come to the idea that this was the problem all the time. i have rewritten my code and now its working .. if someone is interested in how to load .png files and make them opengl textures (on linux) i'll post my solution. |
|
#4
|
|||
|
|||
Re: problem with castingQuote:
I am always interested in things that work. If it's not really, really (really) long, I would like to see it. Regards, Dave |
|
#5
|
||||
|
||||
Re: problem with castingQuote:
I am curious enough to look at your solution. OpenGL stuff intruigues me but I have not had a chance to play with it in FLTK yet. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#6
|
|||
|
|||
Re: problem with castingk... so here it is.
it's no really professional code and a bit large too, but its working and i'm happy about that first the main.c file... CPP / C++ / C Code:
now the texture.c and .h file followed by the makefile CPP / C++ / C Code:
now texture.h .. CPP / C++ / C Code:
and finally the makefile for linux. (i am using ubuntu and it also worked with gentoo ... don't now if this is working on other operating systems) Code:
i have modified the code a little bit for posting .. if something isn't working ill post the fixed part again.. alex. btw.. what is FLTK? |
|
#7
|
||||
|
||||
Re: problem with castingQuote:
Quote:
The Fast Light Tool Kit, can be found at FLTK.org is an open source UI library that can be used under a number of OS'es. We also have a forum here but since I do most of the responding the quality may be a bit suspect. It can work with OpenGL so I am going to see if I can force your example into it or not. Most likely not since I have never given it a go but what the heck, it's worth a shot. Thanks for sharing your example with us. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#8
|
||||
|
||||
Re: problem with castingOk, with a few changes I can get it to use the OpenGL stuff that I have with FLTK.
Namely, CPP / C++ / C Code:
becomes, CPP / C++ / C Code:
I had a problem with the malloc in load_tex_img and had to cast it to a Texture*. I suppose at that point tex should be checked to make sure it isn't NULL. Now to read the docs and put it in an OpenGL window to see if it works. Right now, running the exe just crashes miserably when attempting to open the TEST window. I'm going to go through the FLTK example program and convert your main code into something FLTK understands and set up an OpenGL container in an FLTK window. Oh, I had one question, what type of image should the png be? Can it be anything or should it be some sort of greyscale imagery? Just curious about that is all. If you could attach the one you used in your testing that would be cool. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#9
|
|||
|
|||
Re: problem with castingQuote:
No, it has to be an image with alpha channel and it's dimensions must be powers of 2. If you have an image that hasn't dimensions of powers of two you can resize it or put it into a bigger one, but then you have to use other texture coordinates. I have attached the image I used. |
|
#10
|
|||
|
|||
Re: problem with castingI have compiled the posted programm myself to see if I've accomplished to put some mistakes in it and it compiled and worked without errors. The only mistake are the C-style comments in the makefile .. ^^.
Quote:
Oh.. thx Quote:
This could have happened because of the use of a wrong image.. the programm is still in test phase so it sadly doesn't support all types of png images yet. Quote:
hm this sounds interesting I'll deal with that at some time. Thanks for your interest in this Alex |
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Graphic problem in Unreal Tournament 2004 | zerox | Computer Software Forum - Games | 10 | 09-Oct-2005 12:31 |
| Runtime Problem involving "printf" in C Program | supamakia | C Programming Language | 2 | 09-Oct-2005 10:09 |
| a significant problem after installing Xp | mohammad | Computer Software Forum - Windows | 10 | 09-Aug-2005 07:03 |
| String problem | vaha | C Programming Language | 3 | 24-May-2005 18:21 |
| Another FX 5600 problem (but with details that might shed light on this) | BobDaDuck | Computer Hardware Forum | 2 | 16-Apr-2004 07:53 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The