summaryrefslogtreecommitdiff
path: root/src/glut/dos/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glut/dos/window.c')
-rw-r--r--src/glut/dos/window.c107
1 files changed, 73 insertions, 34 deletions
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c
index cce1a1f777..a7a7d9ca59 100644
--- a/src/glut/dos/window.c
+++ b/src/glut/dos/window.c
@@ -27,17 +27,16 @@
*/
-#include "GL/glut.h"
+#include "glutint.h"
#include "GL/dmesa.h"
-#include "internal.h"
-static int window;
+GLUTwindow *g_curwin;
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
-static DMesaBuffer buffer[MAX_WINDOWS];
+static GLUTwindow *windows[MAX_WINDOWS];
@@ -45,8 +44,8 @@ static void clean (void)
{
int i;
- for (i=0; i<MAX_WINDOWS; i++) {
- glutDestroyWindow(i+1);
+ for (i=1; i<=MAX_WINDOWS; i++) {
+ glutDestroyWindow(i);
}
if (context) DMesaDestroyContext(context);
if (visual) DMesaDestroyVisual(visual);
@@ -60,9 +59,11 @@ static void clean (void)
int APIENTRY glutCreateWindow (const char *title)
{
int i;
+ GLint screen_size[2];
+ int m8width = (g_init_w + 7) & ~7;
if (!visual) {
- if ((visual=DMesaCreateVisual(g_xpos + g_width, g_ypos + g_height, g_bpp, g_refresh,
+ if ((visual=DMesaCreateVisual(g_init_x + m8width, g_init_y + g_init_h, g_bpp, g_refresh,
g_display_mode & GLUT_DOUBLE,
!(g_display_mode & GLUT_INDEX),
g_display_mode & GLUT_ALPHA,
@@ -71,34 +72,46 @@ int APIENTRY glutCreateWindow (const char *title)
g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
return 0;
}
-
+
if ((context=DMesaCreateContext(visual, NULL))==NULL) {
DMesaDestroyVisual(visual);
return 0;
}
-
+
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}
for (i=0; i<MAX_WINDOWS; i++) {
- if (!buffer[i]) {
+ if (windows[i] == NULL) {
DMesaBuffer b;
-
- if ((b=DMesaCreateBuffer(visual, g_xpos, g_ypos, g_width, g_height))==NULL) {
+ GLUTwindow *w;
+
+ if ((w=(GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) {
+ return 0;
+ }
+
+ if ((b=DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h))==NULL) {
+ free(w);
return 0;
}
if (!DMesaMakeCurrent(context, b)) {
DMesaDestroyBuffer(b);
+ free(w);
return 0;
}
- if (g_mouse) {
- pc_mouse_area(g_xpos, g_ypos, g_xpos + g_width - 1, g_ypos + g_height - 1);
- }
- buffer[window = i] = b;
- return i+1;
+ g_curwin = windows[i] = w;
+
+ w->num = ++i;
+ w->xpos = g_init_x;
+ w->ypos = g_init_y;
+ w->width = m8width;
+ w->height = g_init_h;
+ w->buffer = b;
+
+ return i;
}
}
@@ -106,73 +119,88 @@ int APIENTRY glutCreateWindow (const char *title)
}
+
int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
{
return GL_FALSE;
}
+
void APIENTRY glutDestroyWindow (int win)
{
- if (buffer[win-1]) {
- DMesaDestroyBuffer(buffer[win-1]);
- buffer[win-1] = NULL;
+ if (windows[--win]) {
+ DMesaDestroyBuffer(windows[win]->buffer);
+ free(windows[win]);
+ windows[win] = NULL;
}
}
+
void APIENTRY glutPostRedisplay (void)
{
g_redisplay = GL_TRUE;
}
+
void APIENTRY glutSwapBuffers (void)
{
- if (g_mouse) pc_scare_mouse();
- DMesaSwapBuffers(buffer[window]);
- if (g_mouse) pc_unscare_mouse();
+ if (g_curwin->show_mouse) {
+ /* XXX scare mouse */
+ DMesaSwapBuffers(g_curwin->buffer);
+ /* XXX unscare mouse */
+ } else {
+ DMesaSwapBuffers(g_curwin->buffer);
+ }
}
+
int APIENTRY glutGetWindow (void)
{
- return window + 1;
+ return g_curwin->num;
}
+
void APIENTRY glutSetWindow (int win)
{
- window = win - 1;
+ g_curwin = windows[win - 1];
}
+
void APIENTRY glutSetWindowTitle (const char *title)
{
}
+
void APIENTRY glutSetIconTitle (const char *title)
{
}
+
void APIENTRY glutPositionWindow (int x, int y)
{
- if (DMesaViewport(buffer[window], x, y, g_width, g_height)) {
- g_xpos = x;
- g_ypos = y;
+ if (DMesaMoveBuffer(x, y)) {
+ g_curwin->xpos = x;
+ g_curwin->ypos = y;
}
}
+
void APIENTRY glutReshapeWindow (int width, int height)
-{
- if (DMesaViewport(buffer[window], g_xpos, g_ypos, width, height)) {
- g_width = width;
- g_height = height;
- if (reshape_func) {
- reshape_func(width, height);
+{
+ if (DMesaResizeBuffer(width, height)) {
+ g_curwin->width = width;
+ g_curwin->height = height;
+ if (g_curwin->reshape) {
+ g_curwin->reshape(width, height);
} else {
glViewport(0, 0, width, height);
}
@@ -180,26 +208,37 @@ void APIENTRY glutReshapeWindow (int width, int height)
}
+
+void APIENTRY glutFullScreen (void)
+{
+}
+
+
+
void APIENTRY glutPopWindow (void)
{
}
+
void APIENTRY glutPushWindow (void)
{
}
+
void APIENTRY glutIconifyWindow (void)
{
}
+
void APIENTRY glutShowWindow (void)
{
}
+
void APIENTRY glutHideWindow (void)
{
}