Add SetVrOutputTransform
This commit is contained in:
parent
36e434099d
commit
625caacbf0
10
src/raylib.h
10
src/raylib.h
|
|
@ -872,6 +872,15 @@ typedef enum {
|
||||||
NPT_3PATCH_HORIZONTAL // Npatch defined by 3x1 tiles
|
NPT_3PATCH_HORIZONTAL // Npatch defined by 3x1 tiles
|
||||||
} NPatchType;
|
} NPatchType;
|
||||||
|
|
||||||
|
// VR Output Transformations
|
||||||
|
typedef enum {
|
||||||
|
VR_OUTPUT_ROTATE_90 = 0x00000001, // Set to rotate the output stereo view by 90 degrees (clockwise)
|
||||||
|
VR_OUTPUT_ROTATE_180 = 0x00000002, // Set to rotate the output stereo view by 180 degrees (clockwise)
|
||||||
|
VR_OUTPUT_ROTATE_270 = 0x00000003, // Set to rotate the output stereo view by 270 degrees (clockwise)
|
||||||
|
VR_OUTPUT_FLIP_H = 0x00000004, // Set to horizontally flip the stereo view before applying all rotations
|
||||||
|
VR_OUTPUT_FLIP_V = 0x00000008 // Set to vertically flip the stereo view before applying all rotations
|
||||||
|
} VrOutputTransform;
|
||||||
|
|
||||||
// Callbacks to be implemented by users
|
// Callbacks to be implemented by users
|
||||||
typedef void (*TraceLogCallback)(int logType, const char *text, va_list args);
|
typedef void (*TraceLogCallback)(int logType, const char *text, va_list args);
|
||||||
typedef void *(*MemAllocCallback)(int size);
|
typedef void *(*MemAllocCallback)(int size);
|
||||||
|
|
@ -1446,6 +1455,7 @@ RLAPI void InitVrSimulator(void); // Init VR simulator for
|
||||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||||
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||||
RLAPI void SetVrConfiguration(VrDeviceInfo info, Shader distortion); // Set stereo rendering configuration parameters
|
RLAPI void SetVrConfiguration(VrDeviceInfo info, Shader distortion); // Set stereo rendering configuration parameters
|
||||||
|
RLAPI void SetVrOutputTransform(unsigned int transform);// Set the VR simulator output transform flags
|
||||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
||||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
||||||
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
||||||
|
|
|
||||||
32
src/rlgl.h
32
src/rlgl.h
|
|
@ -618,6 +618,7 @@ RLAPI void InitVrSimulator(void); // Init VR simulator for
|
||||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||||
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||||
RLAPI void SetVrConfiguration(VrDeviceInfo info, Shader distortion); // Set stereo rendering configuration parameters
|
RLAPI void SetVrConfiguration(VrDeviceInfo info, Shader distortion); // Set stereo rendering configuration parameters
|
||||||
|
RLAPI void SetVrOutputTransform(unsigned int transform);// Set the VR simulator output transform flags
|
||||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
||||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
||||||
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
||||||
|
|
@ -907,6 +908,7 @@ typedef struct rlglData {
|
||||||
VrStereoConfig config; // VR stereo configuration for simulator
|
VrStereoConfig config; // VR stereo configuration for simulator
|
||||||
unsigned int stereoFboId; // VR stereo rendering framebuffer id
|
unsigned int stereoFboId; // VR stereo rendering framebuffer id
|
||||||
unsigned int stereoTexId; // VR stereo color texture (attached to framebuffer)
|
unsigned int stereoTexId; // VR stereo color texture (attached to framebuffer)
|
||||||
|
unsigned int outputTransformFlags; // VR stereo rendering output transform flags.
|
||||||
bool simulatorReady; // VR simulator ready flag
|
bool simulatorReady; // VR simulator ready flag
|
||||||
bool stereoRender; // VR stereo rendering enabled/disabled flag
|
bool stereoRender; // VR stereo rendering enabled/disabled flag
|
||||||
} Vr;
|
} Vr;
|
||||||
|
|
@ -3923,6 +3925,12 @@ void SetVrConfiguration(VrDeviceInfo hmd, Shader distortion)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetVrOutputTransform(unsigned int transform) {
|
||||||
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
|
RLGL.Vr.outputTransformFlags = transform;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Detect if VR simulator is running
|
// Detect if VR simulator is running
|
||||||
bool IsVrSimulatorReady(void)
|
bool IsVrSimulatorReady(void)
|
||||||
{
|
{
|
||||||
|
|
@ -3997,25 +4005,41 @@ void EndVrDrawing(void)
|
||||||
|
|
||||||
rlEnableTexture(RLGL.Vr.stereoTexId);
|
rlEnableTexture(RLGL.Vr.stereoTexId);
|
||||||
|
|
||||||
|
bool shouldFlipH = RLGL.Vr.outputTransformFlags & VR_OUTPUT_FLIP_H;
|
||||||
|
bool shouldFlipV = RLGL.Vr.outputTransformFlags & VR_OUTPUT_FLIP_V;
|
||||||
|
|
||||||
|
int point = RLGL.Vr.outputTransformFlags & 0b11; // Extract lower bits from transform flags
|
||||||
|
|
||||||
|
float uvPoints[][2] = {
|
||||||
|
{ (float)(shouldFlipH ^ 0), (float)(shouldFlipV ^ 1) },
|
||||||
|
{ (float)(shouldFlipH ^ 0), (float)(shouldFlipV ^ 0) },
|
||||||
|
{ (float)(shouldFlipH ^ 1), (float)(shouldFlipV ^ 0) },
|
||||||
|
{ (float)(shouldFlipH ^ 1), (float)(shouldFlipV ^ 1) }
|
||||||
|
};
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlBegin(RL_QUADS);
|
rlBegin(RL_QUADS);
|
||||||
rlColor4ub(255, 255, 255, 255);
|
rlColor4ub(255, 255, 255, 255);
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
// Bottom-left corner for texture and quad
|
// Bottom-left corner for texture and quad
|
||||||
rlTexCoord2f(0.0f, 1.0f);
|
rlTexCoord2f(uvPoints[point][0], uvPoints[point][1]);
|
||||||
|
point = (point + 1) % 4;
|
||||||
rlVertex2f(0.0f, 0.0f);
|
rlVertex2f(0.0f, 0.0f);
|
||||||
|
|
||||||
// Bottom-right corner for texture and quad
|
// Bottom-right corner for texture and quad
|
||||||
rlTexCoord2f(0.0f, 0.0f);
|
rlTexCoord2f(uvPoints[point][0], uvPoints[point][1]);
|
||||||
|
point = (point + 1) % 4;
|
||||||
rlVertex2f(0.0f, (float)RLGL.State.framebufferHeight);
|
rlVertex2f(0.0f, (float)RLGL.State.framebufferHeight);
|
||||||
|
|
||||||
// Top-right corner for texture and quad
|
// Top-right corner for texture and quad
|
||||||
rlTexCoord2f(1.0f, 0.0f);
|
rlTexCoord2f(uvPoints[point][0], uvPoints[point][1]);
|
||||||
|
point = (point + 1) % 4;
|
||||||
rlVertex2f((float)RLGL.State.framebufferWidth, (float)RLGL.State.framebufferHeight);
|
rlVertex2f((float)RLGL.State.framebufferWidth, (float)RLGL.State.framebufferHeight);
|
||||||
|
|
||||||
// Top-left corner for texture and quad
|
// Top-left corner for texture and quad
|
||||||
rlTexCoord2f(1.0f, 1.0f);
|
rlTexCoord2f(uvPoints[point][0], uvPoints[point][1]);
|
||||||
|
point = (point + 1) % 4;
|
||||||
rlVertex2f((float)RLGL.State.framebufferWidth, 0.0f);
|
rlVertex2f((float)RLGL.State.framebufferWidth, 0.0f);
|
||||||
rlEnd();
|
rlEnd();
|
||||||
rlPopMatrix();
|
rlPopMatrix();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user