mirror of
https://github.com/ScrelliCopter/Lesson10-SDL3.git
synced 2025-02-21 07:19:26 +11:00
fix windows
This commit is contained in:
@@ -8,8 +8,9 @@ add_executable(Lesson10 Lesson10.cpp)
|
|||||||
set_target_properties(Lesson10 PROPERTIES
|
set_target_properties(Lesson10 PROPERTIES
|
||||||
CXX_STANDARD 98
|
CXX_STANDARD 98
|
||||||
WIN32_EXECUTABLE ON)
|
WIN32_EXECUTABLE ON)
|
||||||
target_link_libraries(Lesson10 SDL3::SDL3 OpenGL::GL)
|
target_link_libraries(Lesson10 SDL3::SDL3 OpenGL::GL $<$<PLATFORM_ID:Windows>:OpenGL::GLU>)
|
||||||
target_compile_options(Lesson10 PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>)
|
target_compile_options(Lesson10 PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>)
|
||||||
|
target_compile_definitions(Lesson10 PRIVATE $<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>)
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
get_property(SDL3_IMPORTED_LOCATION TARGET SDL3::SDL3 PROPERTY IMPORTED_LOCATION)
|
get_property(SDL3_IMPORTED_LOCATION TARGET SDL3::SDL3 PROPERTY IMPORTED_LOCATION)
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
#include <SDL3/SDL_main.h>
|
#include <SDL3/SDL_main.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <SDL3/SDL_opengl.h> // Header File For The OpenGL32 Library
|
#include <SDL3/SDL_opengl.h> // Header File For The OpenGL32 Library
|
||||||
|
#ifdef _WIN32
|
||||||
|
# include <gl/GLU.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_Window* hWnd=NULL; // Holds Our Window Handle
|
SDL_Window* hWnd=NULL; // Holds Our Window Handle
|
||||||
SDL_GLContext hRC=NULL; // Permanent Rendering Context
|
SDL_GLContext hRC=NULL; // Permanent Rendering Context
|
||||||
@@ -167,8 +170,12 @@ int LoadGLTextures() // Load Bitmaps And Conv
|
|||||||
glBindTexture(GL_TEXTURE_2D, texture[2]);
|
glBindTexture(GL_TEXTURE_2D, texture[2]);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
|
||||||
|
#ifndef _WIN32
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->w, TextureImage->h, 0, GL_BGR, GL_UNSIGNED_BYTE, TextureImage->pixels);
|
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->w, TextureImage->h, 0, GL_BGR, GL_UNSIGNED_BYTE, TextureImage->pixels);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
#else
|
||||||
|
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage->w, TextureImage->h, GL_BGR, GL_UNSIGNED_BYTE, TextureImage->pixels);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
SDL_DestroySurface(TextureImage); // Free The Image Structure
|
SDL_DestroySurface(TextureImage); // Free The Image Structure
|
||||||
|
|
||||||
@@ -177,7 +184,7 @@ int LoadGLTextures() // Load Bitmaps And Conv
|
|||||||
|
|
||||||
static void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
|
static void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
|
||||||
{
|
{
|
||||||
double h = 1.0 / tan(fovy * (M_PI / 180.0) * 0.5);
|
double h = 1.0 / tan(fovy * (SDL_PI_D / 180.0) * 0.5);
|
||||||
double w = h / aspect;
|
double w = h / aspect;
|
||||||
double invcliprng = 1.0 / (zFar - zNear);
|
double invcliprng = 1.0 / (zFar - zNear);
|
||||||
double z = -(zFar + zNear) * invcliprng;
|
double z = -(zFar + zNear) * invcliprng;
|
||||||
|
|||||||
Reference in New Issue
Block a user