mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 10:35:44 +00:00
Fix some mistakes
This commit is contained in:
parent
763859283a
commit
efd8679de3
10 changed files with 12 additions and 45 deletions
|
|
@ -47,11 +47,6 @@ func initFramebuffer(w int, h int, hasDepth bool, hasStencil bool) {
|
|||
|
||||
// texture init
|
||||
gl.GenTextures(1, &opt.tex)
|
||||
if opt.tex < 0 {
|
||||
log.Printf("[OpenGL] GenTextures: 0x%X", opt.tex)
|
||||
panic("OpenGL texture initialization has failed")
|
||||
}
|
||||
|
||||
gl.BindTexture(gl.TEXTURE_2D, opt.tex)
|
||||
|
||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
|
||||
|
|
@ -116,15 +111,12 @@ func SetPixelFormat(format PixelFormat) {
|
|||
case UnsignedShort5551:
|
||||
opt.pixFormat = gl.UNSIGNED_SHORT_5_5_5_1
|
||||
opt.pixType = gl.BGRA
|
||||
break
|
||||
case UnsignedShort565:
|
||||
opt.pixFormat = gl.UNSIGNED_SHORT_5_6_5
|
||||
opt.pixType = gl.RGB
|
||||
break
|
||||
case UnsignedInt8888Rev:
|
||||
opt.pixFormat = gl.UNSIGNED_INT_8_8_8_8_REV
|
||||
opt.pixType = gl.BGRA
|
||||
break
|
||||
default:
|
||||
log.Fatalf("[opengl] Error! Unknown pixel type %v", format)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,19 +46,16 @@ func Init(cfg Config) {
|
|||
case CtxOpenGlCore:
|
||||
setAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_CORE)
|
||||
log.Printf("[OpenGL] CONTEXT_PROFILE_CORE")
|
||||
break
|
||||
case CtxOpenGlEs2:
|
||||
setAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_ES)
|
||||
setAttribute(sdl.GL_CONTEXT_MAJOR_VERSION, 3)
|
||||
setAttribute(sdl.GL_CONTEXT_MINOR_VERSION, 0)
|
||||
log.Printf("[OpenGL] CONTEXT_PROFILE_ES 3.0")
|
||||
break
|
||||
case CtxOpenGl:
|
||||
if cfg.Gl.VersionMajor >= 3 {
|
||||
setAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_COMPATIBILITY)
|
||||
}
|
||||
log.Printf("[OpenGL] CONTEXT_PROFILE_COMPATIBILITY")
|
||||
break
|
||||
default:
|
||||
log.Printf("Unsupported hw context: %v", cfg.Ctx)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ func TestRotate(t *testing.T) {
|
|||
|
||||
for _, test := range tests {
|
||||
for i, rot := range test.rotateHow {
|
||||
if output := ExampleRotate(test.input, test.w, test.h, rot); bytes.Compare(output, test.expected[i]) != 0 {
|
||||
if output := ExampleRotate(test.input, test.w, test.h, rot); !bytes.Equal(output, test.expected[i]) {
|
||||
t.Errorf(
|
||||
"Test fail for angle %v with %v that should be \n%v but it's \n%v",
|
||||
rot, test.input, test.expected[i], output)
|
||||
|
|
@ -204,24 +204,21 @@ func TestBoundsAfterRotation(t *testing.T) {
|
|||
|
||||
func BenchmarkDirect(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
p1, p2 := Rotate90(1, 1, 2, 2)
|
||||
p1, p2 = p2, p1
|
||||
_, _ = Rotate90(1, 1, 2, 2)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLiteral(b *testing.B) {
|
||||
fn := Rotate90
|
||||
for i := 0; i < b.N; i++ {
|
||||
p1, p2 := fn(1, 1, 2, 2)
|
||||
p1, p2 = p2, p1
|
||||
_, _ = fn(1, 1, 2, 2)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAssign(b *testing.B) {
|
||||
fn := Angles[Angle90].Call
|
||||
for i := 0; i < b.N; i++ {
|
||||
p1, p2 := fn(1, 1, 2, 2)
|
||||
p1, p2 = p2, p1
|
||||
_, _ = fn(1, 1, 2, 2)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -229,15 +226,13 @@ func BenchmarkMapReassign(b *testing.B) {
|
|||
fn := Angles[Angle90].Call
|
||||
for i := 0; i < b.N; i++ {
|
||||
fn2 := fn
|
||||
p1, p2 := fn2(1, 1, 2, 2)
|
||||
p1, p2 = p2, p1
|
||||
_, _ = fn2(1, 1, 2, 2)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMapDirect(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
p1, p2 := Angles[Angle90].Call(1, 1, 2, 2)
|
||||
p1, p2 = p2, p1
|
||||
_, _ = Angles[Angle90].Call(1, 1, 2, 2)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +242,6 @@ func BenchmarkNewMapDirect(b *testing.B) {
|
|||
}
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
p1, p2 := fns[Angle90](1, 1, 2, 2)
|
||||
p1, p2 = p2, p1
|
||||
_, _ = fns[Angle90](1, 1, 2, 2)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func (m *Manager) Sync() error {
|
|||
if fallback := repo.New(conf.Type, conf.Url, conf.Compression, ""); fallback != nil {
|
||||
defer m.setRepo(m.repo)
|
||||
m.setRepo(fallback)
|
||||
_, failed = m.download(failed)
|
||||
_, _ = m.download(failed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,15 +263,12 @@ func coreEnvironment(cmd C.unsigned, data unsafe.Pointer) C.bool {
|
|||
}
|
||||
}
|
||||
*username = currentUser
|
||||
break
|
||||
case C.RETRO_ENVIRONMENT_GET_LOG_INTERFACE:
|
||||
cb := (*C.struct_retro_log_callback)(data)
|
||||
cb.log = (C.retro_log_printf_t)(C.coreLog_cgo)
|
||||
break
|
||||
case C.RETRO_ENVIRONMENT_GET_CAN_DUPE:
|
||||
bval := (*C.bool)(data)
|
||||
*bval = C.bool(true)
|
||||
break
|
||||
case C.RETRO_ENVIRONMENT_SET_PIXEL_FORMAT:
|
||||
return videoSetPixelFormat(*(*C.enum_retro_pixel_format)(data))
|
||||
case C.RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY:
|
||||
|
|
@ -650,19 +647,16 @@ func videoSetPixelFormat(format uint32) C.bool {
|
|||
video.bpp = 2
|
||||
// format is not implemented
|
||||
pixelFormatConverterFn = nil
|
||||
break
|
||||
case C.RETRO_PIXEL_FORMAT_XRGB8888:
|
||||
video.pixFmt = image.BitFormatInt8888Rev
|
||||
graphics.SetPixelFormat(graphics.UnsignedInt8888Rev)
|
||||
video.bpp = 4
|
||||
pixelFormatConverterFn = image.Rgba8888
|
||||
break
|
||||
case C.RETRO_PIXEL_FORMAT_RGB565:
|
||||
video.pixFmt = image.BitFormatShort565
|
||||
graphics.SetPixelFormat(graphics.UnsignedShort565)
|
||||
video.bpp = 2
|
||||
pixelFormatConverterFn = image.Rgb565
|
||||
break
|
||||
default:
|
||||
log.Fatalf("Unknown pixel type %v", format)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ type testRun struct {
|
|||
system string
|
||||
rom string
|
||||
emulationTicks int
|
||||
|
||||
gl bool
|
||||
libCo bool
|
||||
}
|
||||
|
||||
// EmulatorMock contains naEmulator mocking data.
|
||||
|
|
@ -180,11 +177,6 @@ func (emu *EmulatorMock) handleInput(handler func(event InputEvent)) {
|
|||
}
|
||||
}
|
||||
|
||||
// getSavePath returns the full path to the emulator latest save.
|
||||
func (emu *EmulatorMock) getSavePath() string {
|
||||
return cleanPath(emu.GetHashPath())
|
||||
}
|
||||
|
||||
// dumpState returns the current emulator state and
|
||||
// the latest saved state for its session.
|
||||
// Locks the emulator.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ func (na *naEmulator) Save() (err error) {
|
|||
err = toFile(na.GetSRAMPath(), sramState)
|
||||
}
|
||||
if saveState, err := getSaveState(); err == nil {
|
||||
err = toFile(na.GetHashPath(), saveState)
|
||||
return toFile(na.GetHashPath(), saveState)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ func (na *naEmulator) Load() (err error) {
|
|||
restoreSaveRAM(sramState)
|
||||
}
|
||||
if saveState, err := fromFile(na.GetHashPath()); err == nil {
|
||||
err = restoreSaveState(saveState)
|
||||
return restoreSaveState(saveState)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func TestSave(t *testing.T) {
|
|||
}
|
||||
|
||||
fmt.Printf("[%-14v] ", "before save")
|
||||
snapshot1, _ := mock.dumpState()
|
||||
_, _ = mock.dumpState()
|
||||
if err := mock.Save(); err != nil {
|
||||
t.Errorf("Save fail %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func NewYuvImgProcessor(w, h int, options ...Option) ImgProcessor {
|
|||
opts.override(options...)
|
||||
|
||||
bufSize := int(float32(w*h) * 1.5)
|
||||
buf := make([]byte, bufSize, bufSize)
|
||||
buf := make([]byte, bufSize)
|
||||
|
||||
processor := processor{
|
||||
Data: buf,
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ type Room struct {
|
|||
director emulator.CloudEmulator
|
||||
// Cloud storage to store room state online
|
||||
onlineStorage *storage.Client
|
||||
// GameName
|
||||
gameName string
|
||||
|
||||
vPipe *encoder.VideoPipe
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue