Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
0x64c committed Jun 8, 2016
1 parent 73e80eb commit 9410045
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 44 deletions.
55 changes: 55 additions & 0 deletions Makefile_PC
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
OPK_DIR=opk_build
SDL_CONFIG=/usr/bin/sdl-config

LIB_INCLUDE=/usr/lib
CC=gcc
CXX=g++
STRIP=strip

EXE = aaaa
OPK = $(EXE).opk
RM = rm -f


# Add SDL dependency
LDFLAGS +=-lSDL_gfx -lSDL_image -lSDL_mixer $(shell $(SDL_CONFIG) --libs) -lGLESv1_CM -lEGL -lX11
CFLAGS +=$(shell $(SDL_CONFIG) --cflags) -g -DGCW -DPC

#Pandora Mode
#LDFLAGS +=-lSDL_gfx -lSDL_image -lSDL_mixer $(shell $(SDL_CONFIG) --libs) -lGLESv1_CM -lEGL -lX11
#CFLAGS +=$(shell $(SDL_CONFIG) --cflags) -g -DPANDORA



#LDFLAGS +=-lSDL_gfx -lSDL_image -lSDL_mixer $(shell sdl-config --libs) -lGL
#CFLAGS +=$(shell sdl-config --cflags) -DPC32

# Define targets
SRCS=$(shell echo *.c)
OBJS=$(SRCS:%.c=%.o)

ALL : $(EXE)

.c.o:
$(CC) $(CFLAGS) $(CXXFLAGS) -c $*.c -o $*.o
.cpp.o:
$(CXX) $(CFLAGS) $(CXXFLAGS) -c $*.cpp -o $*.o

$(EXE) : $(OBJS)
$(CXX) $(OBJS) -o $(EXE) $(LDFLAGS)
# $(STRIP) $(EXE)

#opk : $(EXE)
cp $(EXE) $(OPK_DIR)
# mksquashfs opk_build $(EXE).opk -all-root -noappend -no-exports -no-xattrs

#install : $(EXE)
# $(INSTALL_PROG) $(EXE) $(PREFIX)/bin

#uninstall :
# $(RM) $(PREFIX)/bin/$(EXE)

clean :
$(RM) $(OBJS) $(EXE) $(OPK_DIR)/$(EXE) $(OPK)

.PHONY:opk clean install uninstall ALL
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "zcore.h"
#include "zresm.h"

