mirror of
https://github.com/ScrelliCopter/Lesson10-SDL3.git
synced 2025-02-21 07:19:26 +11:00
type usage consistency
This commit is contained in:
44
Lesson10.c
44
Lesson10.c
@@ -39,14 +39,14 @@ typedef struct tagCAMERA
|
|||||||
{
|
{
|
||||||
float heading;
|
float heading;
|
||||||
float xpos, zpos;
|
float xpos, zpos;
|
||||||
GLfloat yrot; // Y Rotation
|
float yrot; // Y Rotation
|
||||||
GLfloat walkbias, walkbiasangle;
|
float walkbias, walkbiasangle;
|
||||||
GLfloat lookupdown;
|
float lookupdown;
|
||||||
GLfloat z; // Depth Into The Screen
|
float z; // Depth Into The Screen
|
||||||
} CAMERA;
|
} CAMERA;
|
||||||
|
|
||||||
CAMERA camera;
|
CAMERA camera;
|
||||||
GLuint filter; // Which Filter To Use
|
unsigned filter; // Which Filter To Use
|
||||||
GLuint texture[3] = { 0, 0, 0 }; // Storage For 3 Textures
|
GLuint texture[3] = { 0, 0, 0 }; // Storage For 3 Textures
|
||||||
|
|
||||||
typedef struct tagVERTEX
|
typedef struct tagVERTEX
|
||||||
@@ -138,7 +138,7 @@ bool FlipSurface(SDL_Surface *surface)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadGLTextures(void) // Load bitmap as textures
|
bool LoadGLTextures(void) // Load bitmap as textures
|
||||||
{
|
{
|
||||||
SDL_Surface *TextureImage = NULL; // Create Storage Space For The Texture
|
SDL_Surface *TextureImage = NULL; // Create Storage Space For The Texture
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ static void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdou
|
|||||||
double invcliprng = 1.0 / (zFar - zNear);
|
double invcliprng = 1.0 / (zFar - zNear);
|
||||||
double z = -(zFar + zNear) * invcliprng;
|
double z = -(zFar + zNear) * invcliprng;
|
||||||
double z2 = -(2.0 * zFar * zNear) * invcliprng;
|
double z2 = -(2.0 * zFar * zNear) * invcliprng;
|
||||||
double mtx[16] =
|
GLdouble mtx[16] =
|
||||||
{
|
{
|
||||||
w, 0.0, 0.0, 0.0,
|
w, 0.0, 0.0, 0.0,
|
||||||
0.0, h, 0.0, 0.0,
|
0.0, h, 0.0, 0.0,
|
||||||
@@ -187,7 +187,7 @@ static void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdou
|
|||||||
glLoadMatrixd(mtx);
|
glLoadMatrixd(mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
|
void ReSizeGLScene(int width, int height) // Resize And Initialize The GL Window
|
||||||
{
|
{
|
||||||
if (height == 0) // Prevent A Divide By Zero By
|
if (height == 0) // Prevent A Divide By Zero By
|
||||||
{
|
{
|
||||||
@@ -200,17 +200,17 @@ void ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initializ
|
|||||||
glLoadIdentity(); // Reset The Projection Matrix
|
glLoadIdentity(); // Reset The Projection Matrix
|
||||||
|
|
||||||
// Calculate The Aspect Ratio Of The Window
|
// Calculate The Aspect Ratio Of The Window
|
||||||
gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f);
|
gluPerspective(45.0f, (float)width / (float)height, 0.1f, 100.0f);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
|
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
|
||||||
glLoadIdentity(); // Reset The Modelview Matrix
|
glLoadIdentity(); // Reset The Modelview Matrix
|
||||||
}
|
}
|
||||||
|
|
||||||
int InitGL(void) // All Setup For OpenGL Goes Here
|
bool InitGL(void) // All Setup For OpenGL Goes Here
|
||||||
{
|
{
|
||||||
if (!LoadGLTextures()) // Jump To Texture Loading Routine
|
if (!LoadGLTextures()) // Jump To Texture Loading Routine
|
||||||
{
|
{
|
||||||
return 0; // If Texture Didn't Load Return FALSE
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
|
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
|
||||||
@@ -224,7 +224,7 @@ int InitGL(void) // All Setup For OpenGL
|
|||||||
|
|
||||||
SetupWorld();
|
SetupWorld();
|
||||||
|
|
||||||
return 1; // Initialization Went OK
|
return true; // Initialization Went OK
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawGLScene(void) // Here's Where We Do All The Drawing
|
void DrawGLScene(void) // Here's Where We Do All The Drawing
|
||||||
@@ -277,27 +277,27 @@ void DrawGLScene(void) // Here's Where We Do A
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KillGLWindow(void) // Properly Kill The Window
|
void KillGLWindow(void) // Properly Kill The Window
|
||||||
{
|
{
|
||||||
if (fullscreen) // Are We In Fullscreen Mode?
|
if (fullscreen) // Are We In Fullscreen Mode?
|
||||||
{
|
{
|
||||||
SDL_SetWindowFullscreen(win, 0); // If So Switch Back To The Desktop
|
SDL_SetWindowFullscreen(win, SDL_FALSE); // If So Switch Back To The Desktop
|
||||||
SDL_ShowCursor(); // Show Mouse Pointer
|
SDL_ShowCursor(); // Show Mouse Pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx) // Do We Have A Rendering Context?
|
if (ctx) // Do We Have A Rendering Context?
|
||||||
{
|
{
|
||||||
if (SDL_GL_MakeCurrent(win, NULL)) // Are We Able To Release The DC And RC Contexts?
|
if (SDL_GL_MakeCurrent(win, NULL)) // Are We Able To Release The DC And RC Contexts?
|
||||||
{
|
{
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "SHUTDOWN ERROR", "Release Of RC Failed.", NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "SHUTDOWN ERROR", "Release Of RC Failed.", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_DeleteContext(ctx); // Delete The RC
|
SDL_GL_DeleteContext(ctx); // Delete The RC
|
||||||
ctx = NULL; // Set RC To NULL
|
ctx = NULL; // Set RC To NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyWindow(win); // Destroy The Window
|
SDL_DestroyWindow(win); // Destroy The Window
|
||||||
win = NULL; // Set hWnd To NULL
|
win = NULL; // Set hWnd To NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user