-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c191b63
Showing
7 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ignore compiled binaries | ||
/bin/ | ||
/obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This is the Makefile for Hello GLUT. It builds the Hello GLUT executable. | ||
|
||
# Directories containing C headers. Edit to match path containing freeglut headers. | ||
INCLUDE_DIRS = -I.\include -I"C:\Program Files\Common Files\freeglut\include" | ||
|
||
# Directories containing import libraries. Edit to match path containing freeglut libs. | ||
LIB_DIRS = -L"C:\Program Files\Common Files\freeglut\lib" | ||
|
||
# Warnings to be raised by the C compiler | ||
WARNS = -Wall | ||
|
||
# Names of tools to use when building | ||
CC = gcc | ||
|
||
# Compiler and linker flags | ||
CFLAGS = -O3 -std=c99 -D _WIN32_IE=0x0500 -D WINVER=0x500 ${WARNS} ${INCLUDE_DIRS} | ||
LDFLAGS = -s -lfreeglut -lopengl32 -Wl,--subsystem,windows ${LIB_DIRS} | ||
|
||
# Object files to create Hello GLUT exe | ||
OBJS = obj/Callbacks.o \ | ||
obj/HelloGLUT.o | ||
|
||
.PHONY: all clean | ||
|
||
all: bin/HelloGLUT.exe | ||
|
||
clean: | ||
if exist obj\*.o del obj\*.o | ||
if exist bin\HelloGLUT.exe del bin\HelloGLUT.exe | ||
|
||
obj: | ||
@if not exist obj mkdir obj | ||
|
||
bin: | ||
@if not exist bin mkdir bin | ||
|
||
bin/HelloGLUT.exe: ${OBJS} | bin | ||
${CC} -o "$@" ${OBJS} ${LDFLAGS} | ||
|
||
obj/%.o: src/%.c | obj | ||
${CC} ${CFLAGS} -c $< -o $@ | ||
|
||
# Dependencies | ||
obj/HelloGLUT.o: include/Callbacks.h | ||
obj/Callbacks.o: include/Callbacks.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Hello GLUT | ||
|
||
## Table of Contents | ||
|
||
- [Introduction](#introduction) | ||
- [Building the Application](#building-the-application) | ||
- [Terms of Use](#terms-of-use) | ||
- [Problems?](#problems) | ||
- [Changelog](#changelog) | ||
|
||
## Introduction | ||
|
||
This application is an example Windows GUI application, written to demonstrate | ||
how to build [freeglut](http://freeglut.sourceforge.net/) applications with | ||
MinGW. It accompanies the | ||
[Using freeglut or GLUT with MinGW](http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/) | ||
article on [Transmission Zero](http://www.transmissionzero.co.uk/). | ||
|
||
The application demonstrates how to process key presses and how to display a | ||
basic shape in a window. It doesn't attempt to do anything fancy, as it's really | ||
just a "Hello world!" example. | ||
|
||
Although the application targets freeglut, there's no reason why it can't use a | ||
compatible alternative GLUT implementation, e.g. Nate Robins' GLUT for Win32. | ||
Similarly, it should be possible to cross-compile the application on a | ||
non-Windows machine, compile the application to target a non-Windows machine, or | ||
build with tools other than MinGW. However, some changes to the Makefile will | ||
likely be needed. | ||
|
||
## Building the Application | ||
|
||
Before you start, changes to the Makefile may be needed. Firstly, the | ||
"INCLUDE_DIRS" and "LIB_DIRS" may need to be updated if your GLUT header files | ||
and import libraries are in a different location. Secondly, the "LDFLAGS" flags | ||
may need to be changed if you're not using freeglut. For example, if you're | ||
using GLUT for Win32, change "-lfreeglut" to "-lglut32". | ||
|
||
To build the application on a Windows machine, open a command prompt, change to | ||
the directory containing the Makefile, and type "mingw32-make". The application | ||
should be compiled, linked, and output as "HelloGLUT.exe". The appropriate GLUT | ||
DLL will either need to be in the same directory as the executable, or will need | ||
to be in a directory referenced in your "%PATH%" environment variable. | ||
|
||
## Terms of Use | ||
|
||
Refer to "License.txt" for terms of use. | ||
|
||
## Problems? | ||
|
||
If you have any problems or questions, please ensure you have read this readme | ||
file and the | ||
[Using freeglut or GLUT with MinGW](http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/) | ||
article. If you are still having trouble, you can | ||
[get in contact](http://www.transmissionzero.co.uk/contact/). | ||
|
||
## Changelog | ||
|
||
1. 2016-08-28: Version 1.0 | ||
- Initial release. | ||
|
||
Transmission Zero | ||
2016-08-28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef CALLBACKS_H | ||
#define CALLBACKS_H | ||
|
||
/* Callback function declarations */ | ||
void keyboard(unsigned char key, int x, int y); | ||
void display(void); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <stdlib.h> | ||
#include <GL/glut.h> | ||
#include "Callbacks.h" | ||
|
||
/* Keyboard callback function */ | ||
void keyboard(unsigned char key, int x, int y) | ||
{ | ||
switch (key) | ||
{ | ||
/* Exit on escape key press */ | ||
case '\x1B': | ||
{ | ||
exit(EXIT_SUCCESS); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
/* Display callback function */ | ||
void display() | ||
{ | ||
glClear(GL_COLOR_BUFFER_BIT); | ||
|
||
/* Display a red square */ | ||
glColor3f(1.0f, 0.0f, 0.0f); | ||
|
||
glBegin(GL_POLYGON); | ||
glVertex2f(-0.5f, -0.5f); | ||
glVertex2f( 0.5f, -0.5f); | ||
glVertex2f( 0.5f, 0.5f); | ||
glVertex2f(-0.5f, 0.5f); | ||
glEnd(); | ||
|
||
glFlush(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* This is a very basic Windows C application for testing GLUT (and compatible | ||
* implementations such as freeglut). It displays a red square, and exits when | ||
* the escape key is pressed. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <GL/glut.h> | ||
#include "Callbacks.h" | ||
|
||
/* Main method */ | ||
int main(int argc, char** argv) | ||
{ | ||
glutInit(&argc, argv); | ||
|
||
/* Create a single window with a keyboard and display callback */ | ||
glutCreateWindow("GLUT Test"); | ||
glutKeyboardFunc(&keyboard); | ||
glutDisplayFunc(&display); | ||
|
||
/* Run the GLUT event loop */ | ||
glutMainLoop(); | ||
|
||
return EXIT_SUCCESS; | ||
} |