Skip to content

Instantly share code, notes, and snippets.

@toughrogrammer
Created October 24, 2014 15:54
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toughrogrammer/206e9eac27fb50e51fc9 to your computer and use it in GitHub Desktop.
Save toughrogrammer/206e9eac27fb50e51fc9 to your computer and use it in GitHub Desktop.
helloworld for opengl & glut with clion
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="ProjectRootManager" version="2" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/helloworld.iml" filepath="$PROJECT_DIR$/.idea/helloworld.iml" />
</modules>
</component>
</project>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
cmake_minimum_required(VERSION 2.8.4)
project(helloworld)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#########################################################
# Include Files
#########################################################
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
)
include(src/CMakeLists.txt)
add_executable (helloworld
main.cpp
${SOURCE_FILES})
IF (APPLE)
include_directories (/System/Library/Frameworks)
find_library (GLUT_LIBRARY GLUT)
find_library (OpenGL_LIBRARY OpenGL)
mark_as_advanced (GLUT_LIBRARY
OpenGL_LIBRARY)
set (EXTRA_LIBS ${GLUT_LIBRARY} ${OpenGL_LIBRARY})
ENDIF (APPLE)
target_link_libraries(helloworld ${EXTRA_LIBS})
#include <iostream>
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
using namespace std;
void display() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 500.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(2, 2, 2, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef(.005,.005,.005);
glRotatef(20, 0, 1, 0);
glRotatef(30, 0, 0, 1);
glRotatef(5, 1, 0, 0);
glTranslatef(-300, 0, 0);
glColor3f(1,1,1);
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'H');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'e');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'l');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'l');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'o');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'W');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'o');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'r');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'l');
glutStrokeCharacter(GLUT_STROKE_ROMAN, 'd');
glutStrokeCharacter(GLUT_STROKE_ROMAN, '!');
glutSwapBuffers();
} /* end func displayCall */
int main(int argc, char *argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(500, 500);
glutInitWindowPosition(300, 200);
glutCreateWindow("Hello World!");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
set (SOURCE_FILES
src/Guy.h
src/Cool.h
src/Cool.cpp
src/Shy.h
src/Shy.cpp
)
#include "Cool.h"
#include <iostream>
using namespace std;
void Cool::Say() {
cout << "I'm cool guy!" << endl;
}
#ifndef _COOL_H_
#define _COOL_H_
#include "Guy.h"
class Cool : public Guy {
public:
virtual void Say() override;
};
#endif
#ifndef _GUY_H_
#define _GUY_H_
class Guy {
public:
virtual void Say() = 0;
};
#endif
#include "Shy.h"
#include <iostream>
using namespace std;
void Shy::Say() {
cout << "I'm shy guy...." << endl;
}
#ifndef _SHY_H_
#define _SHY_H_
#include "Guy.h"
class Shy : public Guy
{
public:
virtual void Say() override;
};
#endif
@iSevenDays
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment