So the game I'm porting originally was written for a resolution of 320x200 on a 4:3 display. (The pixels were not square). I've given the game a 4x resolution boost. Now it runs at 1280x800 at a 16:10 aspect ratio now that the pixels are square. I'm beginning to add the ability to run the game native (1280x800 with a border), Zoomed(Zoom to edge and Maintain Aspect Ratio), and corner-to-corner (stretch/squish).
So now I have this big blank border to deal with. For example, My display is 1920x1080. When I run the game in "Native" 1280x800, I have a thick black border around the outside. When I run zoomed, my display is 16:9 so I have black pillars on the right and left.
I decided to fill the border with a starfield (It fits the theme of the game). I originally was going to put a scrolling tiled background, but I found a starscape generator that makes skyboxes.
Is there a very quick and dirty skybox example written in C? I doesn't even need to use OpenGL (I'd actually rather it didn't) I just need it to lazily rotate around it's center. I'm going to be pasting a 2D picture over the top of it anyway.
It kind of has to be in C as that's the language the original game was written in. Anything using vectors or just STL in general is right out. I see lots of OpenGL examples, but they are all using C++.
I don't need you guys to code up something for me, just a push in the right direction.
Several of us have been through this. Skyboxes are actually rather simple, as they are just a cube rendered centered on the player with textures.
Make a cube. Texture it. Transform it. Draw it.
You can do this with allegro and al_draw_prim or OpenGL directly.
Hmm, this is trickier than I thought...
I was able to draw a triangle using the documentation example. However, When I tried to make a quad, looks like al_draw_prim() only likes triangles. That's cool. however when I started to monkey with the z axis, my triangle disappeared.
ALLEGRO_VERTEX has a warning:
"Note that at this time, the software driver for this addon cannot render 3D primitives. "
How do I know which driver I'm using and how do I switch them if this is the case?
Also, as a extra bonus. I don't know how to do math very well. Anything diving into geometry or algebra and I'm lost. (I haven't been in high school in many, many years) so I'm not sure how transforms are going to work.
==EDIT==
Never mind, I'm aping the code from ex_camera.c I'm adding a floor to that skybox, keeping the camera roll/yaw/pitch and nuking the rest
As long as you're drawing on a video bitmap it should be accelerated.
Also, as a extra bonus. I don't know how to do math very well. Anything diving into geometry or algebra and I'm lost. (I haven't been in high school in many, many years) so I'm not sure how transforms are going to work.
You're going to need to learn math. You just need to. It's not so scary, honest.
Transforms allow you to move, scale, and rotate your objects in space.
They're disappearing because of the default projection matrix, which is orthogonal 2D. You need to setup your own 3D matrix for the projection and the view. After that you push and pop transforms on and off the stack for the view transform to make your models appear in different sizes, positions, and orientations.
No, Allegro doesn't support rendering QUADs. They're just two triangles to be honest. Use a TRIANGLE_FAN and pass the 4 vertices of the quad in counter clockwise order to al_draw_prim or OpenGL.
The camera example was exactly what I needed. It also in code shows me the proper matrix set up and a few useful routines. It's actually a little too verbose, but makes removing the unneeded cruft much easier.
However, I do have an issue... I seem to have seams in my box. The corners are matching up so It's not a texture issue. any ideas on how to solve something like this?
I have an example pic.....
Neil would give you some advice to clamp your texture edges but I haven't needed to do that. How are you drawing your cube? Show code.
I stole the code form the camera example. There are functions that add vertexes to a vertex array (starfield.v). You can either do them on a per quad or per vertex basis.
The original skybox didn't have a proper top or bottom so I had to manually put the vertexes in myself. The relevant code is add_skybox() and draw_scene()
the coordinates are kind of all over the place. I may have to manually remake the cube
This are lots of unneeded variables in here I have yet to zero out or simplify. I'll be cleaning those up later.
Post the images you used to texture your skybox with.
Uploaded here...
Attach them instead so I can try them myself.
Sorry, didn't realize the forums had attachment abilities
I also attached the full modified version of the camera example that I've been tweaking. It's still very much ex_camera.c with junk commented out and some struct modification. It just allows for different textures for the box and you can use an optional border_skybox.png as a test texture.
With a very minor change, it compiled and ran with Allegro 5.2.4 just fine. No seams visible here. Not sure why you can see them. It's very dark though.
I found a solution. I just remodeled the skybox with overlapping edges.
Here is a picture of what I'm talking about...
https://i.imgur.com/MJEECz2.png