Recovered from microbel
This commit is contained in:
5
client/renderer/Makefile.am
Normal file
5
client/renderer/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
||||
INCLUDES = -I.. -I../gui -I../coreclient -I../../common/include @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
noinst_LIBRARIES = librenderer.a
|
||||
|
||||
librenderer_a_SOURCES = renderer.C glgeometry.C glmaterial.C glrenderer.C gltexture.C console.C glconsole.C srvcliconsole.C glsrvcliconsole.C
|
||||
332
client/renderer/Makefile.in
Normal file
332
client/renderer/Makefile.in
Normal file
@@ -0,0 +1,332 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
GL_CFLAGS = @GL_CFLAGS@
|
||||
GL_LIBS = @GL_LIBS@
|
||||
LEX = @LEX@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NETLIBS = @NETLIBS@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
TIFF_CFLAGS = @TIFF_CFLAGS@
|
||||
TIFF_LIBS = @TIFF_LIBS@
|
||||
VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
|
||||
INCLUDES = -I.. -I../gui -I../coreclient -I../../common/include @X_CFLAGS@ @GL_CFLAGS@ -DPVVMUDCLIENT
|
||||
|
||||
noinst_LIBRARIES = librenderer.a
|
||||
|
||||
librenderer_a_SOURCES = renderer.C glgeometry.C glmaterial.C glrenderer.C gltexture.C console.C glconsole.C srvcliconsole.C glsrvcliconsole.C
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
librenderer_a_LIBADD =
|
||||
librenderer_a_OBJECTS = renderer.o glgeometry.o glmaterial.o \
|
||||
glrenderer.o gltexture.o console.o glconsole.o srvcliconsole.o \
|
||||
glsrvcliconsole.o
|
||||
AR = ar
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/console.P .deps/glconsole.P .deps/glgeometry.P \
|
||||
.deps/glmaterial.P .deps/glrenderer.P .deps/glsrvcliconsole.P \
|
||||
.deps/gltexture.P .deps/renderer.P .deps/srvcliconsole.P
|
||||
SOURCES = $(librenderer_a_SOURCES)
|
||||
OBJECTS = $(librenderer_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .C .S .c .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --foreign client/renderer/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-noinstLIBRARIES:
|
||||
|
||||
clean-noinstLIBRARIES:
|
||||
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
|
||||
|
||||
distclean-noinstLIBRARIES:
|
||||
|
||||
maintainer-clean-noinstLIBRARIES:
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
librenderer.a: $(librenderer_a_OBJECTS) $(librenderer_a_DEPENDENCIES)
|
||||
-rm -f librenderer.a
|
||||
$(AR) cru librenderer.a $(librenderer_a_OBJECTS) $(librenderer_a_LIBADD)
|
||||
$(RANLIB) librenderer.a
|
||||
.C.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = client/renderer
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign client/renderer/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
|
||||
%.o: %.C
|
||||
@echo '$(CXXCOMPILE) -c $<'; \
|
||||
$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.C
|
||||
@echo '$(LTCXXCOMPILE) -c $<'; \
|
||||
$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-depend mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \
|
||||
clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-noinstLIBRARIES distclean-compile \
|
||||
distclean-tags distclean-depend distclean-generic \
|
||||
clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-depend maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
|
||||
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
|
||||
clean-tags maintainer-clean-tags distdir mostlyclean-depend \
|
||||
distclean-depend clean-depend maintainer-clean-depend info-am info \
|
||||
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
|
||||
install-exec install-data-am install-data install-am install \
|
||||
uninstall-am uninstall all-redirect all-am all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
264
client/renderer/console.C
Normal file
264
client/renderer/console.C
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include "pvvmud.H"
|
||||
#include "console.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
CConsole::CConsole(CPvvmudClient * cli) {
|
||||
CConsole(cli, 40, 20);
|
||||
}
|
||||
|
||||
CConsole::CConsole(CPvvmudClient * cli, int rows, int cols) {
|
||||
m_client = cli;
|
||||
m_cols = cols;
|
||||
m_rows = rows;
|
||||
m_print_x = m_print_y = 0;
|
||||
m_visible = FALSE;
|
||||
m_state = FALSE;
|
||||
m_echo = TRUE;
|
||||
m_dataReady = FALSE;
|
||||
// Calculate start point for drawing (assumes 8-by-13 font)
|
||||
int cons_width = 8 * rows;
|
||||
int cons_height = 13 * cols;
|
||||
m_screen_x = (getClient()->getGUI()->getWidth() - cons_width) / 2;
|
||||
m_screen_y = getClient()->getGUI()->getHeight() - (getClient()->getGUI()->getHeight() - cons_height) / 2;
|
||||
m_input_x = 0;
|
||||
m_input_y = m_cols - 1;
|
||||
m_charColor = (double*)malloc(sizeof(double) * 3);
|
||||
m_numInputChars = 0;
|
||||
m_bufStart = 0;
|
||||
// Allocate space for console data (one extra char for newline)
|
||||
m_console =(char*)malloc(sizeof(char) * (m_cols+1)*m_rows);
|
||||
memset(m_console, 0, (m_cols+1)*m_rows);
|
||||
} // CConsole()
|
||||
|
||||
CConsole::~CConsole() {
|
||||
free(m_console);
|
||||
free(m_charColor);
|
||||
}
|
||||
|
||||
void CConsole::drawText() {
|
||||
}
|
||||
|
||||
void CConsole::addMsg(char * msg) {
|
||||
}
|
||||
|
||||
int CConsole::printLine(char * string) {
|
||||
int i = print(string);
|
||||
if (i) {
|
||||
// Add newline
|
||||
m_console[m_print_y*m_rows+m_print_x] = '\n';
|
||||
if (m_print_y < m_cols) {
|
||||
m_print_y++;
|
||||
m_print_x = 0;
|
||||
} // if
|
||||
else {
|
||||
m_print_y = m_print_x = 0; //Reached end of console, return to top.
|
||||
} // else
|
||||
} // if
|
||||
return i;
|
||||
} // printLine()
|
||||
|
||||
int CConsole::print(char * string) {
|
||||
char c;
|
||||
int i = 0;
|
||||
while ((c=string[i++])) {
|
||||
if (m_print_y >= m_cols-2) {
|
||||
scroll(1);
|
||||
m_print_y--;
|
||||
}
|
||||
if (m_print_x == m_rows-1) { // Check if the cursor is at the end of a line
|
||||
m_console[m_print_y*m_rows+m_print_x] = '\n';
|
||||
if (m_print_y >= (m_cols-2)) { // check if the cursor is at the bottom
|
||||
scroll(1);
|
||||
m_print_x = 0;
|
||||
m_print_y--;
|
||||
} // if
|
||||
else {
|
||||
m_print_y++;
|
||||
m_print_x = 0;
|
||||
} // else
|
||||
i--;
|
||||
} // if
|
||||
else if (m_print_x < m_rows) {
|
||||
m_console[m_print_y*m_rows+m_print_x] = c;
|
||||
m_print_x++;
|
||||
} // else if
|
||||
else { // m_print> m_rows => error condition (never supposed to happen)
|
||||
return 0;
|
||||
}
|
||||
if (c == '\n') {
|
||||
m_console[m_print_y*m_rows+m_print_x] = '\n';
|
||||
m_print_y++;
|
||||
m_print_x = 0;
|
||||
} // if
|
||||
} // while
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CConsole::printChar(char c) {
|
||||
char * tmp = (char*)malloc(sizeof(char)*2);
|
||||
tmp[0] = c;
|
||||
tmp[1] = 0;
|
||||
print(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
void CConsole::echoChar(char c) {
|
||||
if (m_input_x < m_rows) {
|
||||
m_console[m_input_y * m_rows + m_input_x] = c;
|
||||
m_input_x++;
|
||||
}
|
||||
}
|
||||
|
||||
void CConsole::clear() {
|
||||
memset(m_console, 0, getRows()*(getCols()+1));
|
||||
setCursorPos(0, 0);
|
||||
}
|
||||
|
||||
void CConsole::scroll(int lines) {
|
||||
for (int i=lines;i<m_cols;i++) {
|
||||
memcpy(&m_console[(i-lines)*(m_rows)], &m_console[i*(m_rows)], m_rows+1);
|
||||
}
|
||||
}
|
||||
|
||||
void CConsole::keyboardInput(char k) {
|
||||
switch (k) {
|
||||
case '\r':
|
||||
changeInputMode();
|
||||
if (m_inputBuffer != "") {
|
||||
setDataReady();
|
||||
}
|
||||
break;
|
||||
case '\b':
|
||||
if (m_numInputChars != 0) {
|
||||
m_numInputChars--;
|
||||
m_input_x--;
|
||||
m_console[m_input_y * m_rows + m_input_x] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (m_echo) {
|
||||
echoChar(k);
|
||||
}
|
||||
m_inputBuffer += k;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char * CConsole::getLine() {
|
||||
if (getDataReady()) {
|
||||
const char * s = m_inputBuffer.c_str();
|
||||
cout << s << '\n';
|
||||
m_inputBuffer = "";
|
||||
setDataReady(FALSE);
|
||||
return s;
|
||||
}
|
||||
else {
|
||||
return NULL; // No data ready
|
||||
}
|
||||
}
|
||||
|
||||
/*char CConsole::getChar() {
|
||||
if (m_numInputChars) {
|
||||
char c = m_inputBuffer[m_bufStart++];
|
||||
if (m_bufStart >= INPUTSIZE) {
|
||||
m_bufStart = 0;
|
||||
m_numInputChars--;
|
||||
} // if
|
||||
} // if
|
||||
} // getChar()*/
|
||||
|
||||
void CConsole::setCursorPos(int x, int y) {
|
||||
m_print_x = x;
|
||||
m_print_y = y;
|
||||
}
|
||||
|
||||
int CConsole::getRows() {
|
||||
return m_rows;
|
||||
}
|
||||
|
||||
int CConsole::getCols() {
|
||||
return m_cols;
|
||||
}
|
||||
|
||||
double * CConsole::getColor() {
|
||||
return m_charColor;
|
||||
}
|
||||
|
||||
void CConsole::setColor(double red, double green, double blue) {
|
||||
m_charColor[0] = red;
|
||||
m_charColor[1] = green;
|
||||
m_charColor[2] = blue;
|
||||
}
|
||||
|
||||
CPvvmudClient * CConsole::getClient() {
|
||||
return m_client;
|
||||
}
|
||||
|
||||
int CConsole::changeInputMode() {
|
||||
if(m_state)
|
||||
m_state = 0;
|
||||
else {
|
||||
m_visible = TRUE;
|
||||
m_state = 1;
|
||||
m_input_x = 0;
|
||||
m_input_y = m_cols - 1;
|
||||
} // else
|
||||
for(int i=0;i<getRows();i++) {
|
||||
m_console[m_input_y*getRows()+i]=0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CConsole::getInputMode() {
|
||||
return m_state;
|
||||
}
|
||||
|
||||
int CConsole::setVisible() {
|
||||
m_visible = (m_visible) ? 0 : 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CConsole::isVisible() {
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
void CConsole::setEcho(BOOL e) {
|
||||
m_echo = e;
|
||||
}
|
||||
|
||||
BOOL CConsole::getEcho() {
|
||||
return m_echo;
|
||||
}
|
||||
|
||||
void CConsole::setDataReady(BOOL d) {
|
||||
m_dataReady = d;
|
||||
}
|
||||
|
||||
BOOL CConsole::getDataReady() {
|
||||
return m_dataReady;
|
||||
}
|
||||
|
||||
|
||||
|
||||
95
client/renderer/console.H
Normal file
95
client/renderer/console.H
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef CCONSOLE_H
|
||||
#define CCONSOLE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class CPvvmudClient;
|
||||
|
||||
//class CConsoleCursor {
|
||||
|
||||
|
||||
class CConsole {
|
||||
int m_cols; // Number of columns
|
||||
int m_rows; // Number of rows
|
||||
int m_state; // State variable
|
||||
int m_visible;
|
||||
int num_msgs; // Number of messages printed on console
|
||||
BOOL m_echo;
|
||||
BOOL m_dataReady;
|
||||
CPvvmudClient * m_client;
|
||||
|
||||
protected:
|
||||
char * m_console;
|
||||
string m_inputBuffer;
|
||||
int m_numInputChars;
|
||||
int m_bufStart;
|
||||
double * m_charColor;
|
||||
int m_screen_x; // Startpoint (in screen coordinates)
|
||||
int m_screen_y;
|
||||
int m_print_x; // Position for writing
|
||||
int m_print_y;
|
||||
int m_input_x; // Position for echo
|
||||
int m_input_y;
|
||||
void setDataReady(BOOL d=TRUE);
|
||||
void scrollMsgs();
|
||||
|
||||
public:
|
||||
const int INPUTSIZE = 80;
|
||||
CConsole(CPvvmudClient * cli);
|
||||
CConsole(CPvvmudClient * cli, int cols, int rows);
|
||||
virtual ~CConsole();
|
||||
|
||||
|
||||
virtual void drawText();
|
||||
virtual void addMsg(char * msg);
|
||||
int printLine(char * string);
|
||||
int print(char * string);
|
||||
int printChar(char c);
|
||||
void printMsg(char * msg);
|
||||
void echoChar(char c);
|
||||
void clear();
|
||||
void scroll(int lines);
|
||||
virtual void keyboardInput(char k);
|
||||
|
||||
const char * getLine();
|
||||
void setCursorPos(int x, int y);
|
||||
int getRows();
|
||||
int getCols();
|
||||
double * getColor();
|
||||
void setColor(double red, double green, double blue);
|
||||
CPvvmudClient * getClient();
|
||||
int changeInputMode();
|
||||
int getInputMode();
|
||||
int setVisible();
|
||||
int isVisible();
|
||||
void setEcho(BOOL e);
|
||||
BOOL getEcho();
|
||||
BOOL getDataReady();
|
||||
};
|
||||
|
||||
#endif // CCONSOLE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
115
client/renderer/glconsole.C
Normal file
115
client/renderer/glconsole.C
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include "pvvmud.H"
|
||||
#include "glconsole.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
GLubyte CGLConsole::m_cursor[13] = {
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff,
|
||||
0xff};
|
||||
|
||||
|
||||
|
||||
CGLConsole::CGLConsole(CPvvmudClient * cli) : CConsole(cli) {
|
||||
m_font = GLUT_BITMAP_8_BY_13;
|
||||
}
|
||||
|
||||
CGLConsole::CGLConsole(CPvvmudClient * cli, int rows, int cols) : CConsole(cli, rows, cols) {
|
||||
m_font = GLUT_BITMAP_8_BY_13;
|
||||
setCursorPos(1, 10);
|
||||
}
|
||||
CGLConsole::~CGLConsole() {
|
||||
}
|
||||
|
||||
CGLConsole::drawString(char *string) {
|
||||
int len,t;
|
||||
t = 0;
|
||||
len = getRows();
|
||||
while (t < len && string[t] != '\n') {
|
||||
if (string[t] != 0) {
|
||||
glutBitmapCharacter(m_font,string[t]);
|
||||
}
|
||||
t++;
|
||||
} // while
|
||||
//cout << '\n';
|
||||
}
|
||||
|
||||
void CGLConsole::drawText() {
|
||||
int x, y;
|
||||
// Kode for å tegna opp tekstkonsoll
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LIGHTING);
|
||||
// Darken background
|
||||
|
||||
glLoadIdentity();
|
||||
GLdouble dark[4] = {0.0, 0.0, 0.0, 0.5};
|
||||
//glRotatef(-90, 1.0, 0.0, 0.0);
|
||||
gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0);
|
||||
//CCliViewpoint * viewpoint = getClient()->getManager()->getViewpoint();
|
||||
//viewpoint->transform();
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_QUADS);
|
||||
glColor4dv(dark);
|
||||
glVertex3f(-300, -300, 0.5);
|
||||
glVertex3f(-300, 300, 0.5);
|
||||
glVertex3f(300, 300, 0.5);
|
||||
glVertex3f(300, -300, 0.5);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-0.5,getClient()->getGUI()->getWidth() ,-0.5,getClient()->getGUI()->getHeight(),-1.0,1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glColor3dv(m_charColor);
|
||||
x = m_screen_x;
|
||||
y = m_screen_y;
|
||||
for (int i=0;i<getCols();i++) {
|
||||
glRasterPos2i(x, y);
|
||||
drawString(&m_console[i*getRows()]);
|
||||
y-=13;
|
||||
} // for
|
||||
// Draw cursor
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
if (getInputMode()) {
|
||||
glRasterPos2i(m_screen_x + (8*m_input_x), m_screen_y - (13*(m_input_y+1)));
|
||||
glBitmap(8, 13, 0.0, 0.0, 0.0, 0.0, m_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
39
client/renderer/glconsole.H
Normal file
39
client/renderer/glconsole.H
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef CGLCONSOLE_H
|
||||
#define CGLCONSOLE_H
|
||||
#include <GL/glut.h>
|
||||
#include "console.H"
|
||||
|
||||
class CGLConsole : public CConsole {
|
||||
|
||||
void *m_font;
|
||||
drawString(char *string);
|
||||
public:
|
||||
static GLubyte m_cursor[13];
|
||||
|
||||
CGLConsole(CPvvmudClient * cli);
|
||||
CGLConsole(CPvvmudClient * cli, int cols, int rows);
|
||||
~CGLConsole();
|
||||
|
||||
virtual void drawText();
|
||||
};
|
||||
|
||||
#endif // CGLCONSOLE_H
|
||||
219
client/renderer/glgeometry.C
Normal file
219
client/renderer/glgeometry.C
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "glgeometry.H"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Constructor for ObjectGeometry
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CGLGeometry::CGLGeometry( int objectGeometryId )
|
||||
:CGeometry( objectGeometryId )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CGLGeometry::CGLGeometry( int objectGeometryId, int numVertices,
|
||||
int numNormals, int numTexCoords, int numPolygons )
|
||||
:CGeometry( objectGeometryId, numVertices, numNormals,
|
||||
numTexCoords, numPolygons)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Destructor for ObjectGeometry
|
||||
*
|
||||
******************************************************************************/
|
||||
CGLGeometry::~CGLGeometry(){
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Draw ObjectGeometry
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int CGLGeometry::draw( CMaterialCache * matCache,
|
||||
CTextureCache * texCache ){
|
||||
|
||||
int pp,ii;
|
||||
CPolygon * polygon;
|
||||
CIntArray *normalIndex,*vertexIndex,*texCoordIndex;
|
||||
int numVertex, numNormal, numTexCoord;
|
||||
// CNormal * normal;
|
||||
// CVertex * vertex;
|
||||
// CTexCoord * texCoord;
|
||||
CMaterial * mat;
|
||||
|
||||
for (pp = 0; pp < this->polygonList->getNumElements(); pp ++){
|
||||
|
||||
polygon = this->polygonList->get( pp );
|
||||
numVertex = polygon->getVertexIList()->getNumElements();
|
||||
numNormal = polygon->getNormalIList()->getNumElements();
|
||||
numTexCoord = polygon->getTexCoordIList()->getNumElements();
|
||||
mat = matCache->get( polygon->getMaterial() );
|
||||
if (mat == NULL){
|
||||
mat = matCache->get( 0 );
|
||||
// cdebug(stderr,"Using default material %i for object %i\n",polygon->getMaterial(),id);
|
||||
}
|
||||
if (mat != NULL) mat->exec( texCache );
|
||||
// else cdebug(stderr,"Failed to find material!\n");
|
||||
|
||||
vertexIndex = polygon->getVertexIList();//->getIndex();
|
||||
normalIndex = polygon->getNormalIList();//->getIndex();
|
||||
texCoordIndex = polygon->getTexCoordIList();//->getIndex();
|
||||
//vertex = this->vertexList->getVertex();
|
||||
//normal = this->normalList->getNormal();
|
||||
//texCoord = this->texCoordList->getTexCoord();
|
||||
|
||||
glBegin( (GLenum)polygon->getType() );
|
||||
|
||||
switch ( polygon->getType() ){
|
||||
case POLYGON_POLYGON:
|
||||
case POLYGON_QUAD_STRIP:
|
||||
case POLYGON_TRIANGLE_STRIP:
|
||||
case POLYGON_TRIANGLE_FAN:
|
||||
|
||||
|
||||
|
||||
if (numVertex == numNormal) {
|
||||
// One normal for each vertex
|
||||
if (numVertex == numTexCoord){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(texCoordIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
// No texture coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(texCoordIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// One normal for object
|
||||
if (numVertex == numTexCoord){
|
||||
// Texture Coordinates
|
||||
glNormal3dv(normalList->get(0));
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(texCoordIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
// No texture coordinates
|
||||
glNormal3dv(normalList->get(0));
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glVertex3dv(vertexList->get(texCoordIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POLYGON_QUADS:
|
||||
|
||||
if (numVertex == numNormal) {
|
||||
// One normal for each vertex
|
||||
if (numNormal == numTexCoord){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glTexCoord2dv(texCoordList->get(normalIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// One normal for each quad
|
||||
if (numVertex == numTexCoord){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
if (ii%4 == 0) glNormal3dv(normalList->get(normalIndex->get(ii/4)));
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
if (ii%4 == 0) glNormal3dv(normalList->get(normalIndex->get(ii/4)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POLYGON_TRIANGLES:
|
||||
|
||||
if (numVertex == numNormal) {
|
||||
// One normal for each vertex
|
||||
if (numVertex == numTexCoord){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
glNormal3dv(normalList->get(normalIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// One normal for each triangle
|
||||
if (numVertex == numNormal){
|
||||
// Texture Coordinates
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
if (ii%3 == 0) glNormal3dv(normalList->get(normalIndex->get(ii/3)));
|
||||
glTexCoord2dv(texCoordList->get(texCoordIndex->get(ii)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
} else {
|
||||
for (ii = 0; ii < numVertex; ii++){
|
||||
if (ii%3 == 0) glNormal3dv(normalList->get(normalIndex->get(ii/3)));
|
||||
glVertex3dv(vertexList->get(vertexIndex->get(ii)));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
glEnd( );
|
||||
|
||||
}
|
||||
|
||||
if (next != NULL) {
|
||||
next->draw( matCache, texCache );
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
37
client/renderer/glgeometry.H
Normal file
37
client/renderer/glgeometry.H
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GLGEOMETRY_H
|
||||
#define _GLGEOMETRY_H
|
||||
|
||||
#include "geometry.H"
|
||||
|
||||
|
||||
class CGLGeometry : public CGeometry{
|
||||
|
||||
public:
|
||||
CGLGeometry(int objectGeometryId);
|
||||
CGLGeometry(int objectGeometryId, int numVertices,
|
||||
int numNormals, int numTexCoords, int numPolygons);
|
||||
virtual ~CGLGeometry();
|
||||
virtual int draw( CMaterialCache * matCache, CTextureCache * texCache );
|
||||
|
||||
};
|
||||
|
||||
#endif /* _GLGEOMETRY_H */
|
||||
63
client/renderer/glmaterial.C
Normal file
63
client/renderer/glmaterial.C
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <GL/gl.h>
|
||||
#include <iostream.h>
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include "glmaterial.H"
|
||||
|
||||
|
||||
CGLMaterial::CGLMaterial():CMaterial(){
|
||||
}
|
||||
|
||||
CGLMaterial::CGLMaterial(int materialId):CMaterial(materialId){
|
||||
}
|
||||
|
||||
int CGLMaterial::exec(CTextureCache * texCache){
|
||||
CTexture * tex;
|
||||
if (getTextureId() != -1){
|
||||
if ((tex = texCache->get(getTextureId()))== NULL){
|
||||
if ((tex = texCache->get(0)) == NULL){
|
||||
cdebug << "Failed to find texture!\n";
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
} else {
|
||||
cdebug << "Using default texture for id " << getTextureId() << "\n";
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
tex->exec();
|
||||
}
|
||||
} else {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
tex->exec();
|
||||
}
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT, m_ambient );
|
||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, m_diffuse );
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, m_specular );
|
||||
glMaterialfv(GL_FRONT, GL_SHININESS, m_shininess );
|
||||
glMaterialfv(GL_FRONT, GL_EMISSION, m_emission );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
38
client/renderer/glmaterial.H
Normal file
38
client/renderer/glmaterial.H
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GLMATERIAL_H
|
||||
#define _GLMATERIAL_H
|
||||
|
||||
#include "material.H"
|
||||
|
||||
#define MAT_NOTEXTURE -1
|
||||
|
||||
|
||||
class CGLMaterial : public CMaterial {
|
||||
public:
|
||||
CGLMaterial();
|
||||
CGLMaterial(int materialId);
|
||||
|
||||
virtual ~CGLMaterial() {}
|
||||
|
||||
virtual int exec(CTextureCache * texCache);
|
||||
};
|
||||
|
||||
#endif /* _GLMATERIAL_H */
|
||||
188
client/renderer/glrenderer.C
Normal file
188
client/renderer/glrenderer.C
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include "pvvmud.H"
|
||||
#include "glrenderer.H"
|
||||
#include "cliviewpoint.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
COGLRenderer::COGLRenderer(CPvvmudClient * cli) : CRenderer(cli) {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
{
|
||||
GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
|
||||
GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
GLfloat ambient[4] = {0.4, 0.4, 0.4, 1.0};
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, gray);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient);
|
||||
}
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
// glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
COGLRenderer::~COGLRenderer(){
|
||||
}
|
||||
|
||||
void COGLRenderer::prepareDraw(CWorldObject * object) {
|
||||
if (m_mode == GL_SELECT) {
|
||||
glLoadName(object->getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
void COGLRenderer::draw() {
|
||||
GLfloat light_position[4] = { 0.0, 0.5, 1.0, 0.0 };
|
||||
|
||||
glLoadIdentity();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_LIGHTING);
|
||||
glClearColor(0.5,0.5,0.9,1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glRotatef(-90, 1.0, 0.0, 0.0);
|
||||
CCliViewpoint * viewpoint = getClient()->getManager()->getViewpoint();
|
||||
viewpoint->transform();
|
||||
|
||||
|
||||
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
|
||||
|
||||
getClient()->getManager()->animate();
|
||||
getClient()->getManager()->draw(this);
|
||||
|
||||
glPopMatrix();
|
||||
if (getConsole()->isVisible()) {
|
||||
getConsole()->drawText();
|
||||
}
|
||||
glFlush();
|
||||
|
||||
// Moved to pvvmudclient->pollConsole()
|
||||
// const char * s = getConsole()->getLine();
|
||||
// if (s != NULL) {
|
||||
// getClient()->getManager()->sendMsg(s);
|
||||
// }
|
||||
|
||||
getClient()->getGUI()->reshape(getClient()->getGUI()->getWidth(), getClient()->getGUI()->getHeight());
|
||||
|
||||
}
|
||||
|
||||
void COGLRenderer::transform(CPosition &pos, CDirection &dir) {
|
||||
const double * position = pos.getVector();
|
||||
const double * direction = dir.getVector();
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslated(position[0],position[1],position[2]);
|
||||
glRotated(direction[2],1,0,0);
|
||||
glRotated(direction[1],0,1,0);
|
||||
glRotated(direction[0],0,0,1);
|
||||
}
|
||||
|
||||
void COGLRenderer::reshape(int width, int height) {
|
||||
getClient()->getGUI()->setWidth(width);
|
||||
getClient()->getGUI()->setHeight(height);
|
||||
GLfloat aspectViewport = (GLfloat) height / (GLfloat) width;
|
||||
setAspectViewport(aspectViewport);
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-0.1, 0.1, -0.1*aspectViewport, 0.1*aspectViewport, 0.2, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
void COGLRenderer::postDraw() {
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
#define SELECTBUFSIZE 1024
|
||||
|
||||
void COGLRenderer::mousePick(int x, int y) {
|
||||
cdebug << "Mouse pick " << x << " " << y << "\n";
|
||||
|
||||
GLuint selectBuf[SELECTBUFSIZE];
|
||||
GLint hits;
|
||||
GLint viewport[4];
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
glSelectBuffer(SELECTBUFSIZE, selectBuf);
|
||||
glRenderMode(GL_SELECT);
|
||||
|
||||
glInitNames();
|
||||
glPushName((GLuint)(-1));
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluPickMatrix(x,viewport[3]-y,1.0,1.0,viewport);
|
||||
glFrustum(-0.1, 0.1, -0.1*m_aspectViewport, 0.1*m_aspectViewport, 0.2, 1000.0);
|
||||
setMode(GL_SELECT);
|
||||
draw();
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glFlush();
|
||||
|
||||
hits = glRenderMode(GL_RENDER);
|
||||
getClient()->getInputFunction()->processHits(hits, selectBuf);
|
||||
}
|
||||
|
||||
GLfloat COGLRenderer::getAspectViewport() {
|
||||
return m_aspectViewport;
|
||||
}
|
||||
|
||||
void COGLRenderer::setAspectViewport(GLfloat av) {
|
||||
m_aspectViewport = av;
|
||||
}
|
||||
|
||||
void COGLRenderer::setMode(GLenum mode) {
|
||||
m_mode = mode;
|
||||
}
|
||||
|
||||
void COGLRenderer::dumpScreen(char * texFileName){
|
||||
GLint viewport[4];
|
||||
int width,height;
|
||||
|
||||
BYTE *data;
|
||||
CTexture * texture = new CTexture();
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT,viewport);
|
||||
|
||||
width = viewport[2];
|
||||
height = viewport[3];
|
||||
|
||||
data = (BYTE*)malloc(width*height*4*sizeof(BYTE));
|
||||
|
||||
glReadPixels(0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)data);
|
||||
|
||||
texture->setTextureMap(new CTextureMap(width,height,data));
|
||||
texture->save(texFileName);
|
||||
delete texture;
|
||||
}
|
||||
|
||||
|
||||
46
client/renderer/glrenderer.H
Normal file
46
client/renderer/glrenderer.H
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GLRENDERER_H
|
||||
#define _GLRENDERER_H
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include "renderer.H"
|
||||
class COGLRenderer : public CRenderer {
|
||||
GLenum m_mode;
|
||||
GLfloat m_aspectViewport;
|
||||
|
||||
public:
|
||||
COGLRenderer(CPvvmudClient * cli);
|
||||
virtual ~COGLRenderer();
|
||||
virtual void prepareDraw(CWorldObject * object);
|
||||
virtual void transform(CPosition &pos, CDirection &dir);
|
||||
virtual void draw();
|
||||
virtual void postDraw();
|
||||
virtual void mousePick(int x, int y);
|
||||
virtual void reshape(int width, int height);
|
||||
GLfloat getAspectViewport();
|
||||
void setAspectViewport(GLfloat av);
|
||||
void setMode(GLenum mode);
|
||||
|
||||
virtual void dumpScreen(char * texFileName);
|
||||
|
||||
};
|
||||
|
||||
#endif // _GLRENDERER_H
|
||||
116
client/renderer/glsrvcliconsole.C
Normal file
116
client/renderer/glsrvcliconsole.C
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <iostream.h>
|
||||
#include "pvvmud.H"
|
||||
#include "glsrvcliconsole.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
GLubyte CGLSrvCliConsole::m_cursor[13] = {
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff,
|
||||
0xff};
|
||||
|
||||
|
||||
|
||||
CGLSrvCliConsole::CGLSrvCliConsole(CPvvmudClient * cli) : CSrvCliConsole(cli) {
|
||||
m_font = GLUT_BITMAP_8_BY_13;
|
||||
}
|
||||
|
||||
CGLSrvCliConsole::CGLSrvCliConsole(CPvvmudClient * cli, int rows, int cols) : CSrvCliConsole(cli, rows, cols) {
|
||||
m_font = GLUT_BITMAP_8_BY_13;
|
||||
setCursorPos(1, 10);
|
||||
}
|
||||
CGLSrvCliConsole::~CGLSrvCliConsole() {
|
||||
}
|
||||
|
||||
CGLSrvCliConsole::drawString(char *string) {
|
||||
int len,t;
|
||||
t = 0;
|
||||
len = getRows();
|
||||
while (t < len && string[t] != '\n') {
|
||||
if (string[t] != 0) {
|
||||
glutBitmapCharacter(m_font,string[t]);
|
||||
}
|
||||
t++;
|
||||
} // while
|
||||
//cout << '\n';
|
||||
}
|
||||
|
||||
void CGLSrvCliConsole::drawText() {
|
||||
int x, y;
|
||||
//printMsgs();
|
||||
// Kode for å tegna opp tekstkonsoll
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LIGHTING);
|
||||
// Darken background
|
||||
|
||||
glLoadIdentity();
|
||||
GLdouble dark[4] = {0.0, 0.0, 0.0, 0.5};
|
||||
//glRotatef(-90, 1.0, 0.0, 0.0);
|
||||
gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0);
|
||||
//CCliViewpoint * viewpoint = getClient()->getManager()->getViewpoint();
|
||||
//viewpoint->transform();
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_QUADS);
|
||||
glColor4dv(dark);
|
||||
glVertex3f(-300, -300, 0.5);
|
||||
glVertex3f(-300, 300, 0.5);
|
||||
glVertex3f(300, 300, 0.5);
|
||||
glVertex3f(300, -300, 0.5);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-0.5,getClient()->getGUI()->getWidth() ,-0.5,getClient()->getGUI()->getHeight(),-1.0,1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glColor3dv(m_charColor);
|
||||
x = m_screen_x;
|
||||
y = m_screen_y;
|
||||
for (int i=0;i<getCols();i++) {
|
||||
glRasterPos2i(x, y);
|
||||
drawString(&m_console[i*getRows()]);
|
||||
y-=13;
|
||||
} // for
|
||||
// Draw cursor
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
if (getInputMode()) {
|
||||
glRasterPos2i(m_screen_x + (8*m_input_x), m_screen_y - (13*(m_input_y+1)));
|
||||
glBitmap(8, 13, 0.0, 0.0, 0.0, 0.0, m_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
39
client/renderer/glsrvcliconsole.H
Normal file
39
client/renderer/glsrvcliconsole.H
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef CGLSRVCLICONSOLE_H
|
||||
#define CGLSRVCLICONSOLE_H
|
||||
#include <GL/glut.h>
|
||||
#include "srvcliconsole.H"
|
||||
|
||||
class CGLSrvCliConsole : public CSrvCliConsole {
|
||||
|
||||
void *m_font;
|
||||
drawString(char *string);
|
||||
public:
|
||||
static GLubyte m_cursor[13];
|
||||
|
||||
CGLSrvCliConsole(CPvvmudClient * cli);
|
||||
CGLSrvCliConsole(CPvvmudClient * cli, int cols, int rows);
|
||||
~CGLSrvCliConsole();
|
||||
|
||||
virtual void drawText();
|
||||
};
|
||||
|
||||
#endif // CGLSRVCLICONSOLE_H
|
||||
146
client/renderer/gltexture.C
Normal file
146
client/renderer/gltexture.C
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "gltexture.H"
|
||||
|
||||
#ifdef HAVE_GL_GLUT_H
|
||||
#include <GL/glut.h>
|
||||
#endif /* HAVE_GL_GLUT_H */
|
||||
|
||||
static GLboolean HaveTexObj = GL_FALSE;
|
||||
|
||||
#if defined(GL_VERSION_1_1)
|
||||
# define TEXTURE_OBJECT 1
|
||||
#elif defined(GL_EXT_texture_object)
|
||||
# define TEXTURE_OBJECT 1
|
||||
# define glBindTexture(A,B) glBindTextureEXT(A,B)
|
||||
# define glGenTextures(A,B) glGenTexturesEXT(A,B)
|
||||
# define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B)
|
||||
#endif
|
||||
|
||||
void GLTexture_Init(){
|
||||
/* check that renderer has the GL_EXT_texture_object extension
|
||||
* or supports OpenGL 1.1
|
||||
*/
|
||||
#ifdef TEXTURE_OBJECT
|
||||
char *exten = (char *) glGetString( GL_EXTENSIONS );
|
||||
char *version = (char *) glGetString( GL_VERSION );
|
||||
if ( strstr( exten, "GL_EXT_texture_object" )
|
||||
|| strncmp( version, "1.1", 3 )==0 ) {
|
||||
HaveTexObj = GL_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Construct texture with given id
|
||||
*
|
||||
*****************************************************************************/
|
||||
CGLTexture::CGLTexture(int textureId):CTexture(textureId){
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Destruct texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CGLTexture::~CGLTexture(){
|
||||
|
||||
#ifdef TEXTURE_OBJECT
|
||||
if (loaded())
|
||||
glDeleteTextures( 1, &texObj );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Set texturemap to use with texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
void CGLTexture::setTextureMap(CTextureMap * textureMap){
|
||||
|
||||
/* generate texture object IDs */
|
||||
if (HaveTexObj) {
|
||||
#ifdef TEXTURE_OBJECT
|
||||
glGenTextures( 1, &texObj );
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
texObj = glGenLists(1);
|
||||
}
|
||||
/* setup texture object */
|
||||
if (HaveTexObj) {
|
||||
#ifdef TEXTURE_OBJECT
|
||||
glBindTexture( GL_TEXTURE_2D, texObj );
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
glNewList( texObj, GL_COMPILE );
|
||||
}
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, 4, textureMap->getWidth(),
|
||||
textureMap->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
textureMap->getData() );
|
||||
if (!HaveTexObj) {
|
||||
glEndList();
|
||||
}
|
||||
/* end of texture object */
|
||||
|
||||
CTexture::setTextureMap(textureMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Exec texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int CGLTexture::exec(){
|
||||
|
||||
if (!loaded()) return FALSE;
|
||||
|
||||
if (HaveTexObj) {
|
||||
#ifdef TEXTURE_OBJECT
|
||||
glBindTexture( GL_TEXTURE_2D, texObj );
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
glCallList( texObj );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
56
client/renderer/gltexture.H
Normal file
56
client/renderer/gltexture.H
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _GLTEXTURE_H
|
||||
#define _GLTEXTURE_H
|
||||
|
||||
#include "mudtypes.h"
|
||||
#include "texture.H"
|
||||
|
||||
#ifdef HAVE_GL_GL_H
|
||||
#include <GL/glut.h>
|
||||
typedef GLuint TexObj_t;
|
||||
#else /* HAVE_GL_GL_H */
|
||||
typedef unsigned int TexObj_t;
|
||||
#endif /* HAVE_GL_GL_H */
|
||||
|
||||
#define TEX_STATE_LOADED 0x0001
|
||||
|
||||
void GLTexture_Init();
|
||||
|
||||
class CGLTexture : public CTexture {
|
||||
TexObj_t texObj;
|
||||
|
||||
public:
|
||||
CGLTexture();
|
||||
CGLTexture(int id);
|
||||
~CGLTexture();
|
||||
virtual void setTextureMap(CTextureMap * textureMap);
|
||||
virtual int exec();
|
||||
};
|
||||
|
||||
#endif /* _GLTEXTURE_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
65
client/renderer/renderer.C
Normal file
65
client/renderer/renderer.C
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include "renderer.H"
|
||||
#include "pvvmudclient.H"
|
||||
|
||||
CRenderer::CRenderer(CPvvmudClient * c) {
|
||||
m_client = c;
|
||||
}
|
||||
|
||||
CRenderer::~CRenderer(){
|
||||
}
|
||||
|
||||
CPvvmudClient * CRenderer::getClient() {
|
||||
return m_client;
|
||||
}
|
||||
|
||||
CConsole * CRenderer::getConsole() {
|
||||
return m_console;
|
||||
}
|
||||
|
||||
void CRenderer::setConsole(CConsole * console) {
|
||||
m_console = console;
|
||||
}
|
||||
|
||||
void CRenderer::prepareDraw(CWorldObject * object){
|
||||
}
|
||||
|
||||
void CRenderer::transform(CPosition &pos, CDirection &dir){
|
||||
}
|
||||
|
||||
void CRenderer::draw(){
|
||||
}
|
||||
|
||||
void CRenderer::postDraw(){
|
||||
}
|
||||
|
||||
void CRenderer::mousePick(int x, int y){
|
||||
}
|
||||
|
||||
void CRenderer::reshape(int width, int height) {
|
||||
}
|
||||
|
||||
void CRenderer::dumpScreen(char * texFileName){
|
||||
}
|
||||
|
||||
|
||||
|
||||
45
client/renderer/renderer.H
Normal file
45
client/renderer/renderer.H
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef _RENDERER_H
|
||||
#define _RENDERER_H
|
||||
#include "worldobject.H"
|
||||
#include "console.H"
|
||||
|
||||
class CPvvmudClient;
|
||||
class CRenderer {
|
||||
CPvvmudClient * m_client;
|
||||
CConsole * m_console;
|
||||
|
||||
public:
|
||||
CRenderer(CPvvmudClient * c);
|
||||
virtual ~CRenderer();
|
||||
CPvvmudClient * getClient();
|
||||
CConsole * getConsole();
|
||||
void setConsole(CConsole * console);
|
||||
virtual void prepareDraw(CWorldObject * object);
|
||||
virtual void transform(CPosition &pos, CDirection &dir);
|
||||
virtual void draw();
|
||||
virtual void postDraw();
|
||||
virtual void mousePick(int x, int y);
|
||||
virtual void reshape(int width, int height);
|
||||
virtual void dumpScreen(char * texFileName);
|
||||
};
|
||||
|
||||
#endif // _RENDERER_H
|
||||
185
client/renderer/srvcliconsole.C
Normal file
185
client/renderer/srvcliconsole.C
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <fstream>
|
||||
#include <malloc.h>
|
||||
#include "pvvmud.H"
|
||||
#include "srvcliconsole.H"
|
||||
#include "string.h"
|
||||
|
||||
const char * CSrvCliConsole::HISTORY_FILE = ".pvvmud_history";
|
||||
|
||||
|
||||
CSrvCliConsole::CSrvCliConsole(CPvvmudClient * cli) : CConsole(cli) {
|
||||
m_numMsgs = 0;
|
||||
m_historyPos = 0;
|
||||
m_consSize = getCols()-1;
|
||||
loadHistory();
|
||||
}
|
||||
|
||||
CSrvCliConsole::CSrvCliConsole(CPvvmudClient * cli, int cols, int rows) : CConsole(cli, cols, rows) {
|
||||
m_numMsgs = 0;
|
||||
m_historyPos = 0;
|
||||
m_consSize = getCols()-1;
|
||||
loadHistory();
|
||||
}
|
||||
|
||||
void CSrvCliConsole::drawText() {
|
||||
}
|
||||
|
||||
int CSrvCliConsole::getNumMsgs() {
|
||||
return m_numMsgs;
|
||||
}
|
||||
|
||||
void CSrvCliConsole::setNumMsgs(int num) {
|
||||
m_numMsgs = num;
|
||||
}
|
||||
|
||||
void CSrvCliConsole::addMsg(char * msg) {
|
||||
string s = msg;
|
||||
if (m_numMsgs >= m_consSize) {
|
||||
m_messages.erase(m_messages.begin());
|
||||
}
|
||||
m_messages.push_back(msg);
|
||||
m_numMsgs++;
|
||||
printMsgs();
|
||||
}
|
||||
|
||||
void CSrvCliConsole::printMsgs() {
|
||||
const char * c;
|
||||
clear();
|
||||
for (int i=0;i<m_messages.size();i++) {
|
||||
c = m_messages[i].c_str();
|
||||
print((char *)c);
|
||||
}
|
||||
}
|
||||
|
||||
void CSrvCliConsole::loadHistory() {
|
||||
ifstream * file = new ifstream(HISTORY_FILE);
|
||||
if (!file) {
|
||||
cout << "Error\n";
|
||||
exit(0);
|
||||
} // if
|
||||
filebuf * fb = file->rdbuf();
|
||||
char * buf = (char*)malloc(80);
|
||||
char c = 0;
|
||||
int i = 0;
|
||||
while(file->get(c)) {
|
||||
if (i >= 80 || c == '\n') {
|
||||
string s = string(buf);
|
||||
//cout << s;
|
||||
m_history.push_back(s);
|
||||
m_historyPos++;
|
||||
i = 0;
|
||||
memset(buf, 0, 80);
|
||||
} // if
|
||||
else {
|
||||
buf[i++] = c;
|
||||
} // else
|
||||
} // while
|
||||
file->close();
|
||||
free(buf);
|
||||
delete file;
|
||||
}
|
||||
|
||||
void CSrvCliConsole::saveHistory() {
|
||||
ofstream * file = new ofstream(HISTORY_FILE);
|
||||
filebuf * fb = file->rdbuf();
|
||||
for (int i=0;i<m_history.size();i++) {
|
||||
fb->sputn(m_history[i].c_str(), m_history[i].size());
|
||||
fb->sputc('\n');
|
||||
} // for
|
||||
file->close();
|
||||
delete file;
|
||||
}
|
||||
void CSrvCliConsole::keyboardInput(char k) {
|
||||
switch (k) {
|
||||
case KEY_UP:
|
||||
m_input_x = 0;
|
||||
m_inputBuffer = "";
|
||||
clear();
|
||||
printMsgs();
|
||||
if (m_historyPos > -1) {
|
||||
m_historyPos--;
|
||||
if (m_historyPos > -1) {
|
||||
m_inputBuffer = m_history[m_historyPos];
|
||||
if (getEcho()) {
|
||||
char c;
|
||||
int i = 0;
|
||||
const char * cstr = m_inputBuffer.c_str();
|
||||
while (c = cstr[i]) {
|
||||
echoChar(c);
|
||||
i++;
|
||||
} // while
|
||||
} // if
|
||||
} // if
|
||||
} // if
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
m_input_x = 0;
|
||||
m_inputBuffer = "";
|
||||
clear();
|
||||
printMsgs();
|
||||
if (m_historyPos == -1 || m_historyPos < m_history.size()) { // Stygt hack
|
||||
m_historyPos++;
|
||||
if (m_historyPos < m_history.size()) {
|
||||
m_inputBuffer = m_history[m_historyPos];
|
||||
if (getEcho()) {
|
||||
char c;
|
||||
int i = 0;
|
||||
const char * cstr = m_inputBuffer.c_str();
|
||||
while (c = cstr[i]) {
|
||||
echoChar(c);
|
||||
i++;
|
||||
} // while
|
||||
} // if
|
||||
} // if
|
||||
else {
|
||||
m_inputBuffer = "";
|
||||
m_input_x = 0;
|
||||
} // else
|
||||
}
|
||||
break;
|
||||
case '\r':
|
||||
changeInputMode();
|
||||
m_historyPos = m_history.size();
|
||||
if (m_inputBuffer != "") {
|
||||
setDataReady();
|
||||
m_history.push_back(m_inputBuffer);
|
||||
m_historyPos++;
|
||||
}
|
||||
break;
|
||||
case '\b':
|
||||
if (m_inputBuffer != "") {
|
||||
m_inputBuffer.erase(m_inputBuffer.end()-1);
|
||||
if (getEcho()) {
|
||||
m_input_x--;
|
||||
m_console[m_input_y * getRows() + m_input_x] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (getEcho()) {
|
||||
echoChar(k);
|
||||
}
|
||||
m_inputBuffer += k;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
52
client/renderer/srvcliconsole.H
Normal file
52
client/renderer/srvcliconsole.H
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef SRVCLICONSOLE_H
|
||||
#define SRVCLICONSOLE_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "console.H"
|
||||
|
||||
// Subclass of CConsole for printing messages recieved from server and other clients
|
||||
class CSrvCliConsole : public CConsole {
|
||||
static const char * HISTORY_FILE;
|
||||
int m_consSize;
|
||||
int m_numMsgs;
|
||||
typedef vector<string> msg_t;
|
||||
msg_t m_messages;
|
||||
msg_t m_history;
|
||||
int m_historyPos;
|
||||
public:
|
||||
CSrvCliConsole(CPvvmudClient * cli);
|
||||
CSrvCliConsole(CPvvmudClient * cli, int cols, int rows);
|
||||
|
||||
virtual void drawText();
|
||||
virtual void addMsg(char * msg);
|
||||
int getNumMsgs();
|
||||
void setNumMsgs(int num);
|
||||
void updateConsole();
|
||||
void printMsgs();
|
||||
void loadHistory();
|
||||
void saveHistory();
|
||||
virtual void keyboardInput(char k);
|
||||
|
||||
};
|
||||
|
||||
#endif // SRVCLICONSOLE_H
|
||||
Reference in New Issue
Block a user