//int main(int argc, char *argv[]) //unused arguments
//int main(int argc, char *argv[])
int main()
{
zresminit();
Expand Down
2 changes: 1 addition & 1 deletion vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ s32 tpscam[16];
s32 sprite[33][8],bullet[33][16];
s32 tension[8]= {255,255,255,16,0,0,255,255};

u8 playeraim=0,portraitmode=0,fpsdisplay=0,frameskip=1,thisframenice=1;
u8 playeraim=0,portraitmode=0,fpsdisplay=1,frameskip=1,thisframenice=1;

s32 vibro=127,gsensor[6]= {0,0,0, 0,0,0};

Expand Down
224 changes: 184 additions & 40 deletions zcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ Display *g_x11Display = NULL;
#include "GLES/gl.h"
#include "GLES/egl.h"
#include "GLES/glext.h"
#include <SDL/SDL_syswm.h>
#ifdef PC
#include <X11/Xlib.h>
Display *g_x11Display = NULL;
#endif
#endif
#ifdef GP2XWIZ
#include "OpenGLES/gl.h"
Expand All @@ -46,27 +51,27 @@ const char *gl_vendor,*gl_renderer,*gl_version,*gl_extensions;
#if defined(PANDORA)

EGLint attrib_list_fsaa[]= {
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_DEPTH_SIZE, 16,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_SAMPLE_BUFFERS, 1,
EGL_SAMPLES, 1,
EGL_NONE
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_DEPTH_SIZE, 16,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_SAMPLE_BUFFERS, 1,
EGL_SAMPLES, 1,
EGL_NONE
};

EGLint attrib_list[]= {
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_DEPTH_SIZE, 16,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_SAMPLE_BUFFERS, 1,
EGL_SAMPLES, 4,
EGL_NONE
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_DEPTH_SIZE, 16,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_SAMPLE_BUFFERS, 1,
EGL_SAMPLES, 4,
EGL_NONE
};
#else
EGLint attrib_list_fsaa[]= {EGL_SURFACE_TYPE,EGL_WINDOW_BIT,EGL_BUFFER_SIZE,16,EGL_DEPTH_SIZE,16,EGL_SAMPLE_BUFFERS,1,EGL_SAMPLES,4,EGL_NONE};
Expand Down Expand Up @@ -278,7 +283,9 @@ void zcore_video_init(void)
#if defined(GCW)

////////////////////////////////////////////////////////////////////////////////////////
screen=SDL_SetVideoMode(320,240,16, SDL_SWSURFACE);


/* screen=SDL_SetVideoMode(320,240,16, SDL_SWSURFACE);
const char* output;
Expand All @@ -290,25 +297,27 @@ void zcore_video_init(void)
EGL_NONE // This is important as it tells EGL when to stop looking in the array
};
screenwidth=320;
screenheight=240;
int screenbpp=16;
EGLint numConfigs,majorVersion,minorVersion;
EGLBoolean result;
glDisplay=eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (glDisplay == EGL_NO_DISPLAY)
{
screenwidth=320;
screenheight=240;
int screenbpp=16;
EGLint numConfigs,majorVersion,minorVersion;
EGLBoolean result;
glDisplay=eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (glDisplay == EGL_NO_DISPLAY)
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "OpenGLES ERROR: Unable to create EGL display.\n" );
}
printf( "OpenGLES: Initializing\n" );
result = eglInitialize(glDisplay, &majorVersion, &minorVersion );
if (result != EGL_TRUE )
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "OpenGLES ERROR: Unable to initialize EGL display.\n" );
}
/* Get EGL Library Information */
}
printf( "OpenGLES: Initializing\n" );
result = eglInitialize(glDisplay, &majorVersion, &minorVersion );
if (result != EGL_TRUE )
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "OpenGLES ERROR: Unable to initialize EGL display.\n" );
}
// Get EGL Library Information
printf( "EGL Implementation Version: Major %d Minor %d\n", majorVersion, minorVersion );
output = eglQueryString( glDisplay, EGL_VENDOR );
printf( "EGL_VENDOR: %s\n", output );
Expand All @@ -327,6 +336,7 @@ void zcore_video_init(void)
printf( "OpenGLES: Creating context\n" );
glContext = eglCreateContext(glDisplay, glConfig, EGL_NO_CONTEXT, NULL);
if (glContext== EGL_NO_CONTEXT)
{
CheckGLESErrors( __FILE__, __LINE__ );
Expand All @@ -338,6 +348,7 @@ void zcore_video_init(void)
printf( "OpenGLES: Creating window surface\n" );
glSurface = eglCreateWindowSurface(glDisplay, glConfig, hNativeWnd, NULL);
if (glSurface == EGL_NO_SURFACE)
{
CheckGLESErrors( __FILE__, __LINE__ );
Expand All @@ -346,6 +357,7 @@ void zcore_video_init(void)
printf( "OpenGLES: Making current the new context\n" );
result = eglMakeCurrent(glDisplay, glSurface, glSurface, glContext);
if (result != EGL_TRUE)
{
CheckGLESErrors( __FILE__, __LINE__ );
Expand All @@ -358,14 +370,146 @@ void zcore_video_init(void)
printf( "OpenGLES: Initialization complete\n" );
CheckGLESErrors( __FILE__, __LINE__ );
SDL_ShowCursor(SDL_DISABLE);
SDL_ShowCursor(SDL_DISABLE);
glVertexPointer(3,GL_FIXED,0,mesh);
glTexCoordPointer(2,GL_FIXED,0,mesht);
glFogf(GL_FOG_MODE,GL_LINEAR);
glAlphaFuncx(GL_GREATER,65536/2);
*/

#ifdef PC
const char* output;
EGLBoolean result;

EGLint egl_config_attr[] = {
EGL_BUFFER_SIZE, 16,
EGL_DEPTH_SIZE, 16,
EGL_STENCIL_SIZE, 0,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE // This is important as it tells EGL when to stop looking in the array
};

EGLint numConfigs,majorVersion,minorVersion;

screenwidth=320;
screenheight=240;
int screenbpp=16;
screen=SDL_SetVideoMode(screenwidth,screenheight,screenbpp, SDL_SWSURFACE); // | SDL_FULLSCREEN);
g_x11Display = XOpenDisplay(NULL);
#define _EGL_DSP (EGLNativeDisplayType)g_x11Display
glDisplay=eglGetDisplay(_EGL_DSP);

if (glDisplay == EGL_NO_DISPLAY)
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "OpenGLES ERROR: Unable to create EGL display.\n" );
}

printf( "OpenGLES: Initializing\n" );
result = eglInitialize(glDisplay, &majorVersion, &minorVersion );
if (result != EGL_TRUE )
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "OpenGLES ERROR: Unable to initialize EGL display.\n" );
}
//Get EGL Library Information

printf( "EGL Implementation Version: Major %d Minor %d\n", majorVersion, minorVersion );
output = eglQueryString( glDisplay, EGL_VENDOR );
printf( "EGL_VENDOR: %s\n", output );
output = eglQueryString( glDisplay, EGL_VERSION );
printf( "EGL_VERSION: %s\n", output );
output = eglQueryString( glDisplay, EGL_EXTENSIONS );
printf( "EGL_EXTENSIONS: %s\n", output );
printf("OpenGLES: Requesting %dx%d %dbpp configuration\n", screenwidth, screenheight, screenbpp);

