| 97 | } |
| 98 | |
| 99 | void CaptureBasicApp::draw() |
| 100 | { |
| 101 | gl::clear( Color( 0.1f, 0.1f, 0.1f ) ); |
| 102 | gl::enableAlphaBlending(); |
| 103 | |
| 104 | // Draw video texture centered and scaled to fit window |
| 105 | if( mTexture ) { |
| 106 | Rectf destRect = Rectf( mTexture->getBounds() ).getCenteredFit( getWindowBounds(), true ); |
| 107 | gl::draw( mTexture, destRect ); |
| 108 | } |
| 109 | |
| 110 | // Draw ImGui |
| 111 | if( mShowUI ) { |
| 112 | ImGui::Begin( "Video Capture Control" ); |
| 113 | |
| 114 | // Device selection or "No devices" message |
| 115 | if( ! mDevices.empty() ) { |
| 116 | // Ensure selected index is valid |
| 117 | if( mSelectedDeviceIndex >= (int)mDevices.size() ) { |
| 118 | mSelectedDeviceIndex = 0; |
| 119 | } |
| 120 | |
| 121 | // Device dropdown |
| 122 | if( ImGui::BeginCombo( "Camera Device", mDevices[mSelectedDeviceIndex]->getName().c_str() ) ) { |
| 123 | for( int i = 0; i < mDevices.size(); i++ ) { |
| 124 | bool isSelected = ( mSelectedDeviceIndex == i ); |
| 125 | if( ImGui::Selectable( mDevices[i]->getName().c_str(), isSelected ) ) { |
| 126 | if( mSelectedDeviceIndex != i ) { |
| 127 | mSelectedDeviceIndex = i; |
| 128 | updateModes(); |
| 129 | // Reset to auto mode when switching devices |
| 130 | mSelectedModeIndex = -1; |
| 131 | setupCapture( mDevices[i] ); |
| 132 | } |
| 133 | } |
| 134 | if( isSelected ) { |
| 135 | ImGui::SetItemDefaultFocus(); |
| 136 | } |
| 137 | } |
| 138 | ImGui::EndCombo(); |
| 139 | } |
| 140 | } |
| 141 | else { |
| 142 | // Show message when no devices available |
| 143 | ImGui::TextColored( ImVec4( 1.0f, 0.6f, 0.0f, 1.0f ), "No Capture Devices Found" ); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | // Mode selection dropdown - only show when we have devices |
| 148 | if( ! mDevices.empty() && ! mCurrentModes.empty() ) { |
| 149 | // Determine display text for current mode |
| 150 | string modeDescription; |
| 151 | if( mSelectedModeIndex == -1 ) { |
| 152 | // Auto mode - try to match current resolution with available modes |
| 153 | if( mCapture ) { |
| 154 | int currentWidth = mCapture->getWidth(); |
| 155 | int currentHeight = mCapture->getHeight(); |
| 156 |
nothing calls this directly
no test coverage detected