diff options
author | Wilrik de Loose <wilrik@wilrik.nl> | 2008-04-16 15:04:46 (GMT) |
---|---|---|
committer | Wilrik de Loose <wilrik@wilrik.nl> | 2008-04-16 15:04:46 (GMT) |
commit | 7e5ef59c21af27e98f2a50b076d3b73882929768 (patch) | |
tree | 963750c591d26e4351accaebfadbfe07b58a3609 | |
parent | 3956e14034371e778e7457a344adc66d27f5fc0a (diff) | |
download | 2iv55-7e5ef59c21af27e98f2a50b076d3b73882929768.zip 2iv55-7e5ef59c21af27e98f2a50b076d3b73882929768.tar.gz 2iv55-7e5ef59c21af27e98f2a50b076d3b73882929768.tar.bz2 |
Buttons werkend. Nu nog radio buttons en dergelijke + font/bitmap lettertype toevoegen (en afhandeling van buttons uiteraars.
25 files changed, 95 insertions, 70 deletions
diff --git a/menu_demo/Debug/BuildLog.htm b/menu_demo/Debug/BuildLog.htm Binary files differindex e2e83d7..7eef82b 100644 --- a/menu_demo/Debug/BuildLog.htm +++ b/menu_demo/Debug/BuildLog.htm diff --git a/menu_demo/Debug/main.obj b/menu_demo/Debug/main.obj Binary files differindex fcf316c..93f703d 100644 --- a/menu_demo/Debug/main.obj +++ b/menu_demo/Debug/main.obj diff --git a/menu_demo/Debug/menu.obj b/menu_demo/Debug/menu.obj Binary files differindex 2661be4..3e829eb 100644 --- a/menu_demo/Debug/menu.obj +++ b/menu_demo/Debug/menu.obj diff --git a/menu_demo/Debug/menu_demo.exe b/menu_demo/Debug/menu_demo.exe Binary files differindex f97a812..ec6ec8e 100644 --- a/menu_demo/Debug/menu_demo.exe +++ b/menu_demo/Debug/menu_demo.exe diff --git a/menu_demo/Debug/menu_demo.exe.embed.manifest b/menu_demo/Debug/menu_demo.exe.embed.manifest index 3d9330a..cca7079 100644 --- a/menu_demo/Debug/menu_demo.exe.embed.manifest +++ b/menu_demo/Debug/menu_demo.exe.embed.manifest @@ -1,8 +1,3 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
- <dependency>
- <dependentAssembly>
- <assemblyIdentity type="win32" name="Microsoft.VC80.DebugCRT" version="8.0.50608.0" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
- </dependentAssembly>
- </dependency>
</assembly>
\ No newline at end of file diff --git a/menu_demo/Debug/menu_demo.exe.embed.manifest.res b/menu_demo/Debug/menu_demo.exe.embed.manifest.res Binary files differindex 7b55d19..d639670 100644 --- a/menu_demo/Debug/menu_demo.exe.embed.manifest.res +++ b/menu_demo/Debug/menu_demo.exe.embed.manifest.res diff --git a/menu_demo/Debug/menu_demo.exe.intermediate.manifest b/menu_demo/Debug/menu_demo.exe.intermediate.manifest index 1b520e1..cdaa604 100644 --- a/menu_demo/Debug/menu_demo.exe.intermediate.manifest +++ b/menu_demo/Debug/menu_demo.exe.intermediate.manifest @@ -1,8 +1,3 @@ <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
- <dependency>
- <dependentAssembly>
- <assemblyIdentity type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
- </dependentAssembly>
- </dependency>
</assembly>
diff --git a/menu_demo/Debug/menu_demo.ilk b/menu_demo/Debug/menu_demo.ilk Binary files differindex cdf0c66..372a9b1 100644 --- a/menu_demo/Debug/menu_demo.ilk +++ b/menu_demo/Debug/menu_demo.ilk diff --git a/menu_demo/Debug/menu_demo.pdb b/menu_demo/Debug/menu_demo.pdb Binary files differindex ee72590..2653140 100644 --- a/menu_demo/Debug/menu_demo.pdb +++ b/menu_demo/Debug/menu_demo.pdb diff --git a/menu_demo/Debug/mt.dep b/menu_demo/Debug/mt.dep index 551bc6a..5e3a360 100644 --- a/menu_demo/Debug/mt.dep +++ b/menu_demo/Debug/mt.dep @@ -1 +1 @@ -Manifest resource last updated at 15:12:07,61 on 16-04-2008
+Manifest resource last updated at 17:03:43,17 on 16-04-2008
diff --git a/menu_demo/Debug/vc80.idb b/menu_demo/Debug/vc80.idb Binary files differindex a06ad7a..f50aada 100644 --- a/menu_demo/Debug/vc80.idb +++ b/menu_demo/Debug/vc80.idb diff --git a/menu_demo/Debug/vc80.pdb b/menu_demo/Debug/vc80.pdb Binary files differindex 944b6ef..5ce9f7c 100644 --- a/menu_demo/Debug/vc80.pdb +++ b/menu_demo/Debug/vc80.pdb diff --git a/menu_demo/bitmap.c b/menu_demo/bitmap.c index a13943b..1a32f68 100644 --- a/menu_demo/bitmap.c +++ b/menu_demo/bitmap.c @@ -1,4 +1,9 @@ -#include <windows.h> +#ifdef G_OS_WIN32
+ #define WIN32_LEAN_AND_MEAN 1
+ #include <windows.h>
+ #define GL_BGR 0x80E0
+#endif + #include <GL/gl.h> #include <GL/glu.h> #include <stdio.h> @@ -11,7 +16,7 @@ #define BITMAP_WIDTH 0x12 #define BITMAP_HEIGHT 0x16 -void load_image(char *filename) +void BitmapLoad(char *filename) { GLuint texture; FILE *bitmap; @@ -41,7 +46,7 @@ void load_image(char *filename) glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_UNSIGNED_BYTE, imagedata); + gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_BGR, GL_UNSIGNED_BYTE, imagedata); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); diff --git a/menu_demo/bitmap.h b/menu_demo/bitmap.h index 9aeeba6..9e68dae 100644 --- a/menu_demo/bitmap.h +++ b/menu_demo/bitmap.h @@ -1,6 +1,6 @@ #ifndef _CBITMAP_H
#define _CBITMAP_H
-void load_image(char *filename);
+void BitmapLoad(char *filename);
#endif
diff --git a/menu_demo/button.c b/menu_demo/button.c index cafa94a..7df7b08 100644 --- a/menu_demo/button.c +++ b/menu_demo/button.c @@ -1,6 +1,6 @@ #ifdef G_OS_WIN32
-#define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
+ #define WIN32_LEAN_AND_MEAN 1
+ #include <windows.h>
#endif
#include <GL/gl.h>
@@ -8,13 +8,7 @@ #include "button.h"
#include "bitmap.h"
-#define BUTTON_CLICK_HEIGHT 50
-
-enum ButtonType {
- BUTTON_CLICK,
- BUTTON_RADIO,
- BUTTON_LABEL
-};
+#define BUTTON_CLICK_HEIGHT 49
void ButtonClickRender(struct ButtonStruct *f_sButton)
{
@@ -28,13 +22,36 @@ void ButtonClickRender(struct ButtonStruct *f_sButton) memset(&l_pcTitle, 0, sizeof(l_pcTitle));
memcpy(&l_pcTitle, f_sButton->m_pcTitle, sizeof(f_sButton->m_pcTitle));
+ BitmapLoad("img/button_click_left.bmp");
+
+ glBegin(GL_QUADS);
+ glTexCoord3d(0, 1, 0); glVertex3d(l_dXPos, l_dYPos, 0);
+ glTexCoord3d(1, 1, 0); glVertex3d(l_dXPos + 26, l_dYPos, 0);
+ glTexCoord3d(1, 0, 0); glVertex3d(l_dXPos + 26, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
+ glTexCoord3d(0, 0, 0); glVertex3d(l_dXPos, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
+ glEnd();
+
+ BitmapLoad("img/button_click_right.bmp");
+
glBegin(GL_QUADS);
- glVertex3d(l_dXPos, l_dYPos, 0);
- glVertex3d(l_dXPos + l_dWidth, l_dYPos, 0);
- glVertex3d(l_dXPos + l_dWidth, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
- glVertex3d(l_dXPos, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
+ glTexCoord3d(0, 1, 0); glVertex3d(l_dXPos + 24 + l_dWidth, l_dYPos, 0);
+ glTexCoord3d(1, 1, 0); glVertex3d(l_dXPos + 24 + l_dWidth + 25, l_dYPos, 0);
+ glTexCoord3d(1, 0, 0); glVertex3d(l_dXPos + 24 + l_dWidth + 25, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
+ glTexCoord3d(0, 0, 0); glVertex3d(l_dXPos + 24 + l_dWidth, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
glEnd();
+ if (l_dWidth > 0)
+ {
+ BitmapLoad("img/button_click_center.bmp");
+
+ glBegin(GL_QUADS);
+ glTexCoord3d(0, 1, 0); glVertex3d(l_dXPos + 25, l_dYPos, 0);
+ glTexCoord3d(1, 1, 0); glVertex3d(l_dXPos + 25 + l_dWidth, l_dYPos, 0);
+ glTexCoord3d(1, 0, 0); glVertex3d(l_dXPos + 25 + l_dWidth, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
+ glTexCoord3d(0, 0, 0); glVertex3d(l_dXPos + 25, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
+ glEnd();
+ }
+
} // ButtonClickRender
void ButtonRender(struct ButtonStruct *f_sButton)
diff --git a/menu_demo/button.h b/menu_demo/button.h index 81bb418..77d365e 100644 --- a/menu_demo/button.h +++ b/menu_demo/button.h @@ -11,6 +11,12 @@ struct ButtonStruct { int m_iType;
};
+enum ButtonType {
+ BUTTON_CLICK,
+ BUTTON_RADIO,
+ BUTTON_LABEL
+};
+
void ButtonRender(struct ButtonStruct *f_sButton);
#endif
diff --git a/menu_demo/img/button_click_center.bmp b/menu_demo/img/button_click_center.bmp Binary files differnew file mode 100644 index 0000000..e8a9474 --- /dev/null +++ b/menu_demo/img/button_click_center.bmp diff --git a/menu_demo/img/button_click_left.bmp b/menu_demo/img/button_click_left.bmp Binary files differnew file mode 100644 index 0000000..16e00d2 --- /dev/null +++ b/menu_demo/img/button_click_left.bmp diff --git a/menu_demo/img/button_click_right.bmp b/menu_demo/img/button_click_right.bmp Binary files differnew file mode 100644 index 0000000..9db52b9 --- /dev/null +++ b/menu_demo/img/button_click_right.bmp diff --git a/menu_demo/main.c b/menu_demo/main.c index ad9c49f..89e0b31 100644 --- a/menu_demo/main.c +++ b/menu_demo/main.c @@ -5,8 +5,6 @@ #include <stdlib.h>
#include <GL/gl.h>
-
-#include <GL/gl.h>
#include <GL/glut.h>
#include "menu.h"
@@ -16,13 +14,9 @@ void init_gl(void)
{
- double l_dHalfWidth = SCREEN_WIDTH / 2;
+ double l_dHalfWidth = SCREEN_WIDTH / 2;
double l_dHalfHeight = SCREEN_HEIGHT / 2;
- glDepthFunc(GL_LESS);
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_TEXTURE_2D);
-
glMatrixMode(GL_PROJECTION);
glOrtho(-l_dHalfWidth,
@@ -72,7 +66,7 @@ int main(int argc, char **argv) glutSpecialFunc(process_special_keys);
init_gl();
- MenuInit();
+ MenuInit(SCREEN_WIDTH, SCREEN_HEIGHT);
glutMainLoop();
diff --git a/menu_demo/menu.c b/menu_demo/menu.c index 99a72a9..265c4d8 100644 --- a/menu_demo/menu.c +++ b/menu_demo/menu.c @@ -1,10 +1,13 @@ #ifdef G_OS_WIN32
-#define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
+ #define WIN32_LEAN_AND_MEAN 1
+ #include <windows.h>
#endif
#include <GL/gl.h>
+#include <stdlib.h>
+
+#include "menu.h"
#include "button.h"
#define MENU_MAX_BUTTONS 16
@@ -16,55 +19,64 @@ enum MenuState { };
struct MenuStruct {
+ enum MenuState m_eMenuId;
+ int m_iButtonCount;
struct ButtonStruct m_sButtons[MENU_MAX_BUTTONS];
};
-int g_iState; // which menu state are we in
+struct MenuStruct g_sMenuMain; // definition of the main menu
+struct MenuStruct g_sMenuStart; // definition of the start menu
+struct MenuStruct g_sMenuOptions; // definition of the options menu
+struct MenuStruct *g_pCurMenu; // current menu
-struct MenuStruct g_sMenuMain; // definition of the main menu
-struct MenuStruct g_sMenuStart; // definition of the start menu
-struct MenuStruct g_sMenuOptions; // definition of the options menu
+int g_iWinWidth;
+int g_iWinHeight;
-void MenuMainRender(void)
+void MenuInit(int f_iWinWidth, int f_iWinHeight)
{
+ // init menu props
+ g_iWinWidth = f_iWinWidth;
+ g_iWinHeight = f_iWinHeight;
-} // MenuMainRender
+ // init main menu
+ g_sMenuMain.m_eMenuId = MENU_MAIN;
+ g_sMenuMain.m_sButtons[0].m_dWidth = 200;
+ g_sMenuMain.m_sButtons[0].m_dXPos = 0;
+ g_sMenuMain.m_sButtons[0].m_dYPos = 0;
+ g_sMenuMain.m_sButtons[0].m_iType = BUTTON_CLICK;
+ g_sMenuMain.m_iButtonCount = 1;
-void MenuOptionsRender(void)
-{
-} // MenuMainRender
+ // init start menu
+ g_sMenuStart.m_eMenuId = MENU_START;
+ g_sMenuStart.m_iButtonCount = 0;
+ // init options menu
+ g_sMenuOptions.m_eMenuId = MENU_OPTIONS;
+ g_sMenuOptions.m_iButtonCount = 0;
-void MenuSelectionRender(void)
-{
-} // MenuMainRender
-
-
-void MenuInit(void)
-{
- g_iState = MENU_MAIN;
+ // set pointer to the current menu
+ g_pCurMenu = &g_sMenuMain;
} // InitMenu
void MenuRender(void)
{
- glColor3d(1, 1, 1);
+ int i = 0;
- switch (g_iState)
- {
- case MENU_MAIN:
- MenuMainRender();
- break;
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_TEXTURE_2D);
+
+ glColor3d(1, 1, 1);
- case MENU_START:
- MenuOptionsRender();
- break;
+ glPushMatrix();
- case MENU_OPTIONS:
- MenuSelectionRender();
- break;
+ while (i < g_pCurMenu->m_iButtonCount)
+ {
+ ButtonRender(&g_pCurMenu->m_sButtons[i]);
+ i++;
+ }
- }
+ glPopMatrix();
} // Render
diff --git a/menu_demo/menu.h b/menu_demo/menu.h index f072608..b574b74 100644 --- a/menu_demo/menu.h +++ b/menu_demo/menu.h @@ -1,7 +1,7 @@ #ifndef _CMENU_H
#define _CMENU_H
-void MenuInit(void);
+void MenuInit(int f_iWinWidth, int f_iWinHeight);
void MenuRender(void);
#endif
diff --git a/menu_demo/menu_demo.ncb b/menu_demo/menu_demo.ncb Binary files differindex 06fdc9d..1962c12 100644 --- a/menu_demo/menu_demo.ncb +++ b/menu_demo/menu_demo.ncb diff --git a/menu_demo/menu_demo.suo b/menu_demo/menu_demo.suo Binary files differindex ac4112e..debaa58 100644 --- a/menu_demo/menu_demo.suo +++ b/menu_demo/menu_demo.suo diff --git a/menu_demo/menu_demo.vcproj b/menu_demo/menu_demo.vcproj index b869833..d568978 100644 --- a/menu_demo/menu_demo.vcproj +++ b/menu_demo/menu_demo.vcproj @@ -20,6 +20,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
+ UseOfMFC="0"
CharacterSet="1"
>
<Tool
@@ -44,7 +45,7 @@ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;G_OS_WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
- RuntimeLibrary="3"
+ RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
|