result = eglChooseConfig(glDisplay, egl_config_attr, &glConfig, 1, &numConfigs);

if (result != EGL_TRUE || numConfigs == 0)
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "EGLport ERROR: Unable to query for available configs, found %d.\n", numConfigs );
}

SDL_SysWMinfo sysInfo;
SDL_VERSION(&sysInfo.version); //Set SDL version
SDL_GetWMInfo(&sysInfo);

printf( "OpenGLES: Creating context\n" );
glContext = eglCreateContext(glDisplay, glConfig, EGL_NO_CONTEXT, NULL);

if (glContext== EGL_NO_CONTEXT)
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "OpenGLES ERROR: Unable to create GLES context!\n");
}


printf( "OpenGLES: Creating window surface\n" );
glSurface=eglCreateWindowSurface(glDisplay,glConfig,(EGLNativeWindowType)sysInfo.info.x11.window,0);


if (glSurface == EGL_NO_SURFACE)
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "OpenGLES ERROR: Unable to create EGL surface!\n" );
}




printf( "OpenGLES: Making current the new context\n" );
result = eglMakeCurrent(glDisplay, glSurface, glSurface, glContext);

if (result != EGL_TRUE)
{
CheckGLESErrors( __FILE__, __LINE__ );
printf( "OpenGLES ERROR: Unable to make GLES context current\n" );
}

printf( "OpenGLES: Setting swap interval\n" );
eglSwapInterval(glDisplay, 1); // We want VSYNC

printf( "OpenGLES: Initialization complete\n" );
CheckGLESErrors( __FILE__, __LINE__ );

SDL_ShowCursor(SDL_DISABLE);
glVertexPointer(3,GL_FIXED,0,mesh);
glTexCoordPointer(2,GL_FIXED,0,mesht);
glFogf(GL_FOG_MODE,GL_LINEAR);
glAlphaFuncx(GL_GREATER,65536/2);
#else

EGLint numConfigs,majorVersion,minorVersion;
EGLint egl_config_attr[] = {
EGL_BUFFER_SIZE, 16,
EGL_DEPTH_SIZE, 16,
EGL_STENCIL_SIZE, 0,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};
screen=SDL_SetVideoMode(320,240,16, SDL_SWSURFACE);
glDisplay=eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(glDisplay, &majorVersion, &minorVersion );
eglChooseConfig(glDisplay, egl_config_attr, &glConfig, 1, &numConfigs);
hNativeWnd=0;
SDL_SysWMinfo sysInfo;
SDL_VERSION(&sysInfo.version);
SDL_GetWMInfo(&sysInfo);
glSurface = eglCreateWindowSurface(glDisplay, glConfig, hNativeWnd, NULL);
glContext = eglCreateContext(glDisplay, glConfig, EGL_NO_CONTEXT, NULL);
eglMakeCurrent(glDisplay, glSurface, glSurface, glContext);
//eglSwapInterval(glDisplay, 1);
SDL_ShowCursor(SDL_DISABLE);
glVertexPointer(3,GL_FIXED,0,mesh);
glTexCoordPointer(2,GL_FIXED,0,mesht);
glFogf(GL_FOG_MODE,GL_LINEAR);
glAlphaFuncx(GL_GREATER,65536/2);

#endif
#endif


///////////////////////////////////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -429,7 +573,7 @@ void zcore_video_frame(void)
{
if (thisframenice)
{
coreupdatetextures();
//coreupdatetextures();
corerenderrender();

#ifdef PC32
Expand All @@ -449,9 +593,9 @@ void zcore_video_down(void)
eglDestroySurface(glDisplay,glSurface);
eglDestroyContext(glDisplay,glContext);
eglTerminate(glDisplay);
#ifndef GCW
#ifndef GCW
free(hNativeWnd);
#endif
#endif
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions zresm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void loadconfig(void)
{
FILE *fp;
u8 i;
#ifdef GCW
#if defined(GCW) && !defined(PC)
fp=fopen("/media/data/local/home/.aaaa/donothexedit.me","rb");
#else
fp=fopen("donothexedit.me","rb");
Expand All @@ -55,7 +55,7 @@ void saveconfig(void)
{
FILE *fp;
u8 i;
#ifdef GCW
#if defined(GCW) && !defined(PC)
fp=fopen("/media/data/local/home/.aaaa/donothexedit.me","wb");
#else
fp=fopen("donothexedit.me","wb");
Expand Down

0 comments on commit 9410045

Please sign in to comment.