added text to sliders
This commit is contained in:
parent
790fee53b5
commit
a1292ce40f
3 changed files with 25 additions and 20 deletions
|
@ -6,9 +6,6 @@ Code here is published under the [AGPL-v3](https://www.gnu.org/licenses/agpl-3.0
|
|||
|
||||
# TODO
|
||||
|
||||
- User controlled light source
|
||||
- Add light source
|
||||
- move the light
|
||||
- change intensity
|
||||
- Add popping-floating text of funny cow thoughts when in cow view
|
||||
- Add Textures and stuff :)(optional)
|
||||
- Construct the required pdf with explanations and screenshots
|
||||
- Properly comment the code :/
|
1
cow.c
1
cow.c
|
@ -189,6 +189,7 @@ void drawCow(char cowsPOV) {
|
|||
glColor3f(1.0, 1.0, 1.0);
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
void onCowKeyboardInput(char key) {
|
||||
switch(control) {
|
||||
case COW_CONTROL_MOVE:
|
||||
|
|
37
mmn_17.c
37
mmn_17.c
|
@ -14,7 +14,7 @@
|
|||
#define PI 3.14
|
||||
|
||||
// user controlled light thing
|
||||
vec3 lightPos = { 0.0, 0.0, 0.0 };
|
||||
vec3 lightPos = { 0.0, 10, 25.0 };
|
||||
|
||||
// Camera rotation and stuff
|
||||
float camRadius = 40.0;
|
||||
|
@ -70,39 +70,39 @@ ui_slider sliders[] = {
|
|||
0.3
|
||||
},
|
||||
{ // user light - red
|
||||
/* pos */ { { 0.1, 0.9, 0.0 }, { 0.0, -10.0, 0.0 } },
|
||||
/* pos */ { { 0., 0.9, 0.0 }, { 20.0, -10.0, 0.0 } },
|
||||
/* size */ { 100.0, 10.0, 10.0 },
|
||||
0.0
|
||||
},
|
||||
{ // user light - green
|
||||
/* pos */ { { 0.1, 0.9, 0.0 }, { 0.0, -40.0, 0.0 } },
|
||||
/* pos */ { { 0.0, 0.9, 0.0 }, { 20.0, -40.0, 0.0 } },
|
||||
/* size */ { 100.0, 10.0, 10.0 },
|
||||
0.0
|
||||
},
|
||||
{ // user light - blue
|
||||
/* pos */ { { 0.1, 0.9, 0.0 }, { 0.0, -70.0, 0.0 } },
|
||||
/* pos */ { { 0.0, 0.9, 0.0 }, { 20.0, -70.0, 0.0 } },
|
||||
/* size */ { 100.0, 10.0, 10.0 },
|
||||
0.0
|
||||
1.0
|
||||
},
|
||||
{ // user light - movement step
|
||||
/* pos */ { { 0.1, 0.9, 0.0 }, { 0.0, -100.0, 0.0 } },
|
||||
/* pos */ { { 0.0, 0.9, 0.0 }, { 20.0, -100.0, 0.0 } },
|
||||
/* size */ { 100.0, 10.0, 10.0 },
|
||||
0.2
|
||||
},
|
||||
{ // user light - constant attenuation
|
||||
/* pos */ { { 0.1, 0.9, 0.0 }, { 0.0, -130.0, 0.0 } },
|
||||
/* pos */ { { 0.0, 0.9, 0.0 }, { 20.0, -130.0, 0.0 } },
|
||||
/* size */ { 100.0, 10.0, 10.0 },
|
||||
0.0
|
||||
},
|
||||
{ // user light - linear attenuation
|
||||
/* pos */ { { 0.1, 0.9, 0.0 }, { 0.0, -160.0, 0.0 } },
|
||||
/* pos */ { { 0.0, 0.9, 0.0 }, { 20.0, -160.0, 0.0 } },
|
||||
/* size */ { 100.0, 10.0, 10.0 },
|
||||
0.0
|
||||
},
|
||||
{ // user light - cubic attenuation
|
||||
/* pos */ { { 0.1, 0.9, 0.0 }, { 0.0, -190.0, 0.0 } },
|
||||
/* pos */ { { 0.0, 0.9, 0.0 }, { 20.0, -190.0, 0.0 } },
|
||||
/* size */ { 100.0, 10.0, 10.0 },
|
||||
0.0
|
||||
0.5
|
||||
},
|
||||
};
|
||||
// sliders named, struct to give sliders a name, they are stored in an array to ease handling them
|
||||
|
@ -224,7 +224,14 @@ void drawUi(void) {
|
|||
glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, td);
|
||||
glRasterPos2f(wWidth * 0.9 - glutBitmapLength(GLUT_BITMAP_TIMES_ROMAN_24, tr) * 0.5, wHeight * 0.9 - 150.0);
|
||||
glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, tr);
|
||||
|
||||
// light sliders
|
||||
unsigned char t2[] = "Light orb";
|
||||
unsigned char side[] = "r\ng\nb\nSpeed\nConstant Atten\nLinear Atten\nQuadraic Atten";
|
||||
glRasterPos2f(10.0, wHeight * 0.9 + 20.0);
|
||||
glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, t2);
|
||||
glRasterPos2f(140.0, wHeight * 0.9 - 10.0);
|
||||
glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, side);
|
||||
|
||||
if(settings.showHelp) {
|
||||
glColor3f(0.3, 0.3, 0.3);
|
||||
glBegin(GL_QUADS);
|
||||
|
@ -281,9 +288,9 @@ void drawWorld(void) {
|
|||
glLightfv(GL_LIGHT1, GL_AMBIENT, ulColor);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, ulColor);
|
||||
glLightfv(GL_LIGHT1, GL_SPECULAR, ulColor);
|
||||
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, slidersN.lightConAtten->value * 10.0 + 0.01);
|
||||
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, slidersN.lightLinAtten->value * 0.5);
|
||||
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, slidersN.lightQuadAtten->value * 0.5);
|
||||
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, slidersN.lightConAtten->value * 5.0 + 0.01);
|
||||
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, slidersN.lightLinAtten->value * 0.3);
|
||||
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, slidersN.lightQuadAtten->value * 0.01);
|
||||
// draw a little glowing orb where it stands
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
@ -516,7 +523,7 @@ int main(int argc, char** argv) {
|
|||
/* initialize glut and window */
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
|
||||
glutInitWindowSize(800, 500);
|
||||
glutInitWindowSize(1280, 720);
|
||||
glutInitWindowPosition(450, 450);
|
||||
/* create window and set callbacks */
|
||||
glutCreateWindow("World of Cow - Aviv Romem");
|
||||
|
|
Loading…
Reference in a new issue