增加像素获取
This commit is contained in:
parent
bb1275992f
commit
8b9dbff0ee
@ -45,7 +45,7 @@ find_library(GLES-lib GLESv3)
|
|||||||
|
|
||||||
#System so
|
#System so
|
||||||
set(SYSTEM_LIBS
|
set(SYSTEM_LIBS
|
||||||
libace_napi.z.so libnative_window.so
|
libace_napi.z.so libnative_window.so libnative_display_manager.so
|
||||||
hilog_ndk.z ace_ndk.z uv z
|
hilog_ndk.z ace_ndk.z uv z
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,9 @@ bool NativeRender::init(int width, int height,EGLCore* eglCore) {
|
|||||||
OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Render", "GL Error before render: 0x%{public}x", glGetError());
|
OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Render", "GL Error before render: 0x%{public}x", glGetError());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeRender::initViewer(){
|
void NativeRender::initViewer(){
|
||||||
|
displayPixelRatio();
|
||||||
Handle(Aspect_DisplayConnection) displayConnection=new Aspect_DisplayConnection();
|
Handle(Aspect_DisplayConnection) displayConnection=new Aspect_DisplayConnection();
|
||||||
// 创建图形驱动
|
// 创建图形驱动
|
||||||
if (graphicDriver_.IsNull()) {
|
if (graphicDriver_.IsNull()) {
|
||||||
@ -69,10 +71,21 @@ void NativeRender::initViewer(){
|
|||||||
viewer_->SetDefaultLights();
|
viewer_->SetDefaultLights();
|
||||||
viewer_->SetLightOn();
|
viewer_->SetLightOn();
|
||||||
}
|
}
|
||||||
|
float NativeRender::displayPixelRatio(){
|
||||||
|
float densityPixels;
|
||||||
|
NativeDisplayManager_ErrorCode errCode = OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio(&densityPixels);
|
||||||
|
if (errCode == NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK) {
|
||||||
|
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "DMSTest", "rotation=%{public}d", densityPixels);
|
||||||
|
return densityPixels;
|
||||||
|
} else {
|
||||||
|
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "DMSTest",
|
||||||
|
"GetDefaultDisplayRotation errCode=%{public}d", errCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
void NativeRender::initContext(){
|
void NativeRender::initContext(){
|
||||||
context_ = new AIS_InteractiveContext(viewer_);
|
context_ = new AIS_InteractiveContext(viewer_);
|
||||||
context_->SetDisplayMode(AIS_Shaded, Standard_False); // 默认使用着色模式
|
context_->SetDisplayMode(AIS_Shaded, Standard_False); // 默认使用着色模式
|
||||||
//context_->SetPixelTolerance (int(myDevicePixelRatio * 6.0)); // increase tolerance and adjust to hi-dpi screens
|
context_->SetPixelTolerance (int(displayPixelRatio() * 6.0)); // increase tolerance and adjust to hi-dpi screens
|
||||||
}
|
}
|
||||||
void NativeRender::initView() {
|
void NativeRender::initView() {
|
||||||
Handle(Aspect_NeutralWindow) m_Window = new Aspect_NeutralWindow();
|
Handle(Aspect_NeutralWindow) m_Window = new Aspect_NeutralWindow();
|
||||||
@ -81,6 +94,7 @@ void NativeRender::initView() {
|
|||||||
// 设置渲染参数
|
// 设置渲染参数
|
||||||
view_->SetImmediateUpdate (false);
|
view_->SetImmediateUpdate (false);
|
||||||
//view_->ChangeRenderingParams().ToShowStats = true;
|
//view_->ChangeRenderingParams().ToShowStats = true;
|
||||||
|
view_->ChangeRenderingParams().Resolution = (unsigned int )(96.0 * displayPixelRatio() + 0.5);
|
||||||
view_->ChangeRenderingParams().Method = Graphic3d_RM_RASTERIZATION;
|
view_->ChangeRenderingParams().Method = Graphic3d_RM_RASTERIZATION;
|
||||||
view_->ChangeRenderingParams().IsShadowEnabled = Standard_False;
|
view_->ChangeRenderingParams().IsShadowEnabled = Standard_False;
|
||||||
view_->ChangeRenderingParams().IsReflectionEnabled = Standard_False;
|
view_->ChangeRenderingParams().IsReflectionEnabled = Standard_False;
|
||||||
|
|||||||
@ -23,6 +23,9 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include "EGLCore.h"
|
#include "EGLCore.h"
|
||||||
|
#include <window_manager/oh_display_info.h>
|
||||||
|
#include <window_manager/oh_display_manager.h>
|
||||||
|
|
||||||
class Aspect_Window;
|
class Aspect_Window;
|
||||||
class gp_Quaternion;
|
class gp_Quaternion;
|
||||||
class Graphic3d_Camera;
|
class Graphic3d_Camera;
|
||||||
@ -44,6 +47,7 @@ public:
|
|||||||
void setClearColor(float r, float g, float b, float a);
|
void setClearColor(float r, float g, float b, float a);
|
||||||
void setZoomLevel(float zoom);
|
void setZoomLevel(float zoom);
|
||||||
void setTranslation(float x, float y);
|
void setTranslation(float x, float y);
|
||||||
|
float displayPixelRatio();
|
||||||
private:
|
private:
|
||||||
void initViewer();
|
void initViewer();
|
||||||
void initContext();
|
void initContext();
|
||||||
@ -61,11 +65,14 @@ private:
|
|||||||
|
|
||||||
float rotationX_;
|
float rotationX_;
|
||||||
float rotationY_;
|
float rotationY_;
|
||||||
|
float rotationZ_;
|
||||||
|
|
||||||
float zoomLevel_;
|
float zoomLevel_;
|
||||||
int width_;
|
int width_;
|
||||||
int height_;
|
int height_;
|
||||||
float translationX_;
|
float translationX_;
|
||||||
float translationY_;
|
float translationY_;
|
||||||
|
float translationZ_;
|
||||||
Quantity_Color clearColor_;
|
Quantity_Color clearColor_;
|
||||||
};
|
};
|
||||||
} // namespace NativeRender
|
} // namespace NativeRender
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user