initial commit

This commit is contained in:
Xoro-1337
2025-07-31 22:29:51 -04:00
commit 3ac06f636e
123 changed files with 46603 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
# Design Document
## Overview
This design outlines a simple, cross-platform demo application built with GLFW3 for window management and Nuklear for immediate mode GUI rendering. The application is designed to be minimal and straightforward, serving as a basic example of integrating these technologies.
The core design principle is simplicity - create a working demo that shows basic Nuklear GUI elements in a GLFW window with minimal code complexity.
## Architecture
The application uses a simple, single-file architecture:
```
┌─────────────────────────────────┐
│ Main Application │ ← Single main.c file
│ ┌─────────────────────────────┐ │
│ │ GLFW3 Window Setup │ │ ← Window creation & events
│ ├─────────────────────────────┤ │
│ │ Nuklear Integration │ │ ← GUI context & rendering
│ ├─────────────────────────────┤ │
│ │ Simple UI Demo │ │ ← Basic UI components
│ └─────────────────────────────┘ │
└─────────────────────────────────┘
```
### Key Design Decisions
1. **Single File**: Everything in one main.c file for simplicity
2. **OpenGL Backend**: Using Nuklear's OpenGL3 backend for cross-platform compatibility
3. **Minimal Dependencies**: Only GLFW3, OpenGL, and Nuklear (header-only)
4. **Basic UI Elements**: Simple buttons, text, and input fields for demonstration
## Components and Interfaces
### Main Application Structure
The application consists of simple functions organized in a single file:
```c
// Core application functions
int main(int argc, char** argv);
void init_glfw(void);
void init_nuklear(void);
void render_ui(struct nk_context* ctx);
void cleanup(void);
// Simple state variables
static GLFWwindow* window;
static struct nk_context* ctx;
static int window_width = 800;
static int window_height = 600;
```
### Basic UI Demo Functions
Simple functions to demonstrate different Nuklear UI elements:
```c
// Demo UI functions
void demo_basic_widgets(struct nk_context* ctx);
void demo_text_input(struct nk_context* ctx);
void demo_buttons(struct nk_context* ctx);
```
## Data Models
### Simple State Variables
The demo uses minimal global state:
```c
// UI state for demo
static char text_buffer[256] = "Hello World!";
static float slider_value = 0.5f;
static int checkbox_value = 1;
static int option_selected = 0;
```
## Error Handling
### Simple Error Handling
Basic error checking with immediate exit on failure:
```c
// Simple error checking pattern
if (!glfwInit()) {
fprintf(stderr, "Failed to initialize GLFW\n");
exit(EXIT_FAILURE);
}
if (!window) {
fprintf(stderr, "Failed to create window\n");
glfwTerminate();
exit(EXIT_FAILURE);
}
```
## Testing Strategy
### Manual Testing
- **Build Testing**: Verify compilation on Windows, Linux, and macOS
- **Visual Testing**: Ensure UI elements render correctly
- **Interaction Testing**: Test basic button clicks, text input, and sliders
- **Window Testing**: Test window resize and close functionality
## Implementation Notes
### Build System
- **Simple Makefile or CMake**: Basic build configuration
- **Dependencies**: GLFW3, OpenGL, Nuklear (single header file)
- **Compiler**: C99 standard for maximum compatibility
### File Structure
```
project/
├── main.c # Single source file
├── nuklear.h # Nuklear header (downloaded)
├── nuklear_glfw_gl3.h # Nuklear GLFW+OpenGL3 backend
├── CMakeLists.txt # Build configuration
└── README.md # Build instructions
```
### Cross-Platform Notes
- Use GLFW3 for consistent window management across platforms
- OpenGL 3.3 core profile for modern graphics support
- Standard C library functions only for maximum portability

View File

