移动原本的范例为EnumRenderDevice
This commit is contained in:
parent
fe1e73c245
commit
cc2fce4c8c
@ -1 +1,2 @@
|
|||||||
add_subdirectory(NullWindow)
|
add_subdirectory(EnumRenderDevice)
|
||||||
|
add_subdirectory(NullWindow)
|
||||||
|
3
example/EnumRenderDevice/CMakeLists.txt
Normal file
3
example/EnumRenderDevice/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
add_executable(EnumRenderDevice main.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(EnumRenderDevice PRIVATE MathGeoLib glfw GL ULRE.RenderDevice)
|
71
example/EnumRenderDevice/main.cpp
Normal file
71
example/EnumRenderDevice/main.cpp
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#include<hgl/render/device/RenderDevice.h>
|
||||||
|
#include<iostream>
|
||||||
|
#include<math.h>
|
||||||
|
|
||||||
|
using namespace hgl;
|
||||||
|
|
||||||
|
void put(const struct VideoMode *vm)
|
||||||
|
{
|
||||||
|
std::cout<<"\t"<<vm->width<<"x"<<vm->height<<","<<vm->bit<<"bits,"<<vm->freq<<"hz";
|
||||||
|
}
|
||||||
|
|
||||||
|
void put(const struct Display *disp)
|
||||||
|
{
|
||||||
|
const int inch=sqrt((disp->width*disp->width)+(disp->height*disp->height))*0.03937008;
|
||||||
|
|
||||||
|
std::cout<<"["<<disp->name.c_str()<<"]["<<disp->width<<"x"<<disp->height<<" mm,"<<inch<<" inch][offset "<<disp->x<<","<<disp->y<<"]"<<std::endl;
|
||||||
|
|
||||||
|
std::cout<<"\tcurrent video mode: ";
|
||||||
|
put(disp->GetCurVideoMode());
|
||||||
|
std::cout<<std::endl;
|
||||||
|
|
||||||
|
const ObjectList<VideoMode> &vml=disp->GetVideoModeList();
|
||||||
|
|
||||||
|
for(int i=0;i<vml.GetCount();i++)
|
||||||
|
{
|
||||||
|
std::cout<<"\t"<<i<<" : ";
|
||||||
|
put(vml[i]);
|
||||||
|
std::cout<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
RenderDevice *device=CreateRenderDeviceGLFW();
|
||||||
|
|
||||||
|
if(!device)
|
||||||
|
{
|
||||||
|
std::cerr<<"Create RenderDevice(GLFW) failed."<<std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!device->Init())
|
||||||
|
{
|
||||||
|
std::cerr<<"Init RenderDevice(GLFW) failed."<<std::endl;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const UTF8String device_name=device->GetName();
|
||||||
|
|
||||||
|
std::cout<<"RenderDevice: "<<device_name.c_str()<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Display *> disp_list;
|
||||||
|
|
||||||
|
device->GetDisplayList(disp_list);
|
||||||
|
|
||||||
|
const int count=disp_list.GetCount();
|
||||||
|
|
||||||
|
std::cout<<"Device have "<<count<<" display."<<std::endl;
|
||||||
|
|
||||||
|
for(int i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
std::cout<<"Display "<<i<<" ";
|
||||||
|
put(GetObject(disp_list,i));
|
||||||
|
|
||||||
|
std::cout<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user