15#ifndef CSCI441_OBJECTS_HPP
16#define CSCI441_OBJECTS_HPP
22#ifdef CSCI441_USE_GLEW
28#include <glm/gtc/constants.hpp>
47 void setVertexAttributeLocations( GLint positionLocation, GLint normalLocation = -1, GLint texCoordLocation = -1, GLint tangentLocation = -1 );
71 [[maybe_unused]]
void drawSolidCone( GLfloat base, GLfloat height, GLint stacks, GLint slices );
84 [[maybe_unused]]
void drawWireCone( GLfloat base, GLfloat height, GLint stacks, GLint slices );
119 [[maybe_unused]]
void drawWireCube( GLfloat sideLength );
127 [[maybe_unused]]
void drawCubeMap( GLfloat sideLength );
142 [[maybe_unused]]
void drawSolidCylinder( GLfloat base, GLfloat top, GLfloat height, GLint stacks, GLint slices );
156 [[maybe_unused]]
void drawWireCylinder( GLfloat base, GLfloat top, GLfloat height, GLint stacks, GLint slices );
171 [[maybe_unused]]
void drawSolidDisk( GLfloat inner, GLfloat outer, GLint slices, GLint rings );
185 [[maybe_unused]]
void drawWireDisk( GLfloat inner, GLfloat outer, GLint slices, GLint rings );
204 [[maybe_unused]]
void drawSolidPartialDisk( GLfloat inner, GLfloat outer, GLint slices, GLint rings, GLfloat start, GLfloat sweep );
222 [[maybe_unused]]
void drawWirePartialDisk( GLfloat inner, GLfloat outer, GLint slices, GLint rings, GLfloat start, GLfloat sweep );
234 [[maybe_unused]]
void drawSolidSphere( GLfloat radius, GLint stacks, GLint slices );
245 [[maybe_unused]]
void drawWireSphere( GLfloat radius, GLint stacks, GLint slices );
268 [[maybe_unused]]
void drawWireHalfSphere( GLfloat radius, GLint stacks, GLint slices );
280 [[maybe_unused]]
void drawSolidDome( GLfloat radius, GLint stacks, GLint slices );
291 [[maybe_unused]]
void drawWireDome( GLfloat radius, GLint stacks, GLint slices );
320 [[maybe_unused]]
void drawSolidTorus( GLfloat innerRadius, GLfloat outerRadius, GLint sides, GLint rings );
333 [[maybe_unused]]
void drawWireTorus( GLfloat innerRadius, GLfloat outerRadius, GLint sides, GLint rings );
341 const GLint positionLocation,
342 const GLint normalLocation,
343 const GLint texCoordLocation,
344 const GLint tangentLocation
346 CSCI441_INTERNAL::_positionAttributeLocation = positionLocation;
347 CSCI441_INTERNAL::_normalAttributeLocation = normalLocation;
348 CSCI441_INTERNAL::_texCoordAttributeLocation = texCoordLocation;
349 CSCI441_INTERNAL::_tangentAttributeLocation = tangentLocation;
350 CSCI441_INTERNAL::setTeapotAttributeLocations(positionLocation, normalLocation, texCoordLocation, tangentLocation);
355 CSCI441_INTERNAL::deleteObjectVAOs();
360 CSCI441_INTERNAL::deleteObjectVBOs();
366 const GLfloat height,
370 assert( base > 0.0f );
371 assert( height > 0.0f );
372 assert( stacks > 0 );
373 assert( slices > 2 );
375 CSCI441_INTERNAL::drawCylinder( base, 0.0f, height, stacks, slices, GL_FILL );
381 const GLfloat height,
385 assert( base > 0.0f );
386 assert( height > 0.0f );
387 assert( stacks > 0 );
388 assert( slices > 2 );
390 CSCI441_INTERNAL::drawCylinder( base, 0.0f, height, stacks, slices, GL_LINE );
395 const GLfloat sideLength
402 const GLfloat sideLength
408 const GLfloat sideLength
410 assert( sideLength > 0.0f );
412 CSCI441_INTERNAL::drawCube( sideLength, GL_FILL );
416 const GLfloat sideLength
418 assert( sideLength > 0.0f );
420 CSCI441_INTERNAL::drawCubeFlat( sideLength, GL_FILL );
425 const GLfloat sideLength
427 assert( sideLength > 0.0f );
429 CSCI441_INTERNAL::drawCube( sideLength, GL_LINE );
434 const GLfloat sideLength
436 assert(sideLength > 0.0f);
438 CSCI441_INTERNAL::drawCube( sideLength, GL_FILL );
445 const GLfloat height,
449 assert( (base >= 0.0f && top > 0.0f) || (base > 0.0f && top >= 0.0f) );
450 assert( height > 0.0f );
451 assert( stacks > 0 );
452 assert( slices > 2 );
454 CSCI441_INTERNAL::drawCylinder( base, top, height, stacks, slices, GL_FILL );
461 const GLfloat height,
465 assert( (base >= 0.0f && top > 0.0f) || (base > 0.0f && top >= 0.0f) );
466 assert( height > 0.0f );
467 assert( stacks > 0 );
468 assert( slices > 2 );
470 CSCI441_INTERNAL::drawCylinder( base, top, height, stacks, slices, GL_LINE );
480 assert( inner >= 0.0f );
481 assert( outer > 0.0f );
482 assert( outer > inner );
483 assert( slices > 2 );
486 CSCI441_INTERNAL::drawPartialDisk( inner, outer, slices, rings, 0, glm::two_pi<GLfloat>(), GL_FILL );
496 assert( inner >= 0.0f );
497 assert( outer > 0.0f );
498 assert( outer > inner );
499 assert( slices > 2 );
502 CSCI441_INTERNAL::drawPartialDisk( inner, outer, slices, rings, 0, glm::two_pi<GLfloat>(), GL_LINE );
514 assert( inner >= 0.0f );
515 assert( outer > 0.0f );
516 assert( outer > inner );
517 assert( slices > 2 );
519 assert( start >= 0.0f && start <= 360.0f );
520 assert( sweep >= 0.0f && sweep <= 360.0f );
522 CSCI441_INTERNAL::drawPartialDisk( inner, outer, slices, rings, start * glm::pi<float>() / 180.0f, sweep * glm::pi<float>() / 180.0f, GL_FILL );
534 assert( inner >= 0.0f );
535 assert( outer > 0.0f );
536 assert( outer > inner );
537 assert( slices > 2 );
539 assert( start >= 0.0f && start <= 360.0f );
540 assert( sweep >= 0.0f && sweep <= 360.0f );
542 CSCI441_INTERNAL::drawPartialDisk( inner, outer, slices, rings, start * glm::pi<float>() / 180.0f, sweep * glm::pi<float>() / 180.0f, GL_LINE );
547 const GLfloat radius,
551 assert( radius > 0.0f );
552 assert( stacks > 1 );
553 assert( slices > 2 );
555 CSCI441_INTERNAL::drawSphere( radius, stacks, slices, GL_FILL );
560 const GLfloat radius,
564 assert( radius > 0.0f );
566 assert( slices > 2 );
568 CSCI441_INTERNAL::drawSphere( radius, stacks, slices, GL_LINE );
573 const GLfloat radius,
577 assert( radius > 0.0f );
578 assert( stacks > 1 );
579 assert( slices > 2 );
581 CSCI441_INTERNAL::drawHalfSphere( radius, stacks, slices, GL_FILL );
586 const GLfloat radius,
590 assert( radius > 0.0f );
592 assert( slices > 2 );
594 CSCI441_INTERNAL::drawHalfSphere( radius, stacks, slices, GL_LINE );
599 const GLfloat radius,
603 assert( radius > 0.0f );
604 assert( stacks > 1 );
605 assert( slices > 2 );
607 CSCI441_INTERNAL::drawDome( radius, stacks, slices, GL_FILL );
612 const GLfloat radius,
616 assert( radius > 0.0f );
618 assert( slices > 2 );
620 CSCI441_INTERNAL::drawDome( radius, stacks, slices, GL_LINE );
625 [[maybe_unused]]
const GLfloat unused
627 CSCI441_INTERNAL::drawTeapot(GL_FILL);
632 [[maybe_unused]]
const GLfloat unused
634 CSCI441_INTERNAL::drawTeapot(GL_LINE);
639 const GLfloat innerRadius,
640 const GLfloat outerRadius,
644 assert( innerRadius > 0.0f );
645 assert( outerRadius > 0.0f );
649 CSCI441_INTERNAL::drawTorus( innerRadius, outerRadius, sides, rings, GL_FILL );
654 const GLfloat innerRadius,
655 const GLfloat outerRadius,
659 assert( innerRadius > 0.0f );
660 assert( outerRadius > 0.0f );
664 CSCI441_INTERNAL::drawTorus( innerRadius, outerRadius, sides, rings, GL_LINE );
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17
void drawWireTeapot(GLfloat unused=0.0f)
Draws a wireframe teapot.
Definition: objects.hpp:631
void drawSolidCube(GLfloat sideLength)
Calls through to drawSolidCubeIndexed()
Definition: objects.hpp:394
void drawSolidCylinder(GLfloat base, GLfloat top, GLfloat height, GLint stacks, GLint slices)
Draws a solid open-ended cylinder.
Definition: objects.hpp:442
void drawWireCube(GLfloat sideLength)
Draws a wireframe cube.
Definition: objects.hpp:424
void drawSolidPartialDisk(GLfloat inner, GLfloat outer, GLint slices, GLint rings, GLfloat start, GLfloat sweep)
Draws part of a solid disk.
Definition: objects.hpp:506
void drawSolidDome(GLfloat radius, GLint stacks, GLint slices)
Draws a solid dome.
Definition: objects.hpp:598
void deleteObjectVBOs()
deletes the VBOs stored for all object types
Definition: objects.hpp:359
void deleteObjectVAOs()
deletes the VAOs stored for all object types
Definition: objects.hpp:354
void drawWireTorus(GLfloat innerRadius, GLfloat outerRadius, GLint sides, GLint rings)
Draws a wireframe torus.
Definition: objects.hpp:653
void drawWireDome(GLfloat radius, GLint stacks, GLint slices)
Draws a wireframe dome.
Definition: objects.hpp:611
void drawSolidCone(GLfloat base, GLfloat height, GLint stacks, GLint slices)
Draws a solid cone.
Definition: objects.hpp:364
void drawWireHalfSphere(GLfloat radius, GLint stacks, GLint slices)
Draws a wireframe half sphere with a bottom.
Definition: objects.hpp:585
void drawSolidCubeTextured(GLfloat sideLength)
Draws a solid textured cube. Calls through to drawSolidCubeFlat()
Definition: objects.hpp:401
void drawSolidTorus(GLfloat innerRadius, GLfloat outerRadius, GLint sides, GLint rings)
Draws a solid torus.
Definition: objects.hpp:638
void drawSolidHalfSphere(GLfloat radius, GLint stacks, GLint slices)
Draws a solid half sphere with a bottom.
Definition: objects.hpp:572
void drawSolidTeapot(GLfloat unused=0.0f)
Draws a solid teapot.
Definition: objects.hpp:624
void drawSolidCubeFlat(GLfloat sideLength)
Draws a solid cube with normals aligned with cube face.
Definition: objects.hpp:415
void drawWireSphere(GLfloat radius, GLint stacks, GLint slices)
Draws a wireframe sphere.
Definition: objects.hpp:559
void drawSolidSphere(GLfloat radius, GLint stacks, GLint slices)
Draws a solid sphere.
Definition: objects.hpp:546
void drawWireCone(GLfloat base, GLfloat height, GLint stacks, GLint slices)
Draws a wireframe cone.
Definition: objects.hpp:379
void drawSolidDisk(GLfloat inner, GLfloat outer, GLint slices, GLint rings)
Draws a solid disk.
Definition: objects.hpp:474
void drawSolidCubeIndexed(GLfloat sideLength)
Draws a solid cube.
Definition: objects.hpp:407
void drawCubeMap(GLfloat sideLength)
Draws a cube with 3D Texture Coordinates to map a cube map texture to it.
Definition: objects.hpp:433
void setVertexAttributeLocations(GLint positionLocation, GLint normalLocation=-1, GLint texCoordLocation=-1, GLint tangentLocation=-1)
Sets the attribute locations for vertex positions, normals, and texture coordinates.
Definition: objects.hpp:340
void drawWireDisk(GLfloat inner, GLfloat outer, GLint slices, GLint rings)
Draws a wireframe disk.
Definition: objects.hpp:490
void drawWirePartialDisk(GLfloat inner, GLfloat outer, GLint slices, GLint rings, GLfloat start, GLfloat sweep)
Draws part of a wireframe disk.
Definition: objects.hpp:526
void drawWireCylinder(GLfloat base, GLfloat top, GLfloat height, GLint stacks, GLint slices)
Draws a wireframe open-ended cylinder.
Definition: objects.hpp:458
Helper functions to draw 3D OpenGL 3.0+ objects.
Helper functions to draw teapot with OpenGL 3.0+.