Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix graphics build on win32 #40

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 39 additions & 22 deletions graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,57 @@
find_package(OpenGL REQUIRED)

set(awgraphics_SOURCES
gl/loader.c++ gl/gl_api.c++ gl/enum_check.c++
gl3/shader.c++ gl3/program.c++ gl3/uniform.c++ gl3/resources.c++
gl3/texture.c++ gl3/model.c++ gl3/material.c++ gl3/render_context.c++)
gl/loader.c++
gl/gl_api.c++
gl/enum_check.c++
gl3/shader.c++
gl3/program.c++
gl3/uniform.c++
gl3/resources.c++
gl3/texture.c++
gl3/model.c++
gl3/material.c++
gl3/render_context.c++
)

aw_add_library(awgraphics SHARED
GLOB_HEADERS
SOURCES
${awgraphics_SOURCES}
EXPORT_NAME
graphics)
graphics
)

target_link_libraries(awgraphics
PUBLIC
awio
awmath
awobj
PRIVATE
OpenGL::GL)
target_compile_definitions(awgraphics
PRIVATE
AW_MODULE_GRAPHICS
)

if (WIN32)
target_link_libraries(awgraphics
PRIVATE
OpenGL::GL
awplatform)
set(AW_OPENGL_LIBS
OpenGL::GL
awplatform
)
elseif (APPLE)
target_link_libraries(awgraphics
PRIVATE
OpenGL::GL)
set(AW_OPENGL_LIBS
OpenGL::GL
)
elseif (UNIX)
target_link_libraries(awgraphics
PRIVATE
OpenGL::OpenGL
OpenGL::GLX)
set(AW_OPENGL_LIBS
OpenGL::GL
OpenGL::GLX
)
endif()


target_link_libraries(awgraphics
PUBLIC
awio
awmath
awobj
PRIVATE
${AW_OPENGL_LIBS}
)

add_subdirectory(test)
add_subdirectory(meshes)
2 changes: 1 addition & 1 deletion graphics/gl3/shader.c++
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool shader::compile(string_view code)

bool status = is_compiled();
if (status == false) {
std::cout << "Failed to compile " << enum_string( type() ) << " shader:" << '\n';
std::cerr << "Failed to compile " << enum_string( type() ) << " shader:" << '\n';
report_info_log( _shader );
}

Expand Down
8 changes: 2 additions & 6 deletions io/win32/file.c++
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include <cassert>
#include "winapi_helpers.h"
#include "path.h"
namespace aw {
namespace io {
namespace win32 {
namespace aw::io::win32 {
namespace {
int get_access( file_mode mode )
{
Expand Down Expand Up @@ -155,6 +153,4 @@ uintmax_t size(file_descriptor fd, std::error_code& ec)

return ret ? sz.QuadPart : uintmax_t(-1);
}
} // namespace win32
} // namespace io
} // namespace aw
} // namespace aw::io::win32
13 changes: 9 additions & 4 deletions io/win32/mmap.c++
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* There is NO WARRANTY, to the extent permitted by law.
*/
#include <aw/io/mmap_file.h>
#include <aw/types/support/narrow.h>
#include "winapi_helpers.h"
namespace aw {
namespace io {
Expand Down Expand Up @@ -57,17 +58,21 @@ file_mapping map_file( file_descriptor fd, map_perms perms, std::error_code& ec
return { invalid_mapping };
}

unsigned prot = get_protection( perms );
HANDLE mapping = CreateFileMappingW( HANDLE(fd), nullptr, prot, 0, 0, nullptr);
const unsigned prot = get_protection( perms );
const HANDLE mapping = CreateFileMappingW( HANDLE(fd), nullptr, prot, 0, 0, nullptr);
if (!mapping) {
set_error( ec );
return { invalid_mapping };
}

unsigned access = get_access( perms );
const unsigned access = get_access( perms );
void* view = MapViewOfFile( mapping, access, 0, 0, 0 );

return { uintptr_t(mapping), view, size( fd, ec ) };
return {
.handle = uintptr_t(mapping),
.address = view,
.length = narrow_cast<size_t>(size( fd, ec ))
};
}

bool unmap_file( file_mapping& map, std::error_code& ec )
Expand Down
Loading