Some code tweaks
This commit is contained in:
parent
823abf666e
commit
cbbe948529
3 changed files with 18 additions and 13 deletions
|
@ -77,9 +77,9 @@ int main()
|
||||||
light.specIntensity = 1.0f;
|
light.specIntensity = 1.0f;
|
||||||
|
|
||||||
// Material initialization
|
// Material initialization
|
||||||
matBlinn.diffuse = WHITE;
|
matBlinn.colDiffuse = WHITE;
|
||||||
matBlinn.ambient = (Color){ 50, 50, 50, 255 };
|
matBlinn.colAmbient = (Color){ 50, 50, 50, 255 };
|
||||||
matBlinn.specular = WHITE;
|
matBlinn.colSpecular = WHITE;
|
||||||
matBlinn.glossiness = 50.0f;
|
matBlinn.glossiness = 50.0f;
|
||||||
|
|
||||||
// Setup camera
|
// Setup camera
|
||||||
|
@ -129,8 +129,8 @@ int main()
|
||||||
SetShaderValue(shader, lSpecIntensityLoc, &light.specIntensity, 1);
|
SetShaderValue(shader, lSpecIntensityLoc, &light.specIntensity, 1);
|
||||||
|
|
||||||
// Send material values to shader
|
// Send material values to shader
|
||||||
SetShaderValue(shader, mAmbientLoc, ColorToFloat(matBlinn.ambient), 3);
|
SetShaderValue(shader, mAmbientLoc, ColorToFloat(matBlinn.colAmbient), 3);
|
||||||
SetShaderValue(shader, mSpecularLoc, ColorToFloat(matBlinn.specular), 3);
|
SetShaderValue(shader, mSpecularLoc, ColorToFloat(matBlinn.colSpecular), 3);
|
||||||
SetShaderValue(shader, mGlossLoc, &matBlinn.glossiness, 1);
|
SetShaderValue(shader, mGlossLoc, &matBlinn.glossiness, 1);
|
||||||
|
|
||||||
// Send camera and light transform values to shader
|
// Send camera and light transform values to shader
|
||||||
|
@ -146,7 +146,7 @@ int main()
|
||||||
|
|
||||||
Begin3dMode(camera);
|
Begin3dMode(camera);
|
||||||
|
|
||||||
DrawModel(model, position, 4.0f, matBlinn.diffuse);
|
DrawModel(model, position, 4.0f, matBlinn.colDiffuse);
|
||||||
DrawSphere(light.position, 0.5f, GOLD);
|
DrawSphere(light.position, 0.5f, GOLD);
|
||||||
|
|
||||||
DrawGrid(20, 1.0f);
|
DrawGrid(20, 1.0f);
|
||||||
|
|
|
@ -118,7 +118,6 @@
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#define STORAGE_FILENAME "storage.data"
|
#define STORAGE_FILENAME "storage.data"
|
||||||
#define MAX_TOUCH_POINTS 2
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Types and Structures Definition
|
// Types and Structures Definition
|
||||||
|
@ -324,6 +323,10 @@ void InitWindow(int width, int height, const char *title)
|
||||||
emscripten_set_touchend_callback("#canvas", NULL, 1, EmscriptenInputCallback);
|
emscripten_set_touchend_callback("#canvas", NULL, 1, EmscriptenInputCallback);
|
||||||
emscripten_set_touchmove_callback("#canvas", NULL, 1, EmscriptenInputCallback);
|
emscripten_set_touchmove_callback("#canvas", NULL, 1, EmscriptenInputCallback);
|
||||||
emscripten_set_touchcancel_callback("#canvas", NULL, 1, EmscriptenInputCallback);
|
emscripten_set_touchcancel_callback("#canvas", NULL, 1, EmscriptenInputCallback);
|
||||||
|
|
||||||
|
// TODO: Add gamepad support (not provided by GLFW3 on emscripten)
|
||||||
|
//emscripten_set_gamepadconnected_callback(NULL, 1, EmscriptenInputCallback);
|
||||||
|
//emscripten_set_gamepaddisconnected_callback(NULL, 1, EmscriptenInputCallback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mousePosition.x = (float)screenWidth/2.0f;
|
mousePosition.x = (float)screenWidth/2.0f;
|
||||||
|
|
14
src/raylib.h
14
src/raylib.h
|
@ -166,6 +166,9 @@
|
||||||
#define MOUSE_MIDDLE_BUTTON 2
|
#define MOUSE_MIDDLE_BUTTON 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Touch points registered
|
||||||
|
#define MAX_TOUCH_POINTS 2
|
||||||
|
|
||||||
// Gamepad Number
|
// Gamepad Number
|
||||||
#define GAMEPAD_PLAYER1 0
|
#define GAMEPAD_PLAYER1 0
|
||||||
#define GAMEPAD_PLAYER2 1
|
#define GAMEPAD_PLAYER2 1
|
||||||
|
@ -348,9 +351,6 @@ typedef struct Shader {
|
||||||
|
|
||||||
// Uniforms
|
// Uniforms
|
||||||
int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
|
int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
|
||||||
|
|
||||||
int modelLoc; // Model transformation matrix uniform location point (vertex shader)
|
|
||||||
int viewLoc; // View transformation matrix uniform location point (vertex shader)
|
|
||||||
int tintColorLoc; // Color uniform location point (fragment shader)
|
int tintColorLoc; // Color uniform location point (fragment shader)
|
||||||
|
|
||||||
int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader)
|
int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader)
|
||||||
|
@ -448,15 +448,16 @@ typedef enum {
|
||||||
GESTURE_PINCH_OUT = 512
|
GESTURE_PINCH_OUT = 512
|
||||||
} Gestures;
|
} Gestures;
|
||||||
|
|
||||||
|
// Touch action (fingers or mouse)
|
||||||
typedef enum { TOUCH_UP, TOUCH_DOWN, TOUCH_MOVE } TouchAction;
|
typedef enum { TOUCH_UP, TOUCH_DOWN, TOUCH_MOVE } TouchAction;
|
||||||
|
|
||||||
// Gesture events
|
// Gesture events
|
||||||
// NOTE: MAX_TOUCH_POINTS fixed to 4
|
// NOTE: MAX_TOUCH_POINTS fixed to 2
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int touchAction;
|
int touchAction;
|
||||||
int pointCount;
|
int pointCount;
|
||||||
int pointerId[4];
|
int pointerId[MAX_TOUCH_POINTS];
|
||||||
Vector2 position[4];
|
Vector2 position[MAX_TOUCH_POINTS];
|
||||||
} GestureEvent;
|
} GestureEvent;
|
||||||
|
|
||||||
// Camera system modes
|
// Camera system modes
|
||||||
|
@ -798,6 +799,7 @@ bool IsPosproShaderEnabled(void); // Check if
|
||||||
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||||
void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||||
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||||
|
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||||
void SetShaderMapDiffuse(Shader *shader, Texture2D texture); // Default diffuse shader map texture assignment
|
void SetShaderMapDiffuse(Shader *shader, Texture2D texture); // Default diffuse shader map texture assignment
|
||||||
void SetShaderMapNormal(Shader *shader, const char *uniformName, Texture2D texture); // Normal map texture shader assignment
|
void SetShaderMapNormal(Shader *shader, const char *uniformName, Texture2D texture); // Normal map texture shader assignment
|
||||||
void SetShaderMapSpecular(Shader *shader, const char *uniformName, Texture2D texture); // Specular map texture shader assignment
|
void SetShaderMapSpecular(Shader *shader, const char *uniformName, Texture2D texture); // Specular map texture shader assignment
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue