This is one code definition of the required egress window in a bedroom.
EMERGENCY ESCAPE AND RESCUE REQUIRED SECTION: R 310.1 Basements and every sleeping room shall have at least one operable emergency and rescue opening. Such opening shall open directly into a public street, public alley, yard or court. Where basements contain one or more sleeping rooms, emergency egress and rescue openings shall be required in each sleeping room, but shall not be required in adjoining areas of the basement. Where emergency escape and rescue openings are provided, they shall have a sill height of not more than 44 inches (1,118mm) above the floor. Where a door opening having a threshold below the adjacent ground elevation serves as an emergency escape and rescue opening and is provided with a bulkhead enclosure, the bulkhead enclosure shall comply with SECTION R310.3. The net clear opening dimensions required by this section shall be obtained by the normal operation of the emergency escape and rescue opening from the inside. Emergency escape and rescue openings with a finished sill height below the adjacent ground elevation shall be provided with a window well, in accordance with SECTION R310.2. ◦MINIMUM OPENING AREA: SECTION: R 310.1.1 All emergency escape and rescue openings shall have a minimum net clear opening of 5.7 square feet (0.530 m2). Exception: Grade floor openings shall have a minimum net clear opening of 5 square feet (0.465 m2).
◦MINIMUM OPENING HEIGHT: R 310.1.2 The minimum net clear opening height shall be 24 inches (610mm).
◦MINIMUM OPENING WIDTH: R 310.1.3 The minimum net clear opening width shall be 20 inches (508mm).
◦OPERATIONAL CONSTRAINTS: R 310.1.4 Emergency escape and rescue openings shall be operational from the inside of the room without the use of keys or tools or special knowledge.
Beyond, that the room would require a permanent source of heat, a smoke alarm, net amount of daylight (window glass area) as a percentage of room floor area, a minimum ceiling height, enough electrical outlets, a switch controlled ceiling light, or outlet for a lamp, and other requirements, depending on the local jurisdiction. Local authorities, and appraisers, could requirements a closet. It appears that the requirements for closets are based on outdated rules and myths. In my area, a room with a closet is counted as a bedroom, but there is no requirement for a bedroom to have a closet. This makes sense when used as a tool to design on site septic systems. The systems are sized by the number of bedroom in the house, which gives some idea of the occupant load the system needs to handle. As an example, a homeowner in my neighborhood took a portion of a walk out basement and converted it to a finished bedroom. He had all the legal requirements of a bedroom, but did the job without a permit. He got caught and was informed that he needed about $15K in expansion work done to his septic system to accommodate the additional bedroom, since he had created a five bedroom house. After a battle, he removed the closet and the room magically became an office.