Posts: 1,774
Threads: 62
Joined: Aug 2003
Thanks...
I've got the collision detection down now. I just haven't uploaded the new one yet becasue I'm waiting for the next version of FB. I could do everything I want with the current version, but the code will be alot cleaner when I can have double nested arrays in two seperate udt's. plus I'm adding alot more stuff to those models. I'm going to start making some 3D games... man, this is gonna be some serious fun!
Posts: 3,288
Threads: 167
Joined: Nov 2001
Hey doc!!! I've got some pretty interesting ideas with regards to rotation + collision...
I'll PM it.
Posts: 48
Threads: 2
Joined: Jan 2005
Hey - when I run it on my system, at least, the textures come out wrong. It appears that SDL is reading the RGB values from the BMP as BGR.
Thus, you have to look through each texture and swap the R and B values to make it look right before loading into gl. I got it to work correctly by modifying your code as such:
Code:
dim ptrByte as unsigned byte ptr, iTextSize as integer
...
If image1->Format->BytesPerPixel = 3 then
Mode = GL_RGB
ptrByte = image1->Pixels
iTextSize = (image1->W * image1->H * 3)-1
for iPtr = 0 to iTextSize step 3
swap *(ptrByte+iPtr),*(ptrByte+iPtr+2)
next iPtr
ELSEiF ...
ric Carr
Posts: 1,774
Threads: 62
Joined: Aug 2003
That's it? :roll:
Thanks... I'm making a platform game with this and some of the textures are from the planets surface... grass, trees, etc... and I couldn't figure out why the grass kept coming out with a blue tint. I thought it was something I was initializing wrong... or something. I didn't even think about that.
btw: It doesn't really matter on that demo, but the textures also need to be rotated. I guess SDL just loads the images exactly the way they are stored...upside down.
Posts: 3,522
Threads: 189
Joined: Dec 2003
SDL loads the images the right way... but you need to flip them in order for them to be shown correctly on openGL surfaces...
I read about it somewhere, also, the RGB thingy is openGL messing up again...
SDL does it fine
(I use it, I should know... in theory... maybe.. perhaps...)
Posts: 48
Threads: 2
Joined: Jan 2005
Quote:SDL loads the images the right way... but you need to flip them in order for them to be shown correctly on openGL surfaces...
I read about it somewhere, also, the RGB thingy is openGL messing up again...
SDL does it fine (I use it, I should know... in theory... maybe.. perhaps...)
Nah, both are right. Bitmaps are just stored bottom up, right to left. Opengl expects top down, left to right. Thankfully since you can fiddle with the U/V you can just do a byte swap instead of reversing the entire image.
Normally you would load the BMP manually and dump the bytes in reverse into a byte array. That's what I've done in VisualC with opengl. SDL is just too "simple" of an sdk. You'd think they would have a way to reverse it for gl since they provide an interface for it. Maybe we are just missing something.
ric Carr
Posts: 48
Threads: 2
Joined: Jan 2005
Posts: 3,288
Threads: 167
Joined: Nov 2001
I think there is an OpenGL constant to reverse the format from RGB to BGR when passing formats to gltexture2d.
GL_BGR
I'm not sure though as I haven't been coding lately. I'll try to verify it this saturday.
Posts: 1,774
Threads: 62
Joined: Aug 2003
I found some stuff on it, but it isn't available in all versions of OpenGL. I'll probably just keep reversing them manually, rotating 180 around X and Z, and then building the mipmaps... unless you can find out more about GL_BGR/GL_BGRA.
Does anyone get strange depth buffer artifacts in this demo? I wonder if it's the way I'm doing it, my video card is going out... or my video card drivers are messing up. I downloaded the latest universal driver from Nvidia, but that didn't do much.
Anyway, got any depth buffer problems?
Posts: 48
Threads: 2
Joined: Jan 2005
Yeah I noticed depth buffer artifacts in your demo.
I changed it it 1024x768x32 and also tweaked some of the GL_ commands. But I'm at work right now and I'm not looking at the source so I forget what I did.. But I did get rid of the artifacts that I saw.
Basically try to make everything look it's "GL" "nicest". I think you might have been using a 16 bit depth buffer or somethin.
ric Carr