Project 1 – Interactive 2D Geometry

This is my submission for Project 1 – Interactive 2D Geometry.

Description

This project implements an interactive OpenGL application. Users can move, scale, and rotate a textured square loaded from a PPM image. Pressing ‘r’ resets the square to its initial state.

Translation (Drag Inside Square)

Translating only when the user drags inside the square (not edges)

Scaling

Scaling the square when dragging from corners

Rotation

Rotating the square when dragging from edges

Texture Loading

Before applying texture:

Brightening the Texture

Before brightening:

After brightening:

Resetting Square ('r' Key)

Visual Change via Keyboard

Background color change triggered by keyboard input

Textured Triangle (Toggle Shape)

Toggling between triangle and square shape

Animation (No Per-Frame Input)

Animation triggered by holding down the 'M' key

Maintaining Shape on Window Resize

Square keeps its shape when window is resized

Difficulties Encountered

While completing Project 1 I encountered several challenges related to animation logic, shape control, optimization of the initial approach, and real-time input handling. One difficulty was accounting for all edge cases when designing the logic for smooth scaling and rotation. Although the initial setup was straightforward, debugging and improving interactivity took considerable time. Another issue was getting the animation to run smoothly without relying on continuous mouse or key input, which required understanding SDL’s event loop and decoupling logic from frame-based input. Maintaining a perfect square shape during window resizing was also tricky and required correcting for aspect ratio distortion. Texture mapping using a PPM file and applying a brightening effect without color distortion introduced challenges with pixel-level image handling. Finally, due to GitHub’s file size limitations, I had to convert large `.gif` files into `.mp4` and host the code externally via Google Drive for submission. These difficulties gave me deeper insight into OpenGL rendering, coordinate transformations, and deployment workflows.

Download Code & Executable

Download from Google Drive

Project Setup on Windows Visual Studio IDE

View Setup Instructions (README.md)