@@ -0,0 +1,62 @@
# Requirements Document
## Introduction
This feature involves creating a clean, standalone desktop GUI application using GLFW3 and Nuklear. The application will provide a professional desktop application interface with basic UI components and proper window management, serving as a foundation for building native desktop applications.
## Requirements
### Requirement 1
**User Story:** As a developer, I want a basic desktop window framework using GLFW3 and Nuklear, so that I can build native desktop applications with a clean interface.
#### Acceptance Criteria
1. WHEN the application starts THEN the system SHALL create a main desktop window using GLFW3
2. WHEN the window is created THEN the system SHALL initialize Nuklear rendering context with OpenGL backend
3. WHEN the application runs THEN the system SHALL maintain a stable render loop with proper frame timing
4. WHEN the user closes the window THEN the system SHALL properly cleanup all resources and exit gracefully
### Requirement 2
**User Story:** As a user, I want to see a clean desktop application interface, so that I can interact with the application like any other native desktop program.
#### Acceptance Criteria
1. WHEN the application starts THEN the system SHALL display a window with native desktop appearance
2. WHEN the window is displayed THEN the system SHALL show a proper title bar with application name
3. WHEN the window is rendered THEN the system SHALL use appropriate desktop styling and colors
4. WHEN the application runs THEN the system SHALL respond to standard window operations (minimize, maximize, resize)
### Requirement 3
**User Story:** As a user, I want to interact with basic UI components, so that I can perform common application tasks.
#### Acceptance Criteria
1. WHEN the interface is displayed THEN the system SHALL show basic UI components (buttons, text inputs, labels)
2. WHEN the user clicks a button THEN the system SHALL provide visual feedback and execute the associated action
3. WHEN the user types in text inputs THEN the system SHALL capture and display the input text
4. WHEN UI components are rendered THEN the system SHALL maintain consistent styling and layout
### Requirement 4
**User Story:** As a user, I want the application window to be resizable and responsive, so that I can adjust it to fit my desktop workflow.
#### Acceptance Criteria
1. WHEN the user resizes the window THEN the system SHALL adjust the UI layout accordingly
2. WHEN the window size changes THEN the system SHALL maintain proper proportions of UI elements
3. WHEN the window is minimized or maximized THEN the system SHALL handle state changes properly
4. WHEN the application is resized THEN the system SHALL maintain minimum window dimensions for usability
### Requirement 5
**User Story:** As a developer, I want the application structure to be modular and extensible, so that I can easily add new features and UI components.
#### Acceptance Criteria
1. WHEN adding new UI components THEN the system SHALL provide a clear structure for component organization
2. WHEN the application initializes THEN the system SHALL separate rendering logic from application logic
3. WHEN components are created THEN the system SHALL support easy addition of new UI elements
4. WHEN the application runs THEN the system SHALL maintain clean separation between GLFW, Nuklear, and application code

View File

@@ -0,0 +1,83 @@
# Implementation Plan
- [x] 1. Set up project structure and dependencies
- Create project directory structure with main.c file
- Download Nuklear header files (nuklear.h and nuklear_glfw_gl3.h)
- Create CMakeLists.txt for cross-platform building
- _Requirements: 1.1, 1.2_
-
- [x] 2. Implement basic GLFW3 window setup
- Initialize GLFW library and create window context
- Set up OpenGL context with proper version (3.3 core)
- Implement basic window callbacks for resize and close events
- Add main render loop with proper frame timing
- _Requirements: 1.1, 1.4, 2.1, 2.4_
- [x] 3. Integrate Nuklear with GLFW3 and OpenGL
- Initialize Nuklear context with GLFW+OpenGL3 backend
- Set up Nuklear input handling from GLFW events
- Implement basic Nuklear rendering pipeline
- Add proper cleanup for Nuklear resources
- _Requirements: 1.2, 2.2, 2.3_
- [x] 4. Create basic UI demonstration components
- Implement simple window with title bar showing application name
- Add basic UI elements: buttons, text labels, text input field
- Create slider component for demonstrating value controls
- Add checkbox and radio button examples
- _Requirements: 2.2, 3.1, 3.2, 3.3_
- [x] 5. Implement window responsiveness and layout
- Add proper window resize handling that adjusts UI layout
- Implement minimum window size constraints
- Ensure UI elements scale appropriately with window size
- Test window maximize, minimize, and restore functionality
- _Requirements: 4.1, 4.2, 4.3, 4.4_
- [x] 6. Add modular UI component structure
- Separate UI rendering into distinct functions for different components
- Create clean interface between GLFW, Nuklear, and application code
- Implement simple state management for UI component values
- Add structure that allows easy addition of new UI elements
- _Requirements: 5.1, 5.2, 5.3, 5.4_
- [ ] 7. Create build system and documentation
- Write CMakeLists.txt that works on Windows, Linux, and macOS
- Create simple Makefile as alternative build option
- Add README.md with build instructions and dependencies
- Test compilation on multiple platforms
- _Requirements: 1.1, 1